]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-fonts.el
Merge from emacs-24; up to 117687
[gnu-emacs] / lisp / progmodes / cc-fonts.el
index 6ebd6c6a8fc0ac0d2d5a237aa0ff32ed5f31e700..8035c1891d774a3819d113634750534b0793a35d 100644 (file)
              (parse-sexp-lookup-properties
               (cc-eval-when-compile
                 (boundp 'parse-sexp-lookup-properties))))
-
-         ;; (while (re-search-forward ,regexp limit t)
-         ;;   (unless (progn
-         ;;          (goto-char (match-beginning 0))
-         ;;          (c-skip-comments-and-strings limit))
-         ;;     (goto-char (match-end 0))
-         ;;     ,@(mapcar
-         ;;     (lambda (highlight)
-         ;;       (if (integerp (car highlight))
-         ;;           (progn
-         ;;             (unless (eq (nth 2 highlight) t)
-         ;;               (error
-         ;;                "The override flag must currently be t in %s"
-         ;;                highlight))
-         ;;             (when (nth 3 highlight)
-         ;;               (error
-         ;;                "The laxmatch flag may currently not be set in %s"
-         ;;                highlight))
-         ;;             `(save-match-data
-         ;;                (c-put-font-lock-face
-         ;;                 (match-beginning ,(car highlight))
-         ;;                 (match-end ,(car highlight))
-         ;;                 ,(elt highlight 1))))
-         ;;         (when (nth 3 highlight)
-         ;;           (error "Match highlights currently not supported in %s"
-         ;;                  highlight))
-         ;;         `(progn
-         ;;            ,(nth 1 highlight)
-         ;;            (save-match-data ,(car highlight))
-         ;;            ,(nth 2 highlight))))
-         ;;     highlights)))
          ,(c-make-font-lock-search-form regexp highlights))
-
        nil)))
 
   (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights)
@@ -716,7 +684,11 @@ stuff.  Used on level 1 and higher."
   (let ((start (1- (point))))
     (save-excursion
       (and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start)
-          (if (integerp c-multiline-string-start-char)
+          (if (if (eval-when-compile (integerp ?c))
+                  ;; Emacs
+                  (integerp c-multiline-string-start-char)
+                ;; XEmacs
+                (characterp c-multiline-string-start-char))
               ;; There's no multiline string start char before the
               ;; string, so newlines aren't allowed.
               (not (eq (char-before start) c-multiline-string-start-char))
@@ -1037,7 +1009,8 @@ casts and declarations are fontified.  Used on level 2 and higher."
        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,17 +1083,21 @@ casts and declarations are fontified.  Used on level 2 and higher."
            ;; 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) ?\[)
+                      (c-go-up-list-forward))
+                    (setq brackets-after-id t))
+             found))
 
       (setq next-pos (match-beginning 0)
            id-face (if (and (eq (char-after next-pos) ?\()
-                            (let (c-last-identifier-range)
-                              (save-excursion
-                                (goto-char next-pos)
-                                (c-at-toplevel-p))))
+                            (not brackets-after-id))
                        'font-lock-function-name-face
                      'font-lock-variable-name-face)
            got-init (and (match-beginning 1)
@@ -1146,7 +1123,6 @@ casts and declarations are fontified.  Used on level 2 and higher."
       (when list
        ;; Jump past any initializer or function prototype to see if
        ;; there's a ',' to continue at.
-
        (cond ((eq id-face 'font-lock-function-name-face)
               ;; Skip a parenthesized initializer (C++) or a function
               ;; prototype.
@@ -1214,8 +1190,8 @@ casts and declarations are fontified.  Used on level 2 and higher."
          ;; o - nil, if not in an arglist at all.  This includes the
          ;;   parenthesized condition which follows "if", "while", etc.
          context
-         ;; The position of the next token after the closing paren of
-         ;; the last detected cast.
+         ;; A list of starting positions of possible type declarations, or of
+         ;; the typedef preceding one, if any.
          last-cast-end
          ;; The result from `c-forward-decl-or-cast-1'.
          decl-or-cast
@@ -1303,14 +1279,15 @@ casts and declarations are fontified.  Used on level 2 and higher."
              (cond ((not (memq (char-before match-pos) '(?\( ?, ?\[ ?<)))
                     (setq context nil
                           c-restricted-<>-arglists nil))
-                   ;; A control flow expression
+                   ;; A control flow expression or a decltype
                    ((and (eq (char-before match-pos) ?\()
                          (save-excursion
                            (goto-char match-pos)
                            (backward-char)
                            (c-backward-token-2)
                            (or (looking-at c-block-stmt-2-key)
-                               (looking-at c-block-stmt-1-2-key))))
+                               (looking-at c-block-stmt-1-2-key)
+                               (looking-at c-typeof-key))))
                     (setq context nil
                           c-restricted-<>-arglists t))
                    ;; Near BOB.
@@ -1488,9 +1465,12 @@ 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)
-                          (progn
+                          (save-excursion
                             (c-backward-syntactic-ws)
                             (eq (char-before) ?\})))
                      (c-beginning-of-decl-1 decl-search-lim))
@@ -1507,7 +1487,7 @@ casts and declarations are fontified.  Used on level 2 and higher."
                          (goto-char (match-end 0))
                          (c-forward-syntactic-ws))
                        ;; At a real declaration?
-                       (if (memq (c-forward-type t) '(t known found))
+                       (if (memq (c-forward-type t) '(t known found decltype))
                            (progn
                              (c-font-lock-declarators (point-max) t is-typedef)
                              nil)
@@ -1557,9 +1537,7 @@ casts and declarations are fontified.  Used on level 2 and higher."
   ;; Note that this function won't attempt to fontify beyond the end of the
   ;; current enum block, if any.
   (let* ((paren-state (c-parse-state))
-        (encl-pos (c-most-enclosing-brace paren-state))
-        (start (point))
-       )
+        (encl-pos (c-most-enclosing-brace paren-state)))
     (when (and
           encl-pos
           (eq (char-after encl-pos) ?\{)
@@ -2124,7 +2102,7 @@ need for `c-font-lock-extra-types'.")
              ;; Got two parenthesized expressions, so we have to look
              ;; closer at them to decide which is the type.  No need to
              ;; handle `c-record-ref-identifiers' since all references
-             ;; has already been handled by other fontification rules.
+             ;; have already been handled by other fontification rules.
              (let (expr1-res expr2-res)
 
                (goto-char expr1-pos)
@@ -2159,6 +2137,9 @@ need for `c-font-lock-extra-types'.")
                ;; unusual than an initializer.
                (cond ((memq expr1-res '(t known prefix)))
                      ((memq expr2-res '(t known prefix)))
+                     ;; Presumably 'decltype's will be fontified elsewhere.
+                     ((eq expr1-res 'decltype))
+                     ((eq expr2-res 'decltype))
                      ((eq expr1-res 'found)
                       (let ((c-promote-possible-types t))
                         (goto-char expr1-pos)