aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-03 01:47:50 +0000
committerDavid Robillard <d@drobilla.net>2012-03-03 01:47:50 +0000
commit5d73ff3a0b529954e5192f892c21a4ad068905c9 (patch)
treeb2c308ee865bf609fbacb3f8c18a8b9a2be4bd04 /src/reader.c
parentfd3eaa93bde291707405968491ba9a9ab32e41ca (diff)
downloadserd-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/reader.c')
-rw-r--r--src/reader.c14
1 files changed, 7 insertions, 7 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