You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-arch/zip/files/zip-3.0-natspec.patch

215 lines
6.3 KiB

This patch makes zip use libnatspec to recode file names is national charset.
Initially this patch was written for altlinux:
http://sisyphus.ru/ru/srpm/Sisyphus/zip/patches
Later it was a bit improved and improved version was posted here (in Russian):
http://www.opennet.ru/tips/info/2494.shtml
Also I've added natspec support to output of zipnote (thank vapier for notice).
Gentoo reference:
https://bugs.gentoo.org/show_bug.cgi?id=275244
--
pva@gentoo.org
=== modified file 'fileio.c'
--- a/fileio.c
+++ b/fileio.c
@@ -929,7 +929,7 @@
}
if ((zname = in2ex(iname)) == NULL)
return ZE_MEM;
-#ifdef UNICODE_SUPPORT
+#if defined(UNICODE_SUPPORT) && !defined(UNIX)
/* Convert name to display or OEM name */
oname = local_to_display_string(iname);
#else
=== modified file 'globals.c'
--- a/globals.c
+++ b/globals.c
@@ -32,7 +32,7 @@
int scanimage = 1; /* 1=scan through image files */
#endif
int method = BEST; /* one of BEST, DEFLATE (only), or STORE (only) */
-int dosify = 0; /* 1=make new entries look like MSDOS */
+int dosify = 1; /* 1=make new entries look like MSDOS */
int verbose = 0; /* 1=report oddities in zip file structure */
int fix = 0; /* 1=fix the zip file, 2=FF, 3=ZipNote */
int filesync = 0; /* 1=file sync, delete entries not on file system */
=== modified file 'unix/Makefile'
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -38,7 +38,7 @@
MANFLAGS = 644
# target directories - where to install executables and man pages to
-prefix = /usr/local
+prefix = /usr
BINDIR = $(prefix)/bin
MANEXT=1
MANDIR = $(prefix)/man/man$(MANEXT)
@@ -61,6 +61,7 @@
CFLAGS = -O2 $(CFLAGS_NOOPT)
LFLAGS1 =
LFLAGS2 = -s
+LDADD = -lnatspec
# object file lists
OBJZ = zip.o zipfile.o zipup.o fileio.o util.o globals.o crypt.o ttyio.o \
@@ -125,9 +126,9 @@
zipsman: $(ZIPS) $(ZIPMANUALs)
zip$E: $(OBJZ) $(OBJI) $(OBJA) $(LIB_BZ)
- $(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2)
+ $(BIND) -o zip$E $(LFLAGS1) $(OBJZ) $(OBJI) $(OBJA) $(LFLAGS2) $(LDADD)
zipnote$E: $(OBJN)
- $(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2)
+ $(BIND) -o zipnote$E $(LFLAGS1) $(OBJN) $(LFLAGS2) $(LDADD)
zipcloak$E: $(OBJC) $(OCRCTB)
$(BIND) -o zipcloak$E $(LFLAGS1) $(OBJC) $(LFLAGS2)
zipsplit$E: $(OBJS)
=== modified file 'unix/osdep.h'
--- a/unix/osdep.h
+++ b/unix/osdep.h
@@ -78,3 +78,6 @@
#if !defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)
# define USE_EF_UT_TIME
#endif
+
+/* Set Windows code as archive type */
+# define OS_CODE 0xb00
=== modified file 'unix/unix.c'
--- a/unix/unix.c
+++ b/unix/unix.c
@@ -14,6 +14,11 @@
#include <time.h>
+#ifdef UNIX
+# include <natspec.h>
+# include <locale.h>
+#endif
+
#if defined(MINIX) || defined(__mpexl)
# ifdef S_IWRITE
# undef S_IWRITE
@@ -60,6 +65,7 @@
/* Local functions */
local char *readd OF((DIR *));
+local const char *oem_charset = NULL;
#ifdef NO_DIR /* for AT&T 3B1 */
@@ -262,6 +268,16 @@
if (!pathput)
t = last(t, PATH_END);
+#ifdef UNIX
+ if (!oem_charset) {
+ setlocale(LC_CTYPE, "");
+ oem_charset = natspec_get_charset_by_locale(NATSPEC_DOSCS, "");
+ }
+ /* Convert to internal encoding */
+ if ((n = natspec_convert(t, oem_charset, 0, 0)) == NULL)
+ return NULL;
+ return n;
+#else
/* Malloc space for internal name and copy it */
if ((n = malloc(strlen(t) + 1)) == NULL)
return NULL;
@@ -269,6 +285,7 @@
if (dosify)
msname(n);
+#endif
#ifdef EBCDIC
strtoasc(n, n); /* here because msname() needs native coding */
@@ -289,8 +306,19 @@
{
char *x; /* external file name */
+#ifdef UNIX
+ if (!oem_charset) {
+ oem_charset = natspec_get_charset_by_locale(NATSPEC_DOSCS, "");
+ setlocale(LC_CTYPE, "");
+ }
+ /* Convert to internal encoding */
+ if ((x = natspec_convert(n, 0, oem_charset, 0)) == NULL)
+ return NULL;
+ return x;
+#else
if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
return NULL;
+#endif
#ifdef EBCDIC
strtoebc(x, n);
#else
=== modified file 'zip.c'
--- a/zip.c
+++ b/zip.c
@@ -2025,6 +2025,7 @@
#endif /* ?MACOS */
{"J", "junk-sfx", o_NO_VALUE, o_NOT_NEGATABLE, 'J', "strip self extractor from archive"},
{"k", "DOS-names", o_NO_VALUE, o_NOT_NEGATABLE, 'k', "force use of 8.3 DOS names"},
+ {"K", "no DOS-names",o_NO_VALUE, o_NOT_NEGATABLE, 'K', "no use 8.3 DOS names"},
{"l", "to-crlf", o_NO_VALUE, o_NOT_NEGATABLE, 'l', "convert text file line ends - LF->CRLF"},
{"ll", "from-crlf", o_NO_VALUE, o_NOT_NEGATABLE, o_ll, "convert text file line ends - CRLF->LF"},
{"lf", "logfile-path",o_REQUIRED_VALUE, o_NOT_NEGATABLE, o_lf, "log to log file at path (default overwrite)"},
@@ -2289,7 +2290,7 @@
dispose = 0; /* 1=remove files after put in zip file */
pathput = 1; /* 1=store path with name */
method = BEST; /* one of BEST, DEFLATE (only), or STORE (only) */
- dosify = 0; /* 1=make new entries look like MSDOS */
+ dosify = 1; /* 1=make new entries look like MSDOS */
verbose = 0; /* 1=report oddities in zip file structure */
fix = 0; /* 1=fix the zip file */
adjust = 0; /* 1=adjust offsets for sfx'd file (keep preamble) */
@@ -2859,6 +2860,8 @@
junk_sfx = 1; break;
case 'k': /* Make entries using DOS names (k for Katz) */
dosify = 1; break;
+ case 'K': /* Make entries using DOS names (K for Kompat) */
+ dosify = 0; break;
case 'l': /* Translate end-of-line */
translate_eol = 1; break;
case o_ll:
=== modified file 'zipnote.c'
--- a/zipnote.c
+++ b/zipnote.c
@@ -21,6 +21,11 @@
#include "revision.h"
#include <signal.h>
+#ifdef UNIX
+# include <natspec.h>
+# include <locale.h>
+#endif
+
/* Calculate size of static line buffer used in write (-w) mode. */
#define WRBUFSIZ 2047
/* The line buffer size should be at least as large as FNMAX. */
@@ -537,7 +542,13 @@
{
for (z = zfiles; z != NULL; z = z->nxt)
{
+#ifdef UNIX
+ char *oem_charset = NULL;
+ oem_charset = natspec_get_charset_by_locale(NATSPEC_DOSCS, "");
+ printf("%c %s\n", MARK, natspec_convert(z->zname, 0, oem_charset, 0));
+#else
printf("%c %s\n", MARK, z->zname);
+#endif
putclean(z->comment, z->com);
printf("%c%s\n", MARK, MARKE);
}