From f74534b42ac9ac8b0ff496cb0da83f1201bbf8da Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sun, 8 May 2011 13:05:12 -0700 Subject: Decoder redesign in preparation for packed fields and start/endseq. --- src/upb_textprinter.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/upb_textprinter.c') 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 +#include #include #include -#include 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): -- cgit v1.2.3