GNU tar 1.31's regression test #162 (sparse07.at) fails on FreeBSD
11 and 12.

This has nothing to do with sparse files.  It concerns unicode file
names in general.  The underlying problem appears to be a difference
between GNU iconv() and FreeBSD's iconv().  For a conversion from
UTF-8 to ASCII, GNU iconv() will return -1 and signal an error if
the input contains any characters that cannot be represented in
ASCII.  FreeBSD's iconv() replaces those characters with '?' and
returns the number of such substitutions.  This latter behavior is
in agreement with my reading of the POSIX standard on iconv().

Tentative patch below.

I already reported this problem for 1.30.
https://lists.gnu.org/archive/html/bug-tar/2018-04/msg00019.html

When trying to reproduce this on FreeBSD, be careful that the tar
build does not pick up GNU libiconv if the latter happens to be
installed on the test system.  To force use of the native iconv(3),
set CPPFLAGS='-DLIBICONV_PLUG -isystem /usr/local/include'.

--- src/utf8.c.orig     2019-01-11 17:46:41 UTC
+++ src/utf8.c
@@ -81,7 +81,7 @@ utf8_convert (bool to_utf, char const *input, char **o
   outlen = inlen * MB_LEN_MAX + 1;
   ob = ret = xmalloc (outlen);
   ib = (char ICONV_CONST *) input;
-  if (iconv (cd, &ib, &inlen, &ob, &outlen) == -1)
+  if (iconv (cd, &ib, &inlen, &ob, &outlen) != 0)
     {
       free (ret);
       return false;
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de
#                             -*- compilation -*-
162. sparse07.at:21: testing sparse files with unicode names ...
./sparse07.at:24:
mkdir posix
(cd posix
TEST_TAR_FORMAT=posix
export TEST_TAR_FORMAT
TAR_OPTIONS="-H posix"
export TAR_OPTIONS
rm -rf *

genfile --sparse --file žluť --block-size 512 0 ABCD 1M EFGH 2000K IJKL || exit 
77
tar -c -f archive --sparse žluť || exit 1

tar tf archive
)
--- -   2019-01-11 18:58:00.408827000 +0100
+++ 
/usr/ports/archivers/gtar/work/tar-1.31/tests/testsuite.dir/at-groups/162/stdout
    2019-01-11 18:58:00.407853000 +0100
@@ -1,2 +1,2 @@
-\305\276lu\305\245
+?lu?
 
162. sparse07.at:21: 162. sparse files with unicode names (sparse07.at:21): 
FAILED (sparse07.at:24)

Reply via email to