;; reduced by buffer changes, and increased by invocations of
;; `c-state-literal-at'. FIMXE!!!
-(defsubst c-state-pp-to-literal (from to)
+(defsubst c-state-pp-to-literal (from to)
;; Do a parse-partial-sexp from FROM to TO, returning either
;; (STATE TYPE (BEG . END)) if TO is in a literal; or
;; where STATE is the parsing state at TO, TYPE is the type of the literal
;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the literal.
+ ;; Unless NOT-IN-DELIMITER is non-nil, when TO is inside a two-character
+ ;; comment opener, this is recognized as being in a comment literal.
;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote),
;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of
(let ((s (parse-partial-sexp from to))
- (when (or (nth 3 s) (nth 4 s)) ; in a string or comment
+ ((or (nth 3 s) (nth 4 s)) ; in a string or comment
(eq (nth 7 s) t) 'c++)
(parse-partial-sexp (point) (point-max)
- 'syntax-table)) ; stop at end of literal
- `(,s ,ty (,(nth 8 s) . ,(point)))
+ 'syntax-table) ; stop at end of literal
+ `(,s ,ty (,(nth 8 s) . ,(point))))
+ ((and (not not-in-delimiter) ; inside a comment starter
+ (looking-at c-comment-start-regexp)))
+ (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
+ `(,s ,ty (,co-st . ,(point))))
(defun c-state-safe-place (here)
;; Return a buffer position before HERE which is "safe", i.e. outside any
;; This function is called from c-after-change.
;; The caches of non-literals:
- (if (< here c-state-nonlit-pos-cache-limit)
- (setq c-state-nonlit-pos-cache-limit here))
- (if (< here c-state-semi-nonlit-pos-cache-limit)
- (setq c-state-semi-nonlit-pos-cache-limit here))
+ ;; Note that we use "<=" for the possibility of the second char of a two-char
+ ;; comment opener being typed; this would invalidate any cache position at
+ (if (<= here c-state-nonlit-pos-cache-limit)
+ (setq c-state-nonlit-pos-cache-limit (1- here)))
+ (if (<= here c-state-semi-nonlit-pos-cache-limit)
+ (setq c-state-semi-nonlit-pos-cache-limit (1- here)))
;; Case 1: if `here' is in a literal containing point-min, everything
(lim (or lim (c-state-semi-safe-place pos)))
- (c-state-pp-to-literal lim pos)))
+ (c-state-pp-to-literal lim pos)))
(lit-limits (car (cddr pp-to-lit))))
- ((and (not not-in-delimiter)
- (looking-at "[/*]")) ; FIXME!!! use c-line/block-comment-starter. 2008-09-28.
- ;; We're standing in a comment starter.
- (cons (point) (progn (c-forward-single-comment) (point))))