emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100438: Fix an infloop in CC-mode


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100438: Fix an infloop in CC-mode (Bug#7595).
Date: Mon, 31 Jan 2011 18:07:43 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100438
author: Alan Mackenzie <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: emacs-23
timestamp: Mon 2011-01-31 18:07:43 -0500
message:
  Fix an infloop in CC-mode (Bug#7595).
  
  * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue
  parsing if we encounter a naked # (Bug#7595).
  (c-beginning-of-statement): Avoid loop in locating the beginning
  of a macro.
modified:
  lisp/ChangeLog
  lisp/progmodes/cc-cmds.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-01-31 17:03:37 +0000
+++ b/lisp/ChangeLog    2011-01-31 23:07:43 +0000
@@ -1,3 +1,10 @@
+2011-01-31  Alan Mackenzie  <address@hidden>
+
+       * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue
+       parsing if we encounter a naked # (Bug#7595).
+       (c-beginning-of-statement): Avoid loop in locating the beginning
+       of a macro.
+
 2011-01-31  Chong Yidong  <address@hidden>
 
        * files.el (copy-directory): Fix arguments to recursive call.

=== modified file 'lisp/progmodes/cc-cmds.el'
--- a/lisp/progmodes/cc-cmds.el 2011-01-02 23:50:46 +0000
+++ b/lisp/progmodes/cc-cmds.el 2011-01-31 23:07:43 +0000
@@ -2458,13 +2458,15 @@
          (goto-char last)
          (throw 'done '(nil . nil)))
 
-        ;; Stop if we encounter a preprocessor line.
-        ((and (not macro-end)
+        ;; Stop if we encounter a preprocessor line.  Continue if we
+        ;; hit a naked #
+        ((and c-opt-cpp-prefix
+              (not macro-end)
               (eq (char-after) ?#)
               (= (point) (c-point 'boi)))
-         (goto-char last)
-         ;(throw 'done (cons (eq (point) here) 'macro-boundary))) ; Changed 
2003/3/26
-         (throw 'done '(t . macro-boundary)))
+         (if (= (point) here)          ; Not a macro, therefore naked #.
+             (forward-char)
+           (throw 'done '(t . macro-boundary))))
 
         ;; Stop after a ';', '}', or "};"
         ((looking-at ";\\|};?")
@@ -2578,14 +2580,21 @@
                                    (c-backward-syntactic-ws))
                                  (or (bobp) 
(c-after-statement-terminator-p)))))))
                ;; Are we about to move backwards into or out of a
-               ;; preprocessor command?  If so, locate it's beginning.
+               ;; preprocessor command?  If so, locate its beginning.
                (when (eq (cdr res) 'macro-boundary)
-                 (save-excursion
-                   (beginning-of-line)
-                   (setq macro-fence
-                         (and (not (bobp))
-                              (progn (c-skip-ws-backward) 
(c-beginning-of-macro))
-                              (point)))))
+                 (setq macro-fence
+                       (save-excursion
+                         (if macro-fence
+                             (progn
+                               (end-of-line)
+                               (and (not (eobp))
+                                    (progn (c-skip-ws-forward)
+                                           (c-beginning-of-macro))
+                                    (progn (c-end-of-macro)
+                                           (point))))
+                           (and (not (eobp))
+                                (c-beginning-of-macro)
+                                (progn (c-end-of-macro) (point)))))))
                ;; Are we about to move backwards into a literal?
                (when (memq (cdr res) '(macro-boundary literal))
                  (setq range (c-ascertain-preceding-literal)))


reply via email to

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