diff options
author | David Robillard <d@drobilla.net> | 2021-08-11 23:28:18 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | a8ffb15c4a0566fabb50c94524e881ba2036dd1a (patch) | |
tree | 4494c45d8101f9de631f19f391d86033fa5b970d /src/string.c | |
parent | fc9ca54c77241fc33e59a3b8fb682cbc848b1288 (diff) | |
download | serd-a8ffb15c4a0566fabb50c94524e881ba2036dd1a.tar.gz serd-a8ffb15c4a0566fabb50c94524e881ba2036dd1a.tar.bz2 serd-a8ffb15c4a0566fabb50c94524e881ba2036dd1a.zip |
Expose serd_strncasecmp in public API
Diffstat (limited to 'src/string.c')
-rw-r--r-- | src/string.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c index 6942b7b6..b9885d4f 100644 --- a/src/string.c +++ b/src/string.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2020 David Robillard <d@drobilla.net> + Copyright 2011-2021 David Robillard <d@drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -14,8 +14,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "string_utils.h" + #include "serd/serd.h" +#include <stdint.h> #include <stdlib.h> void @@ -68,3 +71,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 ((*(const uint8_t*)s1 < *(const uint8_t*)s2) ? -1 : +1); + } + } + + return 0; +} |