Rev 2465 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2465 | Rev 4034 | ||
---|---|---|---|
Line 82... | Line 82... | ||
82 | * |
82 | * |
83 | */ |
83 | */ |
84 | static void print_number(const unative_t num, const unsigned int base) |
84 | static void print_number(const unative_t num, const unsigned int base) |
85 | { |
85 | { |
86 | int val = num; |
86 | int val = num; |
- | 87 | ||
- | 88 | /* This is enough even for base 2. */ |
|
87 | char d[sizeof(unative_t) * 8 + 1]; /* this is good enough even for base == 2 */ |
89 | char d[sizeof(unative_t) * 8 + 1]; |
88 | int i = sizeof(unative_t) * 8 - 1; |
90 | int i = sizeof(unative_t) * 8 - 1; |
89 | 91 | ||
90 | do { |
92 | do { |
91 | d[i--] = digits[val % base]; |
93 | d[i--] = digits[val % base]; |
92 | } while (val /= base); |
94 | } while (val /= base); |
Line 186... | Line 188... | ||
186 | * Hexadecimal conversions with fixed width. |
188 | * Hexadecimal conversions with fixed width. |
187 | */ |
189 | */ |
188 | case 'P': |
190 | case 'P': |
189 | puts("0x"); |
191 | puts("0x"); |
190 | case 'p': |
192 | case 'p': |
191 | print_fixed_hex(va_arg(ap, unative_t), sizeof(unative_t)); |
193 | print_fixed_hex(va_arg(ap, unative_t), |
- | 194 | sizeof(unative_t)); |
|
192 | goto loop; |
195 | goto loop; |
193 | 196 | ||
194 | case 'Q': |
197 | case 'Q': |
195 | puts("0x"); |
198 | puts("0x"); |
196 | case 'q': |
199 | case 'q': |
Line 236... | Line 239... | ||
236 | } |
239 | } |
237 | 240 | ||
238 | default: |
241 | default: |
239 | write(&c, 1); |
242 | write(&c, 1); |
240 | } |
243 | } |
241 | - | ||
242 | loop: |
244 | loop: |
243 | ; |
245 | ; |
244 | } |
246 | } |
245 | 247 | ||
246 | out: |
248 | out: |