aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/read_turtle.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/read_turtle.c b/src/read_turtle.c
index ef76c858..19a47ebf 100644
--- a/src/read_turtle.c
+++ b/src/read_turtle.c
@@ -26,6 +26,14 @@
#include <stdio.h>
#include <string.h>
+/// Like TRY() but tolerates SERD_FAILURE
+#define TRY_LAX(st, exp) \
+ do { \
+ if (((st) = (exp)) > SERD_FAILURE) { \
+ return (st); \
+ } \
+ } while (0)
+
static SerdStatus
read_collection(SerdReader* reader, ReadContext ctx, SerdNode** dest);
@@ -301,7 +309,7 @@ read_PrefixedName(SerdReader* const reader,
{
SerdStatus st = SERD_SUCCESS;
if (read_prefix) {
- TRY_FAILING(st, read_PN_PREFIX(reader, dest));
+ TRY_LAX(st, read_PN_PREFIX(reader, dest));
}
if (peek_byte(reader) != ':') {
@@ -464,10 +472,8 @@ read_verb(SerdReader* const reader, SerdNode** const dest)
return SERD_BAD_STACK;
}
- SerdStatus st = read_PN_PREFIX(reader, *dest);
- if (st > SERD_FAILURE) {
- return st;
- }
+ SerdStatus st = SERD_SUCCESS;
+ TRY_LAX(st, read_PN_PREFIX(reader, *dest));
bool ate_dot = false;
SerdNode* node = *dest;
@@ -897,8 +903,7 @@ read_turtle_prefixID(SerdReader* const reader,
return SERD_BAD_STACK;
}
- TRY_FAILING(st, read_PN_PREFIX(reader, name));
-
+ TRY_LAX(st, read_PN_PREFIX(reader, name));
TRY(st, eat_byte_check(reader, ':'));
read_turtle_ws_star(reader);
@@ -959,10 +964,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
// Try to read a subject, though it may actually be a directive or graph name
SerdNode* token = NULL;
int s_type = 0;
- if ((st = read_turtle_subject(reader, *ctx, &token, &s_type)) >
- SERD_FAILURE) {
- return st;
- }
+ TRY_LAX(st, read_turtle_subject(reader, *ctx, &token, &s_type));
// Try to interpret as a SPARQL "PREFIX" or "BASE" directive
if (st && (st = read_sparql_directive(reader, token)) != SERD_FAILURE) {
@@ -976,9 +978,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
// Our token is really a subject, read some triples
bool ate_dot = false;
ctx->subject = token;
- if ((st = read_turtle_triples(reader, *ctx, &ate_dot)) > SERD_FAILURE) {
- return st;
- }
+ TRY_LAX(st, read_turtle_triples(reader, *ctx, &ate_dot));
// "Failure" is only allowed for anonymous subjects like "[ ... ] ."
if (st && s_type != '[') {