aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.h')
-rw-r--r--src/reader.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/reader.h b/src/reader.h
index 00a41794..c562ac6c 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -7,6 +7,7 @@
#include "byte_source.h"
#include "node.h"
#include "stack.h"
+#include "try.h"
#include "serd/attributes.h"
#include "serd/error.h"
@@ -119,26 +120,28 @@ eat_byte_safe(SerdReader* reader, const int byte)
return byte;
}
-static inline int SERD_NODISCARD
+static inline SerdStatus SERD_NODISCARD
eat_byte_check(SerdReader* reader, const int byte)
{
const int c = peek_byte(reader);
if (c != byte) {
- r_err(reader, SERD_BAD_SYNTAX, "expected '%c', not '%c'\n", byte, c);
- return 0;
+ return r_err(reader, SERD_BAD_SYNTAX, "expected '%c', not '%c'\n", byte, c);
}
- return eat_byte_safe(reader, byte);
+
+ skip_byte(reader, c);
+ return SERD_SUCCESS;
}
static inline SerdStatus
eat_string(SerdReader* reader, const char* str, unsigned n)
{
+ SerdStatus st = SERD_SUCCESS;
+
for (unsigned i = 0; i < n; ++i) {
- if (!eat_byte_check(reader, str[i])) {
- return SERD_BAD_SYNTAX;
- }
+ TRY(st, eat_byte_check(reader, str[i]));
}
- return SERD_SUCCESS;
+
+ return st;
}
static inline SerdStatus