diff options
-rw-r--r-- | src/read_utf8.c | 2 | ||||
-rw-r--r-- | src/reader.c | 2 | ||||
-rw-r--r-- | src/string.c | 18 | ||||
-rw-r--r-- | src/string_utils.h | 12 | ||||
-rw-r--r-- | src/syntax.c | 4 | ||||
-rw-r--r-- | test/test_canon.c | 13 |
6 files changed, 27 insertions, 24 deletions
diff --git a/src/read_utf8.c b/src/read_utf8.c index f86bbeba..4639c34e 100644 --- a/src/read_utf8.c +++ b/src/read_utf8.c @@ -2,8 +2,8 @@ // SPDX-License-Identifier: ISC #include "read_utf8.h" -#include "reader.h" +#include "reader.h" #include "string_utils.h" #include <stdio.h> diff --git a/src/reader.c b/src/reader.c index bbb1325b..39e85b47 100644 --- a/src/reader.c +++ b/src/reader.c @@ -13,11 +13,11 @@ #include "read_turtle.h" #include "stack.h" #include "statement.h" -#include "string_utils.h" #include "world.h" #include "serd/input_stream.h" #include "serd/log.h" +#include "serd/string.h" #include <assert.h> #include <stdarg.h> diff --git a/src/string.c b/src/string.c index 46f8ff9a..a1151c60 100644 --- a/src/string.c +++ b/src/string.c @@ -1,10 +1,14 @@ -// Copyright 2011-2020 David Robillard <d@drobilla.net> +// Copyright 2011-2021 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #include "memory.h" +#include "string_utils.h" #include "serd/memory.h" #include "serd/status.h" +#include "serd/string.h" + +#include <stddef.h> void serd_free(SerdAllocator* const allocator, void* const ptr) @@ -62,3 +66,15 @@ serd_strerror(const SerdStatus status) return "Unknown error"; } + +int +serd_strncasecmp(const char* s1, const char* s2, size_t n) +{ + for (; n > 0 && *s2; s1++, s2++, --n) { + if (serd_to_lower(*s1) != serd_to_lower(*s2)) { + return (*s1 < *s2) ? -1 : +1; + } + } + + return 0; +} diff --git a/src/string_utils.h b/src/string_utils.h index 3337f012..bd5dd9dd 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -107,18 +107,6 @@ serd_to_lower(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) -{ - for (; n > 0 && *s2; s1++, s2++, --n) { - if (serd_to_lower(*s1) != serd_to_lower(*s2)) { - return (*s1 < *s2) ? -1 : +1; - } - } - - return 0; -} - static inline uint8_t utf8_num_bytes(const uint8_t leading) { diff --git a/src/syntax.c b/src/syntax.c index 6b95446d..67c46d1a 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1,10 +1,10 @@ // Copyright 2011-2020 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "string_utils.h" - #include "serd/syntax.h" +#include "serd/string.h" + #include <assert.h> #include <stdbool.h> #include <string.h> diff --git a/test/test_canon.c b/test/test_canon.c index 1a569664..7d7fbf28 100644 --- a/test/test_canon.c +++ b/test/test_canon.c @@ -63,13 +63,9 @@ test_write_failed_alloc(void) SerdWorld* const world = serd_world_new(&allocator.base); - const SerdNode* const s = - serd_node_new(&allocator.base, serd_a_uri(s_string)); - - const SerdNode* const p = - serd_node_new(&allocator.base, serd_a_uri(p_string)); - - const SerdNode* const o = + SerdNode* const s = serd_node_new(&allocator.base, serd_a_uri(s_string)); + SerdNode* const p = serd_node_new(&allocator.base, serd_a_uri(p_string)); + SerdNode* const o = serd_node_new(&allocator.base, serd_a_typed_literal(o_string, xsd_float)); SerdSink* target = serd_sink_new(&allocator.base, NULL, ignore_event, NULL); @@ -91,6 +87,9 @@ test_write_failed_alloc(void) serd_sink_free(canon); serd_sink_free(target); + serd_node_free(&allocator.base, o); + serd_node_free(&allocator.base, p); + serd_node_free(&allocator.base, s); serd_world_free(world); } |