aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Monnier2019-07-02 18:02:51 -0400
committerStefan Monnier2019-07-02 18:02:51 -0400
commitfe3676fe18577643d9d247db2e6c32691f3acf80 (patch)
tree638a1ef4ce2f7a82aea4929d81463affc111351d /test/src
parentc136f93dfad1a55c653e844d3cf25f804744275e (diff)
downloademacs-fe3676fe18577643d9d247db2e6c32691f3acf80.tar.gz
emacs-fe3676fe18577643d9d247db2e6c32691f3acf80.zip
(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/src')
-rw-r--r--test/src/fileio-tests.el19
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."
107 (setenv "HOME" "x:foo") 107 (setenv "HOME" "x:foo")
108 (should (equal (expand-file-name "~/bar") "x:/foo/bar"))) 108 (should (equal (expand-file-name "~/bar") "x:/foo/bar")))
109 (setenv "HOME" old-home))) 109 (setenv "HOME" old-home)))
110
111(ert-deftest fileio-tests--insert-file-interrupt ()
112 (let ((text "-*- coding: binary -*-\n\xc3\xc3help")
113 f)
114 (unwind-protect
115 (progn
116 (setq f (make-temp-file "ftifi"))
117 (write-region text nil f nil 'silent)
118 (with-temp-buffer
119 (catch 'toto
120 (let ((set-auto-coding-function (lambda (&rest _) (throw 'toto nil))))
121 (insert-file-contents f)))
122 (goto-char (point-min))
123 (forward-line 1)
124 (let ((c1 (char-after)))
125 (forward-char 1)
126 (should (equal c1 (char-before)))
127 (should (equal c1 (char-after))))))
128 (if f (delete-file f)))))