summaryrefslogtreecommitdiff
path: root/prism
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-02-27 21:53:38 +0100
committergit <[email protected]>2025-02-28 00:28:24 +0000
commit025832c3859c4369ed12ace13e35523bd04116fe ()
tree562fb0b4979099e77929d4f85522e0ac8e91f516 /prism
parentd4b8da66ca9533782d2fed9762783c3e560f2998 (diff)
[ruby/prism] Use a locale-insensitive version of tolower
[Bug #21161] The `tolower` function provided by the libc is locale dependent and can behave in ways you wouldn't expect for some value of `LC_CTYPE`. https://.com/ruby/prism/commit/e3488256b4 Co-Authored-By: Nobuyoshi Nakada <[email protected]>
-rw-r--r--prism/util/pm_strncasecmp.c14
1 files changed, 13 insertions, 1 deletions
@@ -1,6 +1,18 @@
#include "prism/util/pm_strncasecmp.h"
/**
* Compare two strings, ignoring case, up to the given length. Returns 0 if the
* strings are equal, a negative number if string1 is less than string2, or a
* positive number if string1 is greater than string2.
@@ -16,7 +28,7 @@ pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
while (offset < length && string1[offset] != '\0') {
if (string2[offset] == '\0') return string1[offset];
- if ((difference = tolower(string1[offset]) - tolower(string2[offset])) != 0) return difference;
offset++;
}