aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-05-08 20:35:56 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-14 14:11:39 -0700
commit082424ef58116db9663a754157d6c441d60fd101 (patch)
treed6752ae8c45ad2de8821bf75993b586aaf3d1af4 /string.c
parentd5c60214c45bafc1cf2a516f852394986f9c84bb (diff)
downloadruby-082424ef58116db9663a754157d6c441d60fd101.tar.gz
Fold to lowercase intead of uppercase for String#casecmp
strcasecmp(3) and String#casecmp? both fold to lowercase.
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/string.c b/string.c
index ed2346267e..9492ec8171 100644
--- a/string.c
+++ b/string.c
@@ -3417,8 +3417,8 @@ str_casecmp(VALUE str1, VALUE str2)
if (single_byte_optimizable(str1) && single_byte_optimizable(str2)) {
while (p1 < p1end && p2 < p2end) {
if (*p1 != *p2) {
- unsigned int c1 = TOUPPER(*p1 & 0xff);
- unsigned int c2 = TOUPPER(*p2 & 0xff);
+ unsigned int c1 = TOLOWER(*p1 & 0xff);
+ unsigned int c2 = TOLOWER(*p2 & 0xff);
if (c1 != c2)
return INT2FIX(c1 < c2 ? -1 : 1);
}
@@ -3432,8 +3432,8 @@ str_casecmp(VALUE str1, VALUE str2)
int l2, c2 = rb_enc_ascget(p2, p2end, &l2, enc);
if (0 <= c1 && 0 <= c2) {
- c1 = TOUPPER(c1);
- c2 = TOUPPER(c2);
+ c1 = TOLOWER(c1);
+ c2 = TOLOWER(c2);
if (c1 != c2)
return INT2FIX(c1 < c2 ? -1 : 1);
}