diff options
| author | Stefan Monnier | 2008-05-25 13:48:22 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-25 13:48:22 +0000 |
| commit | a0fefe5742d09595da6b2e839f6da20e815890b8 (patch) | |
| tree | 222ecee00e82d6645a4230f4061113b5d933ca8d /lisp | |
| parent | b9a6ed295cfb7e53c383b3e6e66bb7af6d7f641f (diff) | |
| download | emacs-a0fefe5742d09595da6b2e839f6da20e815890b8.tar.gz emacs-a0fefe5742d09595da6b2e839f6da20e815890b8.zip | |
(tar-summarize-buffer): Handle GNU Tar @LongLink format.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/tar-mode.el | 26 |
2 files changed, 21 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ce047a0036e..28a7eac3616 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2008-05-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * tar-mode.el (tar-summarize-buffer): Handle GNU Tar @LongLink format. | ||
| 4 | |||
| 1 | 2008-05-24 Alan Mackenzie <acm@muc.de> | 5 | 2008-05-24 Alan Mackenzie <acm@muc.de> |
| 2 | 6 | ||
| 3 | * progmodes/cc-mode.el (c-postprocess-file-styles): Throw an error | 7 | * progmodes/cc-mode.el (c-postprocess-file-styles): Throw an error |
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index 41476f4250b..04ce5dc83a9 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el | |||
| @@ -421,6 +421,16 @@ is visible (and the real data of the buffer is hidden)." | |||
| 421 | (tar-header-block-tokenize | 421 | (tar-header-block-tokenize |
| 422 | (buffer-substring pos (+ pos 512))))))) | 422 | (buffer-substring pos (+ pos 512))))))) |
| 423 | (setq pos (+ pos 512)) | 423 | (setq pos (+ pos 512)) |
| 424 | (when (equal (tar-header-name tokens) "././@LongLink") | ||
| 425 | ;; This is a GNU Tar long-file-name header. | ||
| 426 | (let* ((size (tar-header-size tokens)) | ||
| 427 | ;; -1 so as to strip the terminating 0 byte. | ||
| 428 | (name (buffer-substring pos (+ pos size -1)))) | ||
| 429 | (setq pos (+ pos (ash (ash (+ 511 size) -9) 9))) | ||
| 430 | (setq tokens (tar-header-block-tokenize | ||
| 431 | (buffer-substring pos (+ pos 512)))) | ||
| 432 | (tar-setf (tar-header-name tokens) name) | ||
| 433 | (setq pos (+ pos 512)))) | ||
| 424 | (progress-reporter-update progress-reporter pos) | 434 | (progress-reporter-update progress-reporter pos) |
| 425 | (if (memq (tar-header-link-type tokens) '(20 55)) | 435 | (if (memq (tar-header-link-type tokens) '(20 55)) |
| 426 | ;; Foo. There's an extra empty block after these. | 436 | ;; Foo. There's an extra empty block after these. |
| @@ -429,20 +439,18 @@ is visible (and the real data of the buffer is hidden)." | |||
| 429 | (if (< size 0) | 439 | (if (< size 0) |
| 430 | (error "%s has size %s - corrupted" | 440 | (error "%s has size %s - corrupted" |
| 431 | (tar-header-name tokens) size)) | 441 | (tar-header-name tokens) size)) |
| 432 | ; | 442 | ;; |
| 433 | ; This is just too slow. Don't really need it anyway.... | 443 | ;; This is just too slow. Don't really need it anyway.... |
| 434 | ;(tar-header-block-check-checksum | 444 | ;;(tar-header-block-check-checksum |
| 435 | ; hblock (tar-header-block-checksum hblock) | 445 | ;; hblock (tar-header-block-checksum hblock) |
| 436 | ; (tar-header-name tokens)) | 446 | ;; (tar-header-name tokens)) |
| 437 | 447 | ||
| 438 | (push (make-tar-desc pos tokens) result) | 448 | (push (make-tar-desc pos tokens) result) |
| 439 | 449 | ||
| 440 | (and (null (tar-header-link-type tokens)) | 450 | (and (null (tar-header-link-type tokens)) |
| 441 | (> size 0) | 451 | (> size 0) |
| 442 | (setq pos | 452 | ;; Round up to a multiple of 512. |
| 443 | (+ pos 512 (ash (ash (1- size) -9) 9)) ; this works | 453 | (setq pos (+ pos (ash (ash (+ 511 size) -9) 9)))))) |
| 444 | ;(+ pos (+ size (- 512 (rem (1- size) 512)))) ; this doesn't | ||
| 445 | )))) | ||
| 446 | (make-local-variable 'tar-parse-info) | 454 | (make-local-variable 'tar-parse-info) |
| 447 | (setq tar-parse-info (nreverse result)) | 455 | (setq tar-parse-info (nreverse result)) |
| 448 | ;; A tar file should end with a block or two of nulls, | 456 | ;; A tar file should end with a block or two of nulls, |