From abcb6428ad9bf7d650455a0a180647a05183fd9d Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 30 Jul 2015 14:54:03 -0700 Subject: Changed parser semantics around skipping. Prior to this change: parse(buf, len) -> len + N ...would indicate that the next N bytes of the input are not needed, *and* would advance the decoding position by this much. After this change: parse(buf, len) -> len + N parse(NULL, N) -> N ...can be used to achieve the same thing. But skipping the N bytes is not explicitly performed by the user. A user that doesn't want/need to skip can just say: parsed = parse(buf, len); if (parsed < len) { // Handle suspend, advance stream by "parsed". } else { // Stream was advanced by "len" (even if parsed > len). } Updated unit tests to test this new behavior, and refactored test utility code a bit to support it. --- upb/sink.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'upb/sink.h') diff --git a/upb/sink.h b/upb/sink.h index e7d4960..765916e 100644 --- a/upb/sink.h +++ b/upb/sink.h @@ -272,7 +272,7 @@ UPB_INLINE bool upb_bufsrc_putbuf(const char *buf, size_t len, upb_bufhandle_setbuf(&handle, buf, 0); ret = upb_bytessink_start(sink, len, &subc); if (ret && len != 0) { - ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) == len); + ret = (upb_bytessink_putbuf(sink, subc, buf, len, &handle) >= len); } if (ret) { ret = upb_bytessink_end(sink); -- cgit v1.2.3