aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/unzip-alt-iconv-utf8-print.patch
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2021-03-24 15:28:33 +0200
committerEfraim Flashner <efraim@flashner.co.il>2021-03-24 20:50:44 +0200
commit2aab587f842908a886e3bd08b028885dddd650e0 (patch)
tree87c0723a9ae2c69ab6920d90b6e87ad8510492fe /gnu/packages/patches/unzip-alt-iconv-utf8-print.patch
parent5664bcdcb0e4c10dfe48dd5e4730fc3c746a21e2 (diff)
parent65c46e79e0495fe4d32f6f2725d7233fff10fd70 (diff)
downloadguix-2aab587f842908a886e3bd08b028885dddd650e0.tar.gz
guix-2aab587f842908a886e3bd08b028885dddd650e0.zip
Merge remote-tracking branch 'origin/master' into core-updates
Diffstat (limited to 'gnu/packages/patches/unzip-alt-iconv-utf8-print.patch')
-rw-r--r--gnu/packages/patches/unzip-alt-iconv-utf8-print.patch381
1 files changed, 381 insertions, 0 deletions
diff --git a/gnu/packages/patches/unzip-alt-iconv-utf8-print.patch b/gnu/packages/patches/unzip-alt-iconv-utf8-print.patch
new file mode 100644
index 0000000000..0b0153ba54
--- /dev/null
+++ b/gnu/packages/patches/unzip-alt-iconv-utf8-print.patch
@@ -0,0 +1,381 @@
+From ca0212ba19b64488b9e8459a762c11ecd6e7d0bd Mon Sep 17 00:00:00 2001
+From: Petr Stodulka <pstodulk@redhat.com>
+Date: Tue, 24 Nov 2015 17:56:11 +0100
+Subject: [PATCH] print correctly non-ascii filenames
+
+---
+ extract.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++--------------
+ unzpriv.h | 7 ++
+ 2 files changed, 233 insertions(+), 63 deletions(-)
+
+diff --git a/extract.c b/extract.c
+index 0ee4e93..741b7e0 100644
+--- a/extract.c
++++ b/extract.c
+@@ -2648,8 +2648,21 @@ static void set_deferred_symlink(__G__ slnk_entry)
+ } /* end function set_deferred_symlink() */
+ #endif /* SYMLINKS */
+
++/*
++ * If Unicode is supported, assume we have what we need to do this
++ * check using wide characters, avoiding MBCS issues.
++ */
+
+-
++#ifndef UZ_FNFILTER_REPLACECHAR
++ /* A convenient choice for the replacement of unprintable char codes is
++ * the "single char wildcard", as this character is quite unlikely to
++ * appear in filenames by itself. The following default definition
++ * sets the replacement char to a question mark as the most common
++ * "single char wildcard"; this setting should be overridden in the
++ * appropiate system-specific configuration header when needed.
++ */
++# define UZ_FNFILTER_REPLACECHAR '?'
++#endif
+
+ /*************************/
+ /* Function fnfilter() */ /* here instead of in list.c for SFX */
+@@ -2661,48 +2674,168 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
+ extent size;
+ {
+ #ifndef NATIVE /* ASCII: filter ANSI escape codes, etc. */
+- ZCONST uch *r=(ZCONST uch *)raw;
++ ZCONST uch *r; // =(ZCONST uch *)raw;
+ uch *s=space;
+ uch *slim=NULL;
+ uch *se=NULL;
+ int have_overflow = FALSE;
+
+- if (size > 0) {
+- slim = space + size
+-#ifdef _MBCS
+- - (MB_CUR_MAX - 1)
+-#endif
+- - 4;
++# if defined( UNICODE_SUPPORT) && defined( _MBCS)
++/* If Unicode support is enabled, and we have multi-byte characters,
++ * then do the isprint() checks by first converting to wide characters
++ * and checking those. This avoids our having to parse multi-byte
++ * characters for ourselves. After the wide-char replacements have been
++ * made, the wide string is converted back to the local character set.
++ */
++ wchar_t *wstring; /* wchar_t version of raw */
++ size_t wslen; /* length of wstring */
++ wchar_t *wostring; /* wchar_t version of output string */
++ size_t woslen; /* length of wostring */
++ char *newraw; /* new raw */
++
++ /* 2012-11-06 SMS.
++ * Changed to check the value returned by mbstowcs(), and bypass the
++ * Unicode processing if it fails. This seems to fix a problem
++ * reported in the SourceForge forum, but it's not clear that we
++ * should be doing any Unicode processing without some evidence that
++ * the name actually is Unicode. (Check bit 11 in the flags before
++ * coming here?)
++ * http://sourceforge.net/p/infozip/bugs/40/
++ */
++
++ if (MB_CUR_MAX <= 1)
++ {
++ /* There's no point to converting multi-byte chars if there are
++ * no multi-byte chars.
++ */
++ wslen = (size_t)-1;
+ }
+- while (*r) {
+- if (size > 0 && s >= slim && se == NULL) {
+- se = s;
++ else
++ {
++ /* Get Unicode wide character count (for storage allocation). */
++ wslen = mbstowcs( NULL, raw, 0);
++ }
++
++ if (wslen != (size_t)-1)
++ {
++ /* Apparently valid Unicode. Allocate wide-char storage. */
++ wstring = (wchar_t *)malloc((wslen + 1) * sizeof(wchar_t));
++ if (wstring == NULL) {
++ strcpy( (char *)space, raw);
++ return (char *)space;
+ }
+-#ifdef QDOS
+- if (qlflag & 2) {
+- if (*r == '/' || *r == '.') {
++ wostring = (wchar_t *)malloc(2 * (wslen + 1) * sizeof(wchar_t));
++ if (wostring == NULL) {
++ free(wstring);
++ strcpy( (char *)space, raw);
++ return (char *)space;
++ }
++
++ /* Convert the multi-byte Unicode to wide chars. */
++ wslen = mbstowcs(wstring, raw, wslen + 1);
++
++ /* Filter the wide-character string. */
++ fnfilterw( wstring, wostring, (2 * (wslen + 1) * sizeof(wchar_t)));
++
++ /* Convert filtered wide chars back to multi-byte. */
++ woslen = wcstombs( NULL, wostring, 0);
++ if ((newraw = malloc(woslen + 1)) == NULL) {
++ free(wstring);
++ free(wostring);
++ strcpy( (char *)space, raw);
++ return (char *)space;
++ }
++ woslen = wcstombs( newraw, wostring, (woslen * MB_CUR_MAX) + 1);
++
++ if (size > 0) {
++ slim = space + size - 4;
++ }
++ r = (ZCONST uch *)newraw;
++ while (*r) {
++ if (size > 0 && s >= slim && se == NULL) {
++ se = s;
++ }
++# ifdef QDOS
++ if (qlflag & 2) {
++ if (*r == '/' || *r == '.') {
++ if (se != NULL && (s > (space + (size-3)))) {
++ have_overflow = TRUE;
++ break;
++ }
++ ++r;
++ *s++ = '_';
++ continue;
++ }
++ } else
++# endif
++ {
+ if (se != NULL && (s > (space + (size-3)))) {
+ have_overflow = TRUE;
+ break;
+ }
+- ++r;
+- *s++ = '_';
+- continue;
++ *s++ = *r++;
+ }
+- } else
++ }
++ if (have_overflow) {
++ strcpy((char *)se, "...");
++ } else {
++ *s = '\0';
++ }
++
++ free(wstring);
++ free(wostring);
++ free(newraw);
++ }
++ else
++# endif /* defined( UNICODE_SUPPORT) && defined( _MBCS) */
++ {
++ /* No Unicode support, or apparently invalid Unicode. */
++ r = (ZCONST uch *)raw;
++
++ if (size > 0) {
++ slim = space + size
++#ifdef _MBCS
++ - (MB_CUR_MAX - 1)
++#endif
++ - 4;
++ }
++ while (*r) {
++ if (size > 0 && s >= slim && se == NULL) {
++ se = s;
++ }
++#ifdef QDOS
++ if (qlflag & 2) {
++ if (*r == '/' || *r == '.') {
++ if (se != NULL && (s > (space + (size-3)))) {
++ have_overflow = TRUE;
++ break;
++ }
++ ++r;
++ *s++ = '_';
++ continue;
++ }
++ } else
+ #endif
+ #ifdef HAVE_WORKING_ISPRINT
+-# ifndef UZ_FNFILTER_REPLACECHAR
+- /* A convenient choice for the replacement of unprintable char codes is
+- * the "single char wildcard", as this character is quite unlikely to
+- * appear in filenames by itself. The following default definition
+- * sets the replacement char to a question mark as the most common
+- * "single char wildcard"; this setting should be overridden in the
+- * appropiate system-specific configuration header when needed.
+- */
+-# define UZ_FNFILTER_REPLACECHAR '?'
+-# endif
+- if (!isprint(*r)) {
++ if (!isprint(*r)) {
++ if (*r < 32) {
++ /* ASCII control codes are escaped as "^{letter}". */
++ if (se != NULL && (s > (space + (size-4)))) {
++ have_overflow = TRUE;
++ break;
++ }
++ *s++ = '^', *s++ = (uch)(64 + *r++);
++ } else {
++ /* Other unprintable codes are replaced by the
++ * placeholder character. */
++ if (se != NULL && (s > (space + (size-3)))) {
++ have_overflow = TRUE;
++ break;
++ }
++ *s++ = UZ_FNFILTER_REPLACECHAR;
++ INCSTR(r);
++ }
++#else /* !HAVE_WORKING_ISPRINT */
+ if (*r < 32) {
+ /* ASCII control codes are escaped as "^{letter}". */
+ if (se != NULL && (s > (space + (size-4)))) {
+@@ -2710,47 +2843,30 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
+ break;
+ }
+ *s++ = '^', *s++ = (uch)(64 + *r++);
++#endif /* ?HAVE_WORKING_ISPRINT */
+ } else {
+- /* Other unprintable codes are replaced by the
+- * placeholder character. */
++#ifdef _MBCS
++ unsigned i = CLEN(r);
++ if (se != NULL && (s > (space + (size-i-2)))) {
++ have_overflow = TRUE;
++ break;
++ }
++ for (; i > 0; i--)
++ *s++ = *r++;
++#else
+ if (se != NULL && (s > (space + (size-3)))) {
+ have_overflow = TRUE;
+ break;
+ }
+- *s++ = UZ_FNFILTER_REPLACECHAR;
+- INCSTR(r);
+- }
+-#else /* !HAVE_WORKING_ISPRINT */
+- if (*r < 32) {
+- /* ASCII control codes are escaped as "^{letter}". */
+- if (se != NULL && (s > (space + (size-4)))) {
+- have_overflow = TRUE;
+- break;
+- }
+- *s++ = '^', *s++ = (uch)(64 + *r++);
+-#endif /* ?HAVE_WORKING_ISPRINT */
+- } else {
+-#ifdef _MBCS
+- unsigned i = CLEN(r);
+- if (se != NULL && (s > (space + (size-i-2)))) {
+- have_overflow = TRUE;
+- break;
+- }
+- for (; i > 0; i--)
+ *s++ = *r++;
+-#else
+- if (se != NULL && (s > (space + (size-3)))) {
+- have_overflow = TRUE;
+- break;
+- }
+- *s++ = *r++;
+ #endif
+- }
+- }
+- if (have_overflow) {
+- strcpy((char *)se, "...");
+- } else {
+- *s = '\0';
++ }
++ }
++ if (have_overflow) {
++ strcpy((char *)se, "...");
++ } else {
++ *s = '\0';
++ }
+ }
+
+ #ifdef WINDLL
+@@ -2772,6 +2888,53 @@ char *fnfilter(raw, space, size) /* convert name to safely printable form */
+ } /* end function fnfilter() */
+
+
++#if defined( UNICODE_SUPPORT) && defined( _MBCS)
++
++/****************************/
++/* Function fnfilter[w]() */ /* (Here instead of in list.c for SFX.) */
++/****************************/
++
++/* fnfilterw() - Convert wide name to safely printable form. */
++
++/* fnfilterw() - Convert wide-character name to safely printable form. */
++
++wchar_t *fnfilterw( src, dst, siz)
++ ZCONST wchar_t *src; /* Pointer to source char (string). */
++ wchar_t *dst; /* Pointer to destination char (string). */
++ extent siz; /* Not used (!). */
++{
++ wchar_t *dsx = dst;
++
++ /* Filter the wide chars. */
++ while (*src)
++ {
++ if (iswprint( *src))
++ {
++ /* Printable code. Copy it. */
++ *dst++ = *src;
++ }
++ else
++ {
++ /* Unprintable code. Substitute something printable for it. */
++ if (*src < 32)
++ {
++ /* Replace ASCII control code with "^{letter}". */
++ *dst++ = (wchar_t)'^';
++ *dst++ = (wchar_t)(64 + *src);
++ }
++ else
++ {
++ /* Replace other unprintable code with the placeholder. */
++ *dst++ = (wchar_t)UZ_FNFILTER_REPLACECHAR;
++ }
++ }
++ src++;
++ }
++ *dst = (wchar_t)0; /* NUL-terminate the destination string. */
++ return dsx;
++} /* fnfilterw(). */
++
++#endif /* defined( UNICODE_SUPPORT) && defined( _MBCS) */
+
+
+ #ifdef SET_DIR_ATTRIB
+diff --git a/unzpriv.h b/unzpriv.h
+index 22d3923..e48a652 100644
+--- a/unzpriv.h
++++ b/unzpriv.h
+@@ -1212,6 +1212,7 @@
+ # ifdef UNICODE_WCHAR
+ # if !(defined(_WIN32_WCE) || defined(POCKET_UNZIP))
+ # include <wchar.h>
++# include <wctype.h>
+ # endif
+ # endif
+ # ifndef _MBCS /* no need to include <locale.h> twice, see below */
+@@ -2410,6 +2411,12 @@ int memflush OF((__GPRO__ ZCONST uch *rawbuf, ulg size));
+ char *fnfilter OF((ZCONST char *raw, uch *space,
+ extent size));
+
++# if defined( UNICODE_SUPPORT) && defined( _MBCS)
++wchar_t *fnfilterw OF((ZCONST wchar_t *src, wchar_t *dst,
++ extent siz));
++#endif
++
++
+ /*---------------------------------------------------------------------------
+ Decompression functions:
+ ---------------------------------------------------------------------------*/
+--
+2.4.3
+
$(nodist_bootstrap_armhf_linux_DATA). (gnu/packages/bootstrap/armhf-linux/guile-2.0.11.tar.xz): New target. * build-aux/download.scm (file-name->uri): Use newer date in URI for armhf-linux. * gnu/packages/bootstrap.scm (raw-build): Use "guile-2.0.11.tar.xz" on armhf-linux. (glibc-dynamic-linker, %bootstrap-coreutils&co, %bootstrap-binutils) (%bootstrap-glibc, %bootstrap-gcc): Add armhf-linux cases. * m4/guix.m4 (GUIX_SYSTEM_TYPE): Add armhf case. (GUIX_ASSERT_SUPPORTED_SYSTEM): Add armhf-linux to list of supported systems. * doc/guix.texi (GNU Distribution): Add armhf-linux to the list of supported systems. Mark H Weaver 2014-01-24Add 'guix offload' as a daemon build hook....* nix/nix-daemon/guix-daemon.cc (GUIX_OPT_NO_BUILD_HOOK): New macro. (options): Add '--no-build-hook'. (parse_opt): Handle it. (main)[HAVE_DAEMON_OFFLOAD_HOOK]: Set 'useBuildHook' by default. Set $NIX_BUILD_HOOK to our offload hook unless otherwise specified. [!HAVE_DAEMON_OFFLOAD_HOOK]: Clear 'useBuildHook'. * pre-inst-env.in: Set and export NIX_BUILD_HOOK. * nix/scripts/offload.in, guix/scripts/offload.scm: New files. * guix/ui.scm (show-guix-help)[internal?]: Add "offload". * config-daemon.ac: Call 'GUIX_CHECK_UNBUFFERED_CBIP'. Instantiate 'nix/scripts/offload'. Set 'BUILD_DAEMON_OFFLOAD' conditional, and optionally define 'HAVE_DEAMON_OFFLOAD_HOOK' cpp macro. * daemon.am (nodist_pkglibexec_SCRIPTS)[BUILD_DAEMON_OFFLOAD]: Add it. * Makefile.am (MODULES)[BUILD_DAEMON_OFFLOAD]: Add 'guix/scripts/offload.scm'. (EXTRA_DIST)[!BUILD_DAEMON_OFFLOAD]: Likewise. * m4/guix.m4 (GUIX_CHECK_UNBUFFERED_CBIP): New macro. * doc/guix.texi (Setting Up the Daemon): Move most of the body to... (Build Environment Setup): ... this. New subsection. (Daemon Offload Setup): New subsection. Ludovic Courtès 2013-11-03Add mips64el-linux to the list of supported systems....* m4/guix.m4 (GUIX_ASSERT_SUPPORTED_SYSTEM): Add mips64el-linux to the list of supported systems. Mark H Weaver 2013-07-17build: Provide a replacement (srfi srfi-37) when the user's one is broken....* srfi/srfi-37.scm.in: New file, taken from Guile 2.0.9. * m4/guix.m4: New macro. * configure.ac: Use it. Define Automake conditional `INSTALL_SRFI_37'. * Makefile.am (nobase_nodist_guilemodule_DATA)[INSTALL_SRFI_37]: Add srfi/srfi-37.scm. (GOBJECTS)[INSTALL_SRFI_37]: Add srfi/srfi-37.go. (srfi/srfi-37.scm)[INSTALL_SRFI_37]: New target. (EXTRA_DIST): Add srfi/srfi-37.scm.in. Ludovic Courtès 2013-07-05build: Bail out on unsupported platforms; add `--with-courage'....* m4/guix.m4 (GUIX_ASSERT_SUPPORTED_SYSTEM): New macro. * configure.ac: Use it. Ludovic Courtès 2013-07-05build: Correctly determine the system type for non-Linux systems....* m4/guix.m4 (GUIX_SYSTEM_TYPE): Find `sed'. Fix sed pattern in the non-Linux case. Ludovic Courtès 2013-05-10build: Make sure the user's Guile has all the required features....* m4/guix.m4 (GUIX_ASSERT_GUILE_FEATURES): New macro. * configure.ac: Use it. Ludovic Courtès 2013-01-10build: Print the Guix system type....* m4/guix.m4 (GUIX_SYSTEM_TYPE): Print the system type. Ludovic Courtès 2013-01-06Update a few more license headers....* distro/packages/openssl.scm, m4/guix.m4, nix/sync-with-upstream: Update headers. Ludovic Courtès 2012-12-06build: Capture configure-time settings in (guix config)....* configure.ac: Compute and substitute `guix_localstatedir'. * m4/guix.m4: Substitute `guix_system'. * guix/config.scm.in (%store-directory, %store-directory, %system): New variables. * guix/store.scm (%nix-state-dir): Remove. (%default-socket-path): Use %STATE-DIRECTORY as the default. (%store-prefix): Use %STORE-DIRECTORY as the default. * guix/utils.scm (%current-system): Default to %SYSTEM. Ludovic Courtès 2012-12-03build: Include a copy of Nix's libstore and daemon; build it....* configure.ac: Call `AC_USE_SYSTEM_EXTENSIONS', and `GUIX_SYSTEM_TYPE'. Add `--with-store-dir' option, and substitute `storedir'. Include `config-daemon.ac'. * config-daemon.ac: New file. * Makefile.am [BUILD_DAEMON]: Include `daemon.am'. * daemon.am: New file. * m4/guix.m4 (GUIX_SYSTEM_TYPE): New macro. * nix/libutil/gcrypt-hash.cc, nix/libutil/gcrypt-hash.hh, nix/libutil/md5.h, nix/libutil/sha1.h, nix/libutil/sha256.h, nix/nix-daemon/guix-daemon.cc, nix/nix-daemon/shared.hh: New files. Ludovic Courtès 2012-11-03build: Require GNU libgcrypt....* guix/utils.scm (sha256): Remove Coreutils- and libchop-based implementations. * README: Update accordingly. * m4/guix.m4: New file. * configure.ac: Use `GUIX_ASSERT_LIBGCRYPT_USABLE'. Set and substitute `LIBGCRYPT_PREFIX'. * Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Pass `--with-libgcrypt-prefix=$(LIBGCRYPT_PREFIX)'. Ludovic Courtès