diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 13 | ||||
-rw-r--r-- | src/serdi.c | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/reader.c b/src/reader.c index e6af0b1c..5465dba6 100644 --- a/src/reader.c +++ b/src/reader.c @@ -87,6 +87,7 @@ struct SerdReaderImpl { bool paging; ///< True iff reading a page at a time bool strict; ///< True iff strict parsing bool eof; + bool error; bool seen_genid; #ifdef SERD_STACK_CHECK Ref* allocs; ///< Stack of push offsets @@ -115,7 +116,13 @@ page(SerdReader* reader) if (n_read == 0) { reader->file_buf[0] = '\0'; reader->eof = true; - return ferror(reader->fd) ? SERD_ERR_UNKNOWN : SERD_FAILURE; + if (ferror(reader->fd)) { + reader->error = true; + return r_err(reader, SERD_ERR_UNKNOWN, + "read error: %s\n", strerror(errno)); + } else { + return SERD_FAILURE; + } } else if (n_read < SERD_PAGE_SIZE) { reader->file_buf[n_read] = '\0'; } @@ -1446,7 +1453,7 @@ read_statement(SerdReader* reader) switch (peek_byte(reader)) { case '\0': reader->eof = true; - return true; + return !reader->error; case '@': TRY_RET(read_directive(reader)); read_ws_star(reader); @@ -1472,7 +1479,7 @@ read_turtleDoc(SerdReader* reader) while (!reader->eof) { TRY_RET(read_statement(reader)); } - return true; + return !reader->error; } SERD_API diff --git a/src/serdi.c b/src/serdi.c index 2054470e..9332519b 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -252,15 +252,19 @@ main(int argc, char** argv) } serd_reader_free(reader); + serd_writer_finish(writer); + serd_writer_free(writer); + serd_env_free(env); + serd_node_free(&base); if (from_file) { fclose(in_fd); } - serd_writer_finish(writer); - serd_writer_free(writer); - serd_env_free(env); - serd_node_free(&base); + if (fclose(out_fd)) { + perror("serdi: write error"); + status = SERD_ERR_UNKNOWN; + } return (status > SERD_FAILURE) ? 1 : 0; } |