mirror of
https://github.com/mirror/wget.git
synced 2025-02-08 02:30:17 +08:00
[svn] Slightly better handling of negative numbers in numdigit.
This commit is contained in:
parent
1c942b02b0
commit
dd299a9cf6
@ -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>
|
2005-03-21 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* http.c (gethttp): Print the human-readable size.
|
* http.c (gethttp): Print the human-readable size.
|
||||||
|
15
src/utils.c
15
src/utils.c
@ -1368,17 +1368,16 @@ human_readable (wgint n)
|
|||||||
return NULL; /* unreached */
|
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
|
int
|
||||||
numdigit (wgint number)
|
numdigit (wgint number)
|
||||||
{
|
{
|
||||||
int cnt = 1;
|
int cnt = 1;
|
||||||
if (number < 0)
|
if (number < 0)
|
||||||
{
|
++cnt; /* accomodate '-' */
|
||||||
number = -number;
|
while ((number /= 10) != 0)
|
||||||
++cnt;
|
|
||||||
}
|
|
||||||
while ((number /= 10) > 0)
|
|
||||||
++cnt;
|
++cnt;
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
@ -1468,8 +1467,8 @@ numdigit (wgint number)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Print NUMBER to BUFFER in base 10. This is equivalent to
|
/* Print NUMBER to BUFFER in base 10. This is equivalent to
|
||||||
`sprintf(buffer, "%lld", (long long) number)', only much faster and
|
`sprintf(buffer, "%lld", (long long) number)', only typically much
|
||||||
portable to machines without long long.
|
faster and portable to machines without long long.
|
||||||
|
|
||||||
The speedup may make a difference in programs that frequently
|
The speedup may make a difference in programs that frequently
|
||||||
convert numbers to strings. Some implementations of sprintf,
|
convert numbers to strings. Some implementations of sprintf,
|
||||||
|
Loading…
Reference in New Issue
Block a user