+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
(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
;; 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))
(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
(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)