Note that this function might do hidden buffer changes. See the
comment at the start of cc-engine.el for more info."
- (let ((here (point)))
+ (let ((here (point))
+ (pause (c-point 'eol)))
(when c-opt-cpp-prefix
(if (and (car c-macro-cache)
(>= (point) (car c-macro-cache))
(save-restriction
(if lim (narrow-to-region lim (point-max)))
(beginning-of-line)
- (while (eq (char-before (1- (point))) ?\\)
- (forward-line -1))
+ (when (or (null lim)
+ (>= here lim))
+ (while
+ (progn
+ (while (eq (char-before (1- (point))) ?\\)
+ (forward-line -1))
+ (when (and c-last-c-comment-end-on-line-re
+ (re-search-forward
+ c-last-c-comment-end-on-line-re pause t))
+ (goto-char (match-end 1))
+ (if (c-backward-single-comment)
+ (progn
+ (beginning-of-line)
+ (setq pause (point)))
+ (goto-char pause)
+ nil)))))
+
(back-to-indentation)
(if (and (<= (point) here)
(save-match-data (looking-at c-opt-cpp-start))
c-macro-cache-start-pos nil
c-macro-cache-syntactic nil
c-macro-cache-no-comment nil))
- (while (progn
- (end-of-line)
- (when (and (eq (char-before) ?\\)
- (not (eobp)))
- (forward-char)
- t)))
+ (while
+ (progn
+ (while (progn
+ (end-of-line)
+ (when (and (eq (char-before) ?\\)
+ (not (eobp)))
+ (forward-char)
+ t)))
+ (if (and c-last-open-c-comment-start-on-line-re
+ (re-search-backward
+ c-last-open-c-comment-start-on-line-re
+ (c-point 'bol) t))
+ (progn
+ (goto-char (match-beginning 1))
+ (c-forward-single-comment))
+ nil)))
+
(when (and (car c-macro-cache)
(bolp)
(not (eq (char-before (1- (point))) ?\\)))
;; Take elaborate precautions to detect an open block comment at
;; the end of a macro. If we find one, we set `safe-start' to nil
;; and break off any further scanning of comments.
+ ;;
+ ;; (2019-05-02): `c-end-of-macro' now moves completely over block
+ ;; comments, even multiline ones lacking \s at their EOLs. So a
+ ;; lot of the following is probably redundant now.
(let ((com-begin (point)) com-end in-macro)
(when (and (c-forward-single-comment)
(setq com-end (point))
(c-lang-defvar c-line-comment-start-regexp
(c-lang-const c-line-comment-start-regexp))
+(c-lang-defconst c-last-c-comment-end-on-line-re
+ "Regexp which matches the last block comment ender on the
+current line, if any, or nil in those languages without block
+comments. When a match is found, submatch 1 contains the comment
+ender."
+ t "\\(\\*/\\)\\([^*]\\|\\*[^/]\\)*$"
+ awk nil)
+(c-lang-defvar c-last-c-comment-end-on-line-re
+ (c-lang-const c-last-c-comment-end-on-line-re))
+
+(c-lang-defconst c-last-open-c-comment-start-on-line-re
+ "Regexp which matches the last block comment start on the
+current ine, if any, or nil in those languages without block
+comments. When a match is found, submatch 1 contains the comment
+starter."
+ t "\\(/\\*\\)\\([^*]\\|\\*[^/]\\)*$"
+ awk nil)
+(c-lang-defvar c-last-open-c-comment-start-on-line-re
+ (c-lang-const c-last-open-c-comment-start-on-line-re))
+
(c-lang-defconst c-literal-start-regexp
;; Regexp to match the start of comments and string literals.
t (concat (c-lang-const c-comment-start-regexp)