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.
This commit is contained in:
parent
900947fbe8
commit
42306747d8
2 changed files with 21 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue