2002-05-11  Juan Manuel Guerrero  <st001906@hrz1.hrz.tu-darmstadt.de>

	*** far from be complete. ***

	* gzexe.in: DJGPP support added.
	Honour TMPDIR. If TMPDIR not pointing to a valid dir,
	use the working dir (DJGPP only).
	Look for the used binaries at /dev/env/DJDIR.
	New variables exe, pathsep and suffix.
	Other misc. issues concerning appropiate SFN handling.

	* gzip.c [PART_SEP]: Only define it if not defined previously.
	(get_suffix) [MAX_EXT_CHARS]: New array known_dosish_suffixes.
	(get_suffix) [MAX_EXT_CHARS]: If the file name doesn't have a dot
	in its basename, don't check the DOSish suffixes.
	(get_suffix) [MAX_EXT_CHARS] [HAVE_LONG_NAMES]: If long file names are
	 supported, only check DOSish truncated suffixes when decompressing.
	(get_istat): For systems that disallow multiple dots, remove the dot
	from each suffix we try if ifname already has a dot in its basename.
	DJGPP supports long file names when they are available (Windows 9X),
	so we try both the normal concatenation, like .tar.gz, and the DOS-ish
	truncated .tgz etc.; this will make happy those people who move DOS
	files to Windows filesystems or set up dual-boot DOS/Windows systems.
	(make_ofname) [HAVE_LONG_NAMES]: DJGPP port of gzip will decide at
	runtime if LFN or SFN will be used.

	* gzip.h [HAVE_TIME_H]: Look for time_t definition in time.h or
	sys/time.h if not found in sys/types.h.

	* msdos/tailor.c [DJGPP] (make_valid_dosw32_name): New function.
	Replace characters that aren't allowed in file names, and rename
	files whose names are reserved by character device drivers.

	* tailor.h: New macros for DJGPP 2.x support.

	* util.c (base_name): DJGPP support added.

	* zdiff.in: DJGPP support added.
	Honour TMPDIR. If TMPDIR not pointing to a valid dir,
	use the working dir (DJGPP only).
	New variable pathsep for use in PATH.

	* zgrep.in: DJGPP support added.
	New variable pathsep for use in PATH.

	* zless.in: DJGPP support added.
	New variable pathsep for use in PATH.

	* zmore.in: DJGPP support added.
	New variable pathsep for use in PATH.

	* znew.in: DJGPP support added.
	Honour TMPDIR. If TMPDIR not pointing to a valid dir,
	use the working dir (DJGPP only).
	New variable pathsep for use in PATH.



diff -acprNC5 gzip-1.3.3.orig/gzexe.in gzip-1.3.3.djgpp/gzexe.in
*** gzip-1.3.3.orig/gzexe.in	Fri Sep 18 00:43:06 1998
--- gzip-1.3.3.djgpp/gzexe.in	Sat May 11 20:30:10 2002
*************** if test $# = 0; then
*** 19,28 ****
--- 19,52 ----
    echo usage: ${x} [-d] files...
    echo   "   -d  decompress the executables"
    exit 1
  fi
  
+ tmpdir=${TMPDIR-/tmp}
+ if test ! -d "$tmpdir"; then
+   tmpdir=.
+ fi
+ 
+ CHMOD=/bin/chmod
+ LN=/bin/ln
+ RM=/bin/rm
+ SED=/bin/sed
+ SLEEP=/bin/sleep
+ pathsep=:
+ exe=
+ suffix=~
+ if test -n "$DJGPP$djgpp"; then
+   CHMOD=/dev/env/DJDIR/chmod
+   LN=/dev/env/DJDIR/ln
+   RM=/dev/env/DJDIR/rm
+   SED=/dev/env/DJDIR/sed
+   SLEEP=/dev/env/DJDIR/sleep
+   pathsep=";"
+   exe=.exe
+   suffix=.~
+ fi
+ 
  tmp=gz$$
  trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15
  
  decomp=0
  res=0
*************** test "$x" = "ungzexe" && decomp=1
*** 30,52 ****
  if test "x$1" = "x-d"; then
    decomp=1
    shift
  fi
  
! echo hi > zfoo1$$
! echo hi > zfoo2$$
! if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then
    cpmod=${CPMOD-cpmod}
  fi
! rm -f zfoo[12]$$
  
  tail=""
! IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
!   if test -f $dir/tail; then
!     tail="$dir/tail"
      break
    fi
  done
  IFS="$saveifs"
  if test -z "$tail"; then
--- 54,76 ----
  if test "x$1" = "x-d"; then
    decomp=1
    shift
  fi
  
! echo hi > zfoo$$.1
! echo hi > zfoo$$.2
! if test -z "`(${CPMOD-cpmod} zfoo$$.1 zfoo$$.2) 2>&1`"; then
    cpmod=${CPMOD-cpmod}
  fi
! rm -f zfoo$$.[12]
  
  tail=""
! IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}${pathsep}"
  for dir in $PATH; do
    test -z "$dir" && dir=.
!   if test -f "$dir/tail${exe}"; then
!     tail="$dir/tail${exe}"
      break
    fi
  done
  IFS="$saveifs"
  if test -z "$tail"; then
*************** for i do
*** 92,120 ****
      sed "s|^if tail|if $tail|" >> $tmp <<'EOF'
  skip=22
  set -C
  umask=`umask`
  umask 77
! if tail +$skip $0 | "BINDIR"/gzip -cd > /tmp/gztmp$$; then
    umask $umask
