Function: c-crosses-statement-barrier-p
c-crosses-statement-barrier-p is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-crosses-statement-barrier-p FROM TO)
Documentation
Return non-nil if buffer positions FROM to TO cross one or more statement or declaration boundaries. The returned value is actually the position of the earliest boundary char. FROM must not be within a string or comment.
The variable c-maybe-labelp is set to the position of the first : that
might start a label (i.e. not part of :: and not preceded by ?). If a
single ? is found, then c-maybe-labelp is cleared.
For AWK, a statement which is terminated by an EOL (not a ; or a }) is regarded as having a "virtual semicolon" immediately after the last token on the line. If this virtual semicolon is _at_ from, the function recognizes it.
Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-crosses-statement-barrier-p (from to)
"Return non-nil if buffer positions FROM to TO cross one or more
statement or declaration boundaries. The returned value is actually
the position of the earliest boundary char. FROM must not be within
a string or comment.
The variable `c-maybe-labelp' is set to the position of the first `:' that
might start a label (i.e. not part of `::' and not preceded by `?'). If a
single `?' is found, then `c-maybe-labelp' is cleared.
For AWK, a statement which is terminated by an EOL (not a ; or a }) is
regarded as having a \"virtual semicolon\" immediately after the last token on
the line. If this virtual semicolon is _at_ from, the function recognizes it.
Note that this function might do hidden buffer changes. See the
comment at the start of cc-engine.el for more info."
(let* ((skip-chars (if c-commas-bound-stmts
c-stmt-boundary-skip-chars-with-comma
c-stmt-boundary-skip-chars)) ; e.g. "^#;{}?:"
(non-skip-list (if c-commas-bound-stmts
c-stmt-boundary-skip-list-with-comma
c-stmt-boundary-skip-list)) ; e.g. (?# ?\; ?{ ?} ?? ?:)
lit-range lit-start vsemi-pos attr-end)
(save-restriction
(widen)
(save-excursion
(catch 'done
(goto-char from)
(while (progn (skip-chars-forward
skip-chars
(min to (c-point 'bonl)))
(< (point) to))
(cond
;; Virtual semicolon?
((and (bolp)
(save-excursion
(progn
(if (setq lit-start (c-literal-start from)) ; Have we landed in a string/comment?
(goto-char lit-start))
(c-backward-syntactic-ws (c-point 'bopl))
(setq vsemi-pos (point))
(c-at-vsemi-p))))
(throw 'done vsemi-pos))
;; Optimize for large blocks of comments.
((progn (c-forward-syntactic-ws to)
(>= (point) to))
(throw 'done nil))
;; In a string/comment?
((setq lit-range (c-literal-limits from))
(goto-char (cdr lit-range)))
;; Skip over a C or C++ attribute?
((eq (char-after) ?\[)
(if (setq attr-end (c-looking-at-c++-attribute))
(goto-char attr-end)
(forward-char)))
((eq (char-after) ?:)
(forward-char)
(if (and (eq (char-after) ?:)
(< (point) to))
;; Ignore scope operators.
(forward-char)
(setq c-maybe-labelp (1- (point)))))
((eq (char-after) ??)
;; A question mark. Can't be a label, so stop
;; looking for more : and ?.
(setq c-maybe-labelp nil
skip-chars
(substring (if c-commas-bound-stmts
c-stmt-delim-chars-with-comma
c-stmt-delim-chars)
0 -2)))
;; At a CPP construct or a "#" or "##" operator?
((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol))
(if (save-excursion
(skip-chars-backward " \t")
(and (bolp)
(or (bobp)
(not (eq (char-before (1- (point))) ?\\)))))
(c-end-of-macro)
(skip-chars-forward c-opt-cpp-symbol)))
((memq (char-after) non-skip-list)
(throw 'done (point)))))
;; In trailing space after an as yet undetected virtual semicolon?
(c-backward-syntactic-ws from)
(when (and (bolp) (not (bobp))) ; Can happen in AWK Mode with an
; unterminated string/regexp.
(backward-char))
(if (and (< (point) to)
(c-at-vsemi-p))
(point)
nil))))))