diff options
author | David Robillard <d@drobilla.net> | 2017-09-24 16:35:44 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-09-24 19:02:59 +0200 |
commit | f1d036ccba93c9e9d89dcbdae720887a630a35e5 (patch) | |
tree | cc19501cdb1aaa59c17bc2ccef4495c528c2cfc6 /src/serd_internal.h | |
parent | 8d954ab071e286f0b2bdfc542bb3725eb5a2ab0e (diff) | |
download | serd-f1d036ccba93c9e9d89dcbdae720887a630a35e5.tar.gz serd-f1d036ccba93c9e9d89dcbdae720887a630a35e5.tar.bz2 serd-f1d036ccba93c9e9d89dcbdae720887a630a35e5.zip |
Make serdi syntax options case-insensitive
Diffstat (limited to 'src/serd_internal.h')
-rw-r--r-- | src/serd_internal.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/serd_internal.h b/src/serd_internal.h index 6a2893fb..9af5195b 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -20,6 +20,7 @@ #define _POSIX_C_SOURCE 200809L /* for posix_memalign and posix_fadvise */ #include <assert.h> +#include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -335,6 +336,17 @@ serd_substrlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags); +static inline int +serd_strncasecmp(const char* s1, const char* s2, size_t n) +{ + for (; n > 0 && *s2; s1++, s2++, --n) { + if (toupper(*s1) != toupper(*s2)) { + return ((*(uint8_t*)s1 < *(uint8_t*)s2) ? -1 : +1); + } + } + return 0; +} + static inline uint32_t utf8_num_bytes(const uint8_t c) { |