]> sjero.net Git - wget/commitdiff
[svn] Slightly better handling of negative numbers in numdigit.
authorhniksic <devnull@localhost>
Tue, 29 Mar 2005 20:03:42 +0000 (12:03 -0800)
committerhniksic <devnull@localhost>
Tue, 29 Mar 2005 20:03:42 +0000 (12:03 -0800)
src/ChangeLog
src/utils.c

index d306c41b975bdade2a6977430c3925951b317ae2..9253d31678ec0dbfd4bf1dd93028913c076ef785 100644 (file)
@@ -1,3 +1,7 @@
+2005-03-29  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * utils.c (numdigit): More correct handling of negative numbers.
+
 2005-03-21  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * http.c (gethttp): Print the human-readable size.
index 2e8524edd9bf9e17366e181003adda4dd8e38d21..50de97c6cc1d3118bf42cbd5215d43560a31f00f 100644 (file)
@@ -1368,17 +1368,16 @@ human_readable (wgint n)
   return NULL;                 /* unreached */
 }
 
-/* Count the digits in an integer number.  */
+/* Count the digits in the provided number.  Used to allocate space
+   when printing numbers.  */
+
 int
 numdigit (wgint number)
 {
   int cnt = 1;
   if (number < 0)
-    {
-      number = -number;
-      ++cnt;
-    }
-  while ((number /= 10) > 0)
+    ++cnt;                     /* accomodate '-' */
+  while ((number /= 10) != 0)
     ++cnt;
   return cnt;
 }
@@ -1468,8 +1467,8 @@ numdigit (wgint number)
 #endif
 
 /* Print NUMBER to BUFFER in base 10.  This is equivalent to
-   `sprintf(buffer, "%lld", (long long) number)', only much faster and
-   portable to machines without long long.
+   `sprintf(buffer, "%lld", (long long) number)', only typically much
+   faster and portable to machines without long long.
 
    The speedup may make a difference in programs that frequently
    convert numbers to strings.  Some implementations of sprintf,