!   /bin/chmod 700 /tmp/gztmp$$
!   prog="`echo $0 | /bin/sed 's|^.*/||'`"
!   if /bin/ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then
!     trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0
!     (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null &
!     /tmp/"$prog" ${1+"$@"}; res=$?
    else
!     trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0
!     (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null &
!     /tmp/gztmp$$ ${1+"$@"}; res=$?
    fi
  else
    echo Cannot decompress $0; exit 1
  fi; exit $res
  EOF
      gzip -cv9 "$i" >> $tmp || {
!       /bin/rm -f $tmp
        echo ${x}: compression not possible for $i, file unchanged.
        res=1
        continue
      }
  
--- 116,144 ----
      sed "s|^if tail|if $tail|" >> $tmp <<'EOF'
  skip=22
  set -C
  umask=`umask`
  umask 77
! if tail +$skip $0 | "BINDIR"/gzip -cd > "$tmpdir"/gztmp$$; then
    umask $umask
!   "$CHMOD" 700 "$tmpdir"/gztmp$$
!   prog="`echo $0 | "$SED" 's|^.*/||'`"
!   if "$LN" "$tmpdir"/gztmp$$ "$tmpdir/$prog" 2>/dev/null; then
!     trap '"$RM" -f "$tmpdir"/gztmp$$ "$tmpdir/$prog"; exit $res' 0
!     ("$SLEEP" 5; "$RM" -f "$tmpdir"/gztmp$$ "$tmpdir/$prog") 2>/dev/null &
!     "$tmpdir"/"$prog" ${1+"$@"}; res=$?
    else
!     trap '"$RM" -f "$tmpdir"/gztmp$$; exit $res' 0
!     ("$SLEEP" 5; "$RM" -f "$tmpdir"/gztmp$$) 2>/dev/null &
!     "$tmpdir"/gztmp$$ ${1+"$@"}; res=$?
    fi
  else
    echo Cannot decompress $0; exit 1
  fi; exit $res
  EOF
      gzip -cv9 "$i" >> $tmp || {
!       "$RM" -f $tmp
        echo ${x}: compression not possible for $i, file unchanged.
        res=1
        continue
      }
  
*************** EOF
*** 130,142 ****
        echo ${x}: $i probably not in gzexe format, file unchanged.
        res=1
        continue
      fi
    fi
!   rm -f "$i~"
!   mv "$i" "$i~" || {
!     echo ${x}: cannot backup $i as $i~
      rm -f $tmp
      res=1
      continue
    }
    mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || {
--- 154,166 ----
        echo ${x}: $i probably not in gzexe format, file unchanged.
        res=1
        continue
      fi
    fi
!   rm -f "$i$suffix"
!   mv "$i" "$i$suffix" || {
!     echo ${x}: cannot backup $i as $i$suffix
      rm -f $tmp
      res=1
      continue
    }
    mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || {
*************** EOF
*** 145,155 ****
      res=1
      continue
    }
    rm -f $tmp
    if test -n "$cpmod"; then
!     $cpmod "$i~" "$i" 2>/dev/null
    elif test $writable -eq 0; then
      chmod u-w $i 2>/dev/null
    fi
  done
  exit $res
--- 169,179 ----
      res=1
      continue
    }
    rm -f $tmp
    if test -n "$cpmod"; then
!     $cpmod "$i$suffix" "$i" 2>/dev/null
    elif test $writable -eq 0; then
      chmod u-w $i 2>/dev/null
    fi
  done
  exit $res
diff -acprNC5 gzip-1.3.3.orig/gzip.c gzip-1.3.3.djgpp/gzip.c
*** gzip-1.3.3.orig/gzip.c	Sat Mar  9 00:38:14 2002
--- gzip-1.3.3.djgpp/gzip.c	Sat May 11 20:30:10 2002
*************** typedef RETSIGTYPE (*sig_type) OF((int))
*** 186,198 ****
  #define OFF_T_MAX (~ (off_t) 0 - OFF_T_MIN)
  #endif
  
  /* Separator for file name parts (see shorten_name()) */
  #ifdef NO_MULTIPLE_DOTS
! #  define PART_SEP "-"
  #else
! #  define PART_SEP "."
  #endif
  
  		/* global buffers */
  
  DECLARE(uch, inbuf,  INBUFSIZ +INBUF_EXTRA);
--- 186,202 ----
  #define OFF_T_MAX (~ (off_t) 0 - OFF_T_MIN)
  #endif
  
  /* Separator for file name parts (see shorten_name()) */
  #ifdef NO_MULTIPLE_DOTS
! #  ifndef PART_SEP
! #    define PART_SEP "-"
! #  endif
  #else
! #  ifndef PART_SEP
! #    define PART_SEP "."
! #  endif
  #endif
  
  		/* global buffers */
  
  DECLARE(uch, inbuf,  INBUFSIZ +INBUF_EXTRA);
*************** local char *get_suffix(name)
*** 1000,1014 ****
      char *name;
  {
      int nlen, slen;
      char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */
      static char *known_suffixes[] =
!        {NULL, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z",
  #ifdef MAX_EXT_CHARS
!           "z",
  #endif
-           NULL};
      char **suf = known_suffixes;
  
      *suf = z_suffix;
      if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */
  
--- 1004,1017 ----
      char *name;
  {
      int nlen, slen;
      char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */
      static char *known_suffixes[] =
!        {NULL, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z", NULL};
  #ifdef MAX_EXT_CHARS
!     static char *known_dosish_suffixes[] = {"gz", "z", NULL};
  #endif
      char **suf = known_suffixes;
  
      *suf = z_suffix;
      if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */
  
*************** local char *get_suffix(name)
*** 1032,1051 ****
         if (slen > s && suffix[slen-s-1] != PATH_SEP
             && strequ(suffix + slen - s, *suf)) {
             return name+nlen-s;
         }
      } while (*++suf != NULL);
  
      return NULL;
  }
  
  
  /* ========================================================================
   * Set ifname to the input file name (with a suffix appended if necessary)
   * and istat to its stats. For decompression, if no file exists with the
   * original name, try adding successively z_suffix, .gz, .z, -z and .Z.
!  * For MSDOS, we try only z_suffix and z.
   * Return OK or ERROR.
   */
  local int get_istat(iname, sbuf)
      char *iname;
      struct stat *sbuf;
--- 1035,1086 ----
         if (slen > s && suffix[slen-s-1] != PATH_SEP
             && strequ(suffix + slen - s, *suf)) {
             return name+nlen-s;
         }
      } while (*++suf != NULL);
+ #ifdef MAX_EXT_CHARS
+ # ifdef HAVE_LONG_NAMES
+     /* If long file names are supported, only check DOSish
+        truncated suffixes when decompressing.  This allows to
+        compress, e.g., foo.baz into foo.baz.gz instead of punting.  */
+     {
+        int e = errno;	/* HAVE_LONG_NAMES might set errno */
+        if (HAVE_LONG_NAMES(name) && !decompress) {
+          errno = e;
+          return NULL;
+        }
+        errno = e;
+     }
+ # endif /* HAVE_LONG_NAMES */
+     /* If the file name doesn't have a dot in its basename, don't
+        check the DOSish suffixes.  This allows to compress foobaz
+        into foobaz.gz and decompress it back.  */
+     if (strchr(base_name(name), '.') == NULL)
+       return NULL;
+     suf = known_dosish_suffixes;
+     do {
+       int s = strlen(*suf);
+       if (slen > s && suffix[slen-s-1] != PATH_SEP
+           && strequ(suffix + slen - s, *suf))
+          return name+nlen-s;
+     } while (*++suf != NULL);
+ #endif /* MAX_EXT_CHARS */
  
      return NULL;
  }
  
  
  /* ========================================================================
   * Set ifname to the input file name (with a suffix appended if necessary)
   * and istat to its stats. For decompression, if no file exists with the
   * original name, try adding successively z_suffix, .gz, .z, -z and .Z.
!  * For systems that disallow multiple dots, remove the dot from each
!  * suffix we try if ifname already has a dot in its basename.
!  * DJGPP supports long file names when they are available (Windows 9X), so
!  * we try both the normal concatenation, like .tar.gz, and the DOS-ish
!  * truncated .tgz etc.; this will make happy those people who move DOS
!  * files to Windows filesystems or set up dual-boot DOS/Windows systems.
   * Return OK or ERROR.
   */
  local int get_istat(iname, sbuf)
      char *iname;
      struct stat *sbuf;
*************** local int get_istat(iname, sbuf)
*** 1053,1064 ****
      int ilen;  /* strlen(ifname) */
      int z_suffix_errno = 0;
      static char *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
      char **suf = suffixes;
      char *s;
! #ifdef NO_MULTIPLE_DOTS
!     char *dot; /* pointer to ifname extension, or NULL */
  #endif
  
      *suf = z_suffix;
  
      if (sizeof ifname - 1 <= strlen (iname))
--- 1088,1099 ----
      int ilen;  /* strlen(ifname) */
      int z_suffix_errno = 0;
      static char *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
      char **suf = suffixes;
      char *s;
! #if defined(MAX_EXT_CHARS) || defined(NO_MULTIPLE_DOTS)
!     char *dot = NULL; /* pointer to ifname extension, or NULL */
  #endif
  
      *suf = z_suffix;
  
      if (sizeof ifname - 1 <= strlen (iname))
*************** local int get_istat(iname, sbuf)
*** 1079,1102 ****
      s = get_suffix(ifname);
      if (s != NULL) {
  	progerror(ifname); /* ifname already has z suffix and does not exist */
  	return ERROR;
      }
- #ifdef NO_MULTIPLE_DOTS
-     dot = strrchr(ifname, '.');
-     if (dot == NULL) {
-         strcat(ifname, ".");
-         dot = strrchr(ifname, '.');
-     }
- #endif
      ilen = strlen(ifname);
!     if (strequ(z_suffix, ".gz")) suf++;
  
      /* Search for all suffixes */
      do {
          char *s0 = s = *suf;
          strcpy (ifname, iname);
  #ifdef NO_MULTIPLE_DOTS
          if (*s == '.') s++;
          if (*dot == '\0') strcpy (dot, ".");
  #endif
  #ifdef MAX_EXT_CHARS
--- 1114,1140 ----
      s = get_suffix(ifname);
      if (s != NULL) {
  	progerror(ifname); /* ifname already has z suffix and does not exist */
  	return ERROR;
      }
      ilen = strlen(ifname);
! #if defined(MAX_EXT_CHARS) || defined(NO_MULTIPLE_DOTS)
!     dot = strrchr(base_name(ifname), '.');
!     if (dot == NULL)
!       dot = ifname + ilen;
! #endif
!     if (strequ(z_suffix, suffixes[1])) suf++;
  
      /* Search for all suffixes */
      do {
          char *s0 = s = *suf;
          strcpy (ifname, iname);
+ #ifdef LONG_FILE_NAMES
+         strcat(ifname, s);
+         if (do_stat(ifname, sbuf) == 0) return OK;
+         ifname[ilen] = '\0';
+ #endif
  #ifdef NO_MULTIPLE_DOTS
          if (*s == '.') s++;
          if (*dot == '\0') strcpy (dot, ".");
  #endif
  #ifdef MAX_EXT_CHARS
*************** local int get_istat(iname, sbuf)
*** 1112,1122 ****
      } while (*++suf != NULL);
  
      /* No suffix found, complain using z_suffix: */
      strcpy(ifname, iname);
  #ifdef NO_MULTIPLE_DOTS
!     if (*dot == '\0') strcpy(dot, ".");
  #endif
  #ifdef MAX_EXT_CHARS
      if (MAX_EXT_CHARS < z_len + strlen (dot + 1))
        dot[MAX_EXT_CHARS + 1 - z_len] = '\0';
  #endif
--- 1150,1160 ----
      } while (*++suf != NULL);
  
      /* No suffix found, complain using z_suffix: */
      strcpy(ifname, iname);
  #ifdef NO_MULTIPLE_DOTS
!     if (*dot == '\0' && z_suffix[0] != '.') strcpy(dot, ".");
  #endif
  #ifdef MAX_EXT_CHARS
      if (MAX_EXT_CHARS < z_len + strlen (dot + 1))
        dot[MAX_EXT_CHARS + 1 - z_len] = '\0';
  #endif
*************** local int make_ofname()
*** 1172,1209 ****
  	    WARN((stderr, "%s: %s already has %s suffix -- unchanged\n",
  		  progname, ifname, suff));
  	}
  	return WARNING;
      } else {
          save_orig_name = 0;
  
! #ifdef NO_MULTIPLE_DOTS
! 	suff = strrchr(ofname, '.');
  	if (suff == NULL) {
  	    if (sizeof ofname <= strlen (ofname) + 1)
  		goto name_too_long;
              strcat(ofname, ".");
  #  ifdef MAX_EXT_CHARS
! 	    if (strequ(z_suffix, "z")) {
  		if (sizeof ofname <= strlen (ofname) + 2)
  		    goto name_too_long;
  		strcat(ofname, "gz"); /* enough room */
  		return OK;
  	    }
          /* On the Atari and some versions of MSDOS, name_too_long()
           * does not work correctly because of a bug in stat(). So we
           * must truncate here.
           */
!         } else if (strlen(suff)-1 + z_len > MAX_SUFFIX) {
!             suff[MAX_SUFFIX+1-z_len] = '\0';
              save_orig_name = 1;
  #  endif
          }
  #endif /* NO_MULTIPLE_DOTS */
! 	if (sizeof ofname <= strlen (ofname) + z_len)
  	    goto name_too_long;
! 	strcat(ofname, z_suffix);
  
      } /* decompress ? */
      return OK;
  
   name_too_long:
