diff options
author | David Robillard <d@drobilla.net> | 2021-08-11 23:28:18 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | aa96c067439252b1955cfa11e75948d15f1b1656 (patch) | |
tree | bed2af41d7d4c3b94026b2732fbeeadca06f78ab /src | |
parent | 339f9d90d1fe001978d15e1c007a3861a7145453 (diff) | |
download | serd-aa96c067439252b1955cfa11e75948d15f1b1656.tar.gz serd-aa96c067439252b1955cfa11e75948d15f1b1656.tar.bz2 serd-aa96c067439252b1955cfa11e75948d15f1b1656.zip |
Expose serd_strncasecmp in public API
Diffstat (limited to 'src')
-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 |
5 files changed, 21 insertions, 17 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> |