mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-20 10:23:57 +00:00
Fix problems in CC Mode with " being entered into a comment at EOB.
* lisp/progmodes/cc-engine.el (c-full-lit-near-cache): Amend the definition such that an element's END element will be nil if the pertinent literal is open at EOB. (c-full-pp-to-literal): Before setting the aforementioned END element, check that we're no longer in a literal. (c-literal-limits): When c-full-pp-to-literal returns a list with a nil END element, replace this by (point-max) to keep the interface of c-literal-limits unchanged. * lisp/progmodes/cc-mode.el (c-after-change-mark-abnormal-strings): Having found a string quote, check it is not inside an unterminated comment (i.e. one at EOB).
This commit is contained in:
parent
dfb0ba79b5
commit
6bd817ee66
@ -2977,6 +2977,7 @@ comment at the start of cc-engine.el for more info."
|
||||
;; element is a list (HERE STATE END)), where HERE is the buffer position the
|
||||
;; function was called for, STATE is the `parse-partial-sexp' state there, and
|
||||
;; END is the end of the literal enclosing HERE, if any, or nil otherwise.
|
||||
;; N.B. END will be nil if the literal ends at EOB without a delimiter.
|
||||
|
||||
(defun c-full-trim-near-cache ()
|
||||
;; Remove stale entries in `c-full-lit-near-cache', i.e. those whose END
|
||||
@ -3045,7 +3046,8 @@ comment at the start of cc-engine.el for more info."
|
||||
;; (STATE) otherwise,
|
||||
;; where STATE is the parsing state at HERE, TYPE is the type of the literal
|
||||
;; enclosing HERE, (one of 'string, 'c, 'c++) and (BEG . END) is the
|
||||
;; boundaries of that literal (including the delimiters).
|
||||
;; boundaries of that literal (including the delimiters), with END being nil
|
||||
;; if there is no end delimiter (i.e. the literal ends at EOB).
|
||||
;;
|
||||
;; 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.
|
||||
@ -3064,6 +3066,7 @@ comment at the start of cc-engine.el for more info."
|
||||
(base (car elt))
|
||||
(near-base base)
|
||||
(s (cadr elt))
|
||||
s1
|
||||
(end (car (cddr elt)))
|
||||
far-base-and-state far-base far-s ty start)
|
||||
(if (or
|
||||
@ -3104,12 +3107,17 @@ comment at the start of cc-engine.el for more info."
|
||||
(t 'c)))
|
||||
(setq start (nth 8 s))
|
||||
(unless end
|
||||
(parse-partial-sexp here (point-max)
|
||||
nil ; TARGETDEPTH
|
||||
nil ; STOPBEFORE
|
||||
s ; OLDSTATE
|
||||
'syntax-table) ; stop at end of literal
|
||||
(setq end (point)))
|
||||
(setq s1 (parse-partial-sexp here (point-max)
|
||||
nil ; TARGETDEPTH
|
||||
nil ; STOPBEFORE
|
||||
s ; OLDSTATE
|
||||
'syntax-table)); stop at EO literal
|
||||
(unless (or (nth 3 s1) ; still in a string
|
||||
(and (nth 4 s1)
|
||||
(not (eq (nth 7 s1) 'syntax-table)))) ; still
|
||||
; in a
|
||||
; comment
|
||||
(setq end (point))))
|
||||
(unless (eq near-base here)
|
||||
(c-full-put-near-cache-entry here s end))
|
||||
(list s ty (cons start end)))
|
||||
@ -5555,8 +5563,11 @@ comment at the start of cc-engine.el for more info."
|
||||
s
|
||||
'syntax-table)
|
||||
(point)))))
|
||||
(let ((pp-to-lit (c-full-pp-to-literal pos not-in-delimiter)))
|
||||
(car (cddr pp-to-lit))))))
|
||||
(let* ((pp-to-lit (c-full-pp-to-literal pos not-in-delimiter))
|
||||
(limits (car (cddr pp-to-lit))))
|
||||
(if (and limits (null (cdr limits)))
|
||||
(cons (car limits) (point-max))
|
||||
limits)))))
|
||||
(cond
|
||||
(lit-limits)
|
||||
|
||||
|
@ -1527,7 +1527,9 @@ Note that the style variables are always made local to the buffer."
|
||||
(or (not (nth 3 s))
|
||||
(not (memq (char-before) c-string-delims))))))
|
||||
;; We're at the start of a string.
|
||||
(memq (char-before) c-string-delims)))
|
||||
(and (memq (char-before) c-string-delims)
|
||||
(not (nth 4 s))))) ; Check we're actually out of the
|
||||
; comment. not stuck at EOB
|
||||
(unless (and (c-major-mode-is 'c++-mode)
|
||||
(c-maybe-re-mark-raw-string))
|
||||
(if (c-unescaped-nls-in-string-p (1- (point)))
|
||||
|
Loading…
Reference in New Issue
Block a user