--- 1210,1264 ----
  	    WARN((stderr, "%s: %s already has %s suffix -- unchanged\n",
  		  progname, ifname, suff));
  	}
  	return WARNING;
      } else {
+         char *z_suff = z_suffix;
+         int z_length = z_len;
+ 
          save_orig_name = 0;
  
! #if defined(NO_MULTIPLE_DOTS) || defined(MAX_EXT_CHARS)
! #  ifdef HAVE_LONG_NAMES
!         /* This is for systems where the availability of the long file name
!            support is only known at run time, and depends on the filesystem
!            where the target file OFNAME will be written.  DJGPP running on
!            Windows 9X is an example of such a system.  */
!         if (HAVE_LONG_NAMES(ofname)) {
!             strcat(ofname, z_suff);
!             return OK;
!         }
! #  endif
! 	if (*z_suff == '.') {
! 	    z_suff++;
! 	    z_length--;
! 	}
! 	suff = strrchr(base_name(ofname), '.');
  	if (suff == NULL) {
  	    if (sizeof ofname <= strlen (ofname) + 1)
  		goto name_too_long;
              strcat(ofname, ".");
  #  ifdef MAX_EXT_CHARS
! 	    if (strequ(z_suff, "z")) {
  		if (sizeof ofname <= strlen (ofname) + 2)
  		    goto name_too_long;
  		strcat(ofname, "gz"); /* enough room */
  		return OK;
  	    }
          /* On the Atari and some versions of MSDOS, name_too_long()
           * does not work correctly because of a bug in stat(). So we
           * must truncate here.
           */
!         } else if (strlen(suff)-1 + z_length > MAX_SUFFIX) {
!             suff[MAX_SUFFIX+1-z_length] = '\0';
              save_orig_name = 1;
  #  endif
          }
  #endif /* NO_MULTIPLE_DOTS */
! 	if (sizeof ofname <= strlen (ofname) + z_length)
  	    goto name_too_long;
! 	strcat(ofname, z_suff);
  
      } /* decompress ? */
      return OK;
  
   name_too_long:
