Subject: bug#23518: [PROPOSED PATCH] gzip: drop mentions of Amiga, VMS

From: Paul Eggert <[email-masked]>
Date: Wed, 11 May 2016 16:25:37 -0700

These platforms were not supported anyway, and their code was
suffering from bitrot.  This patch may also fix some file name
glitches on MS-Windowsish platforms.
* bootstrap.conf (gnulib_modules): Add dosname.
* gzip.c: Include dosname.h.
(shorten_name, treat_dir): Use last_component rather than looking
at path separators by hand.
* tailor.h: Remove sections on porting to VMS and to Amiga,
since dosname.h doesn't support these platforms anyway.
(PATH_SEP2, PATH_SEP3, STDC_HEADERS, SUFFIX_SEP, RECORD_IO)
(HAVE_CHOWN, HAVE_LSTAT, HAVE_SYS_DIR_H, direct): Remove.  All
uses removed.  Many uses replaced by calls to ISSLASH and/or
last_component.
---
 NEWS           |  5 +++++
 README         | 18 ++----------------
 TODO           |  4 +---
 bootstrap.conf |  1 +
 doc/gzip.texi  |  6 +-----
 gzip.1         |  5 -----
 gzip.c         | 43 ++++++++++++-------------------------------
 lib/match.c    |  2 +-
 tailor.h       | 58 +---------------------------------------------------------
 util.c         | 14 ++------------
 zip.c          |  4 ++--
 11 files changed, 28 insertions(+), 132 deletions(-)

diff --git a/NEWS b/NEWS
index 104c950..8c81f5c 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU gzip NEWS                                    -*- outline -*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  Support for VMS and Amiga has been removed.  It was not working anyway,
+  and it reportedly caused file name glitches on MS-Windowsish platforms.
+
 
 * Noteworthy changes in release 1.8 (2016-04-26) [stable]
 
diff --git a/README b/README
index 11e6b55..58f4959 100644
--- a/README
+++ b/README
@@ -63,24 +63,10 @@ provided as example (not installed by default since it relies on perl).
 
 gzip is free software, you can redistribute it and/or modify it under
 the terms of the GNU General Public License, a copy of which is
-provided under the name COPYING. The latest version of gzip are always
-available from ftp://ftp.gnu.org/gnu/gzip or in any of the gnu
+provided under the name COPYING. The latest version of gzip is always
+available from ftp://ftp.gnu.org/gnu/gzip or in any of the GNU
 mirror sites.
 
-- sources in gzip-*.tar (or .shar or .tar.gz).
-- MSDOS lha self-extracting exe in gzip-msdos-*.exe. Once extracted,
-  copy gzip.exe to gunzip.exe and zcat.exe, or use "gzip -d" to decompress.
-  gzip386.exe runs much faster but only on 386 and above; it was compiled with
-  djgpp 1.10 available in directory omnigate.clarkson.edu:/pub/msdos/djgpp.
-
-A VMS executable is in ftp://ftp.spc.edu/[.macro32.savesets]gzip-1-*.zip
-(use [.macro32]unzip.exe to extract). A PRIMOS executable is available
-in ftp://ftp.lysator.liu.se/pub/primos/run/gzip.run.
-
-Some ftp servers can automatically make a tar.Z from a tar file. If
-you are getting gzip for the first time, you can ask for a tar.Z file
-instead of the much larger tar file.
-
 Many thanks to those who provided me with bug reports and feedback.
 See the files THANKS and ChangeLog for more details.
 
diff --git a/TODO b/TODO
index 3a3e76b..a5b188a 100644
--- a/TODO
+++ b/TODO
@@ -2,9 +2,7 @@ TODO file for gzip.
 
 Some of the planned features include:
 
-- Remove some of the old porting cruft. since we no longer support
-  FIXME-2011: in mid to late 2011, remove the following directories:
-  amiga, atari, msdos, nt, os2, vms
+- Remove some of the old porting cruft, since we no longer support it.
 
 - Separate out the shell scripts like gzexe into a new little package;
   these scripts are less used and less reliable and should be optional.
diff --git a/bootstrap.conf b/bootstrap.conf
index 6cbaaa2..cabd650 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -25,6 +25,7 @@ announce-gen
 calloc
 close
 dirname-lgpl
+dosname
 fclose
 fcntl
 fcntl-safer
diff --git a/doc/gzip.texi b/doc/gzip.texi
index 1d8d100..c63a892 100644
--- a/doc/gzip.texi
+++ b/doc/gzip.texi
@@ -83,7 +83,7 @@ Free Documentation License''.
 @command{gzip} reduces the size of the named files using Lempel--Ziv coding
 (LZ77).  Whenever possible, each file is replaced by one with the
 extension @samp{.gz}, while keeping the same ownership modes, access and
