Function: c-neutralize-syntax-in-CPP

c-neutralize-syntax-in-CPP is a byte-compiled function defined in cc-mode.el.gz.

Signature

(c-neutralize-syntax-in-CPP BEGG ENDD OLD-LEN)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-mode.el.gz
(defun c-neutralize-syntax-in-CPP (_begg _endd _old-len)
  ;; "Neutralize" every preprocessor line wholly or partially in the changed
  ;; region.  "Restore" lines which were CPP lines before the change and are
  ;; no longer so.
  ;;
  ;; That is, set syntax-table properties on characters that would otherwise
  ;; interact syntactically with those outside the CPP line(s).
  ;;
  ;; This function is called from an after-change function, BEGG ENDD and
  ;; OLD-LEN being the standard parameters.  It prepares the buffer for font
  ;; locking, hence must get called before `font-lock-after-change-function'.
  ;;
  ;; Point is undefined both before and after this function call, the buffer
  ;; has been widened, and match-data saved.  The return value is ignored.
  ;;
  ;; This function is in the C/C++/ObjC value of `c-before-font-lock-functions'.
  ;;
  ;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!!
  ;;
  ;; This function might make hidden buffer changes.
  (c-save-buffer-state (limits)
    ;; Clear 'syntax-table properties "punctuation":
    ;; (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
    ;; The above is now done in `c-depropertize-CPP'.

    ;; Add needed properties to each CPP construct in the region.
    (goto-char c-new-BEG)
    (if (setq limits (c-literal-limits)) ; Go past any literal.
	(goto-char (cdr limits)))
    (skip-chars-backward " \t")
    (let ((pps-position (point))  pps-state mbeg)
      (while (and (< (point) c-new-END)
		  (search-forward-regexp c-anchored-cpp-prefix c-new-END t))
	;; If we've found a "#" inside a macro/string/comment, ignore it.
	(unless
	    (or (save-excursion
		  (goto-char (match-beginning 0))
		  (let ((here (point)))
		    (and (save-match-data (c-beginning-of-macro))
			 (< (point) here))))
		(progn
		  (setq pps-state
			(parse-partial-sexp pps-position (point) nil nil pps-state)
			pps-position (point))
		  (or (nth 3 pps-state)	   ; in a string?
		      (and (nth 4 pps-state)
			   (not (eq (nth 7 pps-state) 'syntax-table)))))) ; in a comment?
	  (goto-char (match-beginning 1))
	  (setq mbeg (point))
	  (if (> (c-no-comment-end-of-macro) mbeg)
	      (c-neutralize-CPP-line mbeg (point)) ; "punctuation" properties
	    (forward-line))	      ; no infinite loop with, e.g., "#//"
	  )))))