*************** local int name_too_long(name, statb)
*** 1536,1550 ****
      char *name;           /* file name to check */
      struct stat *statb;   /* stat buf for this file name */
  {
      int s = strlen(name);
      char c = name[s-1];
!     struct stat	tstat; /* stat for truncated name */
      int res;
  
      tstat = *statb;      /* Just in case OS does not fill all fields */
!     name[s-1] = '\0';
      res = stat(name, &tstat) == 0 && same_file(statb, &tstat);
      name[s-1] = c;
      Trace((stderr, " too_long(%s) => %d\n", name, res));
      return res;
  }
--- 1591,1616 ----
      char *name;           /* file name to check */
      struct stat *statb;   /* stat buf for this file name */
  {
      int s = strlen(name);
      char c = name[s-1];
!     struct stat	tstat; /* stat buf for a file name with last char replaced */
      int res;
  
      tstat = *statb;      /* Just in case OS does not fill all fields */
!     /* Windows 9X VFAT and NTFS filesystems create two names for each
!        file: the original long name, and a short 8+3 alias (for consumption
!        by legacy DOS programs).  In some cases, the short alias is a proper
!        truncation of the long name; for example, `foobar.shar' gets an
!        alias `foobar.sha', and both names point to the same file.  For this
!        reason, checking whether a truncated name points to the same file
!        will produce false alarms for some file names.  To work around these
!        cases, we instead REPLACE the last character of the original file
!        name with a different character and stat the name thus produced to see
!        whether it points to the same file.  The replacement character is
!        deliberately chosen to be one that should be allowed on every OS.  */
!     name[s-1] = c == 'a' ? 'b' : 'a';
      res = stat(name, &tstat) == 0 && same_file(statb, &tstat);
      name[s-1] = c;
      Trace((stderr, " too_long(%s) => %d\n", name, res));
      return res;
  }
*************** local void shorten_name(name)
*** 1585,1596 ****
      }
      /* Try keeping short extensions intact:
       * 1234.678.012.gz -> 123.678.012.gz
       */
      do {
! 	p = strrchr(name, PATH_SEP);
! 	p = p ? p+1 : name;
  	while (*p) {
  	    plen = strcspn(p, PART_SEP);
  	    p += plen;
  	    if (plen > min_part) trunc = p-1;
  	    if (*p) p++;
--- 1651,1661 ----
      }
      /* Try keeping short extensions intact:
       * 1234.678.012.gz -> 123.678.012.gz
       */
      do {
! 	p = base_name(name);
  	while (*p) {
  	    plen = strcspn(p, PART_SEP);
  	    p += plen;
  	    if (plen > min_part) trunc = p-1;
  	    if (*p) p++;
*************** local void shorten_name(name)
*** 1601,1611 ****
  	do {
  	    trunc[0] = trunc[1];
  	} while (*trunc++);
  	trunc--;
      } else {
! 	trunc = strrchr(name, PART_SEP[0]);
  	if (trunc == NULL) error("internal error in shorten_name");
  	if (trunc[1] == '\0') trunc--; /* force truncation */
      }
      strcpy(trunc, z_suffix);
  }
--- 1666,1676 ----
  	do {
  	    trunc[0] = trunc[1];
  	} while (*trunc++);
  	trunc--;
      } else {
! 	trunc = strrchr(base_name(name), PART_SEP[0]);
  	if (trunc == NULL) error("internal error in shorten_name");
  	if (trunc[1] == '\0') trunc--; /* force truncation */
      }
      strcpy(trunc, z_suffix);
  }
diff -acprNC5 gzip-1.3.3.orig/gzip.h gzip-1.3.3.djgpp/gzip.h
*** gzip-1.3.3.orig/gzip.h	Mon Oct  1 05:24:52 2001
--- gzip-1.3.3.djgpp/gzip.h	Sat May 11 20:30:10 2002
***************
*** 19,29 ****
  
  /* I don't like nested includes, but the following headers are used
   * too often
   */
  #include <stdio.h>
! #include <sys/types.h> /* for off_t, time_t */
  #if defined HAVE_STRING_H || defined STDC_HEADERS
  #  include <string.h>
  #  if !defined STDC_HEADERS && defined HAVE_MEMORY_H && !defined __GNUC__
  #    include <memory.h>
  #  endif
--- 19,34 ----
  
  /* I don't like nested includes, but the following headers are used
   * too often
   */
  #include <stdio.h>
! #include <sys/types.h>  /* for off_t, time_t */
! #ifdef HAVE_TIME_H
! #  include <time.h>     /* some systems only have time_t here */
! #else
! #  include <sys/time.h> /* some systems only have time_t here */
! #endif
  #if defined HAVE_STRING_H || defined STDC_HEADERS
  #  include <string.h>
  #  if !defined STDC_HEADERS && defined HAVE_MEMORY_H && !defined __GNUC__
  #    include <memory.h>
  #  endif
diff -acprNC5 gzip-1.3.3.orig/gzip.texi gzip-1.3.3.djgpp/gzip.texi
*** gzip-1.3.3.orig/gzip.texi	Sat Mar  9 00:49:50 2002
--- gzip-1.3.3.djgpp/gzip.texi	Sat May 11 20:30:10 2002
*************** This file documents the @code{gzip} comm
*** 88,111 ****
  @chapter Overview
  @cindex overview
  
  @code{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 VMS,
! @samp{z} for MSDOS, OS/2 FAT and Atari.)  If no files are specified or
  if a file name is "-", the standard input is compressed to the standard
  output. @code{gzip} will only attempt to compress regular files.  In
  particular, it will ignore symbolic links.
  
  If the new file name is too long for its file system, @code{gzip}
  truncates it.  @code{gzip} attempts to truncate only the parts of the
  file name longer than 3 characters.  (A part is delimited by dots.) If
  the name consists of small parts only, the longest parts are truncated.
