* bug#20806: 25.0.50; `string-match' is confused???
@ 2015-06-13 9:33 Vaidheeswaran C
2015-06-13 18:59 ` Vaidheeswaran C
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Vaidheeswaran C @ 2015-06-13 9:33 UTC (permalink / raw
To: 20806
Is an empty string a prefix of all strings or not? `string-match'
should settle this matter first.
Here is an eshell transaction.
----------------------------------------------------------------
Welcome to the Emacs shell
/tmp $ (string-match "\\(.*\\)" "")
0
/tmp $ (string-match "foo" "")
/tmp $
----------------------------------------------------------------
Here is how I ended up with this bug.
Debugger entered--Lisp error: (error "Regexp cannot match an empty string")
signal(error ("Regexp cannot match an empty string"))
error("Regexp cannot match an empty string")
hi-lock-regexp-okay("\\(.*\\)")
byte-code("\300\301\302\303\"!\304 D\207" [hi-lock-regexp-okay
read-regexp "Regexp to highlight" regexp-history-last
hi-lock-read-face-name] 4)
call-interactively(highlight-regexp nil nil)
command-execute(highlight-regexp)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#20806: 25.0.50; `string-match' is confused???
2015-06-13 9:33 bug#20806: 25.0.50; `string-match' is confused??? Vaidheeswaran C
@ 2015-06-13 18:59 ` Vaidheeswaran C
2015-06-14 20:18 ` Stefan Monnier
2015-06-13 19:21 ` Andreas Schwab
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Vaidheeswaran C @ 2015-06-13 18:59 UTC (permalink / raw
To: 20806
[-- Attachment #1: Type: text/plain, Size: 674 bytes --]
On Saturday 13 June 2015 03:03 PM, Vaidheeswaran C wrote:
> Here is how I ended up with this bug.
>
> Debugger entered--Lisp error: (error "Regexp cannot match an empty string")
> signal(error ("Regexp cannot match an empty string"))
> error("Regexp cannot match an empty string")
> hi-lock-regexp-okay("\\(.*\\)")
> byte-code("\300\301\302\303\"!\304 D\207" [hi-lock-regexp-okay
> read-regexp "Regexp to highlight" regexp-history-last
> hi-lock-read-face-name] 4)
> call-interactively(highlight-regexp nil nil)
> command-execute(highlight-regexp)
>
The attached patch solves the above issue. I hope it is OK.
(Stupid me got the title wrong. Apologies.)
[-- Attachment #2: 0001-lisp-hi-lock.el-hi-lock-regexp-okay-Minor-change.patch --]
[-- Type: text/x-patch, Size: 683 bytes --]
From dd0786d3caa8ca83276dbc8ecd363c590cbccdbb Mon Sep 17 00:00:00 2001
From: Vaidheeswaran C <vaidheeswaran.chinnaraju@gmail.com>
Date: Sat, 13 Jun 2015 15:48:10 +0530
Subject: [PATCH] * lisp/hi-lock.el (hi-lock-regexp-okay): Minor change
---
lisp/hi-lock.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 0255585..deb827c 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -658,7 +658,7 @@ not suitable."
(cond
((null regexp)
(error "Regexp cannot match nil"))
- ((string-match regexp "")
+ ((string= regexp "")
(error "Regexp cannot match an empty string"))
(t regexp)))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#20806: 25.0.50; `string-match' is confused???
2015-06-13 9:33 bug#20806: 25.0.50; `string-match' is confused??? Vaidheeswaran C
2015-06-13 18:59 ` Vaidheeswaran C
@ 2015-06-13 19:21 ` Andreas Schwab
2015-06-13 22:58 ` Michael Heerdegen
2015-06-14 13:40 ` Stefan Monnier
3 siblings, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2015-06-13 19:21 UTC (permalink / raw
To: Vaidheeswaran C; +Cc: 20806
Vaidheeswaran C <vaidheeswaran.chinnaraju@gmail.com> writes:
> Is an empty string a prefix of all strings or not? `string-match'
> should settle this matter first.
That question doesn't make sense. The empty string has no special
significance for string-match. It either matches the regexp or not.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#20806: 25.0.50; `string-match' is confused???
2015-06-13 9:33 bug#20806: 25.0.50; `string-match' is confused??? Vaidheeswaran C
2015-06-13 18:59 ` Vaidheeswaran C
2015-06-13 19:21 ` Andreas Schwab
@ 2015-06-13 22:58 ` Michael Heerdegen
2015-06-14 13:40 ` Stefan Monnier
3 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2015-06-13 22:58 UTC (permalink / raw
To: Vaidheeswaran C; +Cc: 20806
Vaidheeswaran C <vaidheeswaran.chinnaraju@gmail.com> writes:
> Debugger entered--Lisp error: (error "Regexp cannot match an empty
> string")
> signal(error ("Regexp cannot match an empty string"))
> error("Regexp cannot match an empty string")
> [...]
> command-execute(highlight-regexp)
AFAICT, you got this error because you entered an regexp to the
`highlight-regexp' prompt that the empty string is matched by. Such a
regexp is rejected by hi-lock. With other words, the error is raised by
intent in hi-lock.el.
I guess, theoretically this rejected case could be made working, but the
code would get a bit uglier and less effective then, and is easy to
avoid.
What's your use case?
Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#20806: 25.0.50; `string-match' is confused???
2015-06-13 9:33 bug#20806: 25.0.50; `string-match' is confused??? Vaidheeswaran C
` (2 preceding siblings ...)
2015-06-13 22:58 ` Michael Heerdegen
@ 2015-06-14 13:40 ` Stefan Monnier
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-06-14 13:40 UTC (permalink / raw
To: Vaidheeswaran C; +Cc: 20806
tags 20806 notabug
thanks
> Is an empty string a prefix of all strings or not?
Yes, but that's unrelated to the uncaught signal you show, nor to the
two string-match calls you show.
> Welcome to the Emacs shell
> /tmp $ (string-match "\\(.*\\)" "")
> 0
Yup, we can find a trivial match for "\\(.*\\)" in the empty string.
> /tmp $ (string-match "foo" "")
And "foo" can't be found in the empty string.
> Here is how I ended up with this bug.
> Debugger entered--Lisp error: (error "Regexp cannot match an empty string")
[...]
> command-execute(highlight-regexp)
And this is "not a bug but a feature". This could arguably
be improved. E.g. it should probably call `user-error'.
But highlight-regexp is simply telling you that it's not a good idea to
try to highlight all the empty strings in your buffer: not only there
are many (e.g. as many as point-max), but you wouldn't notice that
they're highlighted anyway.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#20806: 25.0.50; `string-match' is confused???
2015-06-13 18:59 ` Vaidheeswaran C
@ 2015-06-14 20:18 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2015-06-14 20:18 UTC (permalink / raw
To: Vaidheeswaran C; +Cc: 20806
> The attached patch solves the above issue. I hope it is OK.
No, the intention of the code is really to reject all regular expressions
which match the empty string.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-06-14 20:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-13 9:33 bug#20806: 25.0.50; `string-match' is confused??? Vaidheeswaran C
2015-06-13 18:59 ` Vaidheeswaran C
2015-06-14 20:18 ` Stefan Monnier
2015-06-13 19:21 ` Andreas Schwab
2015-06-13 22:58 ` Michael Heerdegen
2015-06-14 13:40 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.