-modification times.  (The default extension is @samp{-gz} for @abbr{VMS},
+modification times.  (The default extension is
 @samp{z} for @abbr{MSDOS}, @abbr{OS/2} @abbr{FAT} and Atari.)
 If no files are specified or
 if a file name is @file{-}, the standard input is compressed to the standard
@@ -507,10 +507,6 @@ export PATH=/usr/bin
 exec gzip -9 "$@@"
 @end example
 
-On @abbr{VMS}, the name of the obsolescent environment variable is
-@env{GZIP_OPT}, to avoid a conflict with the symbol set for invocation
-of the program.
-
 @node Tapes
 @chapter Using @command{gzip} on tapes
 @cindex tapes
diff --git a/gzip.1 b/gzip.1
index e6aa278..8abba50 100644
--- a/gzip.1
+++ b/gzip.1
@@ -31,8 +31,6 @@ each file is replaced by one with the extension
 .BR "\&.gz" ,
 while keeping the same ownership modes, access and modification times.
 (The default extension is
-.B "\-gz"
-for VMS,
 .B "z"
 for MSDOS, OS/2 FAT, Windows NT FAT and Atari.)
 If no files are specified, or if a file name is "-", the standard input is
@@ -403,9 +401,6 @@ containing the following:
       #! /bin/sh
       export PATH=/usr/bin
       exec gzip \-9 "$@"
-
-On VMS, the name of the obsolescent environment variable is GZIP_OPT, to
-avoid a conflict with the symbol set for invocation of the program.
 .SH "SEE ALSO"
 znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1)
 .PP
