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

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

Re: [make-mode.el] Infinite loop


From: Richard Stallman
Subject: Re: [make-mode.el] Infinite loop
Date: Sun, 05 Jun 2005 16:26:15 -0400

    Suppose you have a Makefile with the following contents:

    FOO = bar \
            xxx/xxx.xx xxx/xxx.xx

    If you put the cursor at the start of the second line and type
    `M-: (looking-at makefile-dependency-regex) RET' Emacs will enter an
    infinite loop.

I tried this.  It was not an infinite loop, but it took
absurdly long.  Does this give good results for you?

*** make-mode.el        03 Jun 2005 06:39:21 -0400      1.100
--- make-mode.el        05 Jun 2005 12:54:34 -0400      
***************
*** 262,268 ****
  ;; index in makefile-imenu-generic-expression.
  (defvar makefile-dependency-regex
    ;; Allow for two nested levels $(v1:$(v2:$(v3:a=b)=c)=d)
!   "^ *\\(\\(?: 
*\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|
 *[^ \n$#:=]+\\)+?\\)[ \t]*\\(:\\)\\(?:[ \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ 
\t]*\\(.+\\)\\)?\\)"
    "Regex used to find dependency lines in a makefile.")
  
  (defconst makefile-bsdmake-dependency-regex
--- 262,268 ----
  ;; index in makefile-imenu-generic-expression.
  (defvar makefile-dependency-regex
    ;; Allow for two nested levels $(v1:$(v2:$(v3:a=b)=c)=d)
!   
"^\\(\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[({]\\(?:\\$\\(?:[^({]\\|.[^\n$#})]+?[})]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#)}]\\)+?[})]\\|[^({]\\)\\|[^\n$#:=]\\)+?\\)\\(:\\)\\(?:[
 \t]*$\\|[^=\n]\\(?:[^#\n]*?;[ \t]*\\(bb.+\\)\\)?\\)"
    "Regex used to find dependency lines in a makefile.")
  
  (defconst makefile-bsdmake-dependency-regex
***************
*** 1704,1709 ****
--- 1704,1722 ----
            (when (save-excursion
                    (beginning-of-line)
                    (looking-at makefile-dependency-regex))
+             (save-excursion
+               (let ((deps-end (match-end 1))
+                     (match-data (match-data)))
+                 (goto-char deps-end)
+                 (skip-chars-backward " \t")
+                 (setq deps-end (point))
+                 (beginning-of-line)
+                 (skip-chars-forward " \t")
+                 ;; Alter the bounds recorded for subexp 1,
+                 ;; which is what is supposed to match the targets.
+                 (setcar (nthcdr 2 match-data) (point))
+                 (setcar (nthcdr 3 match-data) deps-end)
+                 (store-match-data match-data)))
              (end-of-line)
              (throw 'found (point)))))
        (goto-char pt))




reply via email to

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