aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/n3.c32
-rw-r--r--src/uri.c6
2 files changed, 16 insertions, 22 deletions
diff --git a/src/n3.c b/src/n3.c
index 3e0db7e8..8832f746 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -305,32 +305,28 @@ read_STRING_LITERAL_LONG(SerdReader* reader, SerdNodeFlags* flags, uint8_t q)
Ref ref = push_node(reader, SERD_LITERAL, "", 0);
while (!reader->status) {
const uint8_t c = peek_byte(reader);
- uint32_t code;
- switch (c) {
- case '\\':
+ if (c == '\\') {
eat_byte_safe(reader, c);
+ uint32_t code;
if (!read_ECHAR(reader, ref, flags) &&
!read_UCHAR(reader, ref, &code)) {
r_err(reader, SERD_ERR_BAD_SYNTAX,
"invalid escape `\\%c'\n", peek_byte(reader));
return pop_node(reader, ref);
}
- break;
- default:
- if (c == q) {
- eat_byte_safe(reader, q);
- const uint8_t q2 = eat_byte_safe(reader, peek_byte(reader));
- const uint8_t q3 = peek_byte(reader);
- if (q2 == q && q3 == q) { // End of string
- eat_byte_safe(reader, q3);
- return ref;
- }
- *flags |= SERD_HAS_QUOTE;
- push_byte(reader, ref, c);
- read_character(reader, ref, flags, q2);
- } else {
- read_character(reader, ref, flags, eat_byte_safe(reader, c));
+ } else if (c == q) {
+ eat_byte_safe(reader, q);
+ const uint8_t q2 = eat_byte_safe(reader, peek_byte(reader));
+ const uint8_t q3 = peek_byte(reader);
+ if (q2 == q && q3 == q) { // End of string
+ eat_byte_safe(reader, q3);
+ return ref;
}
+ *flags |= SERD_HAS_QUOTE;
+ push_byte(reader, ref, c);
+ read_character(reader, ref, flags, q2);
+ } else {
+ read_character(reader, ref, flags, eat_byte_safe(reader, c));
}
}
return ref;
diff --git a/src/uri.c b/src/uri.c
index 0ee9dade..f347f010 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -188,12 +188,10 @@ query:
if (*ptr == '?') {
out->query.buf = ++ptr;
for (uint8_t c; (c = *ptr) != '\0'; ++ptr) {
- switch (c) {
- case '#':
+ if (c == '#') {
goto fragment;
- default:
- ++out->query.len;
}
+ ++out->query.len;
}
}