From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11786: Use c_strcasecmp for portable ASCII case-insensitive comparison Date: Tue, 26 Jun 2012 19:02:20 +0300 Message-ID: <834npy9i43.fsf@gnu.org> References: <4FE91370.2090706@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1340726598 18318 80.91.229.3 (26 Jun 2012 16:03:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jun 2012 16:03:18 +0000 (UTC) Cc: 11786@debbugs.gnu.org To: Paul Eggert , Dmitry Antipov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 26 18:03:17 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SjYEW-0003nc-Rc for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Jun 2012 18:03:17 +0200 Original-Received: from localhost ([::1]:50239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjYEW-0002g4-RQ for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 Jun 2012 12:03:16 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjYEN-0002fl-Ov for bug-gnu-emacs@gnu.org; Tue, 26 Jun 2012 12:03:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SjYEH-0008NL-Dg for bug-gnu-emacs@gnu.org; Tue, 26 Jun 2012 12:03:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjYEH-0008N6-A9 for bug-gnu-emacs@gnu.org; Tue, 26 Jun 2012 12:03:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SjYIA-0007Nh-9o for bug-gnu-emacs@gnu.org; Tue, 26 Jun 2012 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Jun 2012 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 11786-submit@debbugs.gnu.org id=B11786.134072677528319 (code B ref 11786); Tue, 26 Jun 2012 16:07:02 +0000 Original-Received: (at 11786) by debbugs.gnu.org; 26 Jun 2012 16:06:15 +0000 Original-Received: from localhost ([127.0.0.1]:58748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SjYHP-0007Mi-7i for submit@debbugs.gnu.org; Tue, 26 Jun 2012 12:06:15 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:55852) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SjYHM-0007MZ-Jd for 11786@debbugs.gnu.org; Tue, 26 Jun 2012 12:06:13 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0M6800900F6RBX00@a-mtaout22.012.net.il> for 11786@debbugs.gnu.org; Tue, 26 Jun 2012 19:02:09 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M68008O6F7LWB70@a-mtaout22.012.net.il>; Tue, 26 Jun 2012 19:02:09 +0300 (IDT) In-reply-to: <4FE91370.2090706@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:61299 Archived-At: > Date: Mon, 25 Jun 2012 18:42:08 -0700 > From: Paul Eggert > > Emacs currently use 'strcasecmp' and 'strncasecmp' for > case-insensitive comparison but these have problems in multibyte > locales. In practice Emacs code really just wants a C-locale > version of these functions so I'm planning on installing the > following patch after some more testing. I'm giving some > heads-up as this affects the Microsoft ports. Not related to "Microsoft ports", but can we please step back one notch and discuss this stuff in a little bit more detail? First, until revision 108735, committed yesterday by Dmitry, we didn't use strcasecmp or strncasecmp (except in the NS port, which looks like an oversight). We used xtrcasecmp, whose only dependence on the locale is the tolower function/macro. Then Dmitry replaced xstrcasecmp with strcasecmp for those platforms that have it (which I think means all the supported platforms), for reasons that AFAIK were never discussed. Why was that done? Now you are going to replace strcasecmp with several gnulib modules. All the calls to xtrcasecmp are for comparing strings that are known to be plain ASCII: names of fonts, extensions of certain file types, fixed ASCII strings, etc. Can tolower fail for these, somehow, in a locale that uses a multibyte encoding for these strings, and if so, can you give a practical example of such a failure? If tolower is good enough for these cases, I suggest that we revert changes in revision 108735, and perhaps add comments somewhere as to the reasons why we use that custom function instead of library functions. If tolower can fail in some locale, I suggest that we restore xstrcasecmp, and simply augment it with c_tolower from gnulib, or its equivalent. That sounds like a much simpler change to me. Comments are welcome. Thanks.