Commit a4fc77a5 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent 5aaa1d7d
Showing with 6 additions and 5 deletions
+6 -5
...@@ -375,6 +375,9 @@ CVS code - ...@@ -375,6 +375,9 @@ CVS code -
- Unconditionally blank the statusbar as soon as we're finished - Unconditionally blank the statusbar as soon as we're finished
getting input. (DLR, suggested by Benno Schulenberg) getting input. (DLR, suggested by Benno Schulenberg)
- utils.c: - 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() ngetdelim()
- Set errno to EINVAL if stream is not a valid file stream. - Set errno to EINVAL if stream is not a valid file stream.
This matches the manual page. (DLR) This matches the manual page. (DLR)
......
...@@ -33,12 +33,10 @@ ...@@ -33,12 +33,10 @@
/* Return the number of decimal digits in n. */ /* Return the number of decimal digits in n. */
int digits(size_t n) int digits(size_t n)
{ {
int i = 1; int i;
while (n > 10) { for (i = 1; n >= 10; n /= 10, i++)
n /= 10; ;
i++;
}
return i; return i;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment