* re-search-forward hangs
@ 2018-07-30 12:24 Andreas Röhler
2018-07-30 14:33 ` Eli Zaretskii
2018-07-30 17:53 ` Stefan Monnier
0 siblings, 2 replies; 8+ messages in thread
From: Andreas Röhler @ 2018-07-30 12:24 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi,
emacs -Q, when evaluating from in scratch-buffer
(while (re-search-forward "" nil t 1))
Emacs hangs.
Same with plain
(while (search-forward "" nil t 1))
Expect it terminating.
Are there reasons for this?
Thanks,
Andreas
GNU Emacs 27.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.14.5) of
2018-05-29
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
[not found] <mailman.4412.1532953259.1292.help-gnu-emacs@gnu.org>
@ 2018-07-30 13:22 ` Robert Girault
2018-07-30 14:36 ` Ben Bacarisse
1 sibling, 0 replies; 8+ messages in thread
From: Robert Girault @ 2018-07-30 13:22 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Hi,
>
> emacs -Q, when evaluating from in scratch-buffer
>
>
> (while (re-search-forward "" nil t 1))
>
> Emacs hangs.
>
> Same with plain
>
> (while (search-forward "" nil t 1))
>
> Expect it terminating.
Why do you expect it to terminate?
> Are there reasons for this?
The obvious reason is that "" is found anywhere, so this search will
always succeed. This makes sense to me. Why do you think this
shouldn't happen?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
2018-07-30 12:24 Andreas Röhler
@ 2018-07-30 14:33 ` Eli Zaretskii
2018-07-30 19:29 ` Andreas Röhler
[not found] ` <mailman.4430.1532978809.1292.help-gnu-emacs@gnu.org>
2018-07-30 17:53 ` Stefan Monnier
1 sibling, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2018-07-30 14:33 UTC (permalink / raw)
To: help-gnu-emacs
> From: Andreas Röhler <andreas.roehler@easy-emacs.de>
> Date: Mon, 30 Jul 2018 14:24:06 +0200
>
> (while (re-search-forward "" nil t 1))
>
> Emacs hangs.
>
> Same with plain
>
> (while (search-forward "" nil t 1))
>
> Expect it terminating.
>
> Are there reasons for this?
Why did you expect it to terminate?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
[not found] <mailman.4412.1532953259.1292.help-gnu-emacs@gnu.org>
2018-07-30 13:22 ` re-search-forward hangs Robert Girault
@ 2018-07-30 14:36 ` Ben Bacarisse
1 sibling, 0 replies; 8+ messages in thread
From: Ben Bacarisse @ 2018-07-30 14:36 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> emacs -Q, when evaluating from in scratch-buffer
>
> (while (re-search-forward "" nil t 1))
>
> Emacs hangs.
>
> Same with plain
>
> (while (search-forward "" nil t 1))
>
> Expect it terminating.
Why do you expect a difference? I would expect both to loop
indefinitely (and they do in my slightly older Emacs).
> Are there reasons for this?
Both loop because the match always succeeds. Neither match moves point
so neither can fail.
--
Ben.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
2018-07-30 12:24 Andreas Röhler
2018-07-30 14:33 ` Eli Zaretskii
@ 2018-07-30 17:53 ` Stefan Monnier
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2018-07-30 17:53 UTC (permalink / raw)
To: help-gnu-emacs
> emacs -Q, when evaluating from in scratch-buffer
> (while (re-search-forward "" nil t 1))
> Emacs hangs.
It doesn't hang for me. The command doesn't terminate, of course, but
you can interrupt it with C-g.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
2018-07-30 14:33 ` Eli Zaretskii
@ 2018-07-30 19:29 ` Andreas Röhler
[not found] ` <mailman.4430.1532978809.1292.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Andreas Röhler @ 2018-07-30 19:29 UTC (permalink / raw)
To: help-gnu-emacs
On 30.07.2018 16:33, Eli Zaretskii wrote:
>> From: Andreas Röhler <andreas.roehler@easy-emacs.de>
>> Date: Mon, 30 Jul 2018 14:24:06 +0200
>>
>> (while (re-search-forward "" nil t 1))
>>
>> Emacs hangs.
>>
>> Same with plain
>>
>> (while (search-forward "" nil t 1))
>>
>> Expect it terminating.
>>
>> Are there reasons for this?
>
> Why did you expect it to terminate?
>
Expect a call of search-forward from EOB not being successful.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
[not found] ` <mailman.4430.1532978809.1292.help-gnu-emacs@gnu.org>
@ 2018-07-30 19:35 ` Robert Girault
2018-07-30 20:15 ` Andreas Röhler
0 siblings, 1 reply; 8+ messages in thread
From: Robert Girault @ 2018-07-30 19:35 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> On 30.07.2018 16:33, Eli Zaretskii wrote:
>>> From: Andreas Röhler <andreas.roehler@easy-emacs.de>
>>> Date: Mon, 30 Jul 2018 14:24:06 +0200
>>>
>>> (while (re-search-forward "" nil t 1))
>>>
>>> Emacs hangs.
>>>
>>> Same with plain
>>>
>>> (while (search-forward "" nil t 1))
>>>
>>> Expect it terminating.
>>>
>>> Are there reasons for this?
>>
>> Why did you expect it to terminate?
>
> Expect a call of search-forward from EOB not being successful.
I see. But searching for the empty string seems to be an always
successful operation as long as you have a string. The empty string is
before or after any character in a string, so I would expect it to be
always found by {re-}search-forward.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: re-search-forward hangs
2018-07-30 19:35 ` Robert Girault
@ 2018-07-30 20:15 ` Andreas Röhler
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Röhler @ 2018-07-30 20:15 UTC (permalink / raw)
To: help-gnu-emacs
On 30.07.2018 21:35, Robert Girault wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> On 30.07.2018 16:33, Eli Zaretskii wrote:
>>>> From: Andreas Röhler <andreas.roehler@easy-emacs.de>
>>>> Date: Mon, 30 Jul 2018 14:24:06 +0200
>>>>
>>>> (while (re-search-forward "" nil t 1))
>>>>
>>>> Emacs hangs.
>>>>
>>>> Same with plain
>>>>
>>>> (while (search-forward "" nil t 1))
>>>>
>>>> Expect it terminating.
>>>>
>>>> Are there reasons for this?
>>>
>>> Why did you expect it to terminate?
>>
>> Expect a call of search-forward from EOB not being successful.
>
> I see. But searching for the empty string seems to be an always
> successful operation as long as you have a string. The empty string is
> before or after any character in a string, so I would expect it to be
> always found by {re-}search-forward.
>
Hmm, when trying at BOB with some content, changing the times argument
(message "%s" (search-forward "" nil t 1))
(message "%s" (search-forward "" nil t 2))
(message "%s" (search-forward "" nil t 3))
the result remains "43" - looks like the match is not regular.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-07-30 20:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.4412.1532953259.1292.help-gnu-emacs@gnu.org>
2018-07-30 13:22 ` re-search-forward hangs Robert Girault
2018-07-30 14:36 ` Ben Bacarisse
2018-07-30 12:24 Andreas Röhler
2018-07-30 14:33 ` Eli Zaretskii
2018-07-30 19:29 ` Andreas Röhler
[not found] ` <mailman.4430.1532978809.1292.help-gnu-emacs@gnu.org>
2018-07-30 19:35 ` Robert Girault
2018-07-30 20:15 ` Andreas Röhler
2018-07-30 17:53 ` Stefan Monnier
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 read-only IMAP folder(s) and NNTP newsgroup(s).