! For example, if file names are limited to 14 characters, gzip.msdos.exe
! is compressed to gzi.msd.exe.gz.  Names are not truncated on systems
! which do not have a limit on file name length.
  
  By default, @code{gzip} keeps the original file name and timestamp in
  the compressed file. These are used when decompressing the file with the
  @samp{-N} option. This is useful when the compressed file name was
  truncated or when the time stamp was not preserved after a file
--- 88,111 ----
  @chapter Overview
  @cindex overview
  
  @code{gzip} reduces the size of the named files using Lempel-Ziv coding
  (LZ77).  Whenever possible, each file is replaced by one with the
! extension @file{.gz}, while keeping the same ownership modes, access and
! modification times.  (The default extension is @file{-gz} for VMS,
! @file{z} for MSDOS, OS/2 FAT and Atari.)  If no files are specified or
  if a file name is "-", the standard input is compressed to the standard
  output. @code{gzip} will only attempt to compress regular files.  In
  particular, it will ignore symbolic links.
  
  If the new file name is too long for its file system, @code{gzip}
  truncates it.  @code{gzip} attempts to truncate only the parts of the
  file name longer than 3 characters.  (A part is delimited by dots.) If
  the name consists of small parts only, the longest parts are truncated.
! For example, if file names are limited to 14 characters,
! @file{gzip.msdos.exe} is compressed to @file{gzi.msd.exe.gz}.  Names are
! not truncated on systems which do not have a limit on file name length.
  
  By default, @code{gzip} keeps the original file name and timestamp in
  the compressed file. These are used when decompressing the file with the
  @samp{-N} option. This is useful when the compressed file name was
  truncated or when the time stamp was not preserved after a file
*************** Compressed files can be restored to thei
*** 115,141 ****
  or @code{gunzip} or @code{zcat}.  If the original name saved in the
  compressed file is not suitable for its file system, a new name is
  constructed from the original one to make it legal.
  
  @code{gunzip} takes a list of files on its command line and replaces
! each file whose name ends with @samp{.gz}, @samp{.z}, @samp{.Z},
! @samp{-gz}, @samp{-z} or @samp{_z} and which begins with the correct
  magic number with an uncompressed file without the original extension.
! @code{gunzip} also recognizes the special extensions @samp{.tgz} and
! @samp{.taz} as shorthands for @samp{.tar.gz} and @samp{.tar.Z}
! respectively. When compressing, @code{gzip} uses the @samp{.tgz}
! extension if necessary instead of truncating a file with a @samp{.tar}
  extension.
  
  @code{gunzip} can currently decompress files created by @code{gzip},
  @code{zip}, @code{compress} or @code{pack}. The detection of the input
  format is automatic.  When using the first two formats, @code{gunzip}
  checks a 32 bit CRC (cyclic redundancy check). For @code{pack},
  @code{gunzip} checks the uncompressed length. The @code{compress} format
  was not designed to allow consistency checks. However @code{gunzip} is
! sometimes able to detect a bad @samp{.Z} file. If you get an error when
! uncompressing a @samp{.Z} file, do not assume that the @samp{.Z} file is
  correct simply because the standard @code{uncompress} does not complain.
  This generally means that the standard @code{uncompress} does not check
  its input, and happily generates garbage output.  The SCO @samp{compress
  -H} format (@code{lzh} compression method) does not include a CRC but
  also allows some consistency checks.
--- 115,141 ----
  or @code{gunzip} or @code{zcat}.  If the original name saved in the
  compressed file is not suitable for its file system, a new name is
  constructed from the original one to make it legal.
  
  @code{gunzip} takes a list of files on its command line and replaces
! each file whose name ends with @file{.gz}, @file{.z}, @file{.Z},
! @file{-gz}, @file{-z} or @file{_z} and which begins with the correct
  magic number with an uncompressed file without the original extension.
! @code{gunzip} also recognizes the special extensions @file{.tgz} and
! @file{.taz} as shorthands for @file{.tar.gz} and @file{.tar.Z}
! respectively. When compressing, @code{gzip} uses the @file{.tgz}
! extension if necessary instead of truncating a file with a @file{.tar}
  extension.
  
  @code{gunzip} can currently decompress files created by @code{gzip},
  @code{zip}, @code{compress} or @code{pack}. The detection of the input
  format is automatic.  When using the first two formats, @code{gunzip}
  checks a 32 bit CRC (cyclic redundancy check). For @code{pack},
  @code{gunzip} checks the uncompressed length. The @code{compress} format
  was not designed to allow consistency checks. However @code{gunzip} is
! sometimes able to detect a bad @file{.Z} file. If you get an error when
! uncompressing a @file{.Z} file, do not assume that the @file{.Z} file is
  correct simply because the standard @code{uncompress} does not complain.
  This generally means that the standard @code{uncompress} does not check
  its input, and happily generates garbage output.  The SCO @samp{compress
  -H} format (@code{lzh} compression method) does not include a CRC but
  also allows some consistency checks.
*************** members, use @code{unzip} instead of @co
*** 148,158 ****
  
  @code{zcat} is identical to @samp{gunzip -c}.  @code{zcat}
  uncompresses either a list of files on the command line or its standard
  input and writes the uncompressed data on standard output.  @code{zcat}
  will uncompress files that have the correct magic number whether they
! have a @samp{.gz} suffix or not.
  
  @code{gzip} uses the Lempel-Ziv algorithm used in @code{zip} and PKZIP.
  The amount of compression obtained depends on the size of the input and
  the distribution of common substrings.  Typically, text such as source
  code or English is reduced by 60-70%.  Compression is generally much
--- 148,158 ----
  
  @code{zcat} is identical to @samp{gunzip -c}.  @code{zcat}
  uncompresses either a list of files on the command line or its standard
  input and writes the uncompressed data on standard output.  @code{zcat}
  will uncompress files that have the correct magic number whether they
! have a @file{.gz} suffix or not.
  
  @code{gzip} uses the Lempel-Ziv algorithm used in @code{zip} and PKZIP.
  The amount of compression obtained depends on the size of the input and
  the distribution of common substrings.  Typically, text such as source
  code or English is reduced by 60-70%.  Compression is generally much
*************** uncompressed size: size of the uncompres
*** 273,283 ****
  ratio: compression ratio (0.0% if unknown)
  uncompressed_name: name of the uncompressed file
  @end example
  
  The uncompressed size is given as @samp{-1} for files not in @code{gzip}
! format, such as compressed @samp{.Z} files. To get the uncompressed size for
  such a file, you can use:
  
  @example
  zcat file.Z | wc -c
  @end example
--- 273,283 ----
  ratio: compression ratio (0.0% if unknown)
  uncompressed_name: name of the uncompressed file
  @end example
  
  The uncompressed size is given as @samp{-1} for files not in @code{gzip}
! format, such as compressed @file{.Z} files. To get the uncompressed size for
  such a file, you can use:
  
  @example
  zcat file.Z | wc -c
  @end example
