Commit 9e27e0d1 authored by Noam Postavsky's avatar Noam Postavsky

Fix handling of non-integer START param to write-region

The previous patch for Bug#354 incorrectly assumed that START would
always be an integer.

* lisp/epa-file.el (epa-file-write-region):
* lisp/jka-compr.el (jka-compr-write-region):
* lisp/net/ange-ftp.el (ange-ftp-write-region):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-write-region):
* lisp/net/tramp-sh.el (tramp-sh-handle-write-region):
* src/fileio.c (write_region): Handle nil and string values of START.
parent 88532ae8
......@@ -290,7 +290,11 @@ If no one is selected, symmetric encryption will be performed. "
(if (or (eq visit t)
(eq visit nil)
(stringp visit))
(message "Wrote %d characters to `%s'" (- end start) buffer-file-name))))
(message "Wrote %d characters to `%s'"
(cond ((null start) (buffer-size))
((stringp start) (length start))
(t (- end start)))
buffer-file-name))))
(put 'write-region 'epa-file 'epa-file-write-region)
(defun epa-file-select-keys ()
......
......@@ -357,7 +357,11 @@ There should be no more than seven characters after the final `/'."
(and (or (eq visit t)
(eq visit nil)
(stringp visit))
(message "Wrote %d characters to `%s'" (- end start) visit-file))
(message "Wrote %d characters to `%s'"
(cond ((null start) (buffer-size))
((stringp start) (length start))
(t (- end start)))
visit-file))
;; ensure `last-coding-system-used' has an appropriate value
(setq last-coding-system-used coding-system-used)
......
......@@ -3284,7 +3284,11 @@ system TYPE.")
(set-buffer-modified-p nil)))
;; ensure `last-coding-system-used' has an appropriate value
(setq last-coding-system-used coding-system-used)
(ange-ftp-message "Wrote %d characters to `%s'" (- end start) abbr)
(ange-ftp-message "Wrote %d characters to `%s'"
(cond ((null start) (buffer-size))
((stringp start) (length start))
(t (- end start)))
abbr)
(ange-ftp-add-file-entry filename))
(ange-ftp-real-write-region start end filename append visit))))
......
......@@ -1223,7 +1223,11 @@ file-notify events."
;; The end.
(when (or (eq visit t) (null visit) (stringp visit))
(tramp-message v 0 "Wrote %d characters to `%s'" (- end start) filename))
(tramp-message v 0 "Wrote %d characters to `%s'"
(cond ((null start) (buffer-size))
((stringp start) (length start))
(t (- end start)))
filename))
(run-hooks 'tramp-handle-write-region-hook)))
......
......@@ -3412,7 +3412,10 @@ the result will be a local, non-Tramp, file name."
(tramp-set-file-uid-gid filename uid gid))
(when (or (eq visit t) (null visit) (stringp visit))
(tramp-message v 0 "Wrote %d characters to `%s'"
(- end start) filename))
(cond ((null start) (buffer-size))
((stringp start) (length start))
(t (- end start)))
filename))
(run-hooks 'tramp-handle-write-region-hook)))))
(defvar tramp-vc-registered-file-names nil
......
......@@ -5157,7 +5157,8 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
? "Added %d characters to `%s'"
: "Wrote %d characters to `%s'");
CALLN (Fmessage, format,
make_number (XINT (end) - XINT (start)),
(STRINGP (start) ? Flength (start)
: make_number (XINT (end) - XINT (start))),
visit_file);
}
return Qnil;
......
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