diff --git a/gzip.c b/gzip.c
index 4a51b13..0d0953c 100644
--- a/gzip.c
+++ b/gzip.c
@@ -43,7 +43,7 @@ static char const *const license_msg[] = {
  *     or stdout with -c option or if stdin used as input.
  * If the output file name had to be truncated, the original name is kept
  * in the compressed file.
- * On MSDOS, file.tmp -> file.tmz. On VMS, file.tmp -> file.tmp-gz.
+ * On MSDOS, file.tmp -> file.tmz.
  *
  * Using gz on MSDOS would create too many file name conflicts. For
  * example, foo.txt -> foo.tgz (.tgz must be reserved as shorthand for
@@ -71,6 +71,7 @@ static char const *const license_msg[] = {
 #include "timespec.h"
 
 #include "dirname.h"
+#include "dosname.h"
 #include "fcntl--.h"
 #include "getopt.h"
 #include "ignore-value.h"
@@ -429,7 +430,7 @@ int main (int argc, char **argv)
     program_name = gzip_base_name (argv[0]);
     proglen = strlen (program_name);
 
-    /* Suppress .exe for MSDOS, OS/2 and VMS: */
+    /* Suppress .exe for MSDOS and OS/2: */
     if (4 < proglen && strequ (program_name + proglen - 4, ".exe"))
       program_name[proglen - 4] = '\0';
 
@@ -447,7 +448,7 @@ int main (int argc, char **argv)
      * gzip even if it is invoked under the name gunzip or zcat.
      *
      * Systems which do not support links can still use -d or -dc.
-     * Ignore an .exe extension for MSDOS, OS/2 and VMS.
+     * Ignore an .exe extension for MSDOS and OS/2.
      */
     if (strncmp (program_name, "un",  2) == 0     /* ungzip, uncompress */
         || strncmp (program_name, "gun", 3) == 0) /* gunzip */
@@ -1149,8 +1150,6 @@ local int create_outfile()
  * also accepted suffixes. For Unix, we do not want to accept any
  * .??z suffix as indicating a compressed file; some people use .xyz
  * to denote volume data.
- *   On systems allowing multiple versions of the same file (such as VMS),
- * this function removes any version suffix in the given name.
  */
 local char *get_suffix(name)
     char *name;
@@ -1182,13 +1181,6 @@ local char *get_suffix(name)
                    : 0] = z_suffix;
     suf = known_suffixes + suffix_of_builtin;
 
-#ifdef SUFFIX_SEP
-    /* strip a version number from the file name */
-    {
-        char *v = strrchr(name, SUFFIX_SEP);
-        if (v != NULL) *v = '\0';
-    }
-#endif
     nlen = strlen(name);
     if (nlen <= MAX_SUFFIX+2) {
         strcpy(suffix, name);
@@ -1199,7 +1191,7 @@ local char *get_suffix(name)
     slen = strlen(suffix);
     do {
        int s = strlen(*suf);
-       if (slen > s && suffix[slen-s-1] != PATH_SEP
+       if (slen > s && ! ISSLASH (suffix[slen - s - 1])
            && strequ(suffix + slen - s, *suf)) {
            return name+nlen-s;
        }
@@ -1226,7 +1218,7 @@ open_and_stat (char *name, int flags, struct stat *st)
         flags |= O_NOFOLLOW;
       else
         {
-#if HAVE_LSTAT || defined lstat
+#ifdef S_ISLNK
           if (lstat (name, st) != 0)
             return -1;
           else if (S_ISLNK (st->st_mode))
@@ -1301,9 +1293,7 @@ open_input_file (iname, sbuf)
         progerror(ifname);
         return -1;
     }
-    /* file.ext doesn't exist, try adding a suffix (after removing any
-     * version number for VMS).
-     */
+    /* File.ext doesn't exist.  Try adding a suffix.  */
     s = get_suffix(ifname);
     if (s != NULL) {
         progerror(ifname); /* ifname already has z suffix and does not exist */
@@ -1510,7 +1500,7 @@ local int get_method(in)
     method = -1;                 /* unknown yet */
     part_nb++;                   /* number of parts in gzip file */
     header_bytes = 0;
-    last_member = RECORD_IO;
+    last_member = 0;
     /* assume multiple members in gzip file except for record oriented I/O */
 
     if (memcmp(magic, GZIP_MAGIC, 2) == 0
@@ -1753,7 +1743,7 @@ local void do_list(ifd, method)
     bytes_out = -1L;
     bytes_in = ifile_size;
 
-    if (!RECORD_IO && method == DEFLATED && !last_member) {
+    if (method == DEFLATED && !last_member) {
         /* Get the crc and uncompressed size for gzip'ed (not zip'ed) files.
          * If the lseek fails, we could use read() to get to the end, but
          * --list is used to get quick results.
@@ -1845,8 +1835,7 @@ local void shorten_name(name)
      * 1234.678.012.gz -> 123.678.012.gz
      */
     do {
-        p = strrchr(name, PATH_SEP);
-        p = p ? p+1 : name;
+        p = last_component (name);
         while (*p) {
             plen = strcspn(p, PART_SEP);
             p += plen;
@@ -2013,16 +2002,8 @@ local void treat_dir (fd, dir)
           continue;
         if (len + entrylen < MAX_PATH_LEN - 2) {
             strcpy(nbuf,dir);
-            if (len != 0 /* dir = "" means current dir on Amiga */
-#ifdef PATH_SEP2
-                && dir[len-1] != PATH_SEP2
-#endif
-#ifdef PATH_SEP3
-                && dir[len-1] != PATH_SEP3
-#endif
-            ) {
-                nbuf[len++] = PATH_SEP;
-            }
+            if (*last_component (nbuf) && !ISSLASH (nbuf[len - 1]))
+              nbuf[len++] = '/';
             strcpy (nbuf + len, entry);
             treat_file(nbuf);
         } else {
diff --git a/lib/match.c b/lib/match.c
index 41fb03e..cbafab2 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -231,7 +231,7 @@ maxmatch:
 #  define predec(An)		-(An)
 #  define postinc(An)		(An)+
 
-#else /* default style (Sun 3, NeXT, Amiga, Atari) */
+#else /* default style (Sun 3, NeXT, Atari) */
 
 #  define GLOBAL(symbol)	.globl	symbol
 #  define TEXT			.text
diff --git a/tailor.h b/tailor.h
index 1feb807..e381611 100644
--- a/tailor.h
+++ b/tailor.h
@@ -50,13 +50,10 @@
 #      define HAVE_SYS_UTIME_H
 #    endif
 #  endif
-#  define PATH_SEP2 '\\'
-#  define PATH_SEP3 ':'
 #  define MAX_PATH_LEN  128
 #  define NO_MULTIPLE_DOTS
 #  define MAX_EXT_CHARS 3
 #  define Z_SUFFIX "z"
-#  define STDC_HEADERS
 #  define NO_SIZE_CHECK
 #  define UNLINK_READONLY_BUG
 #  define casemap(c) tolow(c) /* Force file names to lower case */
@@ -71,8 +68,6 @@
 #endif
 
 #ifdef OS2
-#  define PATH_SEP2 '\\'
-#  define PATH_SEP3 ':'
 #  define MAX_PATH_LEN  260
 #  ifdef OS2FAT
 #    define NO_MULTIPLE_DOTS
@@ -80,7 +75,6 @@
 #    define Z_SUFFIX "z"
 #    define casemap(c) tolow(c)
 #  endif
-#  define STDC_HEADERS
 #  define UNLINK_READONLY_BUG
 #  include <io.h>
 #  define OS_CODE  0x06
@@ -107,12 +101,9 @@
 #  endif
 #endif
 
-#ifdef WIN32 /* Windows NT */
+#if defined WIN32 || defined _WIN32
 #  define HAVE_SYS_UTIME_H
-#  define PATH_SEP2 '\\'
-#  define PATH_SEP3 ':'
 #  define MAX_PATH_LEN  260
-#  define STDC_HEADERS
 #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
 #  define UNLINK_READONLY_BUG
 #  include <io.h>
@@ -147,49 +138,10 @@
 #  define fcfree(ptr) free(ptr)
 #endif
 
-#if defined(VAXC) || defined(VMS)
-#  define PATH_SEP ']'
-#  define PATH_SEP2 ':'
-#  define SUFFIX_SEP ';'
-#  define NO_MULTIPLE_DOTS
-#  define NO_SIZE_CHECK
-#  define Z_SUFFIX "-gz"
-#  define RECORD_IO 1
-#  define casemap(c) tolow(c)
-#  define OS_CODE  0x02
-#  define OPTIONS_VAR "GZIP_OPT"
-#  define STDC_HEADERS
-#  define EXPAND(argc,argv) vms_expand_args(&argc,&argv);
-#  include <file.h>
-#  define unlink delete
-#  ifdef VAXC
-#    include <unixio.h>
-#  endif
-#endif
-
-#ifdef AMIGA
-#  define PATH_SEP2 ':'
-#  define STDC_HEADERS
-#  define OS_CODE  0x01
-#  define ASMV
-#  ifdef __GNUC__
-#    define HAVE_CHOWN
-#    define HAVE_LSTAT
-#  else /* SASC */
-#    define HAVE_SYS_DIR_H
-#    include <fcntl.h> /* for read() and write() */
-#    define direct dirent
-     extern void _expand_args(int *argc, char ***argv);
-#    define EXPAND(argc,argv) _expand_args(&argc,&argv);
-#  endif
-#endif
-
 #if defined(ATARI) || defined(atarist)
 #  define ASMV
 #  define OS_CODE  0x05
 #  ifdef TOSFS
-#    define PATH_SEP2 '\\'
-#    define PATH_SEP3 ':'
 #    define MAX_PATH_LEN  128
 #    define NO_MULTIPLE_DOTS
 #    define MAX_EXT_CHARS 3
@@ -213,10 +165,6 @@
 #  define OS_CODE  0x03  /* assume Unix */
 #endif
 
-#ifndef PATH_SEP
-#  define PATH_SEP '/'
-#endif
-
 #ifndef casemap
 #  define casemap(c) (c)
 #endif
@@ -252,10 +200,6 @@
 #  define EXPAND(argc,argv)
 #endif
 
-#ifndef RECORD_IO
-#  define RECORD_IO 0
-#endif
-
 #ifndef SET_BINARY_MODE
 #  define SET_BINARY_MODE(fd)
 #endif
diff --git a/util.c b/util.c
index c06bcc4..4790be0 100644
--- a/util.c
+++ b/util.c
@@ -29,6 +29,7 @@
 
 #include "tailor.h"
 #include "gzip.h"
+#include <dirname.h>
 #include <xalloc.h>
 
 #ifndef CHAR_BIT
@@ -299,18 +300,7 @@ char *
 gzip_base_name (fname)
     char *fname;
 {
-    char *p;
-
-    if ((p = strrchr(fname, PATH_SEP))  != NULL) fname = p+1;
-#ifdef PATH_SEP2
-    if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1;
-#endif
-#ifdef PATH_SEP3
-    if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1;
-#endif
-#ifdef SUFFIX_SEP
-    if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0';
-#endif
+    fname = last_component (fname);
     if (casemap('A') == 'a') strlwr(fname);
     return fname;
 }
diff --git a/zip.c b/zip.c
index 178bfd0..793cf42 100644
--- a/zip.c
+++ b/zip.c
@@ -80,8 +80,8 @@ int zip(in, out)
     (void)deflate();
 
 #ifndef NO_SIZE_CHECK
-  /* Check input size (but not in VMS -- variable record lengths mess it up)
-   * and not on MSDOS -- diet in TSR mode reports an incorrect file size)
+  /* Check input size
+   * (but not on MSDOS -- diet in TSR mode reports an incorrect file size)
    */
     if (ifile_size != -1L && bytes_in != ifile_size) {
         fprintf(stderr, "%s: %s: file size changed while zipping\n",
-- 
2.5.5