diff options
author | Bob Rogers <rogers@rgrjr.com> | 2022-02-13 09:32:13 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-02-13 09:32:13 +0100 |
commit | 51d44fd705a2779beeb3fe1d59af88caadbc247a (patch) | |
tree | dcd9bc8dc1a092352f84489aa10dfe91f945394c /lisp/mail | |
parent | ae13948ff52c91b4a8188be6a2cc8d65b440731c (diff) | |
download | emacs-51d44fd705a2779beeb3fe1d59af88caadbc247a.tar.gz emacs-51d44fd705a2779beeb3fe1d59af88caadbc247a.tar.bz2 emacs-51d44fd705a2779beeb3fe1d59af88caadbc247a.zip |
Fix ietf-drums-remove-whitespace unmatched " and (
* lisp/mail/ietf-drums.el:
+ (ietf-drums-skip-comment): New helper function.
+ (ietf-drums-remove-comments): Use ietf-drums-skip-comment.
+ (ietf-drums-remove-whitespace): Handle unterminated quotes and
comments, as ietf-drums-remove-comments already does.
* test/lisp/mail/ietf-drums-tests.el:
+ Test unterminated quote and comment for
ietf-drums-remove-whitespace and ietf-drums-remove-comments (bug#53965).
Diffstat (limited to 'lisp/mail')
-rw-r--r-- | lisp/mail/ietf-drums.el | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el index db77aba172f..85aa27235fc 100644 --- a/lisp/mail/ietf-drums.el +++ b/lisp/mail/ietf-drums.el @@ -65,6 +65,21 @@ backslash and doublequote.") (modify-syntax-entry ?\' "_" table) table)) +(defvar ietf-drums-comment-syntax-table + (let ((table (copy-syntax-table ietf-drums-syntax-table))) + (modify-syntax-entry ?\" "w" table) + table) + "In comments, DQUOTE is normal and does not start a string.") + +(defun ietf-drums--skip-comment () + ;; From just before the start of a comment, go to the end. Returns + ;; point. If the comment is unterminated, go to point-max. + (condition-case () + (with-syntax-table ietf-drums-comment-syntax-table + (forward-sexp 1)) + (scan-error (goto-char (point-max)))) + (point)) + (defun ietf-drums-token-to-list (token) "Translate TOKEN into a list of characters." (let ((i 0) @@ -109,14 +124,7 @@ backslash and doublequote.") (forward-sexp 1) (error (goto-char (point-max))))) ((eq c ?\() - (delete-region - (point) - (condition-case nil - (with-syntax-table (copy-syntax-table ietf-drums-syntax-table) - (modify-syntax-entry ?\" "w") - (forward-sexp 1) - (point)) - (error (point-max))))) + (delete-region (point) (ietf-drums--skip-comment))) (t (forward-char 1)))) (buffer-string)))) @@ -130,9 +138,11 @@ backslash and doublequote.") (setq c (char-after)) (cond ((eq c ?\") - (forward-sexp 1)) + (condition-case () + (forward-sexp 1) + (scan-error (goto-char (point-max))))) ((eq c ?\() - (forward-sexp 1)) + (ietf-drums--skip-comment)) ((memq c '(?\ ?\t ?\n ?\r)) (delete-char 1)) (t |