(concat ".\\(" c-string-limit-regexp "\\)")
'((c-font-lock-invalid-string)))
+ ;; Fontify C++ raw strings.
+ ,@(when (c-major-mode-is 'c++-mode)
+ '(c-font-lock-raw-strings))
+
;; Fontify keyword constants.
,@(when (c-lang-const c-constant-kwds)
(let ((re (c-make-keywords-re nil (c-lang-const c-constant-kwds))))
;;
;; Fontify types and references in names containing angle bracket
;; arglists from the point to LIMIT. Note that
- ;; `c-font-lock-declarations' already has handled many of them.
+ ;; `c-font-lock-declarations' has already handled many of them.
;;
;; This function might do hidden buffer changes.
(when (and c-opt-identifier-concat-key
(not (get-text-property id-start 'face)))
(c-forward-syntactic-ws)
- (if (looking-at c-opt-identifier-concat-key)
- (c-put-font-lock-face id-start id-end
- c-reference-face-name)
- (c-put-font-lock-face id-start id-end
- 'font-lock-type-face)))))
+ (cond ((looking-at c-opt-identifier-concat-key)
+ (c-put-font-lock-face id-start id-end
+ c-reference-face-name))
+ ((eq (char-after) ?\())
+ (t (c-put-font-lock-face id-start id-end
+ 'font-lock-type-face))))))
(goto-char pos)))
(goto-char pos)))))
(when (> (point) max-type-decl-end)
(setq max-type-decl-end (point))))
+ ;; Do we have an expression as the second or third clause of
+ ;; a "for" paren expression?
+ (if (save-excursion
+ (and
+ (car (cddr decl-or-cast)) ; maybe-expression flag.
+ (goto-char start-pos)
+ (c-go-up-list-backward)
+ (eq (char-after) ?\()
+ (progn (c-backward-syntactic-ws)
+ (c-simple-skip-symbol-backward))
+ (looking-at c-paren-stmt-key)
+ (progn (goto-char match-pos)
+ (while (and (eq (char-before) ?\))
+ (c-go-list-backward))
+ (c-backward-syntactic-ws))
+ (eq (char-before) ?\;))))
+ ;; We've got an expression in "for" parens. Remove the
+ ;; "type" that would spuriously get fontified.
+ (let ((elt (and (consp c-record-type-identifiers)
+ (assq (cadr (cddr decl-or-cast))
+ c-record-type-identifiers))))
+ (when elt
+ (setq c-record-type-identifiers
+ (c-delq-from-dotted-list
+ elt c-record-type-identifiers)))
+ t)
;; Back up to the type to fontify the declarator(s).
(goto-char (car decl-or-cast))
(c-backward-syntactic-ws)
(unless (bobp)
(c-put-char-property (1- (point)) 'c-type
- (if (cdr decl-or-cast)
+ (if (cadr decl-or-cast)
'c-decl-type-start
'c-decl-id-start)))))
(c-font-lock-declarators
- (point-max) decl-list (cdr decl-or-cast)))
+ (point-max) decl-list (cadr decl-or-cast)))
;; A declaration has been successfully identified, so do all the
;; fontification of types and refs that've been recorded.
(c-fontify-recorded-types-and-refs)
- nil)
+ nil))
;; Restore point, since at this point in the code it has been
;; left undefined by c-forward-decl-or-cast-1 above.
(c-forward-syntactic-ws)
(c-font-lock-declarators limit t in-typedef)))))))
+(defun c-font-lock-raw-strings (limit)
+ ;; Fontify C++ raw strings.
+ ;;
+ ;; This function will be called from font-lock for a region bounded by POINT
+ ;; and LIMIT, as though it were to identify a keyword for
+ ;; font-lock-keyword-face. It always returns NIL to inhibit this and
+ ;; prevent a repeat invocation. See elisp/lispref page "Search-based
+ ;; Fontification".
+ (while (search-forward-regexp
+ "R\\(\"\\)\\([^ ()\\\n\r\t]\\{,16\\}\\)(" limit t)
+ (when
+ (or (and (eobp)
+ (eq (c-get-char-property (1- (point)) 'face)
+ 'font-lock-warning-face))
+ (eq (c-get-char-property (point) 'face) 'font-lock-string-face)
+ (and (equal (c-get-char-property (match-end 2) 'syntax-table) '(1))
+ (equal (c-get-char-property (match-beginning 1) 'syntax-table)
+ '(1))))
+ (let ((paren-prop (c-get-char-property (1- (point)) 'syntax-table)))
+ (if paren-prop
+ (progn
+ (c-put-font-lock-face (match-beginning 0) (match-end 0)
+ 'font-lock-warning-face)
+ (when
+ (and
+ (equal paren-prop '(15))
+ (not (c-search-forward-char-property 'syntax-table '(15) limit)))
+ (goto-char limit)))
+ (c-put-font-lock-face (match-beginning 1) (match-end 2) 'default)
+ (when (search-forward-regexp
+ (concat ")\\(" (regexp-quote (match-string-no-properties 2))
+ "\\)\"")
+ limit t)
+ (c-put-font-lock-face (match-beginning 1) (point)
+ 'default))))))
+ nil)
+
(c-lang-defconst c-simple-decl-matchers
"Simple font lock matchers for types and declarations. These are used
on level 2 only and so aren't combined with `c-complex-decl-matchers'."