diff options
author | David Robillard <d@drobilla.net> | 2012-03-03 01:47:50 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-03 01:47:50 +0000 |
commit | 5d73ff3a0b529954e5192f892c21a4ad068905c9 (patch) | |
tree | b2c308ee865bf609fbacb3f8c18a8b9a2be4bd04 /src | |
parent | fd3eaa93bde291707405968491ba9a9ab32e41ca (diff) | |
download | serd-5d73ff3a0b529954e5192f892c21a4ad068905c9.tar.gz serd-5d73ff3a0b529954e5192f892c21a4ad068905c9.tar.bz2 serd-5d73ff3a0b529954e5192f892c21a4ad068905c9.zip |
Fix reading of empty files (e.g. /dev/null) test case.
git-svn-id: http://svn.drobilla.net/serd/trunk@328 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 14 | ||||
-rw-r--r-- | src/serdi.c | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/reader.c b/src/reader.c index 41e0fb7d..333aabde 100644 --- a/src/reader.c +++ b/src/reader.c @@ -98,7 +98,7 @@ error(SerdReader* reader, const char* fmt, ...) return 0; } -static inline bool +static inline SerdStatus page(SerdReader* reader) { reader->read_head = 0; @@ -106,11 +106,11 @@ page(SerdReader* reader) if (n_read == 0) { reader->read_buf[0] = '\0'; reader->eof = true; - return false; + return ferror(reader->fd) ? SERD_ERR_UNKNOWN : SERD_FAILURE; } else if (n_read < SERD_PAGE_SIZE) { reader->read_buf[n_read] = '\0'; } - return true; + return SERD_SUCCESS; } static inline uint8_t @@ -1461,16 +1461,16 @@ serd_reader_read_file_handle(SerdReader* me, FILE* file, const uint8_t* name) memset(me->read_buf, '\0', SERD_PAGE_SIZE); - bool ret = page(me); - if (ret) { + SerdStatus st = page(me); + if (!st) { skip_bom(me); - ret = read_turtleDoc(me); + st = read_turtleDoc(me) ? SERD_SUCCESS : SERD_ERR_UNKNOWN; } free(me->read_buf); me->fd = 0; me->read_buf = NULL; - return ret ? SERD_SUCCESS : SERD_ERR_UNKNOWN; + return st; } SERD_API diff --git a/src/serdi.c b/src/serdi.c index 63822e94..661b60e0 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -215,5 +215,5 @@ main(int argc, char** argv) serd_env_free(env); serd_node_free(&base_uri_node); - return (status == SERD_SUCCESS) ? 0 : 1; + return (status > SERD_FAILURE) ? 1 : 0; } |