unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Regexp search hangs Emacs
@ 2003-02-28  9:07 Tim Morley (remove vegetable for email address)
  2003-02-28  9:56 ` Piet van Oostrum
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Morley (remove vegetable for email address) @ 2003-02-28  9:07 UTC (permalink / raw)


Doing a regexp I-search for `;\(.*,\)*-I,' in a buffer containing the line

ALTA:FU,KOM,MUZ;-O,FIZ,MAT,-AJXO,BIB,-ECO,GEO,AS,-IGI,-IGXI,-IGILO,MIL,-OMET
RO,FIZ,-OMETRIO,MAL-A,FU,MUZ,MAL-O,MAL-AJXO,Z,MAL-IGI,Z,MAL-IGXI,PLEJ-A,MA,D
IKMAL-A.

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

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

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


Tim Morley


[Apologies is you've seen this message before; posted it to gnu.emacs.bug 36
hours ago but still can't see it on the server.]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Regexp search hangs Emacs
  2003-02-28  9:07 Regexp search hangs Emacs Tim Morley (remove vegetable for email address)
@ 2003-02-28  9:56 ` Piet van Oostrum
  2003-02-28 10:36   ` Tim Morley (remove vegetable for email address)
  0 siblings, 1 reply; 3+ messages in thread
From: Piet van Oostrum @ 2003-02-28  9:56 UTC (permalink / raw)


>>>>> "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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Regexp search hangs Emacs
  2003-02-28  9:56 ` Piet van Oostrum
@ 2003-02-28 10:36   ` Tim Morley (remove vegetable for email address)
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Morley (remove vegetable for email address) @ 2003-02-28 10:36 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]



"Piet van Oostrum" <piet@cs.uu.nl> a écrit dans le message
news:<wzheaoenjn.fsf@nono.cs.uu.nl>...

> >>>>> "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.

> TM> <snip>

>

> 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.

> <snip>

> --

> Piet van Oostrum <piet@cs.uu.nl>

> URL: http://www.cs.uu.nl/~piet [PGP]

> Private email: P.van.Oostrum@hccnet.nl



You're exactly right of course; I got distracted by the fact that there
could be any number of arguments separated by commas in my text, but of
course a whole list of arguments separated by commas is still just a long
string that ends in a comma. D'oh!



Thanks for the help.





Tim

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-28 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-28  9:07 Regexp search hangs Emacs Tim Morley (remove vegetable for email address)
2003-02-28  9:56 ` Piet van Oostrum
2003-02-28 10:36   ` Tim Morley (remove vegetable for email address)

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).