From 48fedab345674000dd2f8dd4d8356ee995d9263e Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 27 Aug 2011 18:44:37 -0700 Subject: Add packed field support (untested). --- upb/bytestream.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'upb/bytestream.c') diff --git a/upb/bytestream.c b/upb/bytestream.c index 976b139..dc2fa61 100644 --- a/upb/bytestream.c +++ b/upb/bytestream.c @@ -66,12 +66,12 @@ size_t upb_stdio_fetch(void *src, uint64_t ofs, upb_status *s) { size_t read = fread(&buf->data, 1, BUF_SIZE, stdio->file); if(read < (size_t)BUF_SIZE) { // Error or EOF. - if(feof(stdio->file)) { - upb_status_setf(s, UPB_EOF, ""); - } else if(ferror(stdio->file)) { + if(feof(stdio->file)) return 0; + if(ferror(stdio->file)) { upb_status_fromerrno(s); - return 0; + return -1; } + assert(false); } buf->len = read; return buf->ofs + buf->len; @@ -190,9 +190,8 @@ upb_bytesink* upb_stdio_bytesink(upb_stdio *stdio) { return &stdio->sink; } size_t upb_stringsrc_fetch(void *_src, uint64_t ofs, upb_status *s) { upb_stringsrc *src = _src; - size_t bytes = src->len - ofs; - if (bytes == 0) s->code = UPB_EOF; - return bytes; + (void)s; // No errors can occur. + return src->len - ofs; } void upb_stringsrc_read(void *_src, uint64_t src_ofs, size_t len, char *dst) { -- cgit v1.2.3