Function: c-before-change-fix-comment-escapes

c-before-change-fix-comment-escapes is a byte-compiled function defined in cc-mode.el.gz.

Signature

(c-before-change-fix-comment-escapes BEG END)

Documentation

Remove punctuation syntax-table text properties from C/C++ comment markers.

This is to handle the rare case of two or more backslashes at an end of line in a // comment or the equally rare case of a backslash preceding the terminator of a /* comment, as \*/.

This function is used solely as a member of c-get-state-before-change-functions, where it should appear late in that variable, and it must be used only together with c-after-change-fix-comment-escapes.

Note that the function currently only handles comments beginning with // and /*, not more generic line and block comments.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-mode.el.gz
(defun c-before-change-fix-comment-escapes (beg end)
  "Remove punctuation syntax-table text properties from C/C++ comment markers.
This is to handle the rare case of two or more backslashes at an
end of line in a // comment or the equally rare case of a
backslash preceding the terminator of a /* comment, as \\*/.

This function is used solely as a member of
`c-get-state-before-change-functions', where it should appear
late in that variable, and it must be used only together with
`c-after-change-fix-comment-escapes'.

Note that the function currently only handles comments beginning
with // and /*, not more generic line and block comments."
  (c-save-buffer-state (end-state)
    (setq end-state (c-full-pp-to-literal end))
    (when (memq (cadr end-state) '(c c++))
      (goto-char (max (- beg 2) (point-min)))
      (if (eq (cadr end-state) 'c)
	  (when (search-forward "\\*/"
				(or (cdr (caddr end-state)) (point-max)) t)
	    (c-clear-syntax-table-trim-caches (match-beginning 0)))
	(while (search-forward "\\\\\n"
			       (or (cdr (caddr end-state)) (point-max)) t)
	  (c-clear-syntax-table-trim-caches (match-beginning 0)))))))