Commit 096f638d authored by Alan Mackenzie's avatar Alan Mackenzie

Correct the indentation of C99's compound literals.

* lisp/progmodes/cc-engine.el (c-looking-at-statement-block): Amend so that
if there is only syntactic whitespace in a brace block, it is regarded as a
statement block.  Also, if there is no semicolon or comma delimiter, treat as
a statement block when there is a keyword.
(c-guess-basic-syntax): CASE 9 test: Regard a brace as starting a brace block
when its contents indicate a brace block.
parent c52a2aa8
...@@ -10726,26 +10726,35 @@ comment at the start of cc-engine.el for more info." ...@@ -10726,26 +10726,35 @@ comment at the start of cc-engine.el for more info."
(defun c-looking-at-statement-block () (defun c-looking-at-statement-block ()
;; Point is at an opening brace. If this is a statement block (i.e. the ;; Point is at an opening brace. If this is a statement block (i.e. the
;; elements in it are terminated by semicolons) return t. Otherwise, return ;; elements in the block are terminated by semicolons, or the block is
;; nil. ;; empty, or the block contains a keyword) return t. Otherwise, return nil.
(let ((here (point))) (let ((here (point)))
(prog1 (prog1
(if (c-go-list-forward) (if (c-go-list-forward)
(let ((there (point))) (let ((there (point)))
(backward-char) (backward-char)
(c-syntactic-skip-backward (c-syntactic-skip-backward "^;," here t)
"^;," here t)
(cond (cond
((eq (char-before) ?\;) t) ((eq (char-before) ?\;) t)
((eq (char-before) ?,) nil) ((eq (char-before) ?,) nil)
(t (goto-char here) (t ; We're at (1+ here).
(forward-char) (cond
(and (c-syntactic-re-search-forward "{" there t t) ((progn (c-forward-syntactic-ws)
(progn (backward-char) (eq (point) (1- there)))
(c-looking-at-statement-block)))))) t)
((c-syntactic-re-search-forward c-keywords-regexp there t)
t)
((c-syntactic-re-search-forward "{" there t t)
(backward-char)
(c-looking-at-statement-block))
(t nil)))))
(forward-char) (forward-char)
(and (c-syntactic-re-search-forward "[;,]" nil t t) (cond
(eq (char-before) ?\;))) ((c-syntactic-re-search-forward "[;,]" nil t t)
(eq (char-before) ?\;))
((c-syntactic-re-search-forward c-keywords-regexp nil t t)
t)
(t nil)))
(goto-char here)))) (goto-char here))))
(defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end) (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end)
...@@ -12534,7 +12543,11 @@ comment at the start of cc-engine.el for more info." ...@@ -12534,7 +12543,11 @@ comment at the start of cc-engine.el for more info."
(save-excursion (save-excursion
(goto-char containing-sexp) (goto-char containing-sexp)
(c-looking-at-special-brace-list))) (c-looking-at-special-brace-list)))
(c-inside-bracelist-p containing-sexp paren-state t)))) (c-inside-bracelist-p containing-sexp paren-state t)
(save-excursion
(goto-char containing-sexp)
(and (eq (char-after) ?{)
(not (c-looking-at-statement-block)))))))
(cond (cond
;; CASE 9A: In the middle of a special brace list opener. ;; CASE 9A: In the middle of a special brace list opener.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment