Commit 4bf40029 authored by Alan Mackenzie's avatar Alan Mackenzie

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.
parent 5b48dab4
Pipeline #2241 failed with stage
in 52 minutes and 49 seconds
......@@ -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)))))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment