From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/28972 Path: main.gmane.org!not-for-mail From: Gerd Moellmann Newsgroups: gmane.emacs.gnus.general Subject: Re: string-match doesn't honor anchor when START is nonzero Date: Wed, 26 Jan 2000 17:07:32 +0100 (CET) Sender: owner-ding@hpc.uh.edu Message-ID: <200001261607.RAA07804@online.de> References: Reply-To: gerd@gnu.org NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035165724 32594 80.91.224.250 (21 Oct 2002 02:02:04 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 02:02:04 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, ding@gnus.org Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by mailhost.sclp.com (Postfix) with ESMTP id 30C11D051E for ; Thu, 27 Jan 2000 04:29:40 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id DAB27996; Thu, 27 Jan 2000 03:29:32 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Thu, 27 Jan 2000 03:28:42 -0600 (CST) Original-Received: from mailhost.sclp.com (postfix@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id DAA17864 for ; Thu, 27 Jan 2000 03:28:29 -0600 (CST) Original-Received: from mout01.kundenserver.de (mout01.kundenserver.de [195.20.224.132]) by mailhost.sclp.com (Postfix) with ESMTP id AC3C4D051E for ; Thu, 27 Jan 2000 04:28:23 -0500 (EST) Original-Received: from [195.20.224.75] (helo=mrelay00.kundenserver.de) by mout01.kundenserver.de with esmtp (Exim 2.12 #2) id 12DlDt-0008Hb-00 for ding@gnus.org; Thu, 27 Jan 2000 10:28:17 +0100 Original-Received: from p3e9bd34c.dip0.t-ipconnect.de ([62.155.211.76] helo=online.de) by mrelay00.kundenserver.de with esmtp (Exim 2.12 #2) id 12DlDm-0001K5-00 for ding@gnus.org; Thu, 27 Jan 2000 10:28:10 +0100 Original-Received: (from gerd@localhost) by online.de (8.9.3/8.8.7) id RAA07804; Wed, 26 Jan 2000 17:07:32 +0100 (CET) (envelope-from gerd) Original-To: Jim Meyering In-Reply-To: Jim Meyering's message of "25 Jan 2000 22:20:39 +0100" User-Agent: Gnus/5.070099 (Pterodactyl Gnus v0.99) Emacs/20.5.93 Original-Lines: 101 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:28972 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:28972 Jim Meyering writes: > In GNU Emacs 20.5.1 (i686-pc-linux-gnu, X toolkit) > of Fri Dec 10 1999 on ixi.eng.ascend.com > configured using `configure --prefix=/p/p/emacs-20.5' > ------------ > > The following seems to be at the root of a problem I noticed in Gnus. > > Is it expected that this would evaluate to nil? (it does) > > (string-match "^j" " j" 1) > > I expected it to return `1', but the `^' gets in the way. > The documentation for string-match doesn't address this point > as far as I could see. > The `^' is a special character in regular expressions, matching at the beginning of text. > If returning `nil' is the intended behavior, then there's a bug in > mail-utils.el (rmail-dont-reply-to) because it seems to expect `1' and > fails when it gets the `nil'. The result is that that function removes > only one of two matching, adjacent addresses. > > This illustrates the problem: > > (setq rmail-dont-reply-to-names "f.") > (load "mail-utils") > (rmail-dont-reply-to "b, f1, f2, f3, f4, f5, f6") > > Return value: "b, f2, f4, f6" > Thanks for the test case. Does the following patch solve the problem? Index: mail-utils.el =================================================================== RCS file: /gd/gnu/cvsroot/emacs/lisp/mail/mail-utils.el,v retrieving revision 1.44 diff -c -r1.44 mail-utils.el *** mail-utils.el 1999/08/16 03:14:25 1.44 --- mail-utils.el 2000/01/26 16:06:58 *************** *** 230,254 **** (case-fold-search t) pos epos) (while (setq pos (string-match match userids pos)) ! (if (> pos 0) (setq pos (match-beginning 2))) ! (setq epos ! ;; Delete thru the next comma, plus whitespace after. ! (if (string-match ",[ \t\n]*" userids (match-end 0)) ! (match-end 0) ! (length userids))) ! ;; Count the double-quotes since the beginning of the list. ! ;; Reject this match if it is inside a pair of doublequotes. ! (let (quote-pos inside-quotes) ! (while (and (setq quote-pos (string-match "\"" userids quote-pos)) ! (< quote-pos pos)) ! (setq quote-pos (1+ quote-pos)) ! (setq inside-quotes (not inside-quotes))) (if inside-quotes ;; Advance to next even-parity quote, and scan from there. (setq pos (string-match "\"" userids pos)) ! (setq userids ! (mail-string-delete ! userids pos epos))))) ;; get rid of any trailing commas (if (setq pos (string-match "[ ,\t\n]*\\'" userids)) (setq userids (substring userids 0 pos))) --- 230,248 ---- (case-fold-search t) pos epos) (while (setq pos (string-match match userids pos)) ! ;; If there's a match, it starts at the beginning of the string, ! ;; or with `,'. We must delete from that position to the ! ;; end of the user-id which starts at match-beginning 2. ! (let (inside-quotes quote-pos) ! (save-match-data ! (while (and (setq quote-pos (string-match "\"" userids quote-pos)) ! (< quote-pos pos)) ! (setq quote-pos (1+ quote-pos)) ! (setq inside-quotes (not inside-quotes)))) (if inside-quotes ;; Advance to next even-parity quote, and scan from there. (setq pos (string-match "\"" userids pos)) ! (setq userids (replace-match "" nil nil userids))))) ;; get rid of any trailing commas (if (setq pos (string-match "[ ,\t\n]*\\'" userids)) (setq userids (substring userids 0 pos))) *************** *** 256,261 **** --- 250,256 ---- (if (string-match "\\s *" userids) (substring userids (match-end 0)) userids))) + ;;;###autoload (defun mail-fetch-field (field-name &optional last all list)