diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/n3.c | 3 | ||||
-rw-r--r-- | src/serdi.c | 4 | ||||
-rw-r--r-- | src/string_utils.h | 16 | ||||
-rw-r--r-- | test/meson.build | 5 |
5 files changed, 19 insertions, 12 deletions
@@ -2,13 +2,14 @@ serd (0.32.3) unstable; urgency=medium * Clean up enum declarations * Fix library current_version on MacOS + * Fix overly permissive parsing of syntax names on the command line * Fix parsing NQuads lines with no space before the final dot * Gracefully handle errors while writing the end of anonymous nodes * Support reading lone lists in lax mode * Treat out of range unicode characters as errors * Write blank lines between graphs and statements in TriG - -- David Robillard <d@drobilla.net> Mon, 24 Jun 2024 14:01:08 +0000 + -- David Robillard <d@drobilla.net> Mon, 24 Jun 2024 16:44:31 +0000 serd (0.32.2) stable; urgency=medium @@ -1599,7 +1599,8 @@ tokcmp(SerdReader* const reader, return -1; } - return serd_strncasecmp((const char*)node->buf, tok, n); + assert(node->buf[node->n_bytes] == '\0'); + return serd_strcasecmp((const char*)node->buf, tok); } SerdStatus diff --git a/src/serdi.c b/src/serdi.c index 2bea9e3a..9d0a8f44 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -44,7 +44,7 @@ static SerdSyntax get_syntax(const char* const name) { for (const Syntax* s = syntaxes; s->name; ++s) { - if (!serd_strncasecmp(s->name, name, strlen(name))) { + if (!serd_strcasecmp(s->name, name)) { return s->syntax; } } @@ -59,7 +59,7 @@ guess_syntax(const char* const filename) const char* ext = strrchr(filename, '.'); if (ext) { for (const Syntax* s = syntaxes; s->name; ++s) { - if (!serd_strncasecmp(s->extension, ext, strlen(ext))) { + if (!serd_strcasecmp(s->extension, ext)) { return s->syntax; } } diff --git a/src/string_utils.h b/src/string_utils.h index 7770e1eb..4babee63 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -101,16 +101,20 @@ serd_to_upper(const char c) return (char)((c >= 'a' && c <= 'z') ? c - 32 : c); } -static inline int -serd_strncasecmp(const char* s1, const char* s2, size_t n) +SERD_PURE_FUNC static inline int +serd_strcasecmp(const char* s1, const char* s2) { - for (; n > 0 && *s2; s1++, s2++, --n) { - if (serd_to_upper(*s1) != serd_to_upper(*s2)) { - return ((*(const uint8_t*)s1 < *(const uint8_t*)s2) ? -1 : +1); + while (*s1 && *s2) { + const char c1 = serd_to_upper(*s1++); + const char c2 = serd_to_upper(*s2++); + if (c1 != c2) { + return (c1 < c2) ? -1 : +1; } } - return 0; + const char c1 = serd_to_upper(*s1); + const char c2 = serd_to_upper(*s2); + return (c1 == c2) ? 0 : (c1 < c2) ? -1 : +1; } static inline uint32_t diff --git a/test/meson.build b/test/meson.build index 0ea7f1a2..fe476491 100644 --- a/test/meson.build +++ b/test/meson.build @@ -155,9 +155,10 @@ simple_command_tests = { ['-c'], ['-fi'], ['-i', 'turtle'], - ['-i', 'unknown'], + ['-i', 'turt'], ['-i'], - ['-o', 'unknown'], + ['-o', '~unknown'], + ['-o', 'ntripleses'], ['-o'], ['-p'], ['-r'], |