diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-05-04 20:56:04 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-05-05 00:28:25 +0200 |
commit | f6940dfa4627301bbd1a24530ac3f4fe3fe8494c (patch) | |
tree | e9f6400ff0e4757ab9a9a990c4b7b9c02c08b25b /src/util-inl.h | |
parent | 6db772d648d2f2a79a4426e6b06fe1de298cd80c (diff) | |
download | node-new-f6940dfa4627301bbd1a24530ac3f4fe3fe8494c.tar.gz |
src: don't use locale-sensitive strcasecmp()
strcasecmp() is affected by the current locale as configured through
e.g. the LC_ALL environment variable and the setlocale() libc function.
It can result in unpredictable results across systems so replace it with
a function that isn't susceptible to that.
PR-URL: https://github.com/nodejs/node/pull/6582
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index 7ff6e51937..355dfcdbee 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -203,7 +203,19 @@ void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen) { dst[i] = (src[i] << 8) | (src[i] >> 8); } +char ToLower(char c) { + return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c; +} +bool StringEqualNoCase(const char* a, const char* b) { + do { + if (*a == '\0') + return *b == '\0'; + if (*b == '\0') + return *a == '\0'; + } while (ToLower(*a++) == ToLower(*b++)); + return false; +} } // namespace node |