Function: c-parse-ps-state-below

c-parse-ps-state-below is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-parse-ps-state-below HERE)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
;; The approximate interval between entries in `c-state-nonlit-pos-cache'.

(defun c-parse-ps-state-below (here)
  ;; Given a buffer position HERE, Return a cons (CACHE-POS . STATE), where
  ;; CACHE-POS is a position not very far before HERE for which the
  ;; parse-partial-sexp STATE is valid.  Note that the only valid elements of
  ;; STATE are those concerning comments and strings; STATE is the state of a
  ;; null `parse-partial-sexp' scan when CACHE-POS is not in a comment or
  ;; string.
  (save-excursion
    (save-restriction
      (widen)
      (c-trim-lit-pos-cache)
      (let ((c c-lit-pos-cache)
	    elt state npos high-elt)
	(while (and c (> (c-ps-state-cache-pos (car c)) here))
	  (setq high-elt (car c))
	  (setq c (cdr c)))
	(goto-char (or (and c (c-ps-state-cache-pos (car c)))
		       (point-min)))
	(setq state
	      (if c
		  (c-cache-to-parse-ps-state (car c))
		(copy-tree '(0 nil nil nil nil nil 0 nil nil nil nil))))

	(when (not high-elt)
	  ;; We need to extend the cache.  Add an element to
	  ;; `c-lit-pos-cache' each iteration of the following.
	  (while
	      (<= (setq npos (+ (point) c-state-nonlit-pos-interval)) here)
	    (setq state (parse-partial-sexp (point) npos nil nil state))
	    ;; If we're after a \ or a / or * which might be a comment
	    ;; delimiter half, move back a character.
	    (when (or (nth 5 state)	; After a quote character
		      (and (memq 'pps-extended-state c-emacs-features)
			   (nth 10 state))) ; in the middle of a 2-char seq.
	      (setq npos (1- npos))
	      (backward-char)
	      (when (nth 10 state)
		(setcar (nthcdr 10 state) nil))
	      (when (nth 5 state)
		(setcar (nthcdr 5 state) nil)))

	    (setq elt (c-parse-ps-state-to-cache state))
	    (setq c-lit-pos-cache
		  (cons elt c-lit-pos-cache))))

	(if (> (point) c-lit-pos-cache-limit)
	    (setq c-lit-pos-cache-limit (point)))

	(cons (point) state)))))