Mercurial > hg > th-libs
comparison th_string.c @ 320:0362ea9872f0
Some work on sign handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Feb 2016 01:42:34 +0200 |
parents | c532088b4f05 |
children | f7d72b7bebf3 |
comparison
equal
deleted
inserted
replaced
319:f2af6049d958 | 320:0362ea9872f0 |
---|---|
157 return 0; | 157 return 0; |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 int th_printf_vput_intstr(th_printf_ctx *ctx, th_printf_vputch vputch, | 161 int th_printf_vput_intstr(th_printf_ctx *ctx, th_printf_vputch vputch, |
162 const char *buf, const int f_width, int pos, int f_prec, int f_flags) | 162 const char *buf, const int f_width, int pos, int f_prec, int f_flags, |
163 const char f_sign) | |
163 { | 164 { |
164 // Calculate necessary padding, if any | 165 // Calculate necessary padding, if any |
165 int ret, nwidth = f_width - pos; | 166 int ret, nwidth = f_width - pos; |
166 | 167 |
168 if (f_sign) | |
169 nwidth--; | |
170 | |
167 if (f_prec > 0 && f_prec > pos) | 171 if (f_prec > 0 && f_prec > pos) |
168 { | 172 { |
169 nwidth = nwidth - f_prec + 1; | 173 nwidth = nwidth - f_prec + 1; |
170 f_flags &= ~TH_PF_ZERO; | 174 f_flags &= ~TH_PF_ZERO; |
171 } | 175 } |
172 | 176 |
173 // Prefix padding? | 177 // Prefix padding? |
174 if ((ret = th_printf_pad_pre(ctx, vputch, nwidth, f_flags)) == EOF) | 178 if ((ret = th_printf_pad_pre(ctx, vputch, nwidth, f_flags)) == EOF) |
179 return ret; | |
180 | |
181 if (f_sign && (ret = vputch(ctx, f_sign)) == EOF) | |
175 return ret; | 182 return ret; |
176 | 183 |
177 if (f_prec > 0 && f_prec > pos) | 184 if (f_prec > 0 && f_prec > pos) |
178 { | 185 { |
179 while (--f_prec) | 186 while (--f_prec) |