2001-12-29 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 29 Dec 2001 22:35:20 +0000 (22:35 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Sat, 29 Dec 2001 22:35:20 +0000 (22:35 +0000)
* sha1-el.el (sha1-use-external): New variable.
(sha1-region): Use it.
(sha1-string): Ditto.

lisp/ChangeLog
lisp/sha1-el.el

index ca9086a..97a3969 100644 (file)
@@ -1,5 +1,9 @@
 2001-12-29  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
+       * sha1-el.el (sha1-use-external): New variable.
+       (sha1-region): Use it.
+       (sha1-string): Ditto.
+
        * dgnushack.el (dgnushack-compile): Compile gnus-picon for Emacs.
        * gnus-picon.el: Less warnings when compile.
 
index 15c1f5a..0c94c2d 100644 (file)
@@ -54,6 +54,8 @@
 
 (require 'hex-util)
 
+(autoload 'executable-find "executable")
+
 ;;;
 ;;; external SHA1 function.
 ;;;
@@ -69,6 +71,11 @@ If this variable is set to nil, use internal function only.")
   "*Name of program to compute SHA1.
 It must be a string \(program name\) or list of strings \(name and its args\).")
 
+(defvar sha1-use-external 
+  (executable-find (car sha1-program))
+  "*Use external sh1 program.
+If this variable is set to nil, use internal function only.")
+
 (defun sha1-string-external (string)
   ;; `with-temp-buffer' is new in v20, so we do not use it.
   (save-excursion
@@ -396,13 +403,15 @@ It must be a string \(program name\) or list of strings \(name and its args\).")
 ;;;
 
 (defun sha1-region (beg end)
-  (if (and sha1-maximum-internal-length
+  (if (and sha1-use-external
+          sha1-maximum-internal-length
           (> (abs (- end beg)) sha1-maximum-internal-length))
       (sha1-region-external beg end)
     (sha1-region-internal beg end)))
 
 (defun sha1-string (string)
-  (if (and sha1-maximum-internal-length
+  (if (and sha1-use-external
+          sha1-maximum-internal-length
           (> (length string) sha1-maximum-internal-length))
       (sha1-string-external string)
     (sha1-string-internal string)))