It wasn't enough...



Yep, my LZMA patch wasn't enough. It only worked for an effin subset of LZMA files. The one below is the mc-4.6.1 patch that came with lzma 4.32.7 from tukaani.org adapted to mc 4.6.2-pre1 with, as bonuses, my assembler and HTML syntax hacks. If you don't want the bonuses, cut them out before application.

- - 8< - -
diff -Purp mc-4.6.2-pre1/edit/edit.c mc-4.6.2-pre1-with-lzma/edit/edit.c
--- mc-4.6.2-pre1/edit/edit.c    2007-01-04 15:37:23.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/edit/edit.c 2008-10-24 16:20:09.000000000 +0000
@@ -181,9 +181,10 @@ edit_load_file_fast (WEdit *edit, const
static const struct edit_filters {
    const char *read, *write, *extension;
} all_filters[] = {
-    { "bzip2 -cd %s 2>&1",  "bzip2 > %s",  ".bz2" },
-    { "gzip -cd %s 2>&1",   "gzip > %s",   ".gz"  },
-    { "gzip -cd %s 2>&1",   "gzip > %s",   ".Z"   }
+    { "lzma -cd %s 2>&1",   "lzma > %s",   ".lzma" },
+    { "bzip2 -cd %s 2>&1",  "bzip2 > %s",  ".bz2"  },
+    { "gzip -cd %s 2>&1",   "gzip > %s",   ".gz"   },
+    { "gzip -cd %s 2>&1",   "gzip > %s",   ".Z"    }
};

/* Return index of the filter or -1 is there is no appropriate filter */
diff -Purp mc-4.6.2-pre1/lib/mc.ext.in mc-4.6.2-pre1-with-lzma/lib/mc.ext.in
--- mc-4.6.2-pre1/lib/mc.ext.in    2006-12-28 03:57:01.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/lib/mc.ext.in 2008-10-24 16:18:19.000000000 +0000
@@ -119,6 +119,11 @@ regex/\.t(ar\.bz2|bz|b2)$
    Open=%cd %p#utar
    View=%view{ascii} bzip2 -dc %f 2>/dev/null | tar tvvf -

+# .tar.lzma, .tlz
+regex/\.t(ar\.lzma|lz)$
+    Open=%cd %p#utar
+    View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf -
+
# .tar.F - used in QNX
regex/\.tar\.F$
    # Open=%cd %p#utar
@@ -298,6 +303,10 @@ regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|
Open=case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac

+regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$
+ Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} + View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac
+

### Images ###

@@ -542,6 +551,11 @@ type/^compress
    Open=gzip -dc %f | %var{PAGER:more}
    View=%view{ascii} gzip -dc %f 2>/dev/null

+# lzma
+regex/\.lzma$
+    Open=lzma -dc %f | %var{PAGER:more}
+    View=%view{ascii} lzma -dc %f 2>/dev/null
+

### Default ###

Only in mc-4.6.2-pre1: mc.qpg
Only in mc-4.6.2-pre1: mc.spec
diff -Purp mc-4.6.2-pre1/src/util.c mc-4.6.2-pre1-with-lzma/src/util.c
--- mc-4.6.2-pre1/src/util.c    2005-11-03 02:18:38.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/src/util.c 2008-10-24 16:18:19.000000000 +0000
@@ -935,7 +935,7 @@ get_current_wd (char *buffer, int size)
enum compression_type
get_compression_type (int fd)
{
-    unsigned char magic[4];
+    unsigned char magic[16];

    /* Read the magic signature */
    if (mc_read (fd, (char *) magic, 4) != 4)
@@ -979,6 +979,31 @@ get_compression_type (int fd)
        return COMPRESSION_BZIP2;
    }
    }
+
+    /* LZMA files; both LZMA_Alone and LZMA utils formats. The LZMA_Alone
+     * format is used by the LZMA_Alone tool from LZMA SDK. The LZMA utils
+     * format is the default format of LZMA utils 4.32.1 and later. */
+    if (magic[0] < 0xE1 || (magic[0] == 0xFF && magic[1] == 'L' &&
+    magic[2] == 'Z' && magic[3] == 'M')) {
+    if (mc_read (fd, (char *) magic + 4, 9) == 9) {
+        /* LZMA utils format */
+        if (magic[0] == 0xFF && magic[4] == 'A' && magic[5] == 0x00)
+        return COMPRESSION_LZMA;
+        /* The LZMA_Alone format has no magic bytes, thus we
+         * need to play a wizard. This can give false positives,
+         * thus the detection below should be removed when
+         * the newer LZMA utils format has got popular. */
+        if (magic[0] < 0xE1 && magic[4] < 0x20 &&
+        ((magic[10] == 0x00 && magic[11] == 0x00 &&
+          magic[12] == 0x00) ||
+         (magic[5] == 0xFF && magic[6] == 0xFF &&
+          magic[7] == 0xFF && magic[8] == 0xFF &&
+          magic[9] == 0xFF && magic[10] == 0xFF &&
+          magic[11] == 0xFF && magic[12] == 0xFF)))
+        return COMPRESSION_LZMA;
+    }
+    }
+
    return 0;
}