*************** specified on the command line are direct
*** 340,360 ****
  into the directory and compress all the files it finds there (or
  decompress them in the case of @code{gunzip}).
  
  @item --suffix @var{suf}
  @itemx -S @var{suf}
! Use suffix @samp{@var{suf}} instead of @samp{.gz}. Any suffix can be
! given, but suffixes other than @samp{.z} and @samp{.gz} should be
  avoided to avoid confusion when files are transferred to other systems.
  A null suffix forces gunzip to try decompression on all given files
  regardless of suffix, as in:
  
  @example
  gunzip -S "" *        (*.* for MSDOS)
  @end example
  
! Previous versions of gzip used the @samp{.z} suffix. This was changed to
  avoid a conflict with @code{pack}.
  
  @item --test
  @itemx -t
  Test. Check the compressed file integrity.
--- 340,360 ----
  into the directory and compress all the files it finds there (or
  decompress them in the case of @code{gunzip}).
  
  @item --suffix @var{suf}
  @itemx -S @var{suf}
! Use suffix @file{@var{suf}} instead of @file{.gz}. Any suffix can be
! given, but suffixes other than @file{.z} and @file{.gz} should be
  avoided to avoid confusion when files are transferred to other systems.
  A null suffix forces gunzip to try decompression on all given files
  regardless of suffix, as in:
  
  @example
  gunzip -S "" *        (*.* for MSDOS)
  @end example
  
! Previous versions of gzip used the @file{.z} suffix. This was changed to
  avoid a conflict with @code{pack}.
  
  @item --test
  @itemx -t
  Test. Check the compressed file integrity.
*************** is equivalent to
*** 405,415 ****
  
  @example
  cat file1 file2
  @end example
  
! In case of damage to one member of a @samp{.gz} file, other members can
  still be recovered (if the damaged member is removed). However,
  you can get better compression by compressing all members at once:
  
  @example
  cat file1 file2 | gzip > foo.gz
--- 405,415 ----
  
  @example
  cat file1 file2
  @end example
  
! In case of damage to one member of a @file{.gz} file, other members can
  still be recovered (if the damaged member is removed). However,
  you can get better compression by compressing all members at once:
  
  @example
  cat file1 file2 | gzip > foo.gz
diff -acprNC5 gzip-1.3.3.orig/msdos/tailor.c gzip-1.3.3.djgpp/msdos/tailor.c
*** gzip-1.3.3.orig/msdos/tailor.c	Wed Jul  7 22:54:50 1993
--- gzip-1.3.3.djgpp/msdos/tailor.c	Sat May 11 20:30:10 2002
*************** void fcfree(ptr)
*** 54,58 ****
--- 54,116 ----
      *(ush*)&ptr = ptr_offset;
      farfree(ptr);
   }
  
  #endif /* __TURBOC__ */
+ 
+ #ifdef __DJGPP__
+ 
+ #include <string.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ 
+ /* ============================================================
+  * Make a file name valid for file systems supported by DJGPP.
+  * This includes replacing characters that aren't allowed in
+  * file names, and renaming files whose names are reserved by
+  * character device drivers.  Characters that aren't allowed
+  * depend on the filesystem where the file resides.
+  */
+ void make_valid_dosw32_name(name)
+     char *name;
+ {
+     /* The following characters aren't allowed in DOS file names.
+        Some of them aren't allowed by Windows 9X; these begin at
+        offset 7 (zero-based) in the string below.  */
+     static char disallowed_chars[] = "+, ;=[]|<>\\\":?*";
+     static char replacement_char[] = "x'_`_{}!()%'-^#";
+     int long_names = HAVE_LONG_NAMES(ofname);
+     struct stat st;
+     register char *p = name;
+ 
+     /* If the filesystem disallows multiple dots, remove
+        all but the last one.  */
+     if (!long_names)
+         make_simple_name(name);
+ 
+     /* If there are any more invalid characters, replace them.  */
+     for ( ; *p != '\0'; p++)
+     {
+       register int i;
+ 
+       for (i = long_names ? 7 : 0; i < sizeof(disallowed_chars); i++)
+       {
+         if (*p == disallowed_chars[i])
+         {
+           *p = replacement_char[i];
+           break;
+         }
+       }
+     }
+ 
+     /* The list of character devices is not constant: it depends on
+        what device drivers did they install in their CONFIG.SYS.
+        `stat' will tell us if the file name is a character device.  */
+     if (stat(name, &st) == 0 && S_ISCHR(st.st_mode))
+     {
+       /* If it's a reserved name, prepend a '_' to it.  */
+       memmove(name + 1, name, strlen(name) + 1);
+       name[0] = '_';
+     }
+ }
+ 
+ #endif /* __DJGPP__ */
diff -acprNC5 gzip-1.3.3.orig/tailor.h gzip-1.3.3.djgpp/tailor.h
*** gzip-1.3.3.orig/tailor.h	Wed Oct  6 05:07:38 1999
--- gzip-1.3.3.djgpp/tailor.h	Sat May 11 20:30:10 2002
***************
*** 25,64 ****
  #ifdef MSDOS
  #  ifdef __GNUC__
       /* DJGPP version 1.09+ on MS-DOS.
        * The DJGPP 1.09 stat() function must be upgraded before gzip will
        * fully work.
-       * No need for HAVE_DIRENT_H, since <unistd.h> defines POSIX_SOURCE which
-       * implies HAVE_DIRENT_H.
        */
  #    define near
  #  else
  #    define MAXSEG_64K
  #    ifdef __TURBOC__
  #      define off_t long
  #      ifdef __BORLANDC__
  #        define HAVE_DIRENT_H
  #        define HAVE_UTIME
  #      endif
  #      define HAVE_UTIME_H
  #    else /* MSC */
  #      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 PROTO
- #  define STDC_HEADERS
- #  define NO_SIZE_CHECK
- #  define UNLINK_READONLY_BUG
  #  define casemap(c) tolow(c) /* Force file names to lower case */
  #  include <io.h>
- #  define OS_CODE  0x00
  #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
  #  if !defined(NO_ASM) && !defined(ASMV)
  #    define ASMV
  #  endif
  #else
--- 25,94 ----
  #ifdef MSDOS
  #  ifdef __GNUC__
       /* DJGPP version 1.09+ on MS-DOS.
        * The DJGPP 1.09 stat() function must be upgraded before gzip will
        * fully work.
        */
  #    define near
