Article View: gnu.emacs.bug
Article #98689Serious bug in regexp matching
From: macrakis
Date: Sat, 09 Mar 1991 22:33
Date: Sat, 09 Mar 1991 22:33
43 lines
2280 bytes
2280 bytes
GNU Emacs 18.53.11 on NeXT 1.0.1 There is a serious bug and a bugoid in regexp searching in 18.53. Put in a fresh buffer 40 copies of the line "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:" (setq RE "^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)" ) Now, (goto-char 0) (looking-at RE) fails, even though (goto-char 801) (looking-at RE) succeeds; the only difference should be the number of times the first parenthesized expression matches. Experiment shows that this is sensitive to the number of characters (1305) matched (and not the number of iterations). A similar (related?) problem is that the regular expression given as an example in the Regexps section of the Info manual for Emacs, namely \(.*\)\1 fails for lines longer than 1280 characters. Emacs isn't supposed to have arbitrary line-length limits.... The second problem is that even on a small match (e.g. the last two lines) (match-end 1) is incorrect: it points to the CR after the final line. This is presumably because the first ()+ expression matched up to there before having to backtrack. You can also elicit this behavior in a buffer containing just "aaa" with (looking-at "\\(a\\)*a"), which gives match-beg/end 1,4. The documentation is very vague on this point, but presumably they should be 2,3 (the last match). You can make a case for 1,3 (although if you want that you should presumably use "\\(a*\\)a" which _does_ work). 1,4 just seems to be an accident of implementation (it forgot to adjust match-beg/end when backtracking). -s
Technical Details
Message-ID:
<9103071539.AA09571@dupuis.gr.osf.org>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,39359f6724306b1e,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-03-09 14:51:34 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage From: macrakis@gr.osf.org Newsgroups: gnu.emacs.bug Subject: Serious bug in regexp matching Message-ID: <9103071539.AA09571@dupuis.gr.osf.org> Date: 9 Mar 91 22:33:38 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 43 Approved: bug-gnu-emacs@prep.ai.mit.edu Posted: Sat Mar 9 16:33:38 1991 X-Unparsable-Date: Thu, 7 Mar 91 16:39:11 GMT+0100