mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-20 10:23:57 +00:00
Fix an infinite loop in c-end-of-macro. Should fix bug #36484
Also fix two faulty regexps, save-match-data, and check c-major-mode-is 'c++-mode where needed. * lis/progmodes/cc-langs.el (c-last-c-comment-end-on-line-re) (c-last-open-c-comment-start-on-line-re): Handle repeated *s in regexp correctly. * lisp/progmodes/cc-engine.el (c-beginning-of-macro, c-end-of-macro): Protect the match-data with save-match-data around regexp operations. (c-end-of-macro): In the loop handling multiline block comments, check a comment actually is multiline. * lisp/progmodes/cc-mode.el (c-depropertize-CPP): Only call c-depropertize-raw-strings-in-region in C++ Mode.
This commit is contained in:
parent
5b48dab412
commit
4bf4002906
@ -310,20 +310,21 @@ comment at the start of cc-engine.el for more info."
|
||||
(beginning-of-line)
|
||||
(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)))))
|
||||
(save-match-data
|
||||
(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)
|
||||
@ -361,22 +362,25 @@ comment at the start of cc-engine.el for more info."
|
||||
c-macro-cache-start-pos nil
|
||||
c-macro-cache-syntactic nil
|
||||
c-macro-cache-no-comment nil))
|
||||
(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)))
|
||||
(save-match-data
|
||||
(while
|
||||
(progn
|
||||
(while (progn
|
||||
(end-of-line)
|
||||
(when (and (eq (char-before) ?\\)
|
||||
(not (eobp)))
|
||||
(forward-char)
|
||||
t)))
|
||||
(let ((cand-EOM (point)))
|
||||
(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))
|
||||
(and (c-forward-single-comment)
|
||||
(> (point) cand-EOM)))
|
||||
nil)))))
|
||||
|
||||
(when (and (car c-macro-cache)
|
||||
(> (point) (car c-macro-cache)) ; in case we have a
|
||||
|
@ -1608,7 +1608,7 @@ backslash."
|
||||
current line, if any, or nil in those languages without block
|
||||
comments. When a match is found, submatch 1 contains the comment
|
||||
ender."
|
||||
t "\\(\\*/\\)\\([^*]\\|\\*[^/]\\)*$"
|
||||
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))
|
||||
@ -1618,7 +1618,7 @@ ender."
|
||||
current ine, if any, or nil in those languages without block
|
||||
comments. When a match is found, submatch 1 contains the comment
|
||||
starter."
|
||||
t "\\(/\\*\\)\\([^*]\\|\\*[^/]\\)*$"
|
||||
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))
|
||||
|
@ -934,7 +934,8 @@ Note that the style variables are always made local to the buffer."
|
||||
(goto-char (match-beginning 1))
|
||||
(setq m-beg (point))
|
||||
(c-end-of-macro)
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
|
||||
(when (c-major-mode-is 'c++-mode)
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point))))
|
||||
(c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
|
||||
|
||||
(while (and (< (point) end)
|
||||
@ -944,7 +945,8 @@ Note that the style variables are always made local to the buffer."
|
||||
(setq m-beg (point))
|
||||
(c-end-of-macro))
|
||||
(when (and ss-found (> (point) end))
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
|
||||
(when (c-major-mode-is 'c++-mode)
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point))))
|
||||
(c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
|
||||
|
||||
(while (and (< (point) c-new-END)
|
||||
@ -952,7 +954,8 @@ Note that the style variables are always made local to the buffer."
|
||||
(goto-char (match-beginning 1))
|
||||
(setq m-beg (point))
|
||||
(c-end-of-macro)
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
|
||||
(when (c-major-mode-is 'c++-mode)
|
||||
(save-excursion (c-depropertize-raw-strings-in-region m-beg (point))))
|
||||
(c-clear-char-property-with-value
|
||||
m-beg (point) 'syntax-table '(1)))))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user