[comp.emacs] Bug in regexp search in Gnu Emacs.

aj@zyx.UUCP (Arndt Jonasson) (02/16/88)

[Some time ago, I reported a bug in Gnu Emacs 17.62, concerning regular
expression searching. I received a message from FSF stating that the bug had
been fixed in version 18. Now I have 18.49, and I can see that it has not. So,
here is my report again.]

GNU Emacs regular expression matching.

There is a bug in the regular expression code for GNU Emacs version 18.49:
The regular expression

		\(a\(bc\|bcd\)\)+k

doesn't match the string

		abcabcabcdk

which it should. The reason is that an optimization is made in the handling of
loops (+ and * constructs) which removes the loop's failure point if there is
no chance of its being used, namely when the beginning of the loop expression
and the expression after the loop cannot possibly match the same thing. Here
this is the case ('a' versus 'k'), but failure points are generated within the
loop, through the \| construct, so that the wrong failure point is removed,
causing the match to fail.

The quick fix is to emit a 'jump' instead of a 'maybe_finalize_jump'. The right
fix would be to detect whether any failure points can be generated within the
loop expression; if not, emit a 'maybe_finalize_jump', otherwise emit a 'jump'.

[By the way, I have a working unexec for hp9000s800. I recently saw someone
asking if anyone had one. I hadn't then, so I didn't save the request.]

-- 
Arndt Jonasson, ZYX Sweden AB, Styrmansgatan 6, 114 54 Stockholm, Sweden
email address:	 <backbone>!mcvax!enea!zyx!aj	=	aj@zyx.SE