emacs-pretest-bug
[Top][All Lists]
Advanced

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

Regexp not stateless?


From: Lennart Borgman (gmail)
Subject: Regexp not stateless?
Date: Sun, 29 Apr 2007 19:51:58 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.666

I have just seen a state problem with regexps. I am not able to isolate the problem completely at the moment, but here is a sketch of it:

I have this regexp:

(defconst mumamo-script-tag-start-regex
  (rx "<script"
      (1+ space)
      "type"
      (0+ space)
      "="
      (0+ space)
      ?\"
      ;;(or "text" "application")
      ;;"/"
      ;;(or "javascript" "ecmascript")
      "text/javascript"
      ?\"
      (0+ (not (any ">")))
      ">"
      (optional (0+ space) "<![CDATA[" )
      ))

This matches at the start of this text with `looking-at':

<script type="text/javascript">
<![CDATA[

However sometimes it matches just to the end of the first line and sometimes to the end of the second line (as it should). I am using this little function to test:

(defun x() (interactive)
  (when (looking-at mumamo-script-tag-start-regex)
    (goto-char (match-end 0))))

(global-set-key [f7] 'x)

That is unfortunately not all that is needed to reproduce the problem however. It looks like the regexp engine somehow saves a state. Once it matches the first variant it continue to do that and the same for the second variant. It does not matter where in the file I try to do the match. (As long as the text above is available at the test point of course.)

As I said it is easily reproduceable by me, but unfortunately there is a lot of other code involved to "switch between the two states above".




In GNU Emacs 22.1.50.1 (i386-mingw-nt5.1.2600)
 of 2007-04-27 on




reply via email to

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