Mercurial > hg > th-libs
comparison th_string.c @ 431:d41cb5983772
#ifdef out WIP floating point support from printf() implementation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 07 Nov 2016 02:57:23 +0200 |
parents | 77fd4f0327dc |
children | 1b3472ba7b23 |
comparison
equal
deleted
inserted
replaced
430:f8eb47b52a75 | 431:d41cb5983772 |
---|---|
339 // Postfix padding? | 339 // Postfix padding? |
340 return th_printf_pad_post(ctx, vputch, nwidth, f_flags); | 340 return th_printf_pad_post(ctx, vputch, nwidth, f_flags); |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 #ifdef WIP_FLOAT_SUPPORT | |
344 static int th_vprintf_put_float(th_vprintf_ctx *ctx, th_vprintf_putch vputch, | 345 static int th_vprintf_put_float(th_vprintf_ctx *ctx, th_vprintf_putch vputch, |
345 va_list ap, int f_flags, int f_width, int f_prec) | 346 va_list ap, int f_flags, int f_width, int f_prec) |
346 { | 347 { |
347 double pval = va_arg(ap, double); // This needs to be double for type promotion to occur | 348 double pval = va_arg(ap, double); // This needs to be double for type promotion to occur |
348 int64_t val; | 349 int64_t val; |
357 int64_t d_exp = (val >> 52) & 0x7ff; | 358 int64_t d_exp = (val >> 52) & 0x7ff; |
358 uint64_t d_man = val & 0x0fffffffffffff; | 359 uint64_t d_man = val & 0x0fffffffffffff; |
359 | 360 |
360 return 0; | 361 return 0; |
361 } | 362 } |
363 #endif | |
362 | 364 |
363 | 365 |
364 static char * th_printf_altfmt_oct(const char *buf, const size_t len, const int vret, const int flags) | 366 static char * th_printf_altfmt_oct(const char *buf, const size_t len, const int vret, const int flags) |
365 { | 367 { |
366 (void) vret; | 368 (void) vret; |
372 | 374 |
373 static char * th_printf_altfmt_hex(const char *buf, const size_t len, const int vret, const int flags) | 375 static char * th_printf_altfmt_hex(const char *buf, const size_t len, const int vret, const int flags) |
374 { | 376 { |
375 (void) buf; | 377 (void) buf; |
376 (void) vret; | 378 (void) vret; |
379 (void) len; | |
377 if (vret != 0) | 380 if (vret != 0) |
378 return (flags & TH_PF_UPCASE) ? "0X" : "0x"; | 381 return (flags & TH_PF_UPCASE) ? "0X" : "0x"; |
379 else | 382 else |
380 return ""; | 383 return ""; |
381 } | 384 } |
543 f_flags |= TH_PF_ALT | TH_PF_POINTER; | 546 f_flags |= TH_PF_ALT | TH_PF_POINTER; |
544 if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_printf_altfmt_hex)) == EOF) | 547 if ((ret = th_vprintf_put_int(ctx, vputch, ap, 16, f_flags, f_width, f_prec, TRUE, th_printf_altfmt_hex)) == EOF) |
545 goto out; | 548 goto out; |
546 break; | 549 break; |
547 | 550 |
551 #ifdef WIP_FLOAT_SUPPORT | |
548 case 'f': | 552 case 'f': |
549 case 'F': | 553 case 'F': |
550 if ((ret = th_vprintf_put_float(ctx, vputch, ap, | 554 if ((ret = th_vprintf_put_float(ctx, vputch, ap, |
551 f_flags, f_width, f_prec)) == EOF) | 555 f_flags, f_width, f_prec)) == EOF) |
552 goto out; | 556 goto out; |
553 break; | 557 break; |
558 #endif | |
554 | 559 |
555 case 's': | 560 case 's': |
556 if ((ret = th_vprintf_put_str(ctx, vputch, va_arg(ap, char *), | 561 if ((ret = th_vprintf_put_str(ctx, vputch, va_arg(ap, char *), |
557 f_flags, f_width, f_prec)) == EOF) | 562 f_flags, f_width, f_prec)) == EOF) |
558 goto out; | 563 goto out; |