From: Jim Meyering <meyering@ascend.com>
Cc: bug-gnu-emacs@gnu.org, ding@gnus.org
Subject: Re: string-match doesn't honor anchor when START is nonzero
Date: 26 Jan 2000 16:08:44 +0100 [thread overview]
Message-ID: <uryemb47tvn.fsf@ixi.eng.ascend.com> (raw)
In-Reply-To: Richard Stallman's message of "Wed, 26 Jan 2000 07:42:12 -0700 (MST)"
Richard Stallman <rms@gnu.org> 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 <foo@machine>?
"\\([^,\n]*[!<]\\|\\)"
"\\("
rmail-dont-reply-to-names
"\\|"
;; Include the human name that precedes <foo@bar>.
"\\([^\,.<\"]\\|\"[^\"]*\"\\)*"
"<\\(" 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.
next prev parent reply other threads:[~2000-01-26 15:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-25 21:20 Jim Meyering
2000-01-26 14:42 ` Richard Stallman
2000-01-26 15:08 ` Jim Meyering [this message]
2000-01-26 16:07 ` Gerd Moellmann
2000-01-26 16:34 ` Jim Meyering
2000-01-27 12:53 ` Gerd Moellmann
2000-01-27 16:30 ` Jim Meyering
2000-02-09 18:22 ` mail-utils.el (rmail-dont-reply-to) is still buggy Jim Meyering
2000-02-12 16:43 ` Gerd Moellmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uryemb47tvn.fsf@ixi.eng.ascend.com \
--to=meyering@ascend.com \
--cc=bug-gnu-emacs@gnu.org \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).