aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/arc-mode.el
diff options
context:
space:
mode:
authorMiles Bader2007-04-24 21:56:25 +0000
committerMiles Bader2007-04-24 21:56:25 +0000
commit991a760232de757d71d8dbbed47ee12d81e29d53 (patch)
tree2440730c37ae3f167a50f5c3ac5eaeab9b72b7b0 /lisp/arc-mode.el
parent0bb328f8f6fce06a7fc65670c7d5c011b613e1c5 (diff)
parent3851329262d6558d5e1a93157d44777d0a39e38e (diff)
downloademacs-991a760232de757d71d8dbbed47ee12d81e29d53.tar.gz
emacs-991a760232de757d71d8dbbed47ee12d81e29d53.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 698-710) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 216) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-196
Diffstat (limited to 'lisp/arc-mode.el')
-rw-r--r--lisp/arc-mode.el55
1 files changed, 51 insertions, 4 deletions
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 07a48c761aa..657e2ed87d6 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -723,6 +723,10 @@ archive.
723 (string-match "\\.[aA][rR][cC]$" 723 (string-match "\\.[aA][rR][cC]$"
724 (or buffer-file-name (buffer-name)))) 724 (or buffer-file-name (buffer-name))))
725 'arc) 725 'arc)
726 ;; This pattern modelled on the BSD/GNU+Linux `file' command.
727 ;; Have seen capital "LHA's", and file has lower case "LHa's" too.
728 ;; Note this regexp is also in archive-exe-p.
729 ((looking-at "MZ\\(.\\|\n\\)\\{34\\}LH[aA]'s SFX ") 'lzh-exe)
726 (t (error "Buffer format not recognized"))))) 730 (t (error "Buffer format not recognized")))))
727;; ------------------------------------------------------------------------- 731;; -------------------------------------------------------------------------
728(defun archive-summarize (&optional shut-up) 732(defun archive-summarize (&optional shut-up)
@@ -1421,8 +1425,8 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
1421;; ------------------------------------------------------------------------- 1425;; -------------------------------------------------------------------------
1422;; Section: Lzh Archives 1426;; Section: Lzh Archives
1423 1427
1424(defun archive-lzh-summarize () 1428(defun archive-lzh-summarize (&optional start)
1425 (let ((p 1) 1429 (let ((p (or start 1)) ;; 1 for .lzh, something further on for .exe
1426 (totalsize 0) 1430 (totalsize 0)
1427 (maxlen 8) 1431 (maxlen 8)
1428 files 1432 files
@@ -1438,7 +1442,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
1438 (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.) 1442 (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.)
1439 (hdrlvl (byte-after (+ p 20))) ;header level 1443 (hdrlvl (byte-after (+ p 20))) ;header level
1440 thsize ;total header size (base + extensions) 1444 thsize ;total header size (base + extensions)
1441 fnlen efnname fiddle ifnname width p2 1445 fnlen efnname osid fiddle ifnname width p2
1442 neh ;beginning of next extension header (level 1 and 2) 1446 neh ;beginning of next extension header (level 1 and 2)
1443 mode modestr uid gid text dir prname 1447 mode modestr uid gid text dir prname
1444 gname uname modtime moddate) 1448 gname uname modtime moddate)
@@ -1496,7 +1500,22 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
1496 (setq thsize (- neh p)))) 1500 (setq thsize (- neh p))))
1497 (if (= hdrlvl 0) ;total header size 1501 (if (= hdrlvl 0) ;total header size
1498 (setq thsize hsize)) 1502 (setq thsize hsize))
1499 (setq fiddle (if efnname (string= efnname (upcase efnname)))) 1503 ;; OS ID field not present in level 0 header, use code 0 "generic"
1504 ;; in that case as per lha program header.c get_header()
1505 (setq osid (cond ((= hdrlvl 0) 0)
1506 ((= hdrlvl 1) (char-after (+ p 22 fnlen 2)))
1507 ((= hdrlvl 2) (char-after (+ p 23)))))
1508 ;; Filename fiddling must follow the lha program, otherwise the name
1509 ;; passed to "lha pq" etc won't match (which for an extract silently
1510 ;; results in no output). As of version 1.14i it goes from the OS ID,
1511 ;; - For 'M' MSDOS: msdos_to_unix_filename() downcases always, and
1512 ;; converts "\" to "/".
1513 ;; - For 0 generic: generic_to_unix_filename() downcases if there's
1514 ;; no lower case already present, and converts "\" to "/".
1515 ;; - For 'm' MacOS: macos_to_unix_filename() changes "/" to ":" and
1516 ;; ":" to "/"
1517 (setq fiddle (cond ((= ?M osid) t)
1518 ((= 0 osid) (string= efnname (upcase efnname)))))
1500 (setq ifnname (if fiddle (downcase efnname) efnname)) 1519 (setq ifnname (if fiddle (downcase efnname) efnname))
1501 (setq prname (if dir (concat dir ifnname) ifnname)) 1520 (setq prname (if dir (concat dir ifnname) ifnname))
1502 (setq width (if prname (string-width prname) 0)) 1521 (setq width (if prname (string-width prname) 0))
@@ -1625,6 +1644,34 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
1625 ;; This should work even though newmode will be dynamically accessed. 1644 ;; This should work even though newmode will be dynamically accessed.
1626 (lambda (old) (archive-calc-mode old newmode t)) 1645 (lambda (old) (archive-calc-mode old newmode t))
1627 files "a unix-style mode" 8)) 1646 files "a unix-style mode" 8))
1647
1648;; -------------------------------------------------------------------------
1649;; Section: Lzh Self-Extracting .exe Archives
1650;;
1651;; No support for modifying these files. It looks like the lha for unix
1652;; program (as of version 1.14i) can't create or retain the DOS exe part.
1653;; If you do an "lha a" on a .exe for instance it renames and writes to a
1654;; plain .lzh.
1655
1656(defun archive-lzh-exe-summarize ()
1657 "Summarize the contents of an LZH self-extracting exe, for `archive-mode'."
1658
1659 ;; Skip the initial executable code part and apply archive-lzh-summarize
1660 ;; to the archive part proper. The "-lh5-" etc regexp here for the start
1661 ;; is the same as in archive-find-type.
1662 ;;
1663 ;; The lha program (version 1.14i) does this in skip_msdos_sfx1_code() by
1664 ;; a similar scan. It looks for "..-l..-" plus for level 0 or 1 a test of
1665 ;; the header checksum, or level 2 a test of the "attribute" and size.
1666 ;;
1667 (re-search-forward "..-l[hz][0-9ds]-" nil)
1668 (archive-lzh-summarize (match-beginning 0)))
1669
1670;; `archive-lzh-extract' runs "lha pq", and that works for .exe as well as
1671;; .lzh files
1672(defalias 'archive-lzh-exe-extract 'archive-lzh-extract
1673 "Extract a member from an LZH self-extracting exe, for `archive-mode'.")
1674
1628;; ------------------------------------------------------------------------- 1675;; -------------------------------------------------------------------------
1629;; Section: Zip Archives 1676;; Section: Zip Archives
1630 1677