;; the byte compiler.
(defvar c-maybe-labelp)
+(defvar c-commas-bound-stmts nil)
+ ;; Set to non-nil when `c-beginning-of-statement-1' is to regard a comma as
+ ;; a statement terminator.
+
;; New awk-compatible version of c-beginning-of-statement-1, ACM 2002/6/22
;; Macros used internally in c-beginning-of-statement-1 for the
(start (point))
macro-start
(delims (if comma-delim '(?\; ?,) '(?\;)))
- (c-stmt-delim-chars (if comma-delim
- c-stmt-delim-chars-with-comma
- c-stmt-delim-chars))
+ (c-commas-bound-stmts (or c-commas-bound-stmts comma-delim))
c-maybe-labelp after-case:-pos saved
;; Current position.
pos
Note that this function might do hidden buffer changes. See the
comment at the start of cc-engine.el for more info."
- (let* ((skip-chars
- ;; If the current language has CPP macros, insert # into skip-chars.
- (if c-opt-cpp-symbol
- (concat (substring c-stmt-delim-chars 0 1) ; "^"
- c-opt-cpp-symbol ; usually "#"
- (substring c-stmt-delim-chars 1)) ; e.g. ";{}?:"
- c-stmt-delim-chars))
- (skip-chars
- (if (c-major-mode-is 'c++-mode)
- (concat (substring skip-chars 0 1) ; "^"
- "[" ; to catch C++ attributes
- (substring skip-chars 1)) ; e.g. "#;{}?:"
- skip-chars))
- (non-skip-list
- (append (substring skip-chars 1) nil)) ; e.g. (?# ?\; ?{ ?} ?? ?:)
+ (let* ((skip-chars (if c-commas-bound-stmts
+ c-stmt-boundary-skip-chars-with-comma
+ c-stmt-boundary-skip-chars)) ; e.g. "^#;{}?:"
+ (non-skip-list (if c-commas-bound-stmts
+ c-stmt-boundary-skip-list-with-comma
+ c-stmt-boundary-skip-list)) ; e.g. (?# ?\; ?{ ?} ?? ?:)
lit-range lit-start vsemi-pos attr-end)
(save-restriction
(widen)
;; A question mark. Can't be a label, so stop
;; looking for more : and ?.
(setq c-maybe-labelp nil
- skip-chars (substring c-stmt-delim-chars 0 -2)))
+ skip-chars
+ (substring (if c-commas-bound-stmts
+ c-stmt-delim-chars-with-comma
+ c-stmt-delim-chars)
+ 0 -2)))
;; At a CPP construct or a "#" or "##" operator?
((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol))
(if (save-excursion
(save-excursion
(let ((end (point))
c-maybe-labelp)
- (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
+ (c-syntactic-skip-backward
+ (substring
+ (if c-commas-bound-stmts
+ c-stmt-delim-chars-with-comma
+ c-stmt-delim-chars)
+ 1)
+ nil t)
(or (bobp)
(eq (char-before) ?})
(and (eq (char-before) ?{)
(save-excursion
(let ((end (point))
- (c-stmt-delim-chars c-stmt-delim-chars-with-comma)
+ (c-commas-bound-stmts t)
c-maybe-labelp)
- (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
+ (c-syntactic-skip-backward (substring c-stmt-delim-chars-with-comma 1)
+ nil t)
(or (bobp)
(memq (char-before) '(?{ ?}))
(save-excursion (backward-char)
;; There's always at most one syntactic element which got
;; an anchor pos. It's stored in syntactic-relpos.
syntactic-relpos
- (c-stmt-delim-chars c-stmt-delim-chars))
+ (c-commas-bound-stmts c-commas-bound-stmts))
;; Check if we're directly inside an enclosing declaration
;; level block.
;; arglists.
(when (and containing-sexp
(eq (char-after containing-sexp) ?\())
- (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
+ (setq c-commas-bound-stmts t))
;; cache char before and after indent point, and move point to
;; the most likely position to perform the majority of tests
(goto-char indent-point)
t "^;{}?:")
(c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars))
+(c-lang-defconst c-stmt-boundary-skip-chars
+ ;; Like `c-stmt-delim-chars', but augmented by "#" for languages with CPP
+ ;; constructs, and for C++ Mode, also by "[", to help deal with C++
+ ;; attributes.
+ t (if (c-lang-const c-opt-cpp-symbol)
+ (concat (substring (c-lang-const c-stmt-delim-chars) 0 1) ; "^"
+ (c-lang-const c-opt-cpp-symbol) ; usually #
+ (substring (c-lang-const c-stmt-delim-chars) 1)) ; ";{}?:"
+ (c-lang-const c-stmt-delim-chars))
+ c++ (concat (substring (c-lang-const c-stmt-boundary-skip-chars) 0 1) ; "^"
+ "["
+ (substring (c-lang-const c-stmt-boundary-skip-chars) 1))) ; ";{}?:"
+(c-lang-defvar c-stmt-boundary-skip-chars
+ (c-lang-const c-stmt-boundary-skip-chars))
+
+(c-lang-defconst c-stmt-boundary-skip-list
+ ;; The characters (apart from the initial ^) in `c-stmt-boundary-skip-chars'
+ ;; as a list of characters.
+ t (append (substring (c-lang-const c-stmt-boundary-skip-chars) 1) nil))
+(c-lang-defvar c-stmt-boundary-skip-list
+ (c-lang-const c-stmt-boundary-skip-list))
+
(c-lang-defconst c-stmt-delim-chars-with-comma
;; Variant of `c-stmt-delim-chars' that additionally contains ','.
t "^;,{}?:")
(c-lang-defvar c-stmt-delim-chars-with-comma
(c-lang-const c-stmt-delim-chars-with-comma))
+(c-lang-defconst c-stmt-boundary-skip-chars-with-comma
+ ;; Variant of `c-stmt-boundary-skip-chars' also containing ','.
+ t (if (c-lang-const c-opt-cpp-symbol)
+ (concat (substring (c-lang-const c-stmt-delim-chars-with-comma) 0 1)
+ (c-lang-const c-opt-cpp-symbol) ; usually #
+ (substring (c-lang-const c-stmt-delim-chars-with-comma) 1))
+ (c-lang-const c-stmt-delim-chars-with-comma))
+ c++ (concat
+ (substring (c-lang-const c-stmt-boundary-skip-chars-with-comma) 0 1) ; "^"
+ "["
+ (substring (c-lang-const c-stmt-boundary-skip-chars-with-comma) 1))) ; ";,{}?:"
+(c-lang-defvar c-stmt-boundary-skip-chars-with-comma
+ (c-lang-const c-stmt-boundary-skip-chars-with-comma))
+
+(c-lang-defconst c-stmt-boundary-skip-list-with-comma
+ ;; Variant of `c-stmt-boundary-skip-list' also including a comma.
+ t (append (substring (c-lang-const c-stmt-boundary-skip-chars-with-comma)
+ 1)
+ nil))
+(c-lang-defvar c-stmt-boundary-skip-list-with-comma
+ (c-lang-const c-stmt-boundary-skip-list-with-comma))
+
(c-lang-defconst c-pack-ops
"Ops which signal C++11's \"parameter pack\""
t nil