[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117631: Fix confusion in C++ file caused by comma i
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] trunk r117631: Fix confusion in C++ file caused by comma in "= {1, 2}, ". |
Date: |
Sat, 02 Aug 2014 18:58:30 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117631
revision-id: address@hidden
parent: address@hidden
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sat 2014-08-02 18:52:48 +0000
message:
Fix confusion in C++ file caused by comma in "= {1,2},".
cc-engine.el (c-beginning-of-statement-1): In checking for a statement
boundary marked by "}", check there's no "=" before the "{".
(c-guess-basic-syntax CASE 9B): Call c-beginning-of-statement with
non-nil `comma-delim' argument.
cc-fonts.el (c-font-lock-declarators): Parse an initializer expression
more accurately.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/cc-engine.el
ccengine.el-20091113204419-o5vbwnq5f7feedwu-1227
lisp/progmodes/cc-fonts.el ccfonts.el-20091113204419-o5vbwnq5f7feedwu-2930
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-08-02 16:42:29 +0000
+++ b/lisp/ChangeLog 2014-08-02 18:52:48 +0000
@@ -1,5 +1,15 @@
2014-08-02 Alan Mackenzie <address@hidden>
+ Fix confusion in C++ file caused by comma in "= {1,2},". Bug
+ #17756.
+ * progmodes/cc-engine.el (c-beginning-of-statement-1): In checking
+ for a statement boundary marked by "}", check there's no "="
+ before the "{".
+ (c-guess-basic-syntax CASE 9B): Call c-beginning-of-statement with
+ non-nil `comma-delim' argument.
+ * progmodes/cc-fonts.el (c-font-lock-declarators): Parse an
+ initializer expression more accurately.
+
Correct loop termination condition in c-syntactic-skip-backward.
* progmodes/cc-engine.el (c-syntactic-skip-backward): Correct for
the situation where, after moving back out of a literal,
=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el 2014-08-02 16:42:29 +0000
+++ b/lisp/progmodes/cc-engine.el 2014-08-02 18:52:48 +0000
@@ -1033,7 +1033,10 @@
;; Just gone back over a brace block?
((and
(eq (char-after) ?{)
- (not (c-looking-at-inexpr-block lim nil t)))
+ (not (c-looking-at-inexpr-block lim nil t))
+ (save-excursion
+ (c-backward-token-2 1 t nil)
+ (not (looking-at "=\\([^=]\\|$\\)"))))
(save-excursion
(c-forward-sexp) (point)))
;; Just gone back over some paren block?
@@ -10476,7 +10479,7 @@
(if (eq (point) (c-point 'boi))
(c-add-syntax 'brace-list-close (point))
(setq lim (c-most-enclosing-brace c-state-cache (point)))
- (c-beginning-of-statement-1 lim)
+ (c-beginning-of-statement-1 lim nil nil t)
(c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
(t
=== modified file 'lisp/progmodes/cc-fonts.el'
--- a/lisp/progmodes/cc-fonts.el 2014-01-01 07:43:34 +0000
+++ b/lisp/progmodes/cc-fonts.el 2014-08-02 18:52:48 +0000
@@ -1037,7 +1037,8 @@
paren-depth
id-face got-init
c-last-identifier-range
- (separator-prop (if types 'c-decl-type-start 'c-decl-id-start)))
+ (separator-prop (if types 'c-decl-type-start 'c-decl-id-start))
+ brackets-after-id)
;; The following `while' fontifies a single declarator id each time round.
;; It loops only when LIST is non-nil.
@@ -1110,13 +1111,24 @@
;; Search syntactically to the end of the declarator (";",
;; ",", a closing paren, eob etc) or to the beginning of an
;; initializer or function prototype ("=" or "\\s\(").
- ;; Note that the open paren will match array specs in
- ;; square brackets, and we treat them as initializers too.
- (c-syntactic-re-search-forward
- "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
+ ;; Note that square brackets are now not also treated as
+ ;; initializers, since this broke when there were also
+ ;; initializing brace lists.
+ (let (found)
+ (while
+ (and (setq found
+ (c-syntactic-re-search-forward
+ "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
+ (eq (char-before) ?\[))
+ (backward-char)
+ (c-safe (c-forward-sexp 1))
+ (setq found nil)
+ (setq brackets-after-id t))
+ found))
(setq next-pos (match-beginning 0)
id-face (if (and (eq (char-after next-pos) ?\()
+ (not brackets-after-id)
(let (c-last-identifier-range)
(save-excursion
(goto-char next-pos)
@@ -1486,9 +1498,12 @@
c-recognize-knr-p) ; Strictly speaking, bogus, but it
; speeds up lisp.h tremendously.
(save-excursion
+ (unless (or (eobp)
+ (looking-at "\\s(\\|\\s)"))
+ (forward-char))
(setq bod-res (car (c-beginning-of-decl-1 decl-search-lim)))
(if (and (eq bod-res 'same)
- (progn
+ (save-excursion
(c-backward-syntactic-ws)
(eq (char-before) ?\})))
(c-beginning-of-decl-1 decl-search-lim))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117631: Fix confusion in C++ file caused by comma in "= {1, 2}, ".,
Alan Mackenzie <=