From: David Lawrence Ramsey Date: Wed, 21 Jun 2006 16:01:20 +0000 (+0000) Subject: in digits(), return the proper number of digits when n is exactly 10, X-Git-Tag: v1.3.12~6 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a4fc77a5da579018a77a93e58b9aed7780e1638a;p=nano.git in digits(), return the proper number of digits when n is exactly 10, and simplify it to use a for loop instead of a while loop git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3674 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index e3b489ed..dd40995e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -375,6 +375,9 @@ CVS code - - Unconditionally blank the statusbar as soon as we're finished getting input. (DLR, suggested by Benno Schulenberg) - utils.c: + digits() + - Return the proper number of digits when n is exactly 10. (DLR) + - Simplify to use a for loop instead of a while loop. (DLR) ngetdelim() - Set errno to EINVAL if stream is not a valid file stream. This matches the manual page. (DLR) diff --git a/src/utils.c b/src/utils.c index 0758d1ac..475a8745 100644 --- a/src/utils.c +++ b/src/utils.c @@ -33,12 +33,10 @@ /* Return the number of decimal digits in n. */ int digits(size_t n) { - int i = 1; + int i; - while (n > 10) { - n /= 10; - i++; - } + for (i = 1; n >= 10; n /= 10, i++) + ; return i; }