aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-09-23 21:30:52 +0200
committerDavid Robillard <d@drobilla.net>2017-09-23 21:30:52 +0200
commit8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e (patch)
tree6bc42d4c19c76094f39b24edde892f9a77e03edb /src
parent730052666c993e40606a9633865eb46e61867f78 (diff)
downloadserd-8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e.tar.gz
serd-8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e.tar.bz2
serd-8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e.zip
Add basic error tolerant parsing for line-based formats
Diffstat (limited to 'src')
-rw-r--r--src/reader.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/reader.c b/src/reader.c
index afaf411e..9e30f9c1 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -1669,11 +1669,25 @@ read_statement(SerdReader* reader)
return ret;
}
+static void
+skip_until(SerdReader* reader, uint8_t byte)
+{
+ for (uint8_t c = 0; (c = peek_byte(reader)) && c != byte;) {
+ eat_byte_safe(reader, c);
+ }
+}
+
static bool
read_turtleTrigDoc(SerdReader* reader)
{
while (!reader->eof) {
- TRY_RET(read_statement(reader));
+ if (!read_statement(reader)) {
+ if (reader->strict) {
+ return 0;
+ }
+ skip_until(reader, '\n');
+ reader->status = SERD_ERR_BAD_SYNTAX;
+ }
}
return reader->status <= SERD_FAILURE;
}