Skip to content

Teach AUTOs to process escaped backslashes at the end of quoted strings (#1831) #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions verilog-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -3608,38 +3608,46 @@ This creates v-cmts properties where comments are in force."
(save-match-data
(verilog-save-buffer-state
(let (pt)
(goto-char beg)
(while (< (point) end)
(cond ((looking-at "//")
(setq pt (point))
(or (search-forward "\n" end t)
(goto-char end))
;; "1+": The leading // or /* itself isn't considered as
;; being "inside" the comment, so that a (search-backward)
;; that lands at the start of the // won't mis-indicate
;; it's inside a comment. Also otherwise it would be
;; hard to find a commented out /*AS*/ vs one that isn't
(put-text-property (1+ pt) (point) 'v-cmts t))
((looking-at "/\\*")
(setq pt (point))
(or (search-forward "*/" end t)
;; No error - let later code indicate it so we can
;; use inside functions on-the-fly
;;(error "%s: Unmatched /* */, at char %d"
;; (verilog-point-text) (point))
(goto-char end))
(put-text-property (1+ pt) (point) 'v-cmts t))
((looking-at "\"")
(setq pt (point))
(or (re-search-forward "[^\\]\"" end t) ; don't forward-char first, since we look for a non backslash first
;; No error - let later code indicate it so we can
(goto-char end))
(put-text-property (1+ pt) (point) 'v-cmts t))
(t
(forward-char 1)
(if (re-search-forward "[/\"]" end t)
(backward-char 1)
(goto-char end))))))))))
(goto-char beg)
(while (< (point) end)
(cond ((looking-at "//")
(setq pt (point))
(or (search-forward "\n" end t)
(goto-char end))
;; "1+": The leading // or /* itself isn't considered as
;; being "inside" the comment, so that a (search-backward)
;; that lands at the start of the // won't mis-indicate
;; it's inside a comment. Also otherwise it would be
;; hard to find a commented out /*AS*/ vs one that isn't
(put-text-property (1+ pt) (point) 'v-cmts t))
((looking-at "/\\*")
(setq pt (point))
(or (search-forward "*/" end t)
;; No error - let later code indicate it so we can
;; use inside functions on-the-fly
;;(error "%s: Unmatched /* */, at char %d"
;; (verilog-point-text) (point))
(goto-char end))
(put-text-property (1+ pt) (point) 'v-cmts t))
((looking-at "\"")
(setq pt (point))
(setq pt2 nil)
;; Move forward to the first non-escaped (backslashed) double-quote ("). That closes this string.
;; skip: \" (an escaped double-quote)
;; match: \\" (a backslash as the last character of a string)
(while (not pt2)
(or (re-search-forward "\\\\" end t)
(re-search-forward "[^\\]\"" end t)
(goto-char end))
(if (looking-at "\\\\")
(forward-char 2)
(setq pt2 (point))))
(put-text-property (1+ pt) (point) 'v-cmts t))
(t
(forward-char 1)
(if (re-search-forward "[/\"]" end t)
(backward-char 1)
(goto-char end))))))))))

(defun verilog-scan ()
"Parse the buffer, marking all comments with properties.
Expand Down