summaryrefslogtreecommitdiff
path: root/upb/upb.c
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-11-23 16:19:22 -0800
committerJoshua Haberman <jhaberman@gmail.com>2011-11-23 16:19:22 -0800
commitb5f5ee867e6c91b77490dc8894236f17a47bde00 (patch)
treebb11d1e7881d27dfbcb8cef895be53812c57132e /upb/upb.c
parent99ae0ed39723b9c8f97fbdde070681e2a8b7a20e (diff)
Refinement of upb_bytesrc interface.
Added a upb_byteregion that tracks a region of the input buffer; decoders use this instead of using a upb_bytesrc directly. upb_byteregion is also used as the way of passing a string to a upb_handlers callback. This symmetry makes decoders compose better; if you want to take a parsed string and decode it as something else, you can take the string directly from the callback and feed it as input to another parser. A commented-out version of a pinning interface is present; I decline to actually implement it (and accept its extra complexity) until/unless it is clear that it is actually a win. But it is included as a proof-of-concept, to show that it fits well with the existing interface.
Diffstat (limited to 'upb/upb.c')
-rw-r--r--upb/upb.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/upb/upb.c b/upb/upb.c
index a7c4ea0..5002e10 100644
--- a/upb/upb.c
+++ b/upb/upb.c
@@ -71,8 +71,9 @@ void upb_status_seterrliteral(upb_status *status, const char *msg) {
status->space = NULL;
}
-void upb_status_copy(upb_status *to, upb_status *from) {
+void upb_status_copy(upb_status *to, const upb_status *from) {
to->status = from->status;
+ to->eof = from->eof;
to->code = from->code;
to->space = from->space;
if (from->str == from->buf) {
@@ -100,6 +101,7 @@ const char *upb_status_getstr(const upb_status *_status) {
void upb_status_clear(upb_status *status) {
status->status = UPB_OK;
+ status->eof = false;
status->code = 0;
status->space = NULL;
status->str = NULL;
@@ -124,7 +126,7 @@ void upb_status_fromerrno(upb_status *status) {
upb_errorspace upb_posix_errorspace = {"POSIX", NULL}; // TODO
-int upb_vrprintf(char **buf, size_t *size, size_t ofs,
+int upb_vrprintf(char **buf, uint32_t *size, uint32_t ofs,
const char *fmt, va_list args) {
// Try once without reallocating. We have to va_copy because we might have
// to call vsnprintf again.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback