From: yamaoka Date: Wed, 7 Jan 2004 06:42:26 +0000 (+0000) Subject: (sha1-string-external): Use with-temp-buffer. X-Git-Tag: flim-1_14_7~27 X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Fflim.git;a=commitdiff_plain;h=0f9aa0afddb6bd16d9b0146c82af8bbddc313e76 (sha1-string-external): Use with-temp-buffer. --- diff --git a/ChangeLog b/ChangeLog index f720c9a..454f3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2004-01-07 Katsumi Yamaoka + * sha1-el.el (sha1-string-external): Use with-temp-buffer. + +2004-01-07 Katsumi Yamaoka + * sha1-el.el (sha1-string-external): Make it can return a string in binary form. (sha1-region-external): Ditto. diff --git a/sha1-el.el b/sha1-el.el index 9564c7b..760c2d0 100644 --- a/sha1-el.el +++ b/sha1-el.el @@ -88,30 +88,22 @@ If this variable is set to nil, use internal function only." :group 'sha1) (defun sha1-string-external (string &optional binary) - ;; `with-temp-buffer' is new in v20, so we do not use it. - (save-excursion - (let (buffer) - (unwind-protect - (let (prog args digest) - (if (consp sha1-program) - (setq prog (car sha1-program) - args (cdr sha1-program)) - (setq prog sha1-program - args nil)) - (setq buffer (set-buffer - (generate-new-buffer " *sha1 external*"))) - (insert string) - (apply (function call-process-region) - (point-min)(point-max) - prog t t nil args) - ;; SHA1 is 40 bytes long in hexadecimal form. - (setq digest (buffer-substring (point-min)(+ (point-min) 40))) - (if binary - (decode-hex-string digest) - digest)) - (and buffer - (buffer-name buffer) - (kill-buffer buffer)))))) + (let (prog args digest default-enable-multibyte-characters) + (if (consp sha1-program) + (setq prog (car sha1-program) + args (cdr sha1-program)) + (setq prog sha1-program + args nil)) + (with-temp-buffer + (insert string) + (apply (function call-process-region) + (point-min)(point-max) + prog t t nil args) + ;; SHA1 is 40 bytes long in hexadecimal form. + (setq digest (buffer-substring (point-min)(+ (point-min) 40)))) + (if binary + (decode-hex-string digest) + digest))) (defun sha1-region-external (beg end &optional binary) (sha1-string-external (buffer-substring-no-properties beg end) binary))