Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308986
b: refs/heads/master
c: 7c20342
h: refs/heads/master
v: v3
  • Loading branch information
Pierre Carrier authored and Linus Torvalds committed May 29, 2012
1 parent 55a1259 commit d68a6c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5536805292e64393f57054de66578f17eb1ea994
refs/heads/master: 7c20342230ff370c397fc4a9c4c1e7a91964bb66
12 changes: 8 additions & 4 deletions trunk/lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ char *number(char *buf, char *end, unsigned long long num,
char locase;
int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
int i;
bool is_zero = num == 0LL;

/* locase = 0 or 0x20. ORing digits or letters with 'locase'
* produces same digits or (maybe lowercased) letters */
Expand All @@ -305,8 +306,9 @@ char *number(char *buf, char *end, unsigned long long num,
}
}
if (need_pfx) {
spec.field_width--;
if (spec.base == 16)
spec.field_width -= 2;
else if (!is_zero)
spec.field_width--;
}

Expand Down Expand Up @@ -353,9 +355,11 @@ char *number(char *buf, char *end, unsigned long long num,
}
/* "0x" / "0" prefix */
if (need_pfx) {
if (buf < end)
*buf = '0';
++buf;
if (spec.base == 16 || !is_zero) {
if (buf < end)
*buf = '0';
++buf;
}
if (spec.base == 16) {
if (buf < end)
*buf = ('X' | locase);
Expand Down

0 comments on commit d68a6c7

Please sign in to comment.