]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-fonts.el
Use \r rather than ^M in string literals
[gnu-emacs] / lisp / progmodes / cc-fonts.el
index 448e76427f277de96e1e01aa92179b3534ea2238..ad564f7c3dfee2a2a171aed95255cbf9635c03c9 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-fonts.el --- font lock support for CC Mode
 
-;; Copyright (C) 2002-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2015 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             2002- Martin Stjernholm
@@ -539,28 +539,29 @@ stuff.  Used on level 1 and higher."
                  (let* ((re (c-make-keywords-re nil
                               (c-lang-const c-cpp-include-directives)))
                         (re-depth (regexp-opt-depth re)))
-                   `((,(concat noncontinued-line-end
-                               (c-lang-const c-opt-cpp-prefix)
-                               re
-                               (c-lang-const c-syntactic-ws)
-                               "\\(<[^>\n\r]*>?\\)")
-                      (,(+ ncle-depth re-depth sws-depth 1)
-                       font-lock-string-face)
-
-                      ;; Use an anchored matcher to put paren syntax
-                      ;; on the brackets.
-                      (,(byte-compile
-                         `(lambda (limit)
-                            (let ((beg (match-beginning
-                                        ,(+ ncle-depth re-depth sws-depth 1)))
-                                  (end (1- (match-end ,(+ ncle-depth re-depth
-                                                          sws-depth 1)))))
-                              (if (eq (char-after end) ?>)
-                                  (progn
-                                    (c-mark-<-as-paren beg)
-                                    (c-mark->-as-paren end))
-                                (c-unmark-<->-as-paren beg)))
-                            nil)))))))
+                   ;; We used to use a font-lock "anchored matcher" here for
+                   ;; the paren syntax.  This failed when the ">" was at EOL,
+                   ;; since `font-lock-fontify-anchored-keywords' terminated
+                   ;; its loop at EOL without executing our lambda form at
+                   ;; all.
+                   `((,(c-make-font-lock-search-function
+                        (concat noncontinued-line-end
+                                (c-lang-const c-opt-cpp-prefix)
+                                re
+                                (c-lang-const c-syntactic-ws)
+                                "\\(<[^>\n\r]*>?\\)")
+                        `(,(+ ncle-depth re-depth sws-depth 1)
+                          font-lock-string-face t)
+                        `((let ((beg (match-beginning
+                                      ,(+ ncle-depth re-depth sws-depth 1)))
+                                (end (1- (match-end ,(+ ncle-depth re-depth
+                                                        sws-depth 1)))))
+                            (if (eq (char-after end) ?>)
+                                (progn
+                                  (c-mark-<-as-paren beg)
+                                  (c-mark->-as-paren end))
+                              (c-unmark-<->-as-paren beg)))
+                          nil))))))
 
              ;; #define.
              ,@(when (c-lang-const c-opt-cpp-macro-define)
@@ -1464,36 +1465,38 @@ casts and declarations are fontified.  Used on level 2 and higher."
                    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)
-                          (save-excursion
-                            (c-backward-syntactic-ws)
-                            (eq (char-before) ?\})))
-                     (c-beginning-of-decl-1 decl-search-lim))
-
-                 ;; We're now putatively at the declaration.
-                 (setq paren-state (c-parse-state))
-                 ;; At top level or inside a "{"?
-                 (if (or (not (setq encl-pos
-                                    (c-most-enclosing-brace paren-state)))
-                         (eq (char-after encl-pos) ?\{))
-                     (progn
-                       (when (looking-at c-typedef-key) ; "typedef"
-                         (setq is-typedef t)
-                         (goto-char (match-end 0))
-                         (c-forward-syntactic-ws))
-                       ;; At a real declaration?
-                       (if (memq (c-forward-type t) '(t known found decltype))
-                           (progn
-                             (c-font-lock-declarators (point-max) t is-typedef)
-                             nil)
-                         ;; False alarm.  Return t to go on to the next check.
-                         (goto-char start-pos)
-                         t))
-                   t))))))
+                 (if (c-back-over-member-initializers)
+                    t                  ; Can't be at a declarator
+                   (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)
+                            (save-excursion
+                              (c-backward-syntactic-ws)
+                              (eq (char-before) ?\})))
+                       (c-beginning-of-decl-1 decl-search-lim))
+
+                   ;; We're now putatively at the declaration.
+                   (setq paren-state (c-parse-state))
+                   ;; At top level or inside a "{"?
+                   (if (or (not (setq encl-pos
+                                      (c-most-enclosing-brace paren-state)))
+                           (eq (char-after encl-pos) ?\{))
+                       (progn
+                         (when (looking-at c-typedef-key) ; "typedef"
+                           (setq is-typedef t)
+                           (goto-char (match-end 0))
+                           (c-forward-syntactic-ws))
+                         ;; At a real declaration?
+                         (if (memq (c-forward-type t) '(t known found decltype))
+                             (progn
+                               (c-font-lock-declarators (point-max) t is-typedef)
+                               nil)
+                           ;; False alarm.  Return t to go on to the next check.
+                           (goto-char start-pos)
+                           t))
+                     t)))))))
 
          ;; It was a false alarm.  Check if we're in a label (or other
          ;; construct with `:' except bitfield) instead.
@@ -1769,8 +1772,8 @@ on level 2 only and so aren't combined with `c-complex-decl-matchers'."
 ;;                    "\\|"
 ;;                    (c-lang-const c-symbol-key)
 ;;                    "\\)")
-;;            `((c-font-lock-declarators limit t nil) ; That `nil' says use `font-lock-variable-name-face';
-;;                                     ; `t' would mean `font-lock-function-name-face'.
+;;            `((c-font-lock-declarators limit t nil) ; That nil says use `font-lock-variable-name-face';
+;;                                     ; t would mean `font-lock-function-name-face'.
 ;;              (progn
 ;;                (c-put-char-property (match-beginning 0) 'c-type
 ;;                                     'c-decl-id-start)