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.
This commit is contained in:
parent
618931b5b6
commit
e726f2058c
3 changed files with 30 additions and 9 deletions
|
@ -1,3 +1,15 @@
|
|||
2015-01-31 Alan Mackenzie <acm@muc.de>
|
||||
|
||||
Handle "#" operator properly inside macro. Fix coding bug.
|
||||
|
||||
* progmodes/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.
|
||||
|
||||
* progmodes/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.
|
||||
|
||||
2015-01-31 Martin Rudalics <rudalics@gmx.at>
|
||||
|
||||
* menu-bar.el (menu-bar-non-minibuffer-window-p): Return nil when
|
||||
|
|
|
@ -2275,7 +2275,9 @@ comment at the start of cc-engine.el for more info."
|
|||
(while
|
||||
;; Add an element to `c-state-nonlit-pos-cache' each iteration.
|
||||
(and
|
||||
(<= (setq npos (+ pos c-state-nonlit-pos-interval)) here)
|
||||
(setq npos
|
||||
(when (<= (+ pos c-state-nonlit-pos-interval) here)
|
||||
(+ pos c-state-nonlit-pos-interval)))
|
||||
|
||||
;; Test for being in a literal. If so, go to after it.
|
||||
(progn
|
||||
|
@ -2302,7 +2304,9 @@ comment at the start of cc-engine.el for more info."
|
|||
;; Add one extra element above HERE so as to to avoid the previous
|
||||
;; expensive calculation when the next call is close to the current
|
||||
;; one. This is especially useful when inside a large macro.
|
||||
(setq c-state-nonlit-pos-cache (cons npos c-state-nonlit-pos-cache)))
|
||||
(when npos
|
||||
(setq c-state-nonlit-pos-cache
|
||||
(cons npos c-state-nonlit-pos-cache))))
|
||||
|
||||
(if (> pos c-state-nonlit-pos-cache-limit)
|
||||
(setq c-state-nonlit-pos-cache-limit pos))
|
||||
|
@ -3066,7 +3070,7 @@ comment at the start of cc-engine.el for more info."
|
|||
(setq dropped-cons (consp (car c-state-cache)))
|
||||
(setq c-state-cache (cdr c-state-cache))
|
||||
(setq pos pa))
|
||||
;; At this stage, (> pos here);
|
||||
;; At this stage, (>= pos here);
|
||||
;; (< (c-state-cache-top-lparen) here) (or is nil).
|
||||
|
||||
(cond
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue