aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-04-22 22:51:00 +0000
committerJuri Linkov2008-04-22 22:51:00 +0000
commit034e32b05a2d3cf75faf9d867ed5225b078b5e70 (patch)
treeba470e9951dd1feedbfc933ea6384656d24999c0
parentebdb6f22b1d6794441153c02568f212b1dab5055 (diff)
downloademacs-034e32b05a2d3cf75faf9d867ed5225b078b5e70.tar.gz
emacs-034e32b05a2d3cf75faf9d867ed5225b078b5e70.zip
(tar-prefix-offset): New constant.
(tar-header-block-tokenize): Support paths with long names which use the "ustar" standard.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/tar-mode.el16
2 files changed, 18 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 445b805cd7a..d64a22045ea 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12008-04-22 David Glasser <glasser@davidglasser.net> (tiny change)
2
3 * tar-mode.el (tar-prefix-offset): New constant.
4 (tar-header-block-tokenize): Support paths with long names
5 which use the "ustar" standard.
6
12008-04-22 Mathias Dahl <mathias.dahl@gmail.com> 72008-04-22 Mathias Dahl <mathias.dahl@gmail.com>
2 8
3 * image-dired.el (image-dired-track-original-file) 9 * image-dired.el (image-dired-track-original-file)
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index c1b899d3582..2d9651832b5 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -198,7 +198,8 @@ This information is useful, but it takes screen space away from file names."
198(defconst tar-gname-offset (+ tar-uname-offset 32)) 198(defconst tar-gname-offset (+ tar-uname-offset 32))
199(defconst tar-dmaj-offset (+ tar-gname-offset 32)) 199(defconst tar-dmaj-offset (+ tar-gname-offset 32))
200(defconst tar-dmin-offset (+ tar-dmaj-offset 8)) 200(defconst tar-dmin-offset (+ tar-dmaj-offset 8))
201(defconst tar-end-offset (+ tar-dmin-offset 8)) 201(defconst tar-prefix-offset (+ tar-dmin-offset 8))
202(defconst tar-end-offset (+ tar-prefix-offset 155))
202 203
203(defun tar-header-block-tokenize (string) 204(defun tar-header-block-tokenize (string)
204 "Return a `tar-header' structure. 205 "Return a `tar-header' structure.
@@ -209,13 +210,14 @@ write-date, checksum, link-type, and link-name."
209 (;(some 'plusp string) ; <-- oops, massive cycle hog! 210 (;(some 'plusp string) ; <-- oops, massive cycle hog!
210 (or (not (= 0 (aref string 0))) ; This will do. 211 (or (not (= 0 (aref string 0))) ; This will do.
211 (not (= 0 (aref string 101)))) 212 (not (= 0 (aref string 101))))
212 (let* ((name-end (1- tar-mode-offset)) 213 (let* ((name-end tar-mode-offset)
213 (link-end (1- tar-magic-offset)) 214 (link-end (1- tar-magic-offset))
214 (uname-end (1- tar-gname-offset)) 215 (uname-end (1- tar-gname-offset))
215 (gname-end (1- tar-dmaj-offset)) 216 (gname-end (1- tar-dmaj-offset))
216 (link-p (aref string tar-linkp-offset)) 217 (link-p (aref string tar-linkp-offset))
217 (magic-str (substring string tar-magic-offset (1- tar-uname-offset))) 218 (magic-str (substring string tar-magic-offset (1- tar-uname-offset)))
218 (uname-valid-p (or (string= "ustar " magic-str) (string= "GNUtar " magic-str))) 219 (uname-valid-p (or (string= "ustar " magic-str) (string= "GNUtar " magic-str)
220 (string= "ustar\0000" magic-str)))
219 name linkname 221 name linkname
220 (nulsexp "[^\000]*\000")) 222 (nulsexp "[^\000]*\000"))
221 (when (string-match nulsexp string tar-name-offset) 223 (when (string-match nulsexp string tar-name-offset)
@@ -231,6 +233,12 @@ write-date, checksum, link-type, and link-name."
231 nil 233 nil
232 (- link-p ?0))) 234 (- link-p ?0)))
233 (setq linkname (substring string tar-link-offset link-end)) 235 (setq linkname (substring string tar-link-offset link-end))
236 (when (and uname-valid-p
237 (string-match nulsexp string tar-prefix-offset)
238 (> (match-end 0) (1+ tar-prefix-offset)))
239 (setq name (concat (substring string tar-prefix-offset
240 (1- (match-end 0)))
241 "/" name)))
234 (if default-enable-multibyte-characters 242 (if default-enable-multibyte-characters
235 (setq name 243 (setq name
236 (decode-coding-string name tar-file-name-coding-system) 244 (decode-coding-string name tar-file-name-coding-system)
@@ -252,7 +260,7 @@ write-date, checksum, link-type, and link-name."
252 (and uname-valid-p (substring string tar-uname-offset uname-end)) 260 (and uname-valid-p (substring string tar-uname-offset uname-end))
253 (and uname-valid-p (substring string tar-gname-offset gname-end)) 261 (and uname-valid-p (substring string tar-gname-offset gname-end))
254 (tar-parse-octal-integer string tar-dmaj-offset tar-dmin-offset) 262 (tar-parse-octal-integer string tar-dmaj-offset tar-dmin-offset)
255 (tar-parse-octal-integer string tar-dmin-offset tar-end-offset) 263 (tar-parse-octal-integer string tar-dmin-offset tar-prefix-offset)
256 ))) 264 )))
257 (t 'empty-tar-block))) 265 (t 'empty-tar-block)))
258 266