aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2015-01-31 21:44:47 +0000
committerAlan Mackenzie2015-01-31 21:44:47 +0000
commite726f2058c98e68c951bdb290fe68dac2a84ff65 (patch)
treea4fd40dd272840c9b288c7d23e9f72ea14cbaae1
parent618931b5b614df307cfe74c2175287e3f6dfa2a0 (diff)
downloademacs-e726f2058c98e68c951bdb290fe68dac2a84ff65.tar.gz
emacs-e726f2058c98e68c951bdb290fe68dac2a84ff65.zip
Handle "#" operator properly inside macro. Fix coding bug.
cc-mode.el (c-neutralize-syntax-in-and-mark-CPP): On finding a "#" which looks like the start of a macro, check it isn't already inside a macro. cc-engine.el (c-state-safe-place): Don't record a new "safe" position into the list of them when this is beyond our current position.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/progmodes/cc-engine.el10
-rw-r--r--lisp/progmodes/cc-mode.el17
3 files changed, 30 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6cdaf14abe2..fd54c688640 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12015-01-31 Alan Mackenzie <acm@muc.de>
2
3 Handle "#" operator properly inside macro. Fix coding bug.
4
5 * progmodes/cc-mode.el (c-neutralize-syntax-in-and-mark-CPP): On
6 finding a "#" which looks like the start of a macro, check it
7 isn't already inside a macro.
8
9 * progmodes/cc-engine.el (c-state-safe-place): Don't record a new
10 "safe" position into the list of them when this is beyond our
11 current position.
12
12015-01-31 Martin Rudalics <rudalics@gmx.at> 132015-01-31 Martin Rudalics <rudalics@gmx.at>
2 14
3 * menu-bar.el (menu-bar-non-minibuffer-window-p): Return nil when 15 * menu-bar.el (menu-bar-non-minibuffer-window-p): Return nil when
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 1f4aa819a53..b8051b274d2 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2275,7 +2275,9 @@ comment at the start of cc-engine.el for more info."
2275 (while 2275 (while
2276 ;; Add an element to `c-state-nonlit-pos-cache' each iteration. 2276 ;; Add an element to `c-state-nonlit-pos-cache' each iteration.
2277 (and 2277 (and
2278 (<= (setq npos (+ pos c-state-nonlit-pos-interval)) here) 2278 (setq npos
2279 (when (<= (+ pos c-state-nonlit-pos-interval) here)
2280 (+ pos c-state-nonlit-pos-interval)))
2279 2281
2280 ;; Test for being in a literal. If so, go to after it. 2282 ;; Test for being in a literal. If so, go to after it.
2281 (progn 2283 (progn
@@ -2302,7 +2304,9 @@ comment at the start of cc-engine.el for more info."
2302 ;; Add one extra element above HERE so as to to avoid the previous 2304 ;; Add one extra element above HERE so as to to avoid the previous
2303 ;; expensive calculation when the next call is close to the current 2305 ;; expensive calculation when the next call is close to the current
2304 ;; one. This is especially useful when inside a large macro. 2306 ;; one. This is especially useful when inside a large macro.
2305 (setq c-state-nonlit-pos-cache (cons npos c-state-nonlit-pos-cache))) 2307 (when npos
2308 (setq c-state-nonlit-pos-cache
2309 (cons npos c-state-nonlit-pos-cache))))
2306 2310
2307 (if (> pos c-state-nonlit-pos-cache-limit) 2311 (if (> pos c-state-nonlit-pos-cache-limit)
2308 (setq c-state-nonlit-pos-cache-limit pos)) 2312 (setq c-state-nonlit-pos-cache-limit pos))
@@ -3066,7 +3070,7 @@ comment at the start of cc-engine.el for more info."
3066 (setq dropped-cons (consp (car c-state-cache))) 3070 (setq dropped-cons (consp (car c-state-cache)))
3067 (setq c-state-cache (cdr c-state-cache)) 3071 (setq c-state-cache (cdr c-state-cache))
3068 (setq pos pa)) 3072 (setq pos pa))
3069 ;; At this stage, (> pos here); 3073 ;; At this stage, (>= pos here);
3070 ;; (< (c-state-cache-top-lparen) here) (or is nil). 3074 ;; (< (c-state-cache-top-lparen) here) (or is nil).
3071 3075
3072 (cond 3076 (cond
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index c4f1efbfdb1..1cba5027f28 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -957,12 +957,17 @@ Note that the style variables are always made local to the buffer."
957 (let ((pps-position (point)) pps-state mbeg) 957 (let ((pps-position (point)) pps-state mbeg)
958 (while (and (< (point) c-new-END) 958 (while (and (< (point) c-new-END)
959 (search-forward-regexp c-anchored-cpp-prefix c-new-END t)) 959 (search-forward-regexp c-anchored-cpp-prefix c-new-END t))
960 ;; If we've found a "#" inside a string/comment, ignore it. 960 ;; If we've found a "#" inside a macro/string/comment, ignore it.
961 (setq pps-state 961 (unless
962 (parse-partial-sexp pps-position (point) nil nil pps-state) 962 (or (save-excursion
963 pps-position (point)) 963 (goto-char (match-beginning 0))
964 (unless (or (nth 3 pps-state) ; in a string? 964 (c-beginning-of-macro))
965 (nth 4 pps-state)) ; in a comment? 965 (progn
966 (setq pps-state
967 (parse-partial-sexp pps-position (point) nil nil pps-state)
968 pps-position (point))
969 (or (nth 3 pps-state) ; in a string?
970 (nth 4 pps-state)))) ; in a comment?
966 (goto-char (match-beginning 1)) 971 (goto-char (match-beginning 1))
967 (setq mbeg (point)) 972 (setq mbeg (point))
968 (if (> (c-syntactic-end-of-macro) mbeg) 973 (if (> (c-syntactic-end-of-macro) mbeg)