From: David Lawrence Ramsey Date: Fri, 18 Aug 2006 20:30:25 +0000 (+0000) Subject: in digits(), remove the assumption that n is always positive, although X-Git-Tag: v1.9.99pre1~20 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5a22dbb15996c3639e0dbeda0dec3890ed73abd6;p=nano.git in digits(), remove the assumption that n is always positive, although it always is in this particular case git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3842 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 9a767f13..e59fd524 100644 --- a/ChangeLog +++ b/ChangeLog @@ -155,6 +155,10 @@ CVS code - execute_command() - Remove the marking of the file as modified, as do_insertfile() now handles that. (DLR) +- utils.c: + digits() + - Tweak to remove the assumption that n is always positive, + although it always is in this particular case. (DLR) - winio.c: parse_kbinput() - Properly handle combined meta and escape sequences, so that diff --git a/src/utils.c b/src/utils.c index 9e4da45d..6c16b9e4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -35,8 +35,12 @@ int digits(size_t n) { int i; - for (i = 1; n >= 10; n /= 10, i++) - ; + if (n == 0) + i = 1; + else { + for (i = 0; n != 0; n /= 10, i++) + ; + } return i; }