@@ -989,6 +1014,7 @@ decompress_extension (int type)
    case COMPRESSION_GZIP: return "#ugz";
    case COMPRESSION_BZIP:   return "#ubz";
    case COMPRESSION_BZIP2:  return "#ubz2";
+    case COMPRESSION_LZMA:  return "#ulzma";
    }
    /* Should never reach this place */
fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n");
diff -Purp mc-4.6.2-pre1/src/util.h mc-4.6.2-pre1-with-lzma/src/util.h
--- mc-4.6.2-pre1/src/util.h    2006-02-03 17:04:17.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/src/util.h 2008-10-24 16:18:19.000000000 +0000
@@ -179,7 +179,8 @@ enum compression_type {
    COMPRESSION_NONE,
    COMPRESSION_GZIP,
    COMPRESSION_BZIP,
-    COMPRESSION_BZIP2
+    COMPRESSION_BZIP2,
+    COMPRESSION_LZMA
};

/* Looks for ``magic'' bytes at the start of the VFS file to guess the
diff -Purp mc-4.6.2-pre1/syntax/assembler.syntax mc-4.6.2-pre1-with-lzma/syntax/assembler.syntax --- mc-4.6.2-pre1/syntax/assembler.syntax 2006-08-24 03:53:13.000000000 +0000 +++ mc-4.6.2-pre1-with-lzma/syntax/assembler.syntax 2008-10-24 17:02:42.000000000 +0000
@@ -14,7 +14,26 @@ context default lightgray
    keyword whole GLOBAL white
    keyword whole COMMON white
    keyword whole CPU white
- +
+# extras for asmutils hackers
+    keyword whole CODESEG white blue
+    keyword whole DATASEG white blue
+    keyword whole UDATASEG white blue
+    keyword whole END white blue
+
+# FASM directives
+    keyword whole segment white
+    keyword whole readable white
+    keyword whole READABLE white
+    keyword whole writable white
+    keyword whole WRITABLE white
+    keyword whole executable white
+    keyword whole EXECUTABLE white
+    keyword whole format white
+    keyword whole FORMAT white
+    keyword whole entry white
+    keyword whole ENTRY white
+
# NASM, WASM, TASM, MASM and common modifiers
    keyword whole ALIGN white
    keyword whole ALIGNB white
@@ -116,11 +135,15 @@ context default lightgray
    keyword whole .text brightblue
    keyword whole .bss brightblue

-# NASM/TASM Macroses
-    keyword whole %ifdef  brightred
+# NASM/TASM Macros
+    keyword whole %include brightred
+    keyword whole %if brightred
+    keyword whole %ifdef brightred
+    keyword whole %ifndef brightred
    keyword whole %define brightred
    keyword whole %else brightred
-    keyword whole %elif brightred
+    keyword whole %ifdef brightred
+    keyword whole %elifdef brightred
    keyword whole %endif brightred
    keyword whole %macro brightred
    keyword whole %endmacro brightred
diff -Purp mc-4.6.2-pre1/syntax/html.syntax mc-4.6.2-pre1-with-lzma/syntax/html.syntax
--- mc-4.6.2-pre1/syntax/html.syntax    2005-07-05 18:25:31.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/syntax/html.syntax 2007-10-24 19:56:45.000000000 +0000
@@ -1,7 +1,7 @@
# Syntax rules for the HyperText Markup Language

context default
- keyword &\[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\]; brightgreen + keyword &\[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\]; brightgreen
    keyword &#\{xX\}\[0123456789abcdefABCDEF\]; brightgreen
    keyword &#\[0123456789\]; brightgreen
    spellcheck
diff -Purp mc-4.6.2-pre1/vfs/extfs/iso9660.in mc-4.6.2-pre1-with-lzma/vfs/extfs/iso9660.in --- mc-4.6.2-pre1/vfs/extfs/iso9660.in 2006-07-19 11:19:52.000000000 +0000 +++ mc-4.6.2-pre1-with-lzma/vfs/extfs/iso9660.in 2008-10-24 16:18:19.000000000 +0000
@@ -29,6 +29,7 @@ test_iso () {
mcisofs_list () {
# left as a reminder to implement compressed image support =)
case "$1" in
+  *.lzma) MYCAT="lzma -dc";;
  *.bz2) MYCAT="bzip2 -dc";;
  *.gz)  MYCAT="gzip -dc";;
  *.z)   MYCAT="gzip -dc";;
diff -Purp mc-4.6.2-pre1/vfs/extfs/lslR.in mc-4.6.2-pre1-with-lzma/vfs/extfs/lslR.in
--- mc-4.6.2-pre1/vfs/extfs/lslR.in    2003-06-22 09:54:21.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/vfs/extfs/lslR.in 2008-10-24 16:18:19.000000000 +0000
@@ -12,6 +12,7 @@ AWK= AWK@

mclslRfs_list () {
case "$1" in
+  *.lzma) MYCAT="lzma -dc";;
  *.bz2) MYCAT="bzip2 -dc";;
  *.gz)  MYCAT="gzip -dc";;
  *.z)   MYCAT="gzip -dc";;
diff -Purp mc-4.6.2-pre1/vfs/extfs/mailfs.in mc-4.6.2-pre1-with-lzma/vfs/extfs/mailfs.in
--- mc-4.6.2-pre1/vfs/extfs/mailfs.in    2006-05-28 12:35:57.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/vfs/extfs/mailfs.in 2008-10-24 16:18:19.000000000 +0000
@@ -7,6 +7,7 @@ use bytes;

$zcat="zcat";                 # gunzip to stdout
$bzcat="bzip2 -dc";           # bunzip2 to stdout
+$lzcat="lzma -dc";            # unlzma to stdout
$file="file";                 # "file" command
$TZ='GMT';                    # default timezone (for Date module)

@@ -182,6 +183,8 @@ if (/gzip/) {
    exit 1 unless (open IN, "$zcat $mbox_qname|");
} elsif (/bzip/) {
    exit 1 unless (open IN, "$bzcat $mbox_qname|");
+} elsif (/lzma/) {
+    exit 1 unless (open IN, "$lzcat $mbox_qname|");
} else {
    exit 1 unless (open IN, "<$mbox_name");
}
diff -Purp mc-4.6.2-pre1/vfs/extfs/patchfs.in mc-4.6.2-pre1-with-lzma/vfs/extfs/patchfs.in --- mc-4.6.2-pre1/vfs/extfs/patchfs.in 2004-11-16 23:00:40.000000000 +0000 +++ mc-4.6.2-pre1-with-lzma/vfs/extfs/patchfs.in 2008-10-24 16:18:19.000000000 +0000
@@ -12,6 +12,7 @@ use POSIX;
use File::Temp 'tempfile';

# standard binaries
+my $lzma = 'lzma';
my $bzip = 'bzip2';
my $gzip = 'gzip';
my $fileutil = 'file';
@@ -70,7 +71,9 @@ sub myin
    my ($qfname)=(quotemeta $_[0]);

    $_=`$fileutil $qfname`;
-    if (/bzip/) {
+    if (/lzma/) {
+    return "$lzma -dc $qfname";
+    } elsif (/bzip/) {
    return "$bzip -dc $qfname";
    } elsif (/gzip/) {
    return "$gzip -dc $qfname";
@@ -86,7 +89,9 @@ sub myout
    my ($sep) = $append ? '>>' : '>';

    $_=`$fileutil $qfname`;
-    if (/bzip/) {
+    if (/lzma/) {
+    return "$lzma -c $sep $qfname";
+    } elsif (/bzip/) {
    return "$bzip -c $sep $qfname";
    } elsif (/gzip/) {
    return "$gzip -c $sep $qfname";
diff -Purp mc-4.6.2-pre1/vfs/extfs/sfs.ini mc-4.6.2-pre1-with-lzma/vfs/extfs/sfs.ini
--- mc-4.6.2-pre1/vfs/extfs/sfs.ini    1998-12-15 15:57:43.000000000 +0000
+++ mc-4.6.2-pre1-with-lzma/vfs/extfs/sfs.ini 2008-10-24 16:18:19.000000000 +0000
@@ -10,6 +10,8 @@ bz/1    bzip < %1 > %3
ubz/1    bzip -d < %1 > %3
bz2/1    bzip2 < %1 > %3
ubz2/1    bzip2 -d < %1 > %3
+lzma/1    lzma < %1 > %3
+ulzma/1    lzma -d < %1 > %3
tar/1    tar cf %3 %1
tgz/1    tar czf %3 %1
uhtml/1    lynx -force_html -dump %1 > %3
- - 8< - -

Reynir H. Stefánsson (reynirhs mi is)
--
Q: How many Dragonball Z characters does it take to change a light bulb?

A: One. But it takes ten episodes, two level-ups, Piccolo and all the
other humans dying and getting revived, and someone getting pecs the
size of tyres to do it.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]