summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2010-07-17 15:13:05 -0700
committerJoshua Haberman <joshua@reverberate.org>2010-07-17 15:13:05 -0700
commitb77db146466a113bbfb9e56472bda1975f7a25a5 (patch)
tree1acec35fe8245d24bc3cb3d4ff2223e2559d1b9e
parentaf9d691a344746b15fb1df2e454273b637d20433 (diff)
Fixed broken submsg support in upb_streamdata.
-rw-r--r--core/upb_stream.c38
-rw-r--r--stream/upb_textprinter.c2
2 files changed, 23 insertions, 17 deletions
diff --git a/core/upb_stream.c b/core/upb_stream.c
index bda11de..e63ba00 100644
--- a/core/upb_stream.c
+++ b/core/upb_stream.c
@@ -14,24 +14,30 @@
void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) {
upb_fielddef *f;
upb_string *str = NULL;
- while((f = upb_src_getdef(src)) != NULL) {
- CHECKSINK(upb_sink_putdef(sink, f));
- if(upb_issubmsg(f)) {
- // We always recurse into submessages, but the putdef above already told
- // the sink that.
- } else if(upb_isstring(f)) {
- str = upb_string_tryrecycle(str);
- CHECKSRC(upb_src_getstr(src, str));
- CHECKSINK(upb_sink_putstr(sink, str));
- } else {
- // Primitive type.
- upb_value val;
- CHECKSRC(upb_src_getval(src, upb_value_addrof(&val)));
- CHECKSINK(upb_sink_putval(sink, val));
+ int depth = 0;
+ while(1) {
+ while((f = upb_src_getdef(src)) != NULL) {
+ CHECKSINK(upb_sink_putdef(sink, f));
+ if(upb_issubmsg(f)) {
+ upb_src_startmsg(src);
+ upb_sink_startmsg(sink);
+ ++depth;
+ } else if(upb_isstring(f)) {
+ str = upb_string_tryrecycle(str);
+ CHECKSRC(upb_src_getstr(src, str));
+ CHECKSINK(upb_sink_putstr(sink, str));
+ } else {
+ // Primitive type.
+ upb_value val;
+ CHECKSRC(upb_src_getval(src, upb_value_addrof(&val)));
+ CHECKSINK(upb_sink_putval(sink, val));
+ }
}
+ // If we're not EOF now, the loop terminated due to an error.
+ CHECKSRC(upb_src_eof(src));
+ if (depth == 0) break;
+ --depth;
}
- // If we're not EOF now, the loop terminated due to an error.
- CHECKSRC(upb_src_eof(src));
return;
src_err:
diff --git a/stream/upb_textprinter.c b/stream/upb_textprinter.c
index 11ad6a8..201edba 100644
--- a/stream/upb_textprinter.c
+++ b/stream/upb_textprinter.c
@@ -79,7 +79,7 @@ static bool upb_textprinter_putdef(upb_textprinter *p, upb_fielddef *f)
{
upb_textprinter_indent(p);
upb_bytesink_put(p->bytesink, f->name);
- upb_bytesink_put(p->bytesink, UPB_STRLIT(":"));
+ upb_bytesink_put(p->bytesink, UPB_STRLIT(": "));
p->f = f;
return upb_ok(upb_bytesink_status(p->bytesink));
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback