From 946dcf4a5d9e35046eb4c2bd4c31e2d4633199e0 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 3 Aug 2009 17:22:03 -0700 Subject: Fix tests (and src) such that all tests pass again. --- src/upb_parse.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/upb_parse.h') diff --git a/src/upb_parse.h b/src/upb_parse.h index e727c11..f0ec5e2 100644 --- a/src/upb_parse.h +++ b/src/upb_parse.h @@ -208,6 +208,38 @@ INLINE upb_status_t upb_get_f_uint64_t(uint8_t *buf, uint8_t *end, return UPB_STATUS_OK; } +INLINE upb_status_t upb_skip_v_uint64_t(uint8_t *buf, uint8_t *end, + uint8_t **outbuf) +{ + uint8_t *const maxend = buf + 10; + uint8_t last = 0x80; + for(; buf < (uint8_t*)end && (last & 0x80); buf++) + last = *buf; + if(buf >= end && buf <= maxend && (last & 0x80)) return UPB_STATUS_NEED_MORE_DATA; + if(buf > maxend) return UPB_ERROR_UNTERMINATED_VARINT; + *outbuf = buf; + return UPB_STATUS_OK; +} + +INLINE upb_status_t upb_skip_f_uint32_t(uint8_t *buf, uint8_t *end, uint8_t + **outbuf) +{ + uint8_t *uint32_end = buf + sizeof(uint32_t); + if(uint32_end > end) return UPB_STATUS_NEED_MORE_DATA; + *outbuf = uint32_end; + return UPB_STATUS_OK; +} + +INLINE upb_status_t upb_skip_f_uint64_t(uint8_t *buf, uint8_t *end, uint8_t + **outbuf) +{ + uint8_t *uint64_end = buf + sizeof(uint64_t); + if(uint64_end > end) return UPB_STATUS_NEED_MORE_DATA; + *outbuf = uint64_end; + return UPB_STATUS_OK; +} + + /* Functions to read .proto values. *******************************************/ /* These functions read the appropriate wire value for a given .proto type -- cgit v1.2.3