From: Gerd Moellmann <gerd@gnu.org>
Cc: bug-gnu-emacs@gnu.org, ding@gnus.org
Subject: Re: string-match doesn't honor anchor when START is nonzero
Date: Wed, 26 Jan 2000 17:07:32 +0100 (CET) [thread overview]
Message-ID: <200001261607.RAA07804@online.de> (raw)
In-Reply-To: Jim Meyering's message of "25 Jan 2000 22:20:39 +0100"
Jim Meyering <meyering@ascend.com> 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)))
+
\f
;;;###autoload
(defun mail-fetch-field (field-name &optional last all list)
next prev parent reply other threads:[~2000-01-26 16:07 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
2000-01-26 16:07 ` Gerd Moellmann [this message]
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=200001261607.RAA07804@online.de \
--to=gerd@gnu.org \
--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).