comparison th_string.c @ 358:a224327ad94e

More work.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 25 Feb 2016 10:58:48 +0200
parents 77201824790c
children b1984383aaac
comparison
equal deleted inserted replaced
357:77201824790c 358:a224327ad94e
189 189
190 if (ret == EOF) 190 if (ret == EOF)
191 return ret; 191 return ret;
192 192
193 f_altstr = ret != 0 && (f_flags & TH_PF_ALT) && f_alt != NULL ? f_alt(f_flags) : NULL; 193 f_altstr = ret != 0 && (f_flags & TH_PF_ALT) && f_alt != NULL ? f_alt(f_flags) : NULL;
194 if (f_flags & TH_PF_ALT) f_width = 0;
195 194
196 // Are we using a sign prefix? 195 // Are we using a sign prefix?
197 f_sign = f_unsig ? 0 : ((f_flags & TH_PF_SIGN) ? 196 f_sign = f_unsig ? 0 : ((f_flags & TH_PF_SIGN) ?
198 (f_neg ? '-' : '+') : 197 (f_neg ? '-' : '+') :
199 (f_neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0))); 198 (f_neg ? '-' : ((f_flags & TH_PF_SPACE) ? ' ' : 0)));
233 232
234 static int th_printf_vput_str(th_printf_ctx *ctx, th_printf_vputch vputch, 233 static int th_printf_vput_str(th_printf_ctx *ctx, th_printf_vputch vputch,
235 const char *str, int f_flags, const int f_width, const int f_prec) 234 const char *str, int f_flags, const int f_width, const int f_prec)
236 { 235 {
237 int nwidth, f_len, ret = 0; 236 int nwidth, f_len, ret = 0;
238
239 f_flags &= ~TH_PF_ZERO;
240 237
241 // Check for null strings 238 // Check for null strings
242 if (str == NULL) 239 if (str == NULL)
243 str = "(null)"; 240 str = "(null)";
244 241
407 break; 404 break;
408 405
409 case 'p': 406 case 'p':
410 #if (TH_PTRSIZE == 32) 407 #if (TH_PTRSIZE == 32)
411 f_flags = TH_PF_LONG; 408 f_flags = TH_PF_LONG;
412 f_prec = 4*2;
413 #elif (TH_PTRSIZE == 64) 409 #elif (TH_PTRSIZE == 64)
414 f_flags = TH_PF_LONGLONG; 410 f_flags = TH_PF_LONGLONG;
415 f_prec = 8*2;
416 #endif 411 #endif
417 // f_flags |= TH_PF_ZERO; 412 f_flags |= TH_PF_ALT;
418 if ((ret = th_printf_vput_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_printf_altfmt_hex)) == EOF) 413 if ((ret = th_printf_vput_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_printf_altfmt_hex)) == EOF)
419 goto out; 414 goto out;
420 break; 415 break;
421 416
422 case 'f': 417 case 'f':