+ #    define DIRENT
+ #    define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
+ #    define fcfree(ptr) free(ptr)
+ #    ifdef __DJGPP__
+        /* DJGPP version 2.x or later supports long file names on Windows.  */
+ #      define LONG_FILE_NAMES
+ #      define HAVE_LONG_NAMES(f)    (_use_lfn(f))
+ #      define MAX_PATH_LEN          PATH_MAX
+ #      define MAX_EXT_CHARS         3
+ #      define MAX_SUFFIX            30
+ #      define OS_CODE               (HAVE_LONG_NAMES(ifname) ? 0x0e : 0x00)
+ #      define NO_FSTAT
+ #      define PART_SEP              "._- "
+ #      define MAKE_LEGAL_NAME(name) make_valid_dosw32_name(name)
+ #    else /* DJGPP version 1.x */
+ #      define HAVE_LIMITS_H
+ #      define HAVE_UNISTD_H
+ #      define STDC_HEADERS
+ #      define MAX_PATH_LEN  128
+ #      define NO_MULTIPLE_DOTS
+ #      define MAX_EXT_CHARS 3
+ #      define Z_SUFFIX "z"
+ #      define OS_CODE            0x00
+ #    endif
  #  else
+ #    define STDC_HEADERS
  #    define MAXSEG_64K
+ #    define MAX_PATH_LEN  128
+ #    define NO_MULTIPLE_DOTS
+ #    define MAX_EXT_CHARS 3
+ #    define Z_SUFFIX "z"
+ #    define NO_SIZE_CHECK
+ #    define UNLINK_READONLY_BUG
+ #    define OS_CODE  0x00
  #    ifdef __TURBOC__
  #      define off_t long
+ #      include <alloc.h>
+ #      define DYN_ALLOC
+        /* Turbo C 2.0 does not accept static allocations of large arrays */
+        void * fcalloc (unsigned items, unsigned size);
+        void fcfree (void *ptr);
  #      ifdef __BORLANDC__
  #        define HAVE_DIRENT_H
  #        define HAVE_UTIME
  #      endif
  #      define HAVE_UTIME_H
  #    else /* MSC */
  #      define HAVE_SYS_UTIME_H
+ #      include <malloc.h>
+ #      define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
+ #      define fcfree(ptr) hfree(ptr)
  #    endif
  #  endif
  #  define PATH_SEP2 '\\'
  #  define PATH_SEP3 ':'
  #  define PROTO
  #  define casemap(c) tolow(c) /* Force file names to lower case */
  #  include <io.h>
  #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
  #  if !defined(NO_ASM) && !defined(ASMV)
  #    define ASMV
  #  endif
  #else
***************
*** 123,145 ****
  #    define casemap(c) tolow(c) /* Force file names to lower case */
  #  endif
  #  define OS_CODE  0x0b
  #endif
  
! #ifdef MSDOS
! #  ifdef __TURBOC__
! #    include <alloc.h>
! #    define DYN_ALLOC
!      /* Turbo C 2.0 does not accept static allocations of large arrays */
!      void * fcalloc (unsigned items, unsigned size);
!      void fcfree (void *ptr);
! #  else /* MSC */
! #    include <malloc.h>
! #    define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
! #    define fcfree(ptr) hfree(ptr)
! #  endif
! #else
  #  ifdef MAXSEG_64K
  #    define fcalloc(items,size) calloc((items),(size))
  #  else
  #    define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
  #  endif
--- 153,163 ----
  #    define casemap(c) tolow(c) /* Force file names to lower case */
  #  endif
  #  define OS_CODE  0x0b
  #endif
  
! #ifndef MSDOS
  #  ifdef MAXSEG_64K
  #    define fcalloc(items,size) calloc((items),(size))
  #  else
  #    define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
  #  endif
***************
*** 270,282 ****
  #ifndef Z_SUFFIX
  #  define Z_SUFFIX ".gz"
  #endif
  
  #ifdef MAX_EXT_CHARS
! #  define MAX_SUFFIX  MAX_EXT_CHARS
  #else
  #  define MAX_SUFFIX  30
  #endif
  
  #ifndef MAKE_LEGAL_NAME
  #  ifdef NO_MULTIPLE_DOTS
  #    define MAKE_LEGAL_NAME(name)   make_simple_name(name)
--- 288,303 ----
  #ifndef Z_SUFFIX
  #  define Z_SUFFIX ".gz"
  #endif
  
  #ifdef MAX_EXT_CHARS
! #  ifndef MAX_SUFFIX
! #    define MAX_SUFFIX  MAX_EXT_CHARS
! #  endif
  #else
  #  define MAX_SUFFIX  30
+ #  define LONG_FILE_NAMES
  #endif
  
  #ifndef MAKE_LEGAL_NAME
  #  ifdef NO_MULTIPLE_DOTS
  #    define MAKE_LEGAL_NAME(name)   make_simple_name(name)
diff -acprNC5 gzip-1.3.3.orig/util.c gzip-1.3.3.djgpp/util.c
*** gzip-1.3.3.orig/util.c	Wed Sep 26 23:12:28 2001
--- gzip-1.3.3.djgpp/util.c	Sat May 11 20:50:00 2002
*************** char *strlwr(s)
*** 193,216 ****
   * case sensitive, force the base name to lower case.
   */
  char *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
!     if (casemap('A') == 'a') strlwr(fname);
!     return fname;
  }
  
  /* ========================================================================
   * Unlink a file, working around the unlink readonly bug (if present).
   */
--- 193,221 ----
   * case sensitive, force the base name to lower case.
   */
  char *base_name(fname)
      char *fname;
  {
!     register char *p = fname;
  
!     for (p += strlen(fname); p > fname; p--)
!     {
! #ifdef SUFFIX_SEP
!       if (p[-1] == SUFFIX_SEP)
!         p[-1] = '\0';
! #endif
!       if (p[-1] == PATH_SEP
  #ifdef PATH_SEP2
!           || p[-1] == PATH_SEP2
  #endif
  #ifdef PATH_SEP3
!           || p[-1] == PATH_SEP3
  #endif
!          )
!         break;
!     }
!     return (casemap('A') == 'a') ? strlwr(p) : p;
  }
  
  /* ========================================================================
   * Unlink a file, working around the unlink readonly bug (if present).
   */
diff -acprNC5 gzip-1.3.3.orig/zdiff.in gzip-1.3.3.djgpp/zdiff.in
*** gzip-1.3.3.orig/zdiff.in	Fri Sep 18 02:27:28 1998
--- gzip-1.3.3.djgpp/zdiff.in	Sat May 11 20:30:10 2002
***************
*** 8,18 ****
  # the  files  compared  are file1 and an uncompressed file1.gz.
  # If two files are specified, then they are  uncompressed  (if
  # necessary) and fed to cmp or diff.  The exit status from cmp
  # or diff is preserved.
  
! PATH="BINDIR:$PATH"; export PATH
  prog=`echo $0 | sed 's|.*/||'`
  case "$prog" in
    *cmp) comp=${CMP-cmp}   ;;
    *)    comp=${DIFF-diff} ;;
  esac
