aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2001-11-06 17:14:53 +0000
committerRichard M. Stallman2001-11-06 17:14:53 +0000
commit242d2673d993e3d31b73d8fd736273a89faf718f (patch)
treea0cee3e52a348dc92e0654ab7a2ee0534ab7ef54
parentc1966bb4443fa5c06a2bba6223e30877e154cc2b (diff)
downloademacs-242d2673d993e3d31b73d8fd736273a89faf718f.tar.gz
emacs-242d2673d993e3d31b73d8fd736273a89faf718f.zip
(jka-compr-partial-uncompress): Support an alternative of not using dd.
(jka-compr-dd-program): Use defcustom to define this. (jka-compr-load-suffixes): Use defcustom. (jka-compr-mode-alist-additions): Use defcustom.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/jka-compr.el76
2 files changed, 52 insertions, 32 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9d67fe2f9a6..548c25f1cfc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12001-11-06 Richard M. Stallman <rms@gnu.org>
2
3 * jka-compr.el (jka-compr-partial-uncompress): Support
4 an alternative of not using dd.
5 (jka-compr-dd-program): Use defcustom to define this.
6 (jka-compr-load-suffixes): Use defcustom.
7 (jka-compr-mode-alist-additions): Use defcustom.
8
12001-11-06 Stefan Monnier <monnier@cs.yale.edu> 92001-11-06 Stefan Monnier <monnier@cs.yale.edu>
2 10
3 * font-lock.el (font-lock-match-c-style-declaration-item-and-skip-to-next): 11 * font-lock.el (font-lock-match-c-style-declaration-item-and-skip-to-next):
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 23e183b3548..c4a352bc983 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -198,12 +198,16 @@ invoked."
198 (string :tag "Magic Bytes"))) 198 (string :tag "Magic Bytes")))
199 :group 'jka-compr) 199 :group 'jka-compr)
200 200
201(defvar jka-compr-mode-alist-additions 201(defcustom jka-compr-mode-alist-additions
202 (list (cons "\\.tgz\\'" 'tar-mode)) 202 (list (cons "\\.tgz\\'" 'tar-mode))
203 "A list of pairs to add to `auto-mode-alist' when jka-compr is installed.") 203 "A list of pairs to add to `auto-mode-alist' when jka-compr is installed."
204 :type '(repeat (cons string symbol))
205 :group 'jka-compr)
204 206
205(defvar jka-compr-load-suffixes '(".gz") 207(defcustom jka-compr-load-suffixes '(".gz")
206 "List of suffixes to try when loading files.") 208 "List of suffixes to try when loading files."
209 :type '(repeat string)
210 :group 'jka-compr)
207 211
208;; List of all the elements we actually added to file-coding-system-alist. 212;; List of all the elements we actually added to file-coding-system-alist.
209(defvar jka-compr-added-to-file-coding-system-alist nil) 213(defvar jka-compr-added-to-file-coding-system-alist nil)
@@ -268,8 +272,10 @@ based on the filename itself and `jka-compr-compression-info-list'."
268 (list "Opening input file" (format "error %s" message) infile))) 272 (list "Opening input file" (format "error %s" message) infile)))
269 273
270 274
271(defvar jka-compr-dd-program 275(defcustom jka-compr-dd-program "/bin/dd"
272 "/bin/dd") 276 "How to invoke `dd'."
277 :type 'string
278 :group 'jka-compr)
273 279
274 280
275(defvar jka-compr-dd-blocksize 256) 281(defvar jka-compr-dd-blocksize 256)
@@ -279,32 +285,38 @@ based on the filename itself and `jka-compr-compression-info-list'."
279 "Call program PROG with ARGS args taking input from INFILE. 285 "Call program PROG with ARGS args taking input from INFILE.
280Fourth and fifth args, BEG and LEN, specify which part of the output 286Fourth and fifth args, BEG and LEN, specify which part of the output
281to keep: LEN chars starting BEG chars from the beginning." 287to keep: LEN chars starting BEG chars from the beginning."
282 (let* ((skip (/ beg jka-compr-dd-blocksize)) 288 (let ((start (point))
283 (prefix (- beg (* skip jka-compr-dd-blocksize))) 289 (prefix beg))
284 (count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize)))) 290 (if (and jka-compr-use-shell jka-compr-dd-program)
285 (start (point)) 291 ;; Put the uncompression output through dd
286 (err-file (jka-compr-make-temp-name)) 292 ;; to discard the part we don't want.
287 (run-string (format "%s %s 2> %s | %s bs=%d skip=%d %s 2> /dev/null" 293 (let ((skip (/ beg jka-compr-dd-blocksize))
288 prog 294 (err-file (jka-compr-make-temp-name))
289 (mapconcat 'identity args " ") 295 count)
290 err-file 296 ;; Update PREFIX based on the text that we won't read in.
291 jka-compr-dd-program 297 (setq prefix (- beg (* skip jka-compr-dd-blocksize))
292 jka-compr-dd-blocksize 298 count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize))))
293 skip 299 (unwind-protect
294 ;; dd seems to be unreliable about 300 (or (memq (call-process
295 ;; providing the last block. So, always 301 jka-compr-shell infile t nil "-c"
296 ;; read one more than you think you need. 302 (format
297 (if count (format "count=%d" (1+ count)) "")))) 303 "%s %s 2> %s | %s bs=%d skip=%d %s 2> /dev/null"
298 304 prog
299 (unwind-protect 305 (mapconcat 'identity args " ")
300 (or (memq (call-process jka-compr-shell 306 err-file
301 infile t nil "-c" 307 jka-compr-dd-program
302 run-string) 308 jka-compr-dd-blocksize
303 jka-compr-acceptable-retval-list) 309 skip
304 310 ;; dd seems to be unreliable about
305 (jka-compr-error prog args infile message err-file)) 311 ;; providing the last block. So, always
306 312 ;; read one more than you think you need.
307 (jka-compr-delete-temp-file err-file)) 313 (if count (concat "count=" (1+ count)) "")))
314 jka-compr-acceptable-retval-list)
315 (jka-compr-error prog args infile message err-file))
316 (jka-compr-delete-temp-file err-file)))
317 ;; Run the uncompression program directly.
318 ;; We get the whole file and must delete what we don't want.
319 (jka-compr-call-process prog message infile t nil args))
308 320
309 ;; Delete the stuff after what we want, if there is any. 321 ;; Delete the stuff after what we want, if there is any.
310 (and 322 (and