summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-mode.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2015-01-31 21:44:47 +0000
committerAlan Mackenzie <acm@muc.de>2015-01-31 21:44:47 +0000
commite726f2058c98e68c951bdb290fe68dac2a84ff65 (patch)
treea4fd40dd272840c9b288c7d23e9f72ea14cbaae1 /lisp/progmodes/cc-mode.el
parent618931b5b614df307cfe74c2175287e3f6dfa2a0 (diff)
downloademacs-e726f2058c98e68c951bdb290fe68dac2a84ff65.tar.gz
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.
Diffstat (limited to 'lisp/progmodes/cc-mode.el')
-rw-r--r--lisp/progmodes/cc-mode.el17
1 files changed, 11 insertions, 6 deletions
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."
(let ((pps-position (point)) pps-state mbeg)
(while (and (< (point) c-new-END)
(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
- ;; If we've found a "#" inside a string/comment, ignore it.
- (setq pps-state
- (parse-partial-sexp pps-position (point) nil nil pps-state)
- pps-position (point))
- (unless (or (nth 3 pps-state) ; in a string?
- (nth 4 pps-state)) ; in a comment?
+ ;; If we've found a "#" inside a macro/string/comment, ignore it.
+ (unless
+ (or (save-excursion
+ (goto-char (match-beginning 0))
+ (c-beginning-of-macro))
+ (progn
+ (setq pps-state
+ (parse-partial-sexp pps-position (point) nil nil pps-state)
+ pps-position (point))
+ (or (nth 3 pps-state) ; in a string?
+ (nth 4 pps-state)))) ; in a comment?
(goto-char (match-beginning 1))
(setq mbeg (point))
(if (> (c-syntactic-end-of-macro) mbeg)