commit/cc-mode: acm: Fix confusion in C++ file caused by comma in "= {1, 2}, ".

[email protected] Sat, 02 Aug 2014 18:24:58 -0000
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
1 new commit in cc-mode:

https://bitbucket.org/xemacs/cc-mode/commits/1bb8128d2490/
Changeset:   1bb8128d2490
User:        acm
Date:        2014-08-02 20:12:05
Summary:     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.
Affected #:  2 files

diff -r 35a81ed7bf543fd761b6b224025c60f12a10260b -r 1bb8128d249099c24d9ad4535f40d4394d90c84b cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -1038,7 +1038,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?
@@ -10510,7 +10513,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

diff -r 35a81ed7bf543fd761b6b224025c60f12a10260b -r 1bb8128d249099c24d9ad4535f40d4394d90c84b cc-fonts.el
--- a/cc-fonts.el
+++ b/cc-fonts.el
@@ -1009,7 +1009,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.
@@ -1082,13 +1083,24 @@
 	    ;; Search syntactically to the end of the declarator (";",
 	    ;; ",", a closen 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 (eq (char-after next-pos) ?\()
+	    id-face (if (and (eq (char-after next-pos) ?\()
+			     (not brackets-after-id))
 			'font-lock-function-name-face
 		      'font-lock-variable-name-face)
 	    got-init (and (match-beginning 1)
@@ -1458,7 +1470,7 @@
 		    (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))

Repository URL: https://bitbucket.org/xemacs/cc-mode/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.