emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#24826: closed ([PATCH 1/2] gzip --no-name: avoid s


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#24826: closed ([PATCH 1/2] gzip --no-name: avoid spurious warning)
Date: Sat, 05 Nov 2016 03:37:01 +0000

Your message dated Fri, 4 Nov 2016 20:36:45 -0700
with message-id <address@hidden>
and subject line Re: bug#24826: [PATCH 1/2] gzip --no-name: avoid spurious 
warning
has caused the debbugs.gnu.org bug report #24826,
regarding [PATCH 1/2] gzip --no-name: avoid spurious warning
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
24826: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24826
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 1/2] gzip --no-name: avoid spurious warning Date: Sun, 30 Oct 2016 07:55:08 -0700
The first one is a clear bug fix.

For the second, since --no-time (-T) never worked (-m does),
I could also just remove its entry from longopts. We've
done without it for so long, there's little point to adding
an undocumented --no-time, now.

>From ed37ad2fe34cb37a1dc1687fb6c441e2ebd2e86b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 24 Oct 2016 10:10:04 -0700
Subject: [PATCH 1/2] gzip --no-name: avoid spurious warning

I noticed that while attempting to create gzip's own gzip-compressed
release tarball, gzip would emit this warning and exit with status 2:
gzip: stdin: warning: file time stamp out of range for gzip format
Here is a minimal reproducer: : | gzip --no-name > k
* zip.c (zip): Skip validity check when no_time is set.
* gzip.c (no_time): Make this variable global.
* gzip.h (no_time): Declare it extern.
* tests/timestamp: Add a test to exercise the fix.
Introduced by commit v1.8-6-g51dee92
---
 gzip.c          | 2 +-
 gzip.h          | 1 +
 tests/timestamp | 3 +++
 zip.c           | 4 +++-
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gzip.c b/gzip.c
index 0fca5a3..f990fa2 100644
--- a/gzip.c
+++ b/gzip.c
@@ -173,7 +173,7 @@ static int decompress = 0;   /* decompress (-d) */
 static int force = 0;        /* don't ask questions, compress links (-f) */
 static int keep = 0;         /* keep (don't delete) input files */
 static int no_name = -1;     /* don't save or restore the original file name */
-static int no_time = -1;     /* don't save or restore the original file time */
+       int no_time = -1;     /* don't save or restore the original file time */
 static int recursive = 0;    /* recurse through directories (-r) */
 static int list = 0;         /* list the file contents (-l) */
        int verbose = 0;      /* be verbose (-v) */
diff --git a/gzip.h b/gzip.h
index f298b47..4117306 100644
--- a/gzip.h
+++ b/gzip.h
@@ -199,6 +199,7 @@ typedef int file_t;     /* Do not use stdio */

 extern int exit_code;      /* program exit code */
 extern int verbose;        /* be verbose (-v) */
+extern int no_time;        /* --no-time (-T) */
 extern int quiet;          /* be quiet (-q) */
 extern int level;          /* compression level */
 extern int test;           /* check .z file integrity */
diff --git a/tests/timestamp b/tests/timestamp
index 7acfe5d..141c1d4 100755
--- a/tests/timestamp
+++ b/tests/timestamp
@@ -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 eb60409..cebd719 100644
--- 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 (no_time)
+      stamp = 0;
+    else if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff)
       stamp = time_stamp.tv_sec;
     else
       {
--
2.7.4


>From 6d0eabd745de16616beda963e0bee662a1664478 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 24 Oct 2016 09:58:22 -0700
Subject: [PATCH 2/2] gzip: accept --no-time option (undocumented, like -m)

The undocumented -m option has been accepted since the beginning,
but its associated --no-time option has never been accepted, due
to the use of 'T' (not mentioned in shortopts) instead of 'm' in
the definition of longopts.  This made it so an attempt to use
this long option would elicit only a bare "Try `gzip --help' for
more information."
* gzip.c (longopts): Specify 'm' with --no-time, not 'T'.
---
 gzip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gzip.c b/gzip.c
index f990fa2..9e34c80 100644
--- a/gzip.c
+++ b/gzip.c
@@ -285,7 +285,7 @@ static const struct option longopts[] =
     {"recursive",  0, 0, 'r'}, /* recurse through directories */
     {"suffix",     1, 0, 'S'}, /* use given suffix instead of .gz */
     {"test",       0, 0, 't'}, /* test compressed file integrity */
-    {"no-time",    0, 0, 'T'}, /* don't save or restore the time stamp */
+    {"no-time",    0, 0, 'm'}, /* don't save or restore the time stamp */
     {"verbose",    0, 0, 'v'}, /* verbose mode */
     {"version",    0, 0, 'V'}, /* display version number */
     {"fast",       0, 0, '1'}, /* compress faster */
--
2.7.4



--- End Message ---
--- Begin Message --- Subject: Re: bug#24826: [PATCH 1/2] gzip --no-name: avoid spurious warning Date: Fri, 4 Nov 2016 20:36:45 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0
Jim Meyering wrote:
The first one is a clear bug fix.

Oops, my bad. Thanks for catching that. I installed a simpler fix (first attached patch).

For the second, since --no-time (-T) never worked (-m does),
I could also just remove its entry from longopts. We've
done without it for so long, there's little point to adding
an undocumented --no-time, now.

Thanks, I like that idea and installed the 2nd attached patch.

In rereading the code I noticed other problems likely to bite after the year 2038 (3rd attached patch, also installed). This stuff is a pain, as it won't see realistic testing for another 20 years or so and I don't see easy test cases for it, partly because GNU/Linux seems to mishandles these time stamps now on my platform (Fedora 24 x86-64; I'll try to file a bug report about this to Fedora).

Boldly marking the bug as done.

Attachment: 0001-gzip-no-name-avoid-spurious-warning.patch
Description: Text Data

Attachment: 0002-gzip-no-time-cleanup.patch
Description: Text Data

Attachment: 0003-gzip-minor-time-stamp-cleanups.patch
Description: Text Data


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]