diff options
-rw-r--r-- | src/reader.c | 13 | ||||
-rw-r--r-- | src/serdi.c | 2 | ||||
-rw-r--r-- | tests/bad-eof-in-blank.ttl | 3 | ||||
-rw-r--r-- | tests/bad-eof-in-list.ttl | 3 | ||||
-rw-r--r-- | tests/bad-eof-in-string.ttl | 3 | ||||
-rw-r--r-- | tests/bad-eof-in-uri.ttl | 3 | ||||
-rw-r--r-- | wscript | 1 |
7 files changed, 17 insertions, 11 deletions
diff --git a/src/reader.c b/src/reader.c index c1c2a1bd..4424c61c 100644 --- a/src/reader.c +++ b/src/reader.c @@ -158,6 +158,7 @@ eat_byte(SerdReader* reader, const uint8_t byte) const uint8_t c = peek_byte(reader); ++reader->read_head; switch (c) { + case '\0': reader->eof = true; break; case '\n': ++reader->cur.line; reader->cur.col = 0; break; default: ++reader->cur.col; } @@ -169,9 +170,6 @@ eat_byte(SerdReader* reader, const uint8_t byte) TRY_RET(page(reader)); assert(reader->read_head < SERD_PAGE_SIZE); } - if (reader->read_buf[reader->read_head] == '\0') { - reader->eof = true; - } return c; } @@ -1204,9 +1202,6 @@ read_objectList(SerdReader* reader, ReadContext ctx, bool blank) static bool read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool blank) { - if (reader->eof) { - return false; - } Ref predicate = 0; TRY_RET(read_verb(reader, &predicate)); TRY_THROW(read_ws_plus(reader)); @@ -1394,10 +1389,10 @@ read_statement(SerdReader* reader) SerdStatementFlags flags = 0; ReadContext ctx = { 0, 0, 0, &flags }; read_ws_star(reader); - if (reader->eof) { - return true; - } switch (peek_byte(reader)) { + case '\0': + reader->eof = true; + return true; case '@': TRY_RET(read_directive(reader)); break; diff --git a/src/serdi.c b/src/serdi.c index 6020a271..c5183008 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -155,7 +155,7 @@ main(int argc, char** argv) if (from_file) { in_name = in_name ? in_name : input; if (!in_fd) { - input = serd_uri_to_path(input); + input = serd_uri_to_path(in_name); if (!(in_fd = serd_fopen((const char*)input, "r"))) { return 1; } diff --git a/tests/bad-eof-in-blank.ttl b/tests/bad-eof-in-blank.ttl new file mode 100644 index 00000000..08c13ae9 --- /dev/null +++ b/tests/bad-eof-in-blank.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:thing [ eg:comment "Thing"
\ No newline at end of file diff --git a/tests/bad-eof-in-list.ttl b/tests/bad-eof-in-list.ttl new file mode 100644 index 00000000..ca6c352f --- /dev/null +++ b/tests/bad-eof-in-list.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:thing ( eg:car eg:cdr
\ No newline at end of file diff --git a/tests/bad-eof-in-string.ttl b/tests/bad-eof-in-string.ttl new file mode 100644 index 00000000..d3a1aa55 --- /dev/null +++ b/tests/bad-eof-in-string.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:comment "This is the string that never ends
\ No newline at end of file diff --git a/tests/bad-eof-in-uri.ttl b/tests/bad-eof-in-uri.ttl new file mode 100644 index 00000000..9bd2a64d --- /dev/null +++ b/tests/bad-eof-in-uri.ttl @@ -0,0 +1,3 @@ +@prefix eg: <http://example.org> . + +<> eg:uri <http://example.org/dontstop
\ No newline at end of file @@ -262,7 +262,6 @@ def test(ctx): os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH') nul = os.devnull autowaf.run_tests(ctx, APPNAME, [ - 'serdi_static file:%s/tests/manifest.ttl > %s' % (srcdir, nul), 'serdi_static file://%s/tests/manifest.ttl > %s' % (srcdir, nul), 'serdi_static %s/tests/UTF-8.ttl > %s' % (srcdir, nul), 'serdi_static -v > %s' % nul, |