gzip --no-name: avoid spurious warning
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 5 Nov 2016 03:15:42 +0000 (20:15 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 5 Nov 2016 03:25:10 +0000 (20:25 -0700)
Problem reported by Jim Meyering (Bug#24826).
* tests/timestamp: Add a test from Jim Meyering to exercise the fix
* zip.c (zip): Treat unknown time stamps as 0.

tests/timestamp
zip.c

index 7acfe5de6588facb7db113d738fb355ba9b9d0b9..141c1d4dcc029e2d851f3d8dfdad029f08d871bc 100755 (executable)
@@ -49,4 +49,7 @@ touch -t 210602070628.15 in || {
   test $? = 2 || fail=1
 }
 
+# Ensure that --no-name does not provoke a time stamp warning.
+: | gzip --no-name > k || fail=1
+
 Exit $fail
diff --git a/zip.c b/zip.c
index eb60409c7edc1851f31671921ba9d09806c1bb6f..a3b4559fdd5febe1d0825f9f26e28b8cdbc2ab7e 100644 (file)
--- a/zip.c
+++ b/zip.c
@@ -54,7 +54,9 @@ int zip(in, out)
         flags |= ORIG_NAME;
     }
     put_byte(flags);         /* general flags */
-    if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff)
+    if (time_stamp.tv_nsec < 0)
+      stamp = 0;
+    else if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff)
       stamp = time_stamp.tv_sec;
     else
       {