diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-12 13:03:36 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-12 13:03:36 +0000 |
commit | 858547ceb58eda36f8260553f72b5c7486ab3081 (patch) | |
tree | b7e2fcaed74ac40380fa6a639830ef7d0bc11960 | |
parent | 4338ee87ff7bb63cb40c6bd5ad74a146899e3288 (diff) | |
download | libhubbub-858547ceb58eda36f8260553f72b5c7486ab3081.tar.gz libhubbub-858547ceb58eda36f8260553f72b5c7486ab3081.tar.bz2 |
Make locale-agnostic
svn path=/trunk/hubbub/; revision=8474
-rw-r--r-- | src/utils/string.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/utils/string.c b/src/utils/string.c index e216a55..ce4f6a6 100644 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -26,7 +26,7 @@ bool hubbub_string_match(const uint8_t *a, size_t a_len, if (a_len != b_len) return false; - return strncmp((const char *) a, (const char *) b, b_len) == 0; + return memcmp((const char *) a, (const char *) b, b_len) == 0; } /** @@ -43,5 +43,16 @@ bool hubbub_string_match_ci(const uint8_t *a, size_t a_len, if (a_len != b_len) return false; - return strncasecmp((const char *) a, (const char *) b, b_len) == 0; + while (b_len-- > 0) { + uint8_t aa = *(a++); + uint8_t bb = *(b++); + + aa = ('a' <= aa && aa <= 'z') ? (aa - 0x20) : aa; + bb = ('a' <= bb && bb <= 'z') ? (bb - 0x20) : bb; + + if (aa != bb) + return false; + } + + return true; } |