From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: regexp case sensitivity bug Date: 10 Dec 2002 01:45:17 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5xptsad7mq.fsf@kfs2.cua.dk> References: <3DF3B4D0.D4628D27@cs.unc.edu> <3DF518E2.6FDE0A01@cs.unc.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1039479326 31064 80.91.224.249 (10 Dec 2002 00:15:26 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 10 Dec 2002 00:15:26 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18LY3X-00084q-00 for ; Tue, 10 Dec 2002 01:15:23 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18LYDq-0001nY-01 for ; Tue, 10 Dec 2002 01:26:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18LXbB-0003JO-01 for emacs-devel@quimby.gnus.org; Mon, 09 Dec 2002 18:46:05 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18LXao-0003J9-00 for emacs-devel@gnu.org; Mon, 09 Dec 2002 18:45:42 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18LXak-0003Id-00 for emacs-devel@gnu.org; Mon, 09 Dec 2002 18:45:41 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18LXaj-0003II-00; Mon, 09 Dec 2002 18:45:38 -0500 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id F1C517C012; Mon, 9 Dec 2002 23:45:34 +0000 (GMT) Original-To: Dean Herington In-Reply-To: <3DF518E2.6FDE0A01@cs.unc.edu> Original-Lines: 61 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-cc: rms@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10019 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10019 Dean Herington writes: > Richard Stallman wrote: > > > In Emacs 21.1.1, when I do isearch-forward-regexp with input "\bP", > > Emacs matches 'p's case insensitively. > > > > Does this patch fix it? > > > > *** isearch.el.~1.215.~ Sun Nov 10 13:13:37 2002 > > --- isearch.el Mon Dec 9 11:20:37 2002 > > *************** > > *** 1871,1877 **** > > (if (and regexp-flag (eq char ?\\)) > > (setq quote-flag (not quote-flag)) > > (if (and (not quote-flag) (not (eq char (downcase char)))) > > ! (setq found t)))) > > (setq i (1+ i))) > > (not found))) > > > > --- 1871,1878 ---- > > (if (and regexp-flag (eq char ?\\)) > > (setq quote-flag (not quote-flag)) > > (if (and (not quote-flag) (not (eq char (downcase char)))) > > ! (setq found t)) > > ! (setq quote-flag nil))) > > (setq i (1+ i))) > > (not found))) > > That patch fixes the bug I saw. > > How about the following, which I find simpler? > > (defun isearch-no-upper-case-p (string regexp-flag) > "Return t if there are no upper case chars in STRING. > If REGEXP-FLAG is non-nil, disregard letters quoted by `\\' > since they have special meaning in a regexp." > (let ((i 0) (len (length string)) found) > (while (and (not found) (< i len)) > (let ((char (aref string i))) > (if (and regexp-flag (eq char ?\\)) > (setq i (1+ i)) > (if (not (eq char (downcase char))) > (setq found t)))) > (setq i (1+ i))) > (not found))) > Or we can use a completely different approach: (defun isearch-no-upper-case-p (string regexp-flag) "..." (let ((case-fold-search nil)) (save-match-data (null (string-match (if regexp-flag "\\(^\\|[^\\]\\)[[:upper:]]" "[[:upper:]]") string))))) -- Kim F. Storm http://www.cua.dk