diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-07-02 18:02:51 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-07-02 18:02:51 -0400 |
commit | fe3676fe18577643d9d247db2e6c32691f3acf80 (patch) | |
tree | 638a1ef4ce2f7a82aea4929d81463affc111351d /test | |
parent | c136f93dfad1a55c653e844d3cf25f804744275e (diff) | |
download | emacs-fe3676fe18577643d9d247db2e6c32691f3acf80.tar.gz |
(Finsert_file_contents): Keep buffer consistent in non-local exit
* src/fileio.c (decide_coding_unwind): Delete function.
(Finsert_file_contents): Don't let invalid multibyte byte sequences
escape when we exit non-locally.
* test/src/fileio-tests.el (fileio-tests--insert-file-interrupt): New test.
Diffstat (limited to 'test')
-rw-r--r-- | test/src/fileio-tests.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 6262d946df1..bd827e5498f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -107,3 +107,22 @@ Also check that an encoding error can appear in a symlink." (setenv "HOME" "x:foo") (should (equal (expand-file-name "~/bar") "x:/foo/bar"))) (setenv "HOME" old-home))) + +(ert-deftest fileio-tests--insert-file-interrupt () + (let ((text "-*- coding: binary -*-\n\xc3\xc3help") + f) + (unwind-protect + (progn + (setq f (make-temp-file "ftifi")) + (write-region text nil f nil 'silent) + (with-temp-buffer + (catch 'toto + (let ((set-auto-coding-function (lambda (&rest _) (throw 'toto nil)))) + (insert-file-contents f))) + (goto-char (point-min)) + (forward-line 1) + (let ((c1 (char-after))) + (forward-char 1) + (should (equal c1 (char-before))) + (should (equal c1 (char-after)))))) + (if f (delete-file f))))) |