diff --git a/ChangeLog b/ChangeLog index e3b489edaca8357449a9b7bf43dba1dfbfb03a5b..dd40995e292adbc435f48f9990aaed7cb4db1a26 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 0758d1ace911ff57571fe8384a085f7c7878e387..475a87459a8f9cebc782e88bed5e09651d40077c 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; }