]> git.eshelyaron.com Git - emacs.git/commitdiff
(tar-prefix-offset): New constant.
authorJuri Linkov <juri@jurta.org>
Tue, 22 Apr 2008 22:51:00 +0000 (22:51 +0000)
committerJuri Linkov <juri@jurta.org>
Tue, 22 Apr 2008 22:51:00 +0000 (22:51 +0000)
(tar-header-block-tokenize): Support paths with long names
which use the "ustar" standard.

lisp/ChangeLog
lisp/tar-mode.el

index 445b805cd7a0cac917ff0fac47d17ecf33d0ba61..d64a22045eac3be0eb8d91dd2ec6237fe0112201 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-22  David Glasser  <glasser@davidglasser.net>  (tiny change)
+
+       * tar-mode.el (tar-prefix-offset): New constant.
+       (tar-header-block-tokenize): Support paths with long names
+       which use the "ustar" standard.
+
 2008-04-22  Mathias Dahl  <mathias.dahl@gmail.com>
 
        * image-dired.el (image-dired-track-original-file)
index c1b899d358215031a98b8e00a58391e09ecec3b2..2d9651832b50bed22389eb771e0562728e253411 100644 (file)
@@ -198,7 +198,8 @@ This information is useful, but it takes screen space away from file names."
 (defconst tar-gname-offset (+ tar-uname-offset 32))
 (defconst tar-dmaj-offset (+ tar-gname-offset 32))
 (defconst tar-dmin-offset (+ tar-dmaj-offset 8))
-(defconst tar-end-offset (+ tar-dmin-offset 8))
+(defconst tar-prefix-offset (+ tar-dmin-offset 8))
+(defconst tar-end-offset (+ tar-prefix-offset 155))
 
 (defun tar-header-block-tokenize (string)
   "Return a `tar-header' structure.
@@ -209,13 +210,14 @@ write-date, checksum, link-type, and link-name."
        (;(some 'plusp string)           ; <-- oops, massive cycle hog!
         (or (not (= 0 (aref string 0))) ; This will do.
             (not (= 0 (aref string 101))))
-        (let* ((name-end (1- tar-mode-offset))
+        (let* ((name-end tar-mode-offset)
                (link-end (1- tar-magic-offset))
                (uname-end (1- tar-gname-offset))
                (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 (or (string= "ustar  " magic-str) (string= "GNUtar " magic-str)))
+               (uname-valid-p (or (string= "ustar  " magic-str) (string= "GNUtar " magic-str)
+                                   (string= "ustar\0000" magic-str)))
                name linkname
                (nulsexp   "[^\000]*\000"))
           (when (string-match nulsexp string tar-name-offset)
@@ -231,6 +233,12 @@ write-date, checksum, link-type, and link-name."
                            nil
                          (- link-p ?0)))
           (setq linkname (substring string tar-link-offset link-end))
+           (when (and uname-valid-p
+                      (string-match nulsexp string tar-prefix-offset)
+                      (> (match-end 0) (1+ tar-prefix-offset)))
+             (setq name (concat (substring string tar-prefix-offset
+                                           (1- (match-end 0)))
+                                "/" name)))
           (if default-enable-multibyte-characters
               (setq name
                     (decode-coding-string name tar-file-name-coding-system)
@@ -252,7 +260,7 @@ write-date, checksum, link-type, and link-name."
             (and uname-valid-p (substring string tar-uname-offset uname-end))
             (and uname-valid-p (substring string tar-gname-offset gname-end))
             (tar-parse-octal-integer string tar-dmaj-offset tar-dmin-offset)
-            (tar-parse-octal-integer string tar-dmin-offset tar-end-offset)
+            (tar-parse-octal-integer string tar-dmin-offset tar-prefix-offset)
             )))
        (t 'empty-tar-block)))