From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 310541F45F for ; Thu, 9 May 2019 08:01:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 75D45120AFA; Thu, 9 May 2019 17:01:46 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 9D9621209D6 for ; Thu, 9 May 2019 17:01:44 +0900 (JST) Received: by filter0013p3iad2.sendgrid.net with SMTP id filter0013p3iad2-1919-5CD3DE69-1B 2019-05-09 08:01:45.45283403 +0000 UTC m=+122322.642750215 Received: from herokuapp.com (unknown [54.227.1.136]) by ismtpd0024p1mdw1.sendgrid.net (SG) with ESMTP id 9C64hO5UREitbU_7AI8RWA for ; Thu, 09 May 2019 08:01:45.384 +0000 (UTC) Date: Thu, 09 May 2019 08:01:45 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68094 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15816 X-Redmine-Issue-Author: jonathanhefner X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4BwRnBEUfPO3mHeRVbxCG6?= =?us-ascii?Q?F6hlR0Mxvt+sXpp9M09KkKEvnS5YpThcFtbkpUQ?= =?us-ascii?Q?bVjaHJEr02JkL6Zif1sRhq1hcZ4XrgzUT2n0Fjr?= =?us-ascii?Q?sBS0Z1kWLIo+yWKHVxbYpDWcOqSjdEzKSJKxmOf?= =?us-ascii?Q?NHho+8fEZCQrP17TLwIbkKIq36eY8f2=2FnnA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92611 Subject: [ruby-core:92611] [Ruby trunk Bug#15816] String#casecmp compares uppercase characters instead of lowercase X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15816 has been updated by nobu (Nobuyoshi Nakada). Indeed, `rb_enc_upper` is used at https://github.com/ruby/ruby/commit/269bd16b28e86d1333969389b7b402f2915e336f#diff-7a2f2c7dfe0bf61d38272aeaf68ac768R1431, while previous `rb_memcicmp` maps to the lowercase. ---------------------------------------- Bug #15816: String#casecmp compares uppercase characters instead of lowercase https://bugs.ruby-lang.org/issues/15816#change-77971 * Author: jonathanhefner (Jonathan Hefner) * Status: Open * 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/