From: Noam Postavsky Date: Fri, 7 Apr 2017 22:24:35 +0000 (-0400) Subject: Fix handling of non-integer START param to write-region X-Git-Tag: emacs-26.0.90~521^2~684 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9e27e0d1a6c90d0d29e41884155245b6c3378b0a;p=emacs.git 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. --- diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 72ffb58c308..2e06c8374ff 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -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 () diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el index 55440a709c7..a5e24a6f9ac 100644 --- a/lisp/jka-compr.el +++ b/lisp/jka-compr.el @@ -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) diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index aecb9e1ecbe..6e84269e308 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -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)))) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 8ab34af85b7..b7477271d70 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -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))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index f78f54154fd..a8556b9a0d0 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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 diff --git a/src/fileio.c b/src/fileio.c index 0fc52294011..567f56c9063 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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;