help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regexp search hangs Emacs


From: Piet van Oostrum
Subject: Re: Regexp search hangs Emacs
Date: 28 Feb 2003 10:56:28 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>>> "Tim Morley \(remove vegetable for email address\)" 
>>>>> <tim@teamlog.turnip.com> (TM) wrote:

TM> Doing a regexp I-search for `;\(.*,\)*-I,' in a buffer containing the line
TM> ALTA:FU,KOM,MUZ;-O,FIZ,MAT,-AJXO,BIB,-ECO,GEO,AS,-IGI,-IGXI,-IGILO,MIL,-OMET
TM> RO,FIZ,-OMETRIO,MAL-A,FU,MUZ,MAL-O,MAL-AJXO,Z,MAL-IGI,Z,MAL-IGXI,PLEJ-A,MA,D
TM> IKMAL-A.

TM> seems to cause Emacs to hang. I get the same result both with both of these
TM> versions:
TM> "GNU Emacs 21.2.1, i386-msvc-nt5.0.2195 of 2002-03-19 on buffy" under Win2k
TM> "GNU Emacs 20.7.1 (i386-redhat-linux-gnu, X toolkit of Fri Mar 16 2001 on
TM> porky)" under Red Hat Linux 7.2.

TM> Up to and including the capital I in the regexp all goes well, but on typing
TM> the next character (which causes the search to fail) Emacs does not say
TM> `Failing regexp I-search' as normal, but seems to hang. A simple C-g is
TM> sufficient to get control back, but I would like to be able to complete
TM> my search.

TM> I believe I have RTFM and STFW, but please correct me if I've skimped on
TM> either! Explicative URLs, advice and/or solutions would be very gratefully
TM> received.

Your regexp is sub-optimal and I think you didn't wait long enough. 
Try it on a buffer with only that line and just wait a couple of minutes
and you will probably get the `Failing regexp I-search'. At least it did
with me.

The problem is that the outer * is superfluous if it is sure that there is
a comma in the buffer and if not it should be replaced by ?
The regexp searches (if we just forget the beginning and the end for the
moment) for anything ending with a comma, and that zero or more times.
Apart for the `zero times' this just means the same as anything ending
with a comma. If you want to cover the zero times also then ? suffices. As
it stands now emacs will have to do a lot of backtracking when the `-I,'
is not found. Because of the two *'s this is a quadratic search, which
increases very rapidly with the buffer size or line size.
-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum@hccnet.nl


reply via email to

[Prev in Thread] Current Thread [Next in Thread]