diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2011-05-08 13:05:12 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2011-05-08 13:05:12 -0700 |
commit | f74534b42ac9ac8b0ff496cb0da83f1201bbf8da (patch) | |
tree | cf20bb7160a6f37cecd5c2cb4222c03b88e4fcde /src/upb_textprinter.c | |
parent | 4a99abba123fc1d2bef62778846a1f27b2012de0 (diff) |
Decoder redesign in preparation for packed fields and start/endseq.
Diffstat (limited to 'src/upb_textprinter.c')
-rw-r--r-- | src/upb_textprinter.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/upb_textprinter.c b/src/upb_textprinter.c index 948d28c..52be51e 100644 --- a/src/upb_textprinter.c +++ b/src/upb_textprinter.c @@ -7,9 +7,10 @@ #include "upb_textprinter.h" +#include <ctype.h> +#include <float.h> #include <inttypes.h> #include <stdlib.h> -#include <ctype.h> struct _upb_textprinter { upb_bytesink *bytesink; @@ -99,10 +100,12 @@ static upb_flow_t upb_textprinter_value(void *_p, upb_value fval, #define CASE(fmtstr, member) \ CHECK(upb_bytesink_printf(p->bytesink, &p->status, fmtstr, upb_value_get ## member(val))); break; switch(f->type) { + // TODO: figure out what we should really be doing for these + // floating-point formats. case UPB_TYPE(DOUBLE): - CASE("%0.f", double); + CHECK(upb_bytesink_printf(p->bytesink, &p->status, "%.*g", DBL_DIG, upb_value_getdouble(val))); break; case UPB_TYPE(FLOAT): - CASE("%0.f", float) + CHECK(upb_bytesink_printf(p->bytesink, &p->status, "%.*g", FLT_DIG+2, upb_value_getfloat(val))); break; case UPB_TYPE(INT64): case UPB_TYPE(SFIXED64): case UPB_TYPE(SINT64): |