Source patch number I-can't-remember-what
- From: Reynir Stefansson <reynirhs mi is>
- To: mc gnome org
- Subject: Source patch number I-can't-remember-what
- Date: Tue, 09 Dec 2008 23:04:06 +0000
This posting has both my /etc/magic and a source patch to an unadorned
mc-4.6.2-pre1.
The patch contains: lzip/lzma processing in util.c and several VFSes,
and some fixes to the ulha VFS to deal with LZH files without dates and
LZH files with filenames containing spaces.
The 'magic' file contains magic for a few image file formats and lzip.
Reynir H. Stefánsson (reynirhs mi is)
--
Winning consists of making sure you're not the one that made the last
mistake.
# PBMPLUS images
# The next byte following the magic is always whitespace.
0 string P7\ 332 XV/ZGV thumbnail image data
# CIS-RLE images
0 string \033GH Compuserve RLE (256x192) image data
0 string \033GM Compuserve RLE (128x96) image data
# MacPaint images
65 string PNTGMPNT MacPaint (576x720) image data
# ART images (seen on an Angelfire-hosted site)
0 string JG\004\016 .ART image data
13 uleshort x (%d x
15 uleshort x %d)
# WMF (Windows MetaFile)
0 belong 0xd7cdc69a Windows MetaFile image data
# HPI (Hemera PhotoObject)
0 string \211HPI Hemera Photo Object image data
# Doodler-V 5.0x (Art program for Heath/Zenith-100)
0 string PIC Doodler-V 5.0x image data
3 leshort x (%d x
5 leshort x %d)
# Doodler-V 5.1x (Art program for Heath/Zenith-100)
0 string pic Doodler-V 5.1x image data
3 leshort x (%d x
5 leshort x %d)
# Supplementary magic data for the file(1) command to support
# Antonio Diaz's lzip(1). The format is described in magic(5).
#
0 string LZIP lzip compressed data
4 byte 0x00 - version 0.5
diff -Purp mc-4.6.2-pre1~/edit/edit.c mc-4.6.2-pre1/edit/edit.c
--- mc-4.6.2-pre1~/edit/edit.c 2007-01-04 15:37:23.000000000 +0000
+++ mc-4.6.2-pre1/edit/edit.c 2008-12-09 21:10:33.000000000 +0000
@@ -181,9 +181,11 @@ 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" },
+ { "lzip -cd %s 2>&1", "lzip > %s", ".lz" },
+ { "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/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/lib/mc.ext.in 2008-12-09 21:13:59.000000000 +0000
@@ -106,8 +106,8 @@
### Archives ###
-# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk
-regex/\.t([gp]?z|ar\.g?[zZ])$|\.ipk$
+# .taz, .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk
+regex/\.t([agp]?z|ar\.g?[zZ])$|\.ipk$
Open=%cd %p#utar
View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf -
@@ -119,6 +119,16 @@ regex/\.t(ar\.bz2|bz|b2)$
Open=%cd %p#utar
View=%view{ascii} bzip2 -dc %f 2>/dev/null | tar tvvf -
+# .tar.lz
+shell/.tar.lz
+ Open=%cd %p#utar
+ View=%view{ascii} lzip -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 +308,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 ###
@@ -521,7 +535,7 @@ type/^([Zz][Ii][Pp])\ archive
regex/\.([Zz][Oo][Oo])$
Open=%cd %p#uzoo
View=%view{ascii} zoo l %f
-
+
# gzip
type/^gzip
Open=gzip -dc %f | %var{PAGER:more}
@@ -542,6 +556,16 @@ 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
+
+# lzip
+shell/.lz
+ Open=lzip -dc %f | %var{PAGER:more}
+ View=%view{ascii} lzip -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/src/util.c
--- mc-4.6.2-pre1~/src/util.c 2005-11-03 02:18:38.000000000 +0000
+++ mc-4.6.2-pre1/src/util.c 2008-12-09 22:17:23.000000000 +0000
@@ -453,7 +453,7 @@ strip_password (char *p, int has_prefix)
char *at, *inner_colon, *dir;
size_t i;
char *result = p;
-
+
for (i = 0; i < sizeof (prefixes)/sizeof (prefixes[0]); i++) {
char *q;
@@ -462,10 +462,10 @@ strip_password (char *p, int has_prefix)
continue;
else
p = q + prefixes[i].len;
- }
+ }
if ((dir = strchr (p, PATH_SEP)) != NULL)
- *dir = '\0';
+ *dir = '\0';
/* search for any possible user */
at = strrchr (p, '@');
@@ -656,7 +656,7 @@ load_file (const char *filename)
struct stat s;
char *data;
long read_size;
-
+
if ((data_file = fopen (filename, "r")) == NULL){
return 0;
}
@@ -935,10 +935,10 @@ 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)
+ if (mc_read (fd, (char *) magic, 5) != 5)
return COMPRESSION_NONE;
/* GZIP_MAGIC and OLD_GZIP_MAGIC */
@@ -977,8 +977,46 @@ get_compression_type (int fd)
return COMPRESSION_BZIP;
case 'h':
return COMPRESSION_BZIP2;
+ default:
+ return COMPRESSION_NONE;
+ }
+ }
+
+ /* LZIP files */
+ if ((magic[0] == 'L') && (magic[1] == 'Z') &&
+ (magic[2] == 'I') && (magic[3] == 'P')) {
+ switch (magic[4]) {
+ case 0:
+ return COMPRESSION_LZIP;
+ default:
+ return COMPRESSION_NONE;
}
}
+
+ /* 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 + 5, 8) == 8) {
+ /* 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 +1027,8 @@ decompress_extension (int type)
case COMPRESSION_GZIP: return "#ugz";
case COMPRESSION_BZIP: return "#ubz";
case COMPRESSION_BZIP2: return "#ubz2";
+ case COMPRESSION_LZMA: return "#ulzma";
+ case COMPRESSION_LZIP: return "#ulzip";
}
/* 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/src/util.h
--- mc-4.6.2-pre1~/src/util.h 2006-02-03 17:04:17.000000000 +0000
+++ mc-4.6.2-pre1/src/util.h 2008-12-09 21:16:43.000000000 +0000
@@ -179,7 +179,9 @@ enum compression_type {
COMPRESSION_NONE,
COMPRESSION_GZIP,
COMPRESSION_BZIP,
- COMPRESSION_BZIP2
+ COMPRESSION_BZIP2,
+ COMPRESSION_LZMA,
+ COMPRESSION_LZIP
};
/* 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/syntax/assembler.syntax
--- mc-4.6.2-pre1~/syntax/assembler.syntax 2006-08-24 03:53:13.000000000 +0000
+++ mc-4.6.2-pre1/syntax/assembler.syntax 2008-12-09 21:09:43.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/syntax/html.syntax
--- mc-4.6.2-pre1~/syntax/html.syntax 2005-07-05 18:25:31.000000000 +0000
+++ mc-4.6.2-pre1/syntax/html.syntax 2008-12-09 21:09:43.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/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/vfs/extfs/iso9660.in 2008-12-09 22:30:23.000000000 +0000
@@ -29,7 +29,9 @@ test_iso () {
mcisofs_list () {
# left as a reminder to implement compressed image support =)
case "$1" in
+ *.lzma) MYCAT="lzma -dc";;
*.bz2) MYCAT="bzip2 -dc";;
+ *.lz) MYCAT="lzip -dc";;
*.gz) MYCAT="gzip -dc";;
*.z) MYCAT="gzip -dc";;
*.Z) MYCAT="gzip -dc";;
diff -Purp mc-4.6.2-pre1~/vfs/extfs/lslR.in mc-4.6.2-pre1/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/vfs/extfs/lslR.in 2008-12-09 22:30:37.000000000 +0000
@@ -12,7 +12,9 @@ AWK= AWK@
mclslRfs_list () {
case "$1" in
+ *.lzma) MYCAT="lzma -dc";;
*.bz2) MYCAT="bzip2 -dc";;
+ *.lz) MYCAT="lzip -dc";;
*.gz) MYCAT="gzip -dc";;
*.z) MYCAT="gzip -dc";;
*.Z) MYCAT="gzip -dc";;
diff -Purp mc-4.6.2-pre1~/vfs/extfs/mailfs.in mc-4.6.2-pre1/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/vfs/extfs/mailfs.in 2008-12-09 22:33:30.000000000 +0000
@@ -7,6 +7,8 @@ use bytes;
$zcat="zcat"; # gunzip to stdout
$bzcat="bzip2 -dc"; # bunzip2 to stdout
+$lzcat="lzma -dc"; # unlzma to stdout
+$lzkat="lzip -dc"; # unlzip to stdout
$file="file"; # "file" command
$TZ='GMT'; # default timezone (for Date module)
@@ -182,6 +184,10 @@ 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|");
+} elsif (/lzip/) {
+ exit 1 unless (open IN, "$lzkat $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/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/vfs/extfs/patchfs.in 2008-12-09 22:44:51.000000000 +0000
@@ -12,8 +12,10 @@ use POSIX;
use File::Temp 'tempfile';
# standard binaries
+my $lzma = 'lzma';
my $bzip = 'bzip2';
my $gzip = 'gzip';
+my $lzip = 'lzip';
my $fileutil = 'file';
# date parsing requires Date::Parse from TimeDate module
@@ -70,10 +72,14 @@ 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";
+ } elsif (/lzip/) {
+ return "$lzip -dc $qfname";
} else {
return "cat $qfname";
}
@@ -86,7 +92,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/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/vfs/extfs/sfs.ini 2008-12-09 21:26:43.000000000 +0000
@@ -10,6 +10,10 @@ bz/1 bzip < %1 > %3
ubz/1 bzip -d < %1 > %3
bz2/1 bzip2 < %1 > %3
ubz2/1 bzip2 -d < %1 > %3
+lzip/1 lzip < %1 > %3
+ulzip/1 lzip -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
diff -Purp mc-4.6.2-pre1~/vfs/extfs/ulha.in mc-4.6.2-pre1/vfs/extfs/ulha.in
--- mc-4.6.2-pre1~/vfs/extfs/ulha.in 2004-12-27 12:12:31.000000000 +0000
+++ mc-4.6.2-pre1/vfs/extfs/ulha.in 2008-12-09 21:35:59.000000000 +0000
@@ -19,7 +19,7 @@
# LHArc and LHa in exist several versions, and their listing output varies.
# Another variable is the architecture on which the compressed file was made.
# This program attempts to sort out the variables known to me, but it is likely
-# to display an empty panel if it encounters a mystery.
+# to display an empty panel if it encounters a mystery.
# In that case it will be useful to execute this file from the command line:
# ./lha list Mystery.lha
# to examine the output directly on the console. The output string must be
@@ -39,12 +39,18 @@ LHA_PUT="lha aq"
mc_lha_fs_list()
{
- # List the contents of the archive and sort it out
+ # List the contents of the archive and sort it out
$LHA_LIST "$1" | $AWK -v uid=`id -nu` -v gid=`id -ng` '
# Strip a leading '/' if present in a filepath
$(NF) ~ /^\// { $(NF) = substr($NF,2) }
# Print the line this way if there is no permission string
$1 ~ /^\[.*\]/ {
+ # AR, PMA and CP/M LHARC lack date info
+ if ($6 == "") {
+ $6 = $4
+ $5 = "00:00"
+ $4 = "01-01-1980"
+ }
# Invent a generic permission
$1 = ($NF ~ /\/$/) ? "drwxr-xr-x":"-rwxr--r--";
# Print it
@@ -76,12 +82,12 @@ mc_lha_fs_list()
# Well, that is the intent. At the moment mc is translating them.
split($2, id, "/");
printf "%s 1 %-8d %-8d %-8d %s %s %s %s\n",
- $1, id[1], id[2], $3, $5, $6, $7, $8;
+ $1, id[1], id[2], $3, $5, $6, $7, substr($0, 52);
# Get the next line of the list
next;
}
- '
+ '
}
# The 'copyout' command executive to copy displayed files to a destination
@@ -118,7 +124,7 @@ mc_lha_fs_run()
TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-ulha.XXXXXX"` || exit 1
trap "rm -rf \"$TMPDIR\"; exit 0" 1 2 3 4 15
TMPCMD=$TMPDIR/run
- $LHA_GET "$1" "$2" > $TMPCMD
+ $LHA_GET "$1" "$2" > $TMPCMD
chmod a+x "$TMPCMD"
"$TMPCMD"
rm -rf "$TMPDIR"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]