projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe5045c
)
Fix grouping (sigh).
author
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 29 Aug 2004 22:11:32 +0000
(22:11 +0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 29 Aug 2004 22:11:32 +0000
(22:11 +0000)
src/lib/lib.c
patch
|
blob
|
history
diff --git
a/src/lib/lib.c
b/src/lib/lib.c
index 42ca2fd69bdd25c66b33d1d5601fcea1a6b46cf8..17b0a8086e174a65595bcc11c879fe531a69ae15 100644
(file)
--- a/
src/lib/lib.c
+++ b/
src/lib/lib.c
@@
-369,7
+369,7
@@
printf_integer (uintmax_t value, bool negative, const char *digits,
char buf[64], *cp;
int base;
const char *base_name;
char buf[64], *cp;
int base;
const char *base_name;
- int pad_cnt;
+ int pad_cnt
, group_cnt
;
base = strlen (digits);
base = strlen (digits);
@@
-378,10
+378,14
@@
printf_integer (uintmax_t value, bool negative, const char *digits,
will output the buffer's content in reverse. This is also
the reason that later we append zeros and the sign. */
cp = buf;
will output the buffer's content in reverse. This is also
the reason that later we append zeros and the sign. */
cp = buf;
+ group_cnt = 0;
while (value > 0)
{
while (value > 0)
{
- if ((c->flags & GROUP) && cp > buf && (cp - buf) % 3 == 0)
- *cp++ = ',';
+ if ((c->flags & GROUP) && group_cnt++ == 3)
+ {
+ *cp++ = ',';
+ group_cnt = 0;
+ }
*cp++ = digits[value % base];
value /= base;
}
*cp++ = digits[value % base];
value /= base;
}