--- 8,26 ----
  # the  files  compared  are file1 and an uncompressed file1.gz.
  # If two files are specified, then they are  uncompressed  (if
  # necessary) and fed to cmp or diff.  The exit status from cmp
  # or diff is preserved.
  
! pathsep=:
! if test -n "$DJGPP$djgpp"; then
!   pathsep=";"
! fi
! PATH="BINDIR$pathsep$PATH"; export PATH
! tmpdir=${TMPDIR-/tmp}
! if test ! -d "$tmpdir"; then
!   tmpdir=.
! fi
  prog=`echo $0 | sed 's|.*/||'`
  case "$prog" in
    *cmp) comp=${CMP-cmp}   ;;
    *)    comp=${DIFF-diff} ;;
  esac
*************** elif test $# -eq 2; then
*** 45,59 ****
          *[-.]gz* | *[-.][zZ] | *.t[ga]z)
                  case "$2" in
  	        *[-.]gz* | *[-.][zZ] | *.t[ga]z)
  			F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
  			set -C
! 			trap 'rm -f /tmp/"$F".$$; exit 2' 1 2 13 15 0
! 			gzip -cdfq "$2" > /tmp/"$F".$$ || exit
!                         gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$
                          STAT="$?"
! 			/bin/rm -f /tmp/"$F".$$ || STAT=2
  			trap 1 2 13 15 0
  			exit $STAT;;
  
                  *)      gzip -cdfq "$1" | $comp $OPTIONS - "$2";;
                  esac;;
--- 53,67 ----
          *[-.]gz* | *[-.][zZ] | *.t[ga]z)
                  case "$2" in
  	        *[-.]gz* | *[-.][zZ] | *.t[ga]z)
  			F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
  			set -C
! 			trap 'rm -f "$tmpdir"/"$F".$$; exit 2' 1 2 13 15 0
! 			gzip -cdfq "$2" > "$tmpdir"/"$F".$$ || exit
!                         gzip -cdfq "$1" | $comp $OPTIONS - "$tmpdir"/"$F".$$
                          STAT="$?"
! 			rm -f "$tmpdir"/"$F".$$ || STAT=2
  			trap 1 2 13 15 0
  			exit $STAT;;
  
                  *)      gzip -cdfq "$1" | $comp $OPTIONS - "$2";;
                  esac;;
diff -acprNC5 gzip-1.3.3.orig/zgrep.in gzip-1.3.3.djgpp/zgrep.in
*** gzip-1.3.3.orig/zgrep.in	Mon Oct  1 06:45:54 2001
--- gzip-1.3.3.djgpp/zgrep.in	Sat May 11 20:30:10 2002
***************
*** 20,30 ****
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  # 02111-1307, USA.
  
! PATH="BINDIR:$PATH"; export PATH
  
  prog=`echo $0 | sed 's|.*/||'`
  case "$prog" in
  	*egrep)	grep=${EGREP-egrep}	;;
  	*fgrep)	grep=${FGREP-fgrep}	;;
--- 20,34 ----
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  # 02111-1307, USA.
  
! pathsep=:
! if test -n "$DJGPP$djgpp"; then
!   pathsep=";"
! fi
! PATH="BINDIR$pathsep$PATH"; export PATH
  
  prog=`echo $0 | sed 's|.*/||'`
  case "$prog" in
  	*egrep)	grep=${EGREP-egrep}	;;
  	*fgrep)	grep=${FGREP-fgrep}	;;
diff -acprNC5 gzip-1.3.3.orig/zless.in gzip-1.3.3.djgpp/zless.in
*** gzip-1.3.3.orig/zless.in	Thu Sep 17 20:37:18 1998
--- gzip-1.3.3.djgpp/zless.in	Sat May 11 20:30:10 2002
***************
*** 2,10 ****
  #!/bin/sh
  
  : ${PAGER=less}
  export PAGER
  
! PATH="BINDIR:$PATH"
  export PATH
  
  exec zmore ${1+"$@"}
--- 2,14 ----
  #!/bin/sh
  
  : ${PAGER=less}
  export PAGER
  
! pathsep=:
! if test -n "$DJGPP$djgpp"; then
!   pathsep=";"
! fi
! PATH="BINDIR$pathsep$PATH"
  export PATH
  
  exec zmore ${1+"$@"}
diff -acprNC5 gzip-1.3.3.orig/zmore.in gzip-1.3.3.djgpp/zmore.in
*** gzip-1.3.3.orig/zmore.in	Mon Oct  1 05:23:14 2001
--- gzip-1.3.3.djgpp/zmore.in	Sat May 11 20:30:10 2002
***************
*** 17,27 ****
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  # 02111-1307, USA.
  
! PATH="BINDIR:$PATH"; export PATH
  if test "`echo -n a`" = "-n a"; then
    # looks like a SysV system:
    n1=''; n2='\c'
  else
    n1='-n'; n2=''
--- 17,31 ----
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  # 02111-1307, USA.
  
! pathsep=:
! if test -n "$DJGPP$djgpp"; then
!   pathsep=";"
! fi
! PATH="BINDIR$pathsep$PATH"; export PATH
  if test "`echo -n a`" = "-n a"; then
    # looks like a SysV system:
    n1=''; n2='\c'
  else
    n1='-n'; n2=''
diff -acprNC5 gzip-1.3.3.orig/znew.in gzip-1.3.3.djgpp/znew.in
*** gzip-1.3.3.orig/znew.in	Wed Oct 14 23:37:58 1998
--- gzip-1.3.3.djgpp/znew.in	Sat May 11 20:30:10 2002
***************
*** 1,9 ****
  :
  #!/bin/sh
  
! PATH="BINDIR:$PATH"; export PATH
  check=0
  pipe=0
  opt=
  files=
  keep=0
--- 1,17 ----
  :
  #!/bin/sh
  
! pathsep=:
! if test -n "$DJGPP$djgpp"; then
!   pathsep=";"
! fi
! PATH="BINDIR$pathsep$PATH"; export PATH
! tmpdir=${TMPDIR-/tmp}
! if test ! -d "$tmpdir"; then
!   tmpdir=.
! fi
  check=0
  pipe=0
  opt=
  files=
  keep=0
*************** old=0
*** 12,22 ****
  new=0
  block=1024
  # block is the disk block size (best guess, need not be exact)
  
  warn="(does not preserve modes and timestamp)"
! tmp=/tmp/zfoo.$$
  set -C
  echo hi > $tmp.1
  echo hi > $tmp.2
  if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
    cpmod=${CPMOD-cpmod}
--- 20,30 ----
  new=0
  block=1024
  # block is the disk block size (best guess, need not be exact)
  
  warn="(does not preserve modes and timestamp)"
! tmp="$tmpdir"/zf$$
  set -C
  echo hi > $tmp.1
  echo hi > $tmp.2
  if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
    cpmod=${CPMOD-cpmod}
