From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/28963 Path: main.gmane.org!not-for-mail From: Jim Meyering Newsgroups: gmane.emacs.gnus.general Subject: Re: string-match doesn't honor anchor when START is nonzero Date: 26 Jan 2000 16:08:44 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: References: <200001261442.HAA00249@aztec.santafe.edu> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035165716 32515 80.91.224.250 (21 Oct 2002 02:01:56 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 02:01:56 +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 B68ADD051E for ; Wed, 26 Jan 2000 10:09:59 -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 JAB26283; Wed, 26 Jan 2000 09:09:52 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 26 Jan 2000 09:09:47 -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 JAA10851 for ; Wed, 26 Jan 2000 09:09:34 -0600 (CST) Original-Received: from drawbridge.ascend.com (drawbridge.ascend.com [198.4.92.1]) by mailhost.sclp.com (Postfix) with ESMTP id B8FF1D051E for ; Wed, 26 Jan 2000 10:09:25 -0500 (EST) Original-Received: from fw-ext.ascend.com (fw-ext [198.4.92.5]) by drawbridge.ascend.com (8.9.1a/8.9.1) with SMTP id HAA12519; Wed, 26 Jan 2000 07:03:10 -0800 (PST) Original-Received: from russet.ascend.com by fw-ext.ascend.com via smtpd (for drawbridge.ascend.com [198.4.92.1]) with SMTP; 26 Jan 2000 15:09:18 UT Original-Received: from wopr.eng.ascend.com (wopr.eng.ascend.com [206.65.212.178]) by russet.ascend.com (8.9.1a/8.9.1) with ESMTP id HAA11322; Wed, 26 Jan 2000 07:09:18 -0800 (PST) Original-Received: from buckfast.eng.ascend.com (buckfast.eng.ascend.com [172.27.38.21]) by wopr.eng.ascend.com (8.9.1/8.9.1) with ESMTP id HAA04548; Wed, 26 Jan 2000 07:12:40 -0800 (PST) Original-Received: from ixi.eng.ascend.com (ixi.eng.ascend.com [172.27.61.1]) by buckfast.eng.ascend.com (8.8.8+Sun/8.8.8) with ESMTP id QAA08708; Wed, 26 Jan 2000 16:09:12 +0100 (MET) Original-Received: (from meyering@localhost) by ixi.eng.ascend.com (8.9.3/8.9.3) id QAA03172; Wed, 26 Jan 2000 16:08:44 +0100 X-Authentication-Warning: ixi.eng.ascend.com: meyering set sender to meyering@ascend.com using -f Original-To: rms@gnu.org In-Reply-To: Richard Stallman's message of "Wed, 26 Jan 2000 07:42:12 -0700 (MST)" Original-Lines: 75 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:28963 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:28963 Richard Stallman writes: | Is it expected that this would evaluate to nil? (it does) | | (string-match "^j" " j" 1) | | That is correct. The argument 1 means to look for a match starting no | earlier than position 1, but the criterion for a match does not treat | position 1 as the start of a line if it is not one. | | 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'. | | Could you show which call to string-match is seems to have the problem? | It seems you have tracked this down already; I did a quick scan and | I don't see a bug of this kind. We could debug it, but if you already | have done so, why not tell us what you know? 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" It should be Return value: "b" Here's part of mail-utils.el: ======================================== (defun rmail-dont-reply-to (userids) "Returns string of mail addresses USERIDS sans any recipients that start with matches for `rmail-dont-reply-to-names'. Usenet paths ending in an element that matches are removed also." (if (null rmail-dont-reply-to-names) (setq rmail-dont-reply-to-names (concat (if rmail-default-dont-reply-to-names (concat rmail-default-dont-reply-to-names "\\|") "") (concat (regexp-quote (user-login-name)) "\\>")))) (let ((match (concat "\\(^\\|,\\)[ \t\n]*" ;; Can anyone figure out what this is for? ;; Is it an obsolete remnant of another way of ;; handling Foo Bar ? "\\([^,\n]*[!<]\\|\\)" "\\(" rmail-dont-reply-to-names "\\|" ;; Include the human name that precedes . "\\([^\,.<\"]\\|\"[^\"]*\"\\)*" "<\\(" rmail-dont-reply-to-names "\\)" "\\)")) (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))) ======================================== This part of the regex "\\(^\\|,\\)[ \t\n]*" is wrong the second time around because we've already advanced past the comma (2nd string-match above). That means we end up advancing past a potentially matching address to the next comma. Hence, in the example above, only every other matching address is removed.