Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 May 2017 21:54:21 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r319362 - in stable/11/usr.bin/compress: . tests
Message-ID:  <201705312154.v4VLsLQo064823@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Wed May 31 21:54:21 2017
New Revision: 319362
URL: https://svnweb.freebsd.org/changeset/base/319362

Log:
  MFC r318592: compress: Allow uncompress -c with multiple pathnames,
  as required by POSIX.
  
  Per POSIX, allow passing multiple pathnames to uncompress -c, concatenating
  the uncompressed data.
  
  Passing multiple pathnames to compress -c remains disallowed, since the
  result cannot be decompressed.
  
  PR:		219387

Modified:
  stable/11/usr.bin/compress/compress.c
  stable/11/usr.bin/compress/tests/compress_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/compress/compress.c
==============================================================================
--- stable/11/usr.bin/compress/compress.c	Wed May 31 21:31:15 2017	(r319361)
+++ stable/11/usr.bin/compress/compress.c	Wed May 31 21:54:21 2017	(r319362)
@@ -129,7 +129,7 @@ main(int argc, char *argv[])
 		exit (eval);
 	}
 
-	if (cat == 1 && argc > 1)
+	if (cat == 1 && style == COMPRESS && argc > 1)
 		errx(1, "the -c option permits only a single file argument");
 
 	for (; *argv; ++argv)

Modified: stable/11/usr.bin/compress/tests/compress_test.sh
==============================================================================
--- stable/11/usr.bin/compress/tests/compress_test.sh	Wed May 31 21:31:15 2017	(r319361)
+++ stable/11/usr.bin/compress/tests/compress_test.sh	Wed May 31 21:54:21 2017	(r319362)
@@ -161,6 +161,27 @@ compress_uncompress_file_2_body()
 	atf_check cmp file2 expectfile2
 }
 
+atf_test_case compress_uncompress_file_minusc_1
+compress_uncompress_file_minusc_1_head()
+{
+	atf_set "descr" \
+	    "Test compressing and uncompressing some data, passing two filenames to uncompress -c"
+}
+compress_uncompress_file_minusc_1_body()
+{
+	printf '%01000d\n' 7 8 >expectfile1
+	printf '%01000d\n' 8 7 >expectfile2
+	cp expectfile1 file1
+	cp expectfile2 file2
+	atf_check compress file1 file2
+	atf_check -s exit:1 cmp -s file1.Z expectfile1
+	atf_check -s exit:1 cmp -s file2.Z expectfile2
+	atf_check -s exit:1 cmp -s file1.Z file2.Z
+	atf_check -x 'uncompress -c file1.Z file2.Z >all'
+	atf_check -x 'cat expectfile1 expectfile2 >expectall'
+	atf_check cmp all expectall
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case uncompress_file_1
@@ -171,4 +192,5 @@ atf_init_test_cases()
 	atf_add_test_case compress_uncompress_minusc_1
 	atf_add_test_case compress_uncompress_file_1
 	atf_add_test_case compress_uncompress_file_2
+	atf_add_test_case compress_uncompress_file_minusc_1
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705312154.v4VLsLQo064823>