Commit 42306747 authored by Philipp Stephani's avatar Philipp Stephani

Fix error in 'call-process-region' when START is nil (Bug#40576)

* src/callproc.c (Fcall_process_region): Fix behavior when START is
nil and DELETE is non-nil.

* test/src/callproc-tests.el
(call-process-region-entire-buffer-with-delete): New unit test.
parent 900947fb
Pipeline #5229 failed with stage
in 90 minutes and 1 second
......@@ -1099,7 +1099,17 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
}
if (nargs > 3 && !NILP (args[3]))
Fdelete_region (start, end);
{
if (NILP (start))
{
/* No need to save restrictions since we delete everything
anyway. */
Fwiden ();
del_range (BEG, Z);
}
else
Fdelete_region (start, end);
}
if (nargs > 3)
{
......
......@@ -66,4 +66,14 @@
(error :got-error))))
(should have-called-debugger)))
(ert-deftest call-process-region-entire-buffer-with-delete ()
"Check that Bug#40576 is fixed."
(let ((emacs (expand-file-name invocation-name invocation-directory)))
(skip-unless (file-executable-p emacs))
(with-temp-buffer
(insert "Buffer contents\n")
(should
(eq (call-process-region nil nil emacs :delete nil nil "--version") 0))
(should (eq (buffer-size) 0)))))
;;; callproc-tests.el ends here
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