Function: c-parse-quotes-before-change
c-parse-quotes-before-change is a byte-compiled function defined in
cc-mode.el.gz.
Signature
(c-parse-quotes-before-change BEG END)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-mode.el.gz
(defun c-parse-quotes-before-change (_beg _end)
;; This function analyzes 's near the region (c-new-BEG c-new-END), amending
;; those two variables as needed to include 's into that region when they
;; might be syntactically relevant to the change in progress.
;;
;; Having amended that region, the function removes pertinent text
;; properties (syntax-table properties with value '(1) and c-digit-separator
;; props with value t) from 's in it. This operation is performed even
;; within strings and comments.
;;
;; This function is called exclusively as a before-change function via the
;; variable `c-get-state-before-change-functions'.
(c-save-buffer-state (case-fold-search)
(goto-char c-new-BEG)
;; We need to scan for 's from the BO (logical) line.
(beginning-of-line)
(while (eq (char-before (1- (point))) ?\\)
(beginning-of-line 0))
(while (and (< (point) c-new-BEG)
(search-forward "'" c-new-BEG t))
(cond
((c-quoted-number-straddling-point)
(goto-char (match-end 0))
(if (> (match-end 0) c-new-BEG)
(setq c-new-BEG (match-beginning 0))))
((c-quoted-number-head-before-point)
(if (>= (point) c-new-BEG)
(setq c-new-BEG (match-beginning 0))))
((looking-at
"\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][[:xdigit:]]+\\|.\\)\\)'")
(goto-char (match-end 0))
(if (> (match-end 0) c-new-BEG)
(setq c-new-BEG (1- (match-beginning 0)))))
((looking-at "\\\\'")
(setq c-new-BEG (min c-new-BEG (1- (point))))
(goto-char (match-end 0)))
((save-excursion
(not (search-forward "'" c-new-BEG t)))
(setq c-new-BEG (min c-new-BEG (1- (point)))))
(t nil)))
(goto-char c-new-END)
;; We will scan from the BO (logical) line.
(beginning-of-line)
(while (eq (char-before (1- (point))) ?\\)
(beginning-of-line 0))
(while (and (< (point) c-new-END)
(search-forward "'" c-new-END t))
(cond
((c-quoted-number-straddling-point)
(goto-char (match-end 0))
(if (> (match-end 0) c-new-END)
(setq c-new-END (match-end 0))))
((c-quoted-number-tail-after-point)
(goto-char (match-end 0))
(if (> (match-end 0) c-new-END)
(setq c-new-END (match-end 0))))
((looking-at
"\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][[:xdigit:]]+\\|.\\)\\)'")
(goto-char (match-end 0))
(if (> (match-end 0) c-new-END)
(setq c-new-END (match-end 0))))
((looking-at "\\\\'")
(goto-char (match-end 0))
(setq c-new-END (max c-new-END (point))))
((equal (c-get-char-property (1- (point)) 'syntax-table) '(1))
(when (c-search-forward-char-property-with-value-on-char
'syntax-table '(1) ?\' (c-point 'eoll))
(setq c-new-END (max (point) c-new-END))))
(t nil)))
;; Having reached c-new-END, handle any 's after it whose context may be
;; changed by the current buffer change. The idea is to catch
;; monstrosities like ',',',',',' changing "polarity".
(goto-char c-new-END)
(cond
((c-quoted-number-tail-after-point)
(setq c-new-END (match-end 0)))
((looking-at
"\\(\\\\\\([0-7]\\{1,3\\}\\|[xuU][[:xdigit:]]+\\|.\\)\\|.\\)?\
\\('\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][[:xdigit:]]+\\|.\\)\\)\\)*'")
(setq c-new-END (match-end 0))))
;; Remove the '(1) syntax-table property from any "'"s within (c-new-BEG
;; c-new-END).
(goto-char c-new-BEG)
(when (c-search-forward-char-property-with-value-on-char
'syntax-table '(1) ?\' c-new-END)
(c-invalidate-state-cache (1- (point)))
(c-truncate-lit-pos-cache (1- (point)))
(c-clear-char-property-with-value-on-char
(1- (point)) c-new-END
'syntax-table '(1)
?')
;; Remove the c-digit-separator text property from the same "'"s.
(when c-has-quoted-numbers
(c-clear-char-property-with-value-on-char
(1- (point)) c-new-END
'c-digit-separator t
?')))))