Function: c-font-lock-ml-strings
c-font-lock-ml-strings is a byte-compiled function defined in
cc-fonts.el.gz.
Signature
(c-font-lock-ml-strings LIMIT)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-fonts.el.gz
(defun c-font-lock-ml-strings (limit)
;; Fontify multi-line 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".
(let* ((state (c-semi-pp-to-literal (point)))
(string-start (and (eq (cadr state) 'string)
(car (cddr state))))
(open-delim (and string-start
(save-excursion
(goto-char (1+ string-start))
(c-ml-string-opener-around-point))))
(string-delims (and open-delim
(cons open-delim (c-get-ml-closer open-delim))))
found)
;; We go round the next loop twice per raw string, once for each "end".
(while (< (point) limit)
(cond
;; Point is not in an ml string
((not string-delims)
(while (and (setq found (re-search-forward c-ml-string-opener-re
limit 'limit))
(> (match-beginning 0) (point-min))
(memq (c-get-char-property (1- (match-beginning 0)) 'face)
'(font-lock-comment-face font-lock-string-face
font-lock-comment-delimiter-face))))
(when found
(setq open-delim (cons (match-beginning 1)
(cons (match-end 1) (match-beginning 2)))
string-delims (cons open-delim (c-get-ml-closer open-delim)))
(goto-char (caar string-delims))))
;; Point is in the body of an ml string.
((and string-delims
(>= (point) (cadar string-delims))
(or (not (cdr string-delims))
(< (point) (cadr string-delims))))
(cond
((cdr string-delims)
(goto-char (cadr string-delims)))
((equal (c-get-char-property (1- (cadar string-delims))
'syntax-table)
'(15)) ; "Always" the case.
;; The next search should be successful for an unterminated ml
;; string inside a macro, but not for any other unterminated
;; string.
(or (c-search-forward-char-property 'syntax-table '(15) limit)
(goto-char limit))
(setq string-delims nil))
(t (c-benign-error "Messing '(15) syntax-table property at %d"
(1- (cadar string-delims)))
(setq string-delims nil))))
;; Point is at or in a closing delimiter
((and string-delims
(cdr string-delims)
(>= (point) (cadr string-delims)))
(unless (featurep 'xemacs)
(c-put-font-lock-face (cadr string-delims) (1+ (cadr string-delims))
'font-lock-string-face))
(c-remove-font-lock-face
(if (featurep 'xemacs)
(cadr string-delims)
(1+ (cadr string-delims)))
(caddr string-delims))
(goto-char (caddr string-delims))
(setq string-delims nil))
;; point is at or in an opening delimiter.
(t
(if (cdr string-delims)
(progn
(c-remove-font-lock-face (caar string-delims)
(cadar string-delims))
(unless (featurep 'xemacs)
(c-put-font-lock-face (1- (cadar string-delims))
(cadar string-delims)
'font-lock-string-face)))
(c-put-font-lock-face (caar string-delims) (cadar string-delims)
'font-lock-warning-face))
(goto-char (cadar string-delims)))))
nil))