GNU bug report logs - #23949
25.0.95; Regression in handling error caused by (string-match-p "." nil)

Previous Next

Package: emacs;

Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>

Date: Mon, 11 Jul 2016 20:13:02 UTC

Severity: normal

Tags: fixed

Merged with 16294, 24166

Found in versions 25.0.95, 24.3.50

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #83 received at 23949 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: schwab <at> suse.de, 23949 <at> debbugs.gnu.org, kaushal.modi <at> gmail.com
Subject: Re: 25.0.95;
 Regression in handling error caused by (string-match-p "." nil)
Date: Wed, 13 Jul 2016 19:18:05 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: kaushal.modi <at> gmail.com,  schwab <at> suse.de,  23949 <at> debbugs.gnu.org
> Date: Wed, 13 Jul 2016 12:00:40 -0400
> 
> >> > I also think that the "breaks a lot of Elisp code" part is at least a
> >> > tad exaggerated.
> >> Binding inhibit-changing-match-data to t will pretty much break any
> >> function that uses match-beginning or match-end.
> > But those functions aren't supposed to run when string-match is
> > called.
> 
> Yet they are in bug#23949.

No, they aren't.  They run from the debugger.

> >> > (defsubst string-match-p (regexp string &optional start)
> >> >   "\
> >> > Same as `string-match' except this function does not change the match data."
> >> >   (condition-case err
> >> >       (let ((inhibit-changing-match-data t))
> >> > 	(string-match regexp string start))
> >> >     (error (signal (car err) (cdr err)))))
> >> That will still cause the same problems when debug-on-signal is non-nil.
> > So you don't consider this an improvement that should be installed?
> 
> No.

What about the suggestion made by Andreas?

> A simpler and more robust solution would be
> (save-match-data (string-match regexp string start))
> 
> Of course, with either solution, it means that string-match-p is even
> worse in terms of efficiency, whereas the unsuspecting coder would
> rightfully expect string-match-p to be (slightly) *more* efficient than
> string-match.

Exactly.  And we are punishing the innocent (the calls that don't
signal an error) for fear of the guilty (those that do).




This bug report was last modified 8 years and 168 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.