Mercurial > hg > th-libs
comparison th_printf1.c @ 320:0362ea9872f0
Some work on sign handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Feb 2016 01:42:34 +0200 |
parents | f8c385739571 |
children | 40ce4106f4ad |
comparison
equal
deleted
inserted
replaced
319:f2af6049d958 | 320:0362ea9872f0 |
---|---|
18 #endif | 18 #endif |
19 const BOOL upcase) | 19 const BOOL upcase) |
20 { | 20 { |
21 char buf[64]; | 21 char buf[64]; |
22 size_t pos = 0; | 22 size_t pos = 0; |
23 int ret = 0; | 23 char f_sign = 0; |
24 #ifdef TH_PFUNC_SIGNED | 24 #ifdef TH_PFUNC_SIGNED |
25 BOOL neg = FALSE; | 25 BOOL neg = FALSE; |
26 #endif | 26 #endif |
27 | 27 |
28 if (radix > 16) | 28 if (radix > 16) |
57 return EOF; | 57 return EOF; |
58 | 58 |
59 // Do we want a sign prefix? Not for unsigned values | 59 // Do we want a sign prefix? Not for unsigned values |
60 #ifdef TH_PFUNC_SIGNED | 60 #ifdef TH_PFUNC_SIGNED |
61 if (!unsig) | 61 if (!unsig) |
62 { | 62 f_sign = (f_flags & TH_PF_SIGN) ? (neg ? '-' : '+') : (neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0)); |
63 char ch = (f_flags & TH_PF_SIGN) ? (neg ? '-' : '+') : (neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0)); | |
64 if (ch && (ret = vputch(ctx, ch)) == EOF) | |
65 goto out; | |
66 } | |
67 #endif | 63 #endif |
68 | 64 |
69 // Output the data | 65 // Output the data |
70 return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_prec, f_flags); | 66 return th_printf_vput_intstr(ctx, vputch, buf, f_width, pos, f_prec, f_flags, f_sign); |
71 | |
72 #ifdef TH_PFUNC_SIGNED | |
73 out: | |
74 #endif | |
75 return ret; | |
76 } | 67 } |
77 | 68 |
78 | 69 |
79 #undef TH_PFUNC_NAME | 70 #undef TH_PFUNC_NAME |
80 #undef TH_PFUNC_SIGNED | 71 #undef TH_PFUNC_SIGNED |