[ruby-core:95189] [Ruby master Bug#15816] String#casecmp compares uppercase characters instead of lowercase

From: merch-redmine@...
Date: 2019-10-02 15:01:56 UTC
List: ruby-core #95189
Issue #15816 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

Fixed in commit:082424ef58116db9663a754157d6c441d60fd101.

----------------------------------------
Bug #15816: String#casecmp compares uppercase characters instead of lowercase
https://bugs.ruby-lang.org/issues/15816#change-81825

* Author: jonathanhefner (Jonathan Hefner)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The current implementation of `String#casecmp` converts characters to uppercase before comparing them.  However, all references I've found for `strcasecmp` (the C function on which `String#casecmp` is based) indicate characters should be converted to lowercase before being compared.

For example, [this man page](http://manpages.ubuntu.com/manpages/eoan/man3/strcasecmp.3.html) says:

> The POSIX.1-2008 standard says ... shall behave as if the strings had been converted to lowercase and then a byte comparison performed.

The difference in behavior is apparent when comparing / sorting strings containing `[`, `\`, `]`, `^`, `_`, or `` ` `` (the characters that occur between `Z` and `a`).  Converting to lowercase sorts these punctuation characters before `A`-`z` along with most of the other punctuation in ASCII, but converting to uppercase sorts these characters after `A`-`z` instead.


---Files--------------------------------
casecmp-lowercase.patch (1.3 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next