;;; tar-mode.el --- simple editing of tar files from GNU emacs
;; Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Jamie Zawinski <jwz@lucid.com>
;; Maintainer: FSF
(gname-end (1- tar-dmaj-offset))
(link-p (aref string tar-linkp-offset))
(magic-str (substring string tar-magic-offset
- (1- tar-uname-offset)))
- (uname-valid-p (car (member magic-str '("ustar " "ustar\0\0"))))
+ ;; The magic string is actually 6bytes
+ ;; of magic string plus 2bytes of version
+ ;; which we here ignore.
+ (- tar-uname-offset 2)))
+ ;; The magic string is "ustar\0" for POSIX format, and
+ ;; "ustar " for GNU Tar's format.
+ (uname-valid-p (car (member magic-str '("ustar " "ustar\0"))))
name linkname
(nulsexp "[^\000]*\000"))
(when (string-match nulsexp string tar-name-offset)
nil
(- link-p ?0)))
(setq linkname (substring string tar-link-offset link-end))
- (when (and (equal uname-valid-p "ustar\0\0")
+ (when (and (equal uname-valid-p "ustar\0")
(string-match nulsexp string tar-prefix-offset)
(> (match-end 0) (1+ tar-prefix-offset)))
(setq name (concat (substring string tar-prefix-offset
(setq link-p 5)) ; directory
(if (and (equal name "././@LongLink")
- (equal magic-str "ustar ")) ;OLDGNU_MAGIC.
+ (equal magic-str "ustar ")) ;OLDGNU_MAGIC.
;; This is a GNU Tar long-file-name header.
(let* ((size (tar-parse-octal-integer
string tar-size-offset tar-time-offset))
;; buffer for the summary.
(assert (not (tar-data-swapped-p)))
(set (make-local-variable 'revert-buffer-function) 'tar-mode-revert)
+ ;; We started using write-contents-functions, but this hook is not
+ ;; used during auto-save, so we now use
+ ;; write-region-annotate-functions which hooks at a lower-level.
(add-hook 'write-region-annotate-functions 'tar-write-region-annotate nil t)
(add-hook 'kill-buffer-hook 'tar-mode-kill-buffer-hook nil t)
(add-hook 'change-major-mode-hook 'tar-change-major-mode-hook nil t)
(string-match "/" encoded-new-name
(- (length encoded-new-name) 99))
(< (match-beginning 0) 155))
- (unless (equal (tar-header-magic descriptor) "ustar\0\0")
- (tar-alter-one-field tar-magic-offset "ustar\0\0"))
+ (unless (equal (tar-header-magic descriptor) "ustar\0")
+ (tar-alter-one-field tar-magic-offset (concat "ustar\0" "00")))
(setq prefix (substring encoded-new-name 0 (match-beginning 0)))
(setq encoded-new-name (substring encoded-new-name (match-end 0))))
;; When called from M-x write-region, we assume the user wants to save
;; (part of) the summary, not the tar data.
(unless (or start (not (tar-data-swapped-p)))
- (tar-clear-modification-flags)
+ (tar-clear-modification-flags)
(set-buffer tar-data-buffer)
nil))