GNU bug report logs -
#61091
30.0.50; y-or-n-p clobbers match data
Previous Next
Reported by: rms <at> gnu.org
Date: Fri, 27 Jan 2023 04:06:02 UTC
Severity: normal
Found in version 30.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #28 received at 61091-done <at> debbugs.gnu.org (full text, mbox):
> From: Richard Stallman <rms <at> gnu.org>
> Cc: 61091 <at> debbugs.gnu.org
> Date: Sat, 04 Feb 2023 00:15:24 -0500
>
> > > Allowance should be made for the fact that `y-or-n-p'
> > > was safe for the match data for over 35 years.
>
> > I don't object if it's easy to do so.
>
> I think it should be easy. How about trying it?
Done with the patch below.
diff --git a/lisp/subr.el b/lisp/subr.el
index 0f754fc..32c9974 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3573,12 +3573,14 @@ y-or-n-p
(if (or (zerop l) (eq ?\s (aref prompt (1- l))))
"" " ")
(if dialog ""
- (substitute-command-keys
- (if help-form
- (format "(\\`y', \\`n' or \\`%s') "
- (key-description
- (vector help-char)))
- "(\\`y' or \\`n') ")))))))
+ ;; Don't clobber caller's match data.
+ (save-match-data
+ (substitute-command-keys
+ (if help-form
+ (format "(\\`y', \\`n' or \\`%s') "
+ (key-description
+ (vector help-char)))
+ "(\\`y' or \\`n') "))))))))
;; Preserve the actual command that eventually called
;; `y-or-n-p' (otherwise `repeat' will be repeating
;; `exit-minibuffer').
This bug report was last modified 2 years and 110 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.