*** /develop/ports/orig/fileutils-4.0/GNUmakefile	Sat Apr  4 15:06:38 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/GNUmakefile	Sun May 27 11:42:20 2001
***************
*** 4,9 ****
--- 4,11 ----
  # It is necessary if you want to build targets usually of interest
  # only to the maintainer.
  
+ SHELL=/bin/sh
+ 
  have-Makefile := $(shell test -f Makefile && echo yes)
  
  # If the user runs GNU make but has not yet run ./configure,
*** /develop/ports/orig/fileutils-4.0/configure.in	Tue Nov 10 13:54:34 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/configure.in	Sun May 27 11:44:26 2001
*************** AC_PROG_RANLIB
*** 24,29 ****
--- 24,30 ----
  AC_PROG_YACC
  AC_AIX
  AC_MINIX
+ AC_EXEEXT
  
  dnl This test must come as early as possible after the compiler configuration
  dnl tests, because the choice of the file model can (in principle) affect
*************** dnl For addext.c.  FIXME: put these in a
*** 60,65 ****
--- 61,70 ----
  AC_SYS_LONG_FILE_NAMES
  AC_CHECK_FUNC(pathconf)
  
+ dnl (rdawe): DJGPP port: Check whether we have lstat() or not. Versions of
+ dnl          DJGPP > 2.03 have support for symlinks.
+ AC_CHECK_FUNCS(lstat)
+ 
  AC_CHECK_HEADERS(string.h fcntl.h limits.h sys/time.h sys/timeb.h \
      errno.h unistd.h stdlib.h \
      sys/param.h sys/statfs.h sys/fstyp.h mnttab.h mntent.h utime.h \
*** /develop/ports/orig/fileutils-4.0/doc/fileutils.texi	Sun Nov  8 16:12:08 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/doc/fileutils.texi	Sun May 27 11:42:20 2001
*************** by the Foundation.
*** 100,106 ****
  @end titlepage
  
  
! @ifinfo
  @node Top
  @top GNU file utilities
  
--- 100,106 ----
  @end titlepage
  
  
! @ifnottex
  @node Top
  @top GNU file utilities
  
*************** by the Foundation.
*** 109,114 ****
--- 109,116 ----
  
  This manual documents version @value{VERSION} of the GNU file utilities.
  
+ @end ifnottex
+ 
  @menu
  * Introduction::                Caveats, overview, and authors.
  * Common options::              Common options.
*************** This manual documents version @value{VER
*** 121,127 ****
  * Disk usage::                  df du sync
  * Index::                       General index.
  @end menu
- @end ifinfo
  
  
  @node Introduction
--- 123,128 ----
*** /develop/ports/orig/fileutils-4.0/lib/addext.c	Mon Jun 23 13:41:48 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/addext.c	Sun May 27 11:42:20 2001
***************
*** 22,27 ****
--- 22,39 ----
  # include <config.h>
  #endif
  
+ /* Richard Dawe: Cope with MS-DOSisms. */
+ #ifdef MSDOS
+ #define HAVE_DOS_FILE_NAMES 1
+ 
+ /* Leave detection of HAVE_LONG_FILE_NAMES to the configure script. However,
+  * DJGPP has pathconf(), so use that in preference to HAVE_LONG_FILE_NAMES.
+  * Surely the configure script should detect pathconf()? */
+ #ifdef __DJGPP__
+ #define HAVE_PATHCONF 1
+ #endif /* __DJGPP__ */
+ #endif /* MSDOS */
+ 
  #ifndef HAVE_DOS_FILE_NAMES
  #define HAVE_DOS_FILE_NAMES 0
  #endif
*************** addext (filename, ext, e)
*** 83,97 ****
      {
        /* Live within DOS's 8.3 limit.  */
        char *dot = strchr (s, '.');
        if (dot)
  	{
! 	  slen -= dot + 1 - s;
! 	  s = dot + 1;
! 	  slen_max = 3;
  	}
        else
! 	slen_max = 8;
!       extlen = 9; /* Don't use EXT.  */
      }
  
    if (slen + extlen <= slen_max)
--- 95,158 ----
      {
        /* Live within DOS's 8.3 limit.  */
        char *dot = strchr (s, '.');
+       size_t s_ext_len = 0;	/* length of existing extension in `s' */
+ 
        if (dot)
+ 	s_ext_len = slen - (dot + 1 - s);
+       else if (ext[0] == '.')
  	{
! 	  s[slen++] = '.';
! 	  s[slen] = '\0';
! 	  dot = s + slen - 1;
! 	}
! 
!       /* DOS doesn't allow more than a single dot.  */
!       if (ext[0] == '.')
! 	{
! 	  ext++;
! 	  extlen--;
! 	}
! 
!       /* If EXT is "~N~" and there's not enough space to append it,
! 	 lose the leading `~' so that we could salvage more of the
! 	 original name ("foo.c" + ".~9~" -> "foo.c9~").  */
!       if (s_ext_len + extlen > 3 && ext[0] == '~' && extlen > 1)
! 	{
! 	  ext++;
! 	  extlen--;
! 	}
!       /* If there isn't enough space in the extension to append
! 	 EXT, use the base part ("foo.c" + ".~99~" -> "foo99~").  */
!       if (!dot || extlen > 3)
! 	{
! 	  slen_max = 8;
! 	  if (dot)
! 	    slen = dot - s;
! 	  if (extlen < slen_max)
! 	    {
! 	      if (slen + extlen > slen_max)
! 		slen = slen_max - extlen;
! 	    }
! 	  /* Else give up and force using E.  We don't allow EXT to
! 	     eat up all of the original filename's characters.  That
! 	     is, "foo" + ".~3456789~" should NOT yield "3456789~".  */
! 	  else if (dot)
! 	    {
! 	      slen_max = 3;
! 	      extlen = 4;
! 	      s = dot + 1;
! 	      slen = s_ext_len;
! 	    }
  	}
        else
! 	{
! 	  /* Extension has enough space to append EXT.  */
! 	  slen_max = 3;
! 	  slen = s_ext_len;
! 	  s = dot + 1;
! 	  if (slen + extlen > slen_max)
! 	    slen = slen_max - extlen;
! 	}
      }
  
    if (slen + extlen <= slen_max)
*** /develop/ports/orig/fileutils-4.0/lib/backupfile.c	Sat Nov 14 13:17:12 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/backupfile.c	Sun May 27 11:42:20 2001
***************
*** 23,28 ****
--- 23,50 ----
  # include <config.h>
  #endif
  
+ /* Richard Dawe: Cope with MS-DOSisms. */
+ #ifdef MSDOS
+ #define HAVE_DOS_FILE_NAMES 1
+ 
+ #define filename_char_eq(c1,c2)				\
+     ({int _c1 = (c1), _c2 = (c2); 			\
+     (_c1 >= 'A' &&  _c1 <= 'Z' ? tolower(_c1) : _c1) ==	\
+     (_c2 >= 'A' &&  _c2 <= 'Z' ? tolower(_c2) : _c2);	\
+     })
+      
+ #endif /* MSDOS */
+ 
+ #ifndef HAVE_DOS_FILE_NAMES
+ #define HAVE_DOS_FILE_NAMES 0
+ #endif
+ 
+ #ifndef filename_char_eq
+ #define filename_char_eq(c1,c2)  ((c1) == (c2))
+ #else
+ #include <ctype.h>
+ #endif
+ 
  #include <argmatch.h>
  #include <backupfile.h>
  
*************** max_backup_version (const char *file, co
*** 176,182 ****
  
    while ((dp = readdir (dirp)) != 0)
      {
!       if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) < file_name_length + 4)
  	continue;
  
        this_version = version_number (file, dp->d_name, file_name_length);
--- 198,208 ----
  
    while ((dp = readdir (dirp)) != 0)
      {
!       if (!REAL_DIR_ENTRY (dp)
! 	  /* Under DOS 8+3 file name limits, backup extensions
! 	     may consume part of the original name.  */
! 	  || (! HAVE_DOS_FILE_NAMES && NLENGTH (dp) < file_name_length + 4)
! 	  || NLENGTH (dp) < file_name_length)
  	continue;
  
        this_version = version_number (file, dp->d_name, file_name_length);
*************** static int
*** 196,213 ****
  version_number (const char *base, const char *backup, size_t base_length)
  {
    int version;
!   const char *p;
  
    version = 0;
!   if (strncmp (base, backup, base_length) == 0
!       && backup[base_length] == '.'
!       && backup[base_length + 1] == '~')
!     {
!       for (p = &backup[base_length + 2]; ISDIGIT (*p); ++p)
! 	version = version * 10 + *p - '0';
!       if (p[0] != '~' || p[1])
! 	version = 0;
!     }
    return version;
  }
  #endif /* HAVE_DIR */
--- 222,251 ----
  version_number (const char *base, const char *backup, size_t base_length)
  {
    int version;
!   const char *s = base;
!   const char *s_end = base + base_length;
!   const char *p = backup;
  
    version = 0;
! 
!   /* This could use `strncmp', but under HAVE_DOS_FILE_NAMES the two
!      files need not compare equal to the full extent of BASE_LENGTH.  */
!   if (! filename_char_eq (*p, *s))
!     return 0;
!   for ( ; s < s_end && filename_char_eq (*p, *s); p++, s++)
!     ;
!   if (p[0] == '.' && p[1] == '~')
!     p += 2;
!   else if (! HAVE_DOS_FILE_NAMES)
!     return 0;
!   else if (*p == '.')	/* the case of foo.99~ vs foo.c */
!     p++;
! 
!   for ( ; ISDIGIT (*p); ++p)
!     version = version * 10 + *p - '0';
!   if (p[0] != '~' || p[1])
!     version = 0;
! 
    return version;
  }
  #endif /* HAVE_DIR */
*** /develop/ports/orig/fileutils-4.0/lib/basename.c	Wed Feb 25 04:59:10 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/basename.c	Sun May 27 11:42:20 2001
***************
*** 19,24 ****
--- 19,42 ----
  # include <config.h>
  #endif
  
+ /* Richard Dawe: Cope with MS-DOSisms. */
+ #ifdef MSDOS
+ # define FILESYSTEM_PREFIX_LEN(Filename) __filesystem_prefix_len(Filename)
+ # include <ctype.h>
+ # include <string.h>
+ 
+ static __inline__ size_t __filesystem_prefix_len (const char *f)
+ {
+   if ((f == NULL) || (*f == '\0'))
+     return(0);
+   if (f[1] == ':')
+     return(2);
+   return(0);
+ }
+ 
+ #define ISSLASH(c) (((c) == '/') || ((c) == '\\'))
+ #endif /* MSDOS */
+ 
  #ifndef FILESYSTEM_PREFIX_LEN
  # define FILESYSTEM_PREFIX_LEN(Filename) 0
  #endif
*** /develop/ports/orig/fileutils-4.0/lib/dirname.c	Sun Mar 15 16:13:10 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/dirname.c	Sun May 27 11:42:20 2001
*************** char *malloc ();
*** 35,41 ****
  
  /* Return the leading directories part of PATH,
     allocated with malloc.  If out of memory, return 0.
!    Assumes that trailing slashes have already been
     removed.  */
  
  char *
--- 35,41 ----
  
  /* Return the leading directories part of PATH,
     allocated with malloc.  If out of memory, return 0.
!    Does NOT assume that trailing slashes have already been
     removed.  */
  
  char *
*************** dirname (path)
*** 47,52 ****
--- 47,61 ----
    int length;			/* Length of result, not including NUL.  */
  
    slash = strrchr (path, '/');
+ #ifdef MSDOS
+   /* If we have "d:file", make the directory be "d:"  */
+   if (slash == 0 && path[1] == ':')
+     slash = path + 1;
+   /* If we have "d:/file", make the directory be "d:/", not "d:"  */
+   if (slash && slash == path + 2 && path[1] == ':' && path[2] == '/')
+     length = 3;
+   else
+ #endif
    if (slash == 0)
      {
        /* File is in the current directory.  */
*** /develop/ports/orig/fileutils-4.0/lib/euidaccess.c	Sun Mar 15 16:13:10 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/euidaccess.c	Sun May 27 11:42:20 2001
*************** euidaccess (path, mode)
*** 152,157 ****
--- 152,158 ----
      /* If we are not set-uid or set-gid, access does the same.  */
      return access (path, mode);
  
+ #ifndef MSDOS
    if (stat (path, &stats))
      return -1;
  
*************** euidaccess (path, mode)
*** 179,182 ****
--- 180,184 ----
      return 0;
    errno = EACCESS;
    return -1;
+ #endif /* !MSDOS */
  }
*** /develop/ports/orig/fileutils-4.0/lib/lchown.h	Fri Jul 17 01:23:06 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/lchown.h	Sun May 27 11:42:20 2001
***************
*** 7,9 ****
--- 7,18 ----
  #  define ENOSYS ENOMSG
  # endif
  #endif
+ 
+ #ifdef  __DJGPP__
+ /* Versions of DJGPP > 2.03 support symlinks (currently only DJGPP CVS). If
+  * symlinks are not supported, just fail this test every time;
+  * i.e. no file is a link. */
+ #ifndef S_ISLNK
+ #define S_ISLNK(x)  (0)
+ #endif
+ #endif
*** /develop/ports/orig/fileutils-4.0/lib/makepath.c	Thu Feb 12 04:16:56 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/makepath.c	Sun May 27 11:42:20 2001
*************** extern int errno;
*** 81,95 ****
  
  #define WX_USR (S_IWUSR | S_IXUSR)
  
! #ifdef __MSDOS__
  typedef int uid_t;
  typedef int gid_t;
  #endif
  
  #include "save-cwd.h"
  #include "makepath.h"
  #include "error.h"
  
  void strip_trailing_slashes ();
  
  #define CLEANUP_CWD					\
--- 81,111 ----
  
  #define WX_USR (S_IWUSR | S_IXUSR)
  
! #if defined(__MSDOS__) && !defined(HAVE_CONFIG_H)
  typedef int uid_t;
  typedef int gid_t;
  #endif
  
+ #if HAVE_LIMITS_H
+ /* limits.h must come before pathmax.h because limits.h on some systems
+    undefs PATH_MAX, whereas pathmax.h sets PATH_MAX.  */
+ # include <limits.h>
+ #endif
+ 
+ #include "pathmax.h"
+ 
  #include "save-cwd.h"
  #include "makepath.h"
  #include "error.h"
  
+ #ifdef MSDOS
+ # ifdef __DJGPP__
+ #  define FIXPATH(x,y)  _fixpath(x,y)
+ # else  /* !__DJGPP__ */
+ #  error FIXPATH macro not defined on MSDOS!
+ # endif /* !__DJGPP__ */
+ #endif
+ 
  void strip_trailing_slashes ();
  
  #define CLEANUP_CWD					\
*************** void strip_trailing_slashes ();
*** 107,112 ****
--- 123,154 ----
      }							\
    while (0)
  
+ #ifdef MSDOS
+ 
+ #define MSDOS_CLEANUP_CWD					\
+   do								\
+     {								\
+       if (msdos_cwd_saved)					\
+         {							\
+           int fail = restore_cwd (&msdos_cwd, NULL, NULL);	\
+           free_cwd (&msdos_cwd);				\
+           if (fail)						\
+ 	    return 1;						\
+         }							\
+     }								\
+   while (0)
+      
+ #define CLEANUP						\
+   do							\
+     {							\
+       umask (oldmask);					\
+       MSDOS_CLEANUP_CWD;				\
+       CLEANUP_CWD;					\
+     }							\
+   while (0)
+      
+ #else /* !MSDOS */
+      
  #define CLEANUP						\
    do							\
      {							\
*************** void strip_trailing_slashes ();
*** 114,119 ****
--- 156,163 ----
        CLEANUP_CWD;					\
      }							\
    while (0)
+      
+ #endif /* !MSDOS */     
  
  /* Ensure that the directory ARGPATH exists.
     Remove any trailing slashes from ARGPATH before calling this function.
*************** make_path (const char *argpath,
*** 158,163 ****
--- 202,211 ----
        struct ptr_list *p, *leading_dirs = NULL;
        int do_chdir;		/* Whether to chdir before each mkdir.  */
        struct saved_cwd cwd;
+ #ifdef MSDOS
+       struct saved_cwd msdos_cwd;
+       int msdos_cwd_saved = 0;
+ #endif      
        char *basename_dir;
        char *dirpath;
  
*************** make_path (const char *argpath,
*** 165,174 ****
        int oldmask = umask (0);
  
        /* Make a copy of ARGPATH that we can scribble NULs on.  */
        dirpath = (char *) alloca (strlen (argpath) + 1);
!       strcpy (dirpath, argpath);
        strip_trailing_slashes (dirpath);
! 
        /* If leading directories shouldn't be writable or executable,
  	 or should have set[ug]id or sticky bits set and we are setting
  	 their owners, we need to fix their permissions after making them.  */
--- 213,230 ----
        int oldmask = umask (0);
  
        /* Make a copy of ARGPATH that we can scribble NULs on.  */
+ #ifndef MSDOS      
        dirpath = (char *) alloca (strlen (argpath) + 1);
!       strcpy (dirpath, argpath);      
! #else /* MSDOS */
!       /* On MS-DOS we can have paths like c:dir/dir2, since there are multiple
!        * working directories (one per drive) - expand these paths to full
!        * paths in the copy. */
!       dirpath = (char *) alloca(PATH_MAX + 1);	
!       FIXPATH(argpath, dirpath);
! #endif /* MSDOS */
        strip_trailing_slashes (dirpath);
!       
        /* If leading directories shouldn't be writable or executable,
  	 or should have set[ug]id or sticky bits set and we are setting
  	 their owners, we need to fix their permissions after making them.  */
*************** make_path (const char *argpath,
*** 188,202 ****
        /* If we can record the current working directory, we may be able
  	 to do the chdir optimization.  */
        do_chdir = !save_cwd (&cwd);
! 
        /* If we've saved the cwd and DIRPATH is an absolute pathname,
  	 we must chdir to `/' in order to enable the chdir optimization.
           So if chdir ("/") fails, turn off the optimization.  */
        if (do_chdir && *dirpath == '/' && chdir ("/") < 0)
  	do_chdir = 0;
  
        slash = dirpath;
  
        /* Skip over leading slashes.  */
        while (*slash == '/')
  	slash++;
--- 244,283 ----
        /* If we can record the current working directory, we may be able
  	 to do the chdir optimization.  */
        do_chdir = !save_cwd (&cwd);
!       
        /* If we've saved the cwd and DIRPATH is an absolute pathname,
  	 we must chdir to `/' in order to enable the chdir optimization.
           So if chdir ("/") fails, turn off the optimization.  */
+ #ifdef MSDOS
+       {
+         char d[4];
+ 	
+ 	/* Work out which drive letter we need to save the working directory
+ 	 * for & then change to its root directory. On MS-DOS, dirpath will
+ 	 * have a drive letter and be an absolute path, since we've
+ 	 * FIXPATH()'d it. */
+ 	d[0] = dirpath[0], d[1] = dirpath[1], d[2] = '\0';
+ 	if (chdir (d) == 0)
+ 	  msdos_cwd_saved = !save_cwd(&msdos_cwd);
+ 	
+ 	d[2] = '/', d[3] = '\0';
+ 	
+ 	if (do_chdir && chdir (d) < 0)
+ 	  do_chdir = 0;
+       }
+ #else
        if (do_chdir && *dirpath == '/' && chdir ("/") < 0)
  	do_chdir = 0;
+ #endif	  	      
  
        slash = dirpath;
  
+ #ifdef MSDOS
+       /* Skip over leading drive letters. */
+       if (slash[1] == ':')
+ 	slash += 2;
+ #endif
+       
        /* Skip over leading slashes.  */
        while (*slash == '/')
  	slash++;
*************** make_path (const char *argpath,
*** 334,339 ****
--- 415,421 ----
  	    }
  	}
  
+       MSDOS_CLEANUP_CWD;
        CLEANUP_CWD;
  
        /* If the mode for leading directories didn't include owner "wx"
*** /develop/ports/orig/fileutils-4.0/lib/path-concat.c	Sun Mar 15 16:20:04 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/path-concat.c	Sun May 27 11:42:20 2001
*************** path_concat (dir, base, base_in_result)
*** 60,65 ****
--- 60,74 ----
  
    if (*(p - 1) == '/' && *base == '/')
      --p;
+ #ifdef MSDOS
+   /* Make sure "path1"+"d:/path2" yields "path1/path2".  */
+   else if (base[1] == ':' && (base += 2) == 0)
+     /* Fall-through to next else-if clause (base += 2 is never 0).  */
+     ;
+   /* Make sure "d:"+"path" yields "d:path", not "d:/path".  */
+   else if (*(p - 1) == ':')
+     ;
+ #endif
    else if (*(p - 1) != '/' && *base != '/')
      *p++ = '/';
  
*** /develop/ports/orig/fileutils-4.0/lib/stripslash.c	Mon Jun 23 13:41:54 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/stripslash.c	Sun May 27 11:42:20 2001
*************** strip_trailing_slashes (path)
*** 38,43 ****
--- 38,52 ----
    int last;
  
    last = strlen (path) - 1;
+ #ifdef MSDOS
+   /* Leave alone a single slash in "d:/".  "d:" means something
+      VERY different on MSDOS.  */
+   if (path[1] == ':')
+     {
+       path += 2;
+       last -= 2;
+     }
+ #endif
    while (last > 0 && path[last] == '/')
      path[last--] = '\0';
  }
*** /develop/ports/orig/fileutils-4.0/lib/userspec.c	Sat May 16 22:43:46 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/lib/userspec.c	Sun May 27 11:42:20 2001
*************** parse_user_spec (spec_arg, uid, gid, use
*** 155,169 ****
    if (u == NULL && g == NULL)
      return "can not omit both user and group";
  
- #ifdef __DJGPP__
-   /* Pretend that we are the user U whose group is G.  This makes
-      pwd and grp functions ``know'' about the UID and GID of these.  */
-   if (u && !is_number (u))
-     setenv ("USER", u, 1);
-   if (g && !is_number (g))
-     setenv ("GROUP", g, 1);
- #endif
- 
    if (u != NULL)
      {
        pwd = getpwnam (u);
--- 155,160 ----
*************** parse_user_spec (spec_arg, uid, gid, use
*** 171,177 ****
--- 162,173 ----
  	{
  
  	  if (!is_number (u))
+ #ifdef  MSDOS
+ 	    /* Under MS-DOS we allow to give away files to ANY user.  */
+ 	    *uid = 2*getuid();	/* why twice, you ask? why not? */
+ #else
  	    error_msg = "invalid user";
+ #endif
  	  else
  	    {
  	      int use_login_group;
*************** parse_user_spec (spec_arg, uid, gid, use
*** 217,223 ****
--- 213,224 ----
        if (grp == NULL)
  	{
  	  if (!is_number (g))
+ #ifdef  MSDOS
+ 	    /* Under MS-DOS we allow to give away files to ANY group.  */
+ 	    *gid = 2*getgid();
+ #else
  	    error_msg = "invalid group";
+ #endif
  	  else
  	    *gid = atoi (g);
  	}
*** /develop/ports/orig/fileutils-4.0/man/GNUMakefile	Wed Sep  9 15:15:04 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/man/GNUMakefile	Sun May 27 11:42:20 2001
***************
*** 4,9 ****
--- 4,11 ----
  # It is necessary if you want to build targets usually of interest
  # only to the maintainer.
  
+ SHELL=/bin/sh
+ 
  have-Makefile := $(shell test -f Makefile && echo yes)
  
  # If the user runs GNU make but has not yet run ./configure,
*** /develop/ports/orig/fileutils-4.0/man/Makefile.maint	Sat Oct  3 21:41:46 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/man/Makefile.maint	Sun May 27 11:42:20 2001
*************** $(man_MANS): $(top_srcdir)/configure.in
*** 18,24 ****
  regular-men = $(filter-out $(irregular-men),$(man_MANS))
  $(regular-men): %.1: $(top_srcdir)/src/%.c
  
! executable = $(patsubst %/install,%/ginstall, ../src/$(basename $@))
  $(man_MANS): %.1: %.x $(HELP2MAN)
  	@if test -f $(executable); then \
  	  echo "Updating man page $@"; \
--- 18,24 ----
  regular-men = $(filter-out $(irregular-men),$(man_MANS))
  $(regular-men): %.1: $(top_srcdir)/src/%.c
  
! executable = $(patsubst %/install,%/ginstall, ../src/$(basename $@)$(EXEEXT))
  $(man_MANS): %.1: %.x $(HELP2MAN)
  	@if test -f $(executable); then \
  	  echo "Updating man page $@"; \
*** /develop/ports/orig/fileutils-4.0/man/help2man	Tue Oct  6 06:05:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/man/help2man	Sun May 27 11:42:20 2001
*************** use strict;
*** 26,31 ****
--- 26,39 ----
  use Getopt::Long;
  use POSIX 'strftime';
  
+ # If we're running in a DJGPP environment, set up $ENV{'SHELL'} to point
+ # to bash. If we don't do this, the wrong shell might be used
+ # (e.g. command.com) and backtick execution with stderr redirection
+ # (e.g. `$ARGV[0] --help 2>/dev/null`) will fail.
+ if (defined($ENV{DJDIR})) {
+     $ENV{SHELL} = $ENV{DJDIR}.'/bin/bash.exe';
+ }
+ 
  my $RCS_Id = '$Id: help2man.PL,v 1.5.1.2 1998/10/06 00:05:20 bod Exp $';
  my $this_program = 'help2man';
  my $this_version = '0.0';
*** /develop/ports/orig/fileutils-4.0/src/Makefile.am	Sat May 30 21:09:28 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/Makefile.am	Sun May 27 11:42:20 2001
*************** EXTRA_PROGRAMS = df mvdir
*** 11,19 ****
  
  bin_PROGRAMS = chgrp chown chmod cp dd dircolors du \
  ginstall ln dir vdir ls mkdir \
! mkfifo mknod mv rm rmdir sync touch @DF_PROG@
  
! libexec_PROGRAMS = @MVDIR_PROG@
  datadir = $(prefix)/@DATADIRNAME@
  localedir = $(datadir)/locale
  
--- 11,19 ----
  
  bin_PROGRAMS = chgrp chown chmod cp dd dircolors du \
  ginstall ln dir vdir ls mkdir \
! mkfifo mknod mv rm rmdir sync touch @DF_PROG@@EXEEXT@
  
! libexec_PROGRAMS = @MVDIR_PROG@@EXEEXT@
  datadir = $(prefix)/@DATADIRNAME@
  localedir = $(datadir)/locale
  
*************** $(bin_PROGRAMS) $(libexec_PROGRAMS): ../
*** 31,45 ****
  # to install before applying any user-specified name transformations.
  
  transform = s/ginstall/install/; @program_transform_name@
! ginstall_SOURCES = install.c copy.c cp-hash.c
  
! cp_SOURCES = cp.c copy.c cp-hash.c
! dir_SOURCES = ls.c ls-dir.c
! vdir_SOURCES = ls.c ls-vdir.c
! ls_SOURCES = ls.c ls-ls.c
  
! mv_SOURCES = mv.c copy.c cp-hash.c remove.c
! rm_SOURCES = rm.c remove.c
  
  BUILT_SOURCES = dircolors.h
  PERL = @PERL@
--- 31,65 ----
  # to install before applying any user-specified name transformations.
  
  transform = s/ginstall/install/; @program_transform_name@
! ginstall_SOURCES = install.c copy.c cp-hash.c djstart.c
  
! dircolors_SOURCES = dircolors.c djstart.c
! dir_SOURCES = ls.c ls-dir.c ls-msdos.c djutils.c djstart.c
! vdir_SOURCES = ls.c ls-vdir.c ls-msdos.c djutils.c djstart.c
! ls_SOURCES = ls.c ls-ls.c ls-msdos.c djutils.c djstart.c
  
! cp_SOURCES = cp.c copy.c cp-hash.c djutils.c djstart.c
! mv_SOURCES = mv.c copy.c cp-hash.c remove.c djutils.c djstart.c
! rm_SOURCES = rm.c remove.c djutils.c djstart.c
! 
! chgrp_SOURCES = chgrp.c djutils.c djstart.c
! chown_SOURCES = chown.c djutils.c djstart.c
! chmod_SOURCES = chmod.c djutils.c djstart.c
! 
! ln_SOURCES = ln.c djutils.c djstart.c
! 
! touch_SOURCES = touch.c djstart.c
! 
! du_SOURCES = du.c djutils.c djstart.c
! df_SOURCES = df.c djstart.c
! sync_SOURCES = sync.c djstart.c
! 
! mkdir_SOURCES = mkdir.c djstart.c
! rmdir_SOURCES = rmdir.c djstart.c
! 
! dd_SOURCES = dd.c djstart.c
! mkfifo_SOURCES = mkfifo.c djstart.c
! mknod_SOURCES = mknod.c djstart.c
  
  BUILT_SOURCES = dircolors.h
  PERL = @PERL@
*** /develop/ports/orig/fileutils-4.0/src/chgrp.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/chgrp.c	Sun May 27 11:42:20 2001
*************** parse_group (const char *name, int *g)
*** 156,169 ****
        unsigned long int tmp_long;
  
        if (!ISDIGIT (*name))
! 	error (1, 0, _("invalid group name `%s'"), name);
  
!       s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
!       if (s_err != LONGINT_OK)
! 	STRTOL_FATAL_ERROR (name, _("group number"), s_err);
! 
!       if (tmp_long > INT_MAX)
! 	error (1, 0, _("invalid group number `%s'"), name);
  
        *g = tmp_long;
      }
--- 156,178 ----
        unsigned long int tmp_long;
  
        if (!ISDIGIT (*name))
! 	{
! #ifdef  MSDOS
! 	  /* Under MS-DOS we allow to give away files to ANY user.  */
! 	  tmp_long = 2*getgid();	/* why twice, you ask? why not? */
! #else
! 	  error (1, 0, _("invalid group name `%s'"), name);
! #endif
! 	}
!       else
! 	{
! 	  s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
! 	  if (s_err != LONGINT_OK)
! 	    STRTOL_FATAL_ERROR (name, _("group number"), s_err);
  
! 	  if (tmp_long > INT_MAX)
! 	    error (1, 0, _("invalid group number `%s'"), name);
! 	}
  
        *g = tmp_long;
      }
*** /develop/ports/orig/fileutils-4.0/src/copy.c	Mon Sep 28 18:09:18 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/copy.c	Sun May 27 11:42:20 2001
*************** copy_internal (const char *src_path, con
*** 507,512 ****
--- 507,520 ----
  		}
  	      if (!yesno ())
  		return (move_mode ? 1 : 0);
+ #ifdef MSDOS
+ 	      /* Make it writable, so the copy will succeed.  */
+ 	      if (chmod (dst_path, 0200))
+ 		{
+ 		  error (0, errno, "%s", dst_path);
+ 		  return 1;
+ 		}
+ #endif	      
  	    }
  
  	  /* In move_mode, DEST may not be an existing directory.  */
*************** copy_internal (const char *src_path, con
*** 836,842 ****
        utb.actime = src_sb.st_atime;
        utb.modtime = src_sb.st_mtime;
  
!       if (utime (dst_path, &utb))
  	{
  	  error (0, errno, _("preserving times for %s"), dst_path);
  	  if (x->require_preserve)
--- 844,856 ----
        utb.actime = src_sb.st_atime;
        utb.modtime = src_sb.st_mtime;
  
!       if (utime (dst_path, &utb)
! #ifdef  MSDOS
! 	  /* MS-DOS doesn't allow to change timestamp of a directory :-(
! 	   * If we try, we'll get an ugly error message.  */
! 	  && !S_ISDIR (src_type)
! #endif	  
! 	  )
  	{
  	  error (0, errno, _("preserving times for %s"), dst_path);
  	  if (x->require_preserve)
*** /develop/ports/orig/fileutils-4.0/src/cp.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/cp.c	Sun Mar 10 13:36:38 2002
*************** re_protect (const char *const_dst_path, 
*** 242,249 ****
--- 242,253 ----
  
  	  if (utime (dst_path, &utb))
  	    {
+ #ifndef MSDOS
+ 	      /* MS-DOS doesn't allow to change timestamp of a
+ 		 directory.  */
  	      error (0, errno, _("preserving times for %s"), dst_path);
  	      return 1;
+ #endif
  	    }
  	}
  
*** /develop/ports/orig/fileutils-4.0/src/dd.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/dd.c	Sun May 27 11:42:20 2001
*************** static uintmax_t r_truncate = 0;
*** 122,127 ****
--- 122,131 ----
  /* Output representation of newline and space characters.
     They change if we're converting to EBCDIC.  */
  static unsigned char newline_character = '\n';
+ #ifdef MSDOS
+ static unsigned char cr_character = '\r';
+ static int pending_cr = 0;
+ #endif
  static unsigned char space_character = ' ';
  
  /* Output buffer. */
*************** only one conv in {ascii,ebcdic,ibm}, {lc
*** 722,733 ****
--- 726,739 ----
      {
        translate_charset (ascii_to_ebcdic);
        newline_character = ascii_to_ebcdic['\n'];
+       cr_character = ascii_to_ebcdic['\r'];
        space_character = ascii_to_ebcdic[' '];
      }
    else if (conversions_mask & C_IBM)
      {
        translate_charset (ascii_to_ibm);
        newline_character = ascii_to_ibm['\n'];
+       cr_character = ascii_to_ibm['\r'];
        space_character = ascii_to_ibm[' '];
      }
  }
*************** copy_with_block (unsigned char *buf, int
*** 871,876 ****
--- 877,913 ----
  
    for (i = nread; i; i--, buf++)
      {
+ #ifdef MSDOS
+       /* This is more complicated for MS-DOS, because the line separator is
+        * CR-LF, not just LF. If we find a CR, we need to see if it's actually
+        * an MS-DOS newline or just a CR. */
+ 
+       /* Output the CR left from the previous buffer, if the first
+        * character of this buffer isn't a newline.  */
+       if (i == nread && pending_cr && *buf != newline_character)
+ 	{
+ 	  output_char (cr_character);
+ 	  pending_cr = 0;
+ 	  col++;
+ 	}
+ 
+       /* If we have CR-LF pair, lose the CR character too.  */
+       if (*buf == cr_character)
+ 	{
+ 	  if (i == 1)   /* last char, defer decision until next BUF */
+ 	    {
+ 	      pending_cr = 1;
+ 	      continue;
+ 	    }
+ 	  else if (buf[1] == newline_character)
+ 	    {
+ 	      buf++;
+ 	      i--;
+ 	      pending_cr = 0;
+ 	    }
+ 	}
+ #endif /* MSDOS */
+ 
        if (*buf == newline_character)
  	{
  	  if (col < conversion_blocksize)
*************** copy_with_unblock (unsigned char *buf, i
*** 911,916 ****
--- 948,957 ----
  	{
  	  col = pending_spaces = 0; /* Wipe out any pending spaces.  */
  	  i--;			/* Push the char back; get it later. */
+ #ifdef MSDOS
+ 	  /* Make DOS-style text file (we do BINARY I/O!).  */
+ 	  output_char (cr_character);
+ #endif
  	  output_char (newline_character);
  	}
        else if (c == space_character)
*************** copy (void)
*** 1071,1084 ****
        /* If the final input line didn't end with a '\n', pad
  	 the output block to `conversion_blocksize' chars.  */
        size_t i;
        for (i = col; i < conversion_blocksize; i++)
  	output_char (space_character);
      }
  
    if ((conversions_mask & C_UNBLOCK) && col == conversion_blocksize)
!     /* Add a final '\n' if there are exactly `conversion_blocksize'
!        characters in the final record. */
!     output_char (newline_character);
  
    /* Write out the last block. */
    if (oc != 0)
--- 1112,1142 ----
        /* If the final input line didn't end with a '\n', pad
  	 the output block to `conversion_blocksize' chars.  */
        size_t i;
+       
+ #ifdef MSDOS
+       /* Do we have a CR waiting to be output? See copy_with_block(). */
+       if (pending_cr)
+ 	{
+ 	  output_char (cr_character);
+ 	  pending_cr = 0;
+ 	  col++;
+ 	}
+ #endif
+ 
        for (i = col; i < conversion_blocksize; i++)
  	output_char (space_character);
      }
  
    if ((conversions_mask & C_UNBLOCK) && col == conversion_blocksize)
!     {
!       /* Add a final '\n' if there are exactly `conversion_blocksize'
! 	 characters in the final record. */
! #ifdef MSDOS
!       /* Make DOS-style text file (we do I/O in binary mode!).  */
!       output_char (cr_character);
! #endif
!       output_char (newline_character);
!     }
  
    /* Write out the last block. */
    if (oc != 0)
*** /develop/ports/orig/fileutils-4.0/src/df.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/df.c	Sun May 27 11:42:20 2001
*************** show_dev (const char *disk, const char *
*** 218,223 ****
--- 218,226 ----
  {
    struct fs_usage fsu;
    const char *stat_file;
+ #ifdef __DJGPP__
+   char real_drive_name[4];
+ #endif
  
    if (me_remote && show_local_fs)
      return;
*************** show_dev (const char *disk, const char *
*** 234,239 ****
--- 237,260 ----
       but statfs doesn't do that on most systems.  */
    stat_file = mount_point ? mount_point : disk;
  
+ #ifdef __DJGPP__
+   /* JOINed disks seem like a directory on another disk.
+      We want to see the info about the real drive.  */
+   if (fstype && strcmp (fstype, "join") == 0)
+     {
+       struct stat real_drive_stats;
+ 
+       if (stat (stat_file, &real_drive_stats))
+ 	{
+           error (0, errno, "%s", stat_file);
+           exit_status = 1;
+           return;
+ 	}
+       sprintf (real_drive_name, "%c:/", real_drive_stats.st_dev + 'A');
+       stat_file = real_drive_name;
+     }
+ #endif
+ 
    if (get_fs_usage (stat_file, disk, &fsu))
      {
        error (0, errno, "%s", stat_file);
*** /develop/ports/orig/fileutils-4.0/src/dircolors.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/dircolors.c	Sun May 27 11:42:22 2001
*************** static enum Shell_syntax
*** 137,147 ****
--- 137,159 ----
  guess_shell_syntax (void)
  {
    char *shell;
+   char *dot;
+   char path[PATH_MAX];
  
    shell = getenv ("SHELL");
    if (shell == NULL || *shell == '\0')
      return SHELL_SYNTAX_UNKNOWN;
  
+ #ifdef MSDOS
+   /* Fix up the MS-DOS path - \ -> /, etc. */
+   FIXPATH (shell, path);
+   shell = path;
+ 
+   /* Chop executable extensions off the shell name. */
+   dot = strrchr(shell, '.');
+   if ((dot != NULL) && (STREQ (dot, ".exe") || STREQ (dot, ".com")))
+     *dot = '\0';
+ #endif  
    shell = base_name (shell);
  
    if (STREQ (shell, "csh") || STREQ (shell, "tcsh"))
*************** dc_parse_stream (FILE *fp, const char *f
*** 258,263 ****
--- 270,279 ----
  
    /* Get terminal type */
    term = getenv ("TERM");
+ #ifdef __DJGPP__
+   /* DJGPP port can always colorize, but TERM is not usually defined there. */
+   term = "console";
+ #endif  
    if (term == NULL || *term == '\0')
      term = "none";
  
*** /dev/null	Sun Jul  1 14:57:02 2001
--- /develop/ports/gnu.dev/filutil4.0-rel/src/djstart.c	Sun May 27 11:42:22 2001
***************
*** 0 ****
--- 1,189 ----
+ /* dj_startup -- Start-up code for GNU Fileutils under MS-DOS/DJGPP
+ 
+    Written by Eli Zaretskii <eliz@is.elta.co.il>
+ 
+    This code may be freely distributed, provided that this
+    copyright notice is left intact.  There is no warranty on
+    this code.
+ 
+    Commentary:
+    ----------
+ 
+    GNU Fileutils deal with files, and are notorious (as most other
+    Unix file-related utilities) for hardcoded assumptions about
+    filenames, especially regarding the slash character and the
+    insistance on knowing the fact that a filename that begins with
+    anything other than a slash is a relative filename (what about
+    DOS d:/file pathnames?).  To make these programs work on MSDOS,
+    it makes sense to convert all the filename arguments to the
+    forward-slash Unix-style notation at start-up.  This would
+    eliminate multiple #ifdef's in the programs' code.  The only
+    thing to take care of is to leave the options alone.
+ 
+    This module is supplied to do this kind of automagic, by using the
+    static constructor hooks provided in DJGPP v2.0 and above.  It
+    should be linked with every program from this package and will be
+    called automatically by the DJGPP start-up code (on crt1.c) just
+    before the `main' function is called.
+ 
+    There are a few other small services that this module does, while
+    at that:
+ 
+    * It sets the default file open mode to BINARY, which is
+      appropriate for file I/O in this package and removes another
+      reason for #ifdef's in the main code;
+ 
+    * It sets the flag bits for the `stat' and `fstat' functions so
+      as to avoid computing fields of `struct stat' that are expensive,
+      unless that program really needs these fields.
+ 
+    WARNING WARNING WARNING!!!
+ 
+    This code relies heavily on the assumption that it will be called
+    for a single command-line only once during the entire life of the
+    program!  Thus all the flag variables are static.
+ 
+    Also note that some of the code below relies on the program name
+    in argv[0] and will break if you rename the program executable file!
+ 
+    You HAVE been warned!
+ 
+    WARNING WARNING WARNING!!!
+ */
+ 
+ /*
+  * Copied from Fileutils 3.16 DJGPP port for use in Fileutils 4.0 DJGPP port
+  * by Richard Dawe <richdawe@bigfoot.com>.
+  */
+ 
+ #include <config.h>
+ 
+ #ifdef __DJGPP__
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <io.h>
+ #include <crt0.h>
+ 
+ int _crt0_startup_flags = _CRT0_FLAG_DROP_EXE_SUFFIX;
+ 
+ #ifndef _POSIX_SOURCE
+ /* Let's punish the user as little as we can by requesting
+    the fastest possible version of `stat' for each program.
+    Note that `ls' is not here because it sets the bits at
+    run time, given the options on its command line.  */
+ #define  DEFAULT_STAT_BITS  (_STAT_WRITEBIT   | \
+ 			     _STAT_ROOT_TIME  | \
+ 			     _STAT_DIRSIZE    | \
+ 			     _STAT_EXEC_MAGIC | \
+ 			     _STAT_EXEC_EXT)
+ 
+ static struct {
+   char *name;
+   unsigned short stat_bits;
+ } prog_bits[] = {
+     {"chmod",   ~(_STAT_DIRSIZE | _STAT_EXEC_EXT | _STAT_EXEC_MAGIC)},
+     {"chown",   ~_STAT_DIRSIZE},
+     {"cp",      ~(_STAT_DIRSIZE | _STAT_EXEC_EXT)},
+     {"ln",      ~_STAT_EXEC_EXT},
+     {"mv",	~(_STAT_DIRSIZE | _STAT_EXEC_EXT)},
+     {"rm",	~(_STAT_DIRSIZE | _STAT_EXEC_EXT)},
+     {"touch",	~_STAT_ROOT_TIME}
+ };
+ #endif
+ 
+ static void
+ init_stat_bits (const char *prog_name)
+ {
+ #ifndef _POSIX_SOURCE
+   int i;
+ 
+   _djstat_flags = DEFAULT_STAT_BITS;
+ 
+   for (i = 0; i < sizeof (prog_bits) / sizeof (prog_bits[0]); i++)
+     if (strcasecmp (prog_name, prog_bits[i].name) == 0)
+       {
+ 	_djstat_flags &= prog_bits[i].stat_bits;
+ 	break;
+       }
+ #endif
+ }
+ 
+ static void
+ init_file_io (const char *prog_name)
+ {
+   _fmode = O_BINARY;
+ 
+   /* Only `dd' needs to switch standard streams to binary.  */
+   if (strcasecmp (prog_name, "dd") == 0)
+     {
+       if (!isatty (fileno (stdin)))
+ 	setmode (fileno (stdin), O_BINARY);
+       if (!isatty (fileno (stdout)))
+ 	setmode (fileno (stdout), O_BINARY);
+     }
+ }
+ 
+ static int options_first;       /* options preceed non-options */
+ static int no_more_options = 0; /* did we see all of the options yet? */
+ 
+ extern int    __crt0_argc;	/* defined by the DJGPP startup code */
+ extern char **__crt0_argv;
+ 
+ static void __attribute__((constructor))
+ djgpp_fileutils_startup (void)
+ {
+   char *  argv0base, *dot;
+   char ** arg_walker = __crt0_argv;
+   int     arg_count  = __crt0_argc;
+ 
+   /* Convert all non-option ARGV[] elements to forward slashes.  */
+   if (!options_first)
+     options_first = getenv("POSIXLY_CORRECT") != (char *)0;
+ 
+   while (arg_count--)
+     {
+       char *p = *arg_walker++;
+ 
+       if (no_more_options == 0)
+ 	{
+ 	  if (p[0] == '-')
+ 	    {
+ 	      if (p[1] == '-' && p[2] == '\0')
+ 		no_more_options = 1;
+ 	      continue;
+ 	    }
+ 	  else if (options_first)
+ 	    no_more_options = 1;
+ 	}
+       while (*p)
+ 	{
+ 	  if (*p == '\\')
+ 	    *p = '/';
+ 	  p++;
+ 	}
+     }
+ 
+   /* Find out what's the name of the program.  */
+   argv0base = strrchr (*__crt0_argv, '/');
+   if (!argv0base)
+     argv0base = strrchr (*__crt0_argv, ':');
+   if (argv0base)
+     argv0base++;
+   else
+     argv0base = *__crt0_argv;
+ 
+   /* When we are called by another DJGPP program, the
+      _CRT0_FLAG_DROP_EXE_SUFFIX bit does not always work.  */
+   if ((dot = strchr (argv0base, '.')))
+     *dot = '\0';
+ 
+   init_stat_bits (argv0base);
+   init_file_io (argv0base);
+ }
+ 
+ #endif /* __DJGPP__ */
*** /dev/null	Sun Jul  1 14:57:02 2001
--- /develop/ports/gnu.dev/filutil4.0-rel/src/djutils.c	Sun May 27 11:42:22 2001
***************
*** 0 ****
--- 1,28 ----
+ /*
+  * djutils.c
+  * Miscellaneous utility functions for DJGPP port of Fileutils 4.0.
+  *
+  * Some parts written by Richard Dawe <richdawe@bigfoot.com>, some taken from
+  * the port of Fileutils 3.16 by Eli Zaretskii <eliz@is.elta.co.il>.
+  */
+ 
+ #include <config.h>
+ 
+ #ifdef __DJGPP__
+ 
+ /* Versions of DJGPP > 2.03 support symlinks (currently only DJGPP CVS). If
+  * symlinks are supported, we don't need this code. */
+ #ifndef HAVE_LSTAT
+ 
+ #include <sys/stat.h>
+ 
+ /* DJGPP doesn't have `lstat', since MS-DOS doesn't
+  * support links.  Here's a trivial substitute that will do.  */
+ int lstat (const char *fname, struct stat *st_buf)
+ {
+   return stat (fname, st_buf);
+ }
+ 
+ #endif /* !HAVE_LSTAT */
+ 
+ #endif /* __DJGPP__ */
*** /develop/ports/orig/fileutils-4.0/src/du.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/du.c	Sun May 27 11:42:22 2001
***************
*** 60,65 ****
--- 60,71 ----
  #include "xstrtol.h"
  #include "savedir.h"
  
+ #ifdef MSDOS
+ #include <signal.h>
+ static struct saved_cwd start_cwd;
+ static RETSIGTYPE interrupt_handler ();
+ #endif
+ 
  /* Initial number of entries in each hash table entry's table of inodes.  */
  #define INITIAL_HASH_MODULE 100
  
*************** du_files (char **files)
*** 431,436 ****
--- 437,449 ----
    initial_ino = stat_buf.st_ino;
    initial_dev = stat_buf.st_dev;
  
+ #ifdef MSDOS
+   /* We need to install a signal handler to make sure we return to
+    * the original directory even if we are aborted.  */
+   signal (SIGINT, interrupt_handler);
+   save_cwd (&start_cwd);
+ #endif
+   
    for (i = 0; files[i]; i++)
      {
        char *arg;
*************** du_files (char **files)
*** 440,445 ****
--- 453,470 ----
  
        /* Delete final slash in the argument, unless the slash is alone.  */
        s = strlen (arg) - 1;
+ #ifdef MSDOS
+       if (s == 1 && arg[1] == ':')
+ 	{
+ 	  /* Make "d:" explicit so we don't have to handle it specially.  */
+ 	  char full_path[FILENAME_MAX+5];
+ 	  FIXPATH (arg, full_path);
+ 	  str_copyc (path, full_path);
+ 	}
+       else if (s == 2 && arg[2] == '/')
+ 	str_copyc (path, arg);	/* leave alone the slash in "d:/" */
+       else
+ #endif      
        if (s != 0)
  	{
  	  if (arg[s] == '/')
*************** count_entry (const char *ent, int top, d
*** 517,522 ****
--- 542,577 ----
        if (opt_one_file_system && !top && last_dev != dir_dev)
  	return 0;		/* Don't enter a new file system.  */
  
+ #ifdef MSDOS
+       /* Every drive has its own ``working directory''.  If we're about
+ 	 to change drive, we need to save and restore that directory to
+ 	 prevent side-effects.  To this end, we will first chdir to the
+ 	 working directory on that drive so it is remembered by save_cwd.  */
+       if (ent[1] == ':')
+ 	{
+ 	  char work_dir[4];
+ 
+ 	  work_dir[0] = ent[0];
+ 	  work_dir[1] = ':';
+ 	  work_dir[2] = '.';
+ 	  work_dir[3] = '\0';
+ 	  if (chdir (work_dir) < 0)
+ 	    {
+ 	      error (0, errno, _("cannot change to directory %s"), work_dir);
+ 	      exit_status = 1;
+ 	      return 0;
+ 	    }
+ 
+ 	  /* This will return us to work_dir after every chdir, so the
+ 	     working directory is indeed preserved.  */
+ 	  through_symlink = 1;
+ 	}
+ 
+       if (save_cwd (&cwd))
+ 	exit (1);
+ 
+ #else  /* !MSDOS */
+       
  #ifndef S_ISLNK
  # define S_ISLNK(s) 0
  #endif
*************** count_entry (const char *ent, int top, d
*** 529,534 ****
--- 584,591 ----
        if (through_symlink && save_cwd (&cwd))
  	exit (1);
  
+ #endif /* !MSDOS */
+       
        if (chdir (ent) < 0)
  	{
  	  error (0, errno, _("cannot change to directory %s"), path->text);
*************** count_entry (const char *ent, int top, d
*** 561,566 ****
--- 618,628 ----
  
        /* Remember the current path.  */
  
+ #ifdef MSDOS
+       /* Avoid adding extra slash in the case of a root directory.  */
+       if (path->text[path->length-2] != ':'
+ 	  || path->text[path->length-1] != '/')
+ #endif
        str_concatc (path, "/");
        pathlen = path->length;
  
*************** count_entry (const char *ent, int top, d
*** 586,591 ****
--- 648,657 ----
  		 _("cannot change to `..' from directory %s"), path->text);
  	}
  
+ #ifdef MSDOS
+       /* Avoid printing excess slash in the case of a root directory.  */
+       if (path->text[pathlen-2] != ':')
+ #endif      
        str_trunc (path, pathlen - 1); /* Remove the "/" we added.  */
        if (depth <= max_depth || top)
  	print_size (size, path->length > 0 ? path->text : "/");
*************** str_trunc (String *s1, unsigned int leng
*** 808,810 ****
--- 874,885 ----
        s1->length = length;
      }
  }
+ 
+ #ifdef MSDOS
+ static RETSIGTYPE
+ interrupt_handler (void)
+ {
+   restore_cwd (&start_cwd, _("starting directory"), NULL);
+   exit (1);
+ }
+ #endif
*** /develop/ports/orig/fileutils-4.0/src/install.c	Mon Oct  5 14:21:58 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/install.c	Sun May 27 11:42:22 2001
***************
*** 71,76 ****
--- 71,81 ----
  #include <pwd.h>
  #include <grp.h>
  
+ #ifdef __DJGPP__
+ # include <process.h>
+ # include <sys/system.h>
+ #endif
+ 
  #include "system.h"
  #include "backupfile.h"
  #include "modechange.h"
*************** static int
*** 446,451 ****
--- 451,523 ----
  install_file_in_file (const char *from, const char *to,
  		      const struct cp_options *x)
  {
+ #ifdef __DJGPP__  
+   static char STUBIFY[] = "stubify.exe";
+   char *from_dot = strrchr(from, '.');
+ 
+   /* DJGPP executables need to be stubbed and to have a valid executable file
+    * extension, to be executable by some DOS shells (e.g. COMMAND.COM). */
+   if (!(from_dot
+ 	&& (STREQ (from_dot, ".exe") || STREQ (from_dot, ".com"))))
+     {
+       char *new_from, *new_to;
+       const _v2_prog_type *file_type;
+       int status;
+ 
+       file_type = _check_v2_prog(from, -1);
+       
+       if (file_type->valid)
+ 	{
+ 	  /* If FROM is a COFF executable, make a DOS program on the fly.
+ 	   * This makes Unix-born Makefiles happy. */
+ 	  if (file_type->exec_format == _V2_EXEC_FORMAT_COFF)
+ 	    {
+ 	      new_from = alloca (strlen (from) + 1 + 4);
+ 	      stpcpy (stpcpy (new_from, from), ".exe");
+ 	      /* Don't overwrite a stubified .exe if it already exists
+ 		 (it may have been stubedited to change default stub info).  */
+ 	      if (!__file_exists (new_from))
+ 		{
+ 		  status = spawnlp (P_WAIT, STUBIFY, STUBIFY,
+ 				    from, (char *) NULL);
+ 		  if (status == -1)
+ 		    error (1, errno, _("cannot run stubify"));
+ 		}
+ 	      from = new_from;
+ 	      new_to = alloca (strlen (to) + 1 + 4);
+ 	      stpcpy (stpcpy (new_to, to), ".exe");
+ 	      to = new_to;
+ 	    }
+ 	  /* If FROM is a COFF executable that already has a stub, then
+ 	   * make sure that TO has an executable extension. */
+ 	  else if (file_type->exec_format == _V2_EXEC_FORMAT_STUBCOFF)
+ 	    {
+ 	      new_to = alloca (strlen (to) + 1 + 4);
+ 	      stpcpy (stpcpy (new_to, to), ".exe");
+ 	      to = new_to;
+ 	    }
+ 	}
+       else
+ 	{
+ 	  unsigned short header[1];
+ 	  int fd;
+ 
+ 	  fd = open(from, O_RDONLY | O_BINARY);
+ 	  if (   (read(fd, header, sizeof(header)) == sizeof(header))
+ 	      && (header[0] == 0x5a4d) /* "MZ" */)
+ 	    {
+ 	      /* If FROM is any other DOS (MZ) format executable, then
+ 	       * make sure that TO has an executable extension. */
+ 	      /* FIXME: This does not distinguish between .exe and .com. */
+ 	      new_to = alloca (strlen (to) + 1 + 4);
+ 	      stpcpy (stpcpy (new_to, to), ".exe");
+ 	      to = new_to;
+ 	    }
+ 	  close(fd);
+ 	}
+     }
+ #endif
+ 	
    if (copy_file (from, to, x))
      return 1;
    if (strip_files)
*************** install_file_in_dir (const char *from, c
*** 471,476 ****
--- 543,554 ----
  
    from_base = base_name (from);
    to = path_concat (to_dir, from_base, NULL);
+ #ifdef MSDOS
+   /* If we get "d:" in FROM, make "d:to_dir", not "d:/to_dir".  */
+   if (strlen (to_dir) == 2 && to_dir[1] == ':')
+     stpcpy (stpcpy (to, to_dir), from_base);
+   else
+ #endif  
    ret = install_file_in_file (from, to, x);
    free (to);
    return ret;
*************** change_timestamps (const char *from, con
*** 572,577 ****
--- 650,657 ----
     magic numbers vary so much from system to system that making
     it portable would be very difficult.  Not worth the effort. */
  
+ #ifndef MSDOS
+ 
  static void
  strip (const char *path)
  {
*************** strip (const char *path)
*** 595,600 ****
--- 675,722 ----
      }
  }
  
+ #else  /* MSDOS */
+ #ifdef __DJGPP__
+ 
+ static char STRIP[]   = "strip.exe";
+ 
+ static void
+ strip (const char *path)
+ {
+   const _v2_prog_type *file_type;
+   int status;
+ 
+   file_type = _check_v2_prog(path, -1);
+   status    = spawnlp (P_WAIT, STRIP, STRIP, path, (char *) NULL);
+ 
+   if (status == -1)
+     error (1, errno, _("cannot run strip"));
+ 
+   if (status != 0)
+     {
+       /* If `strip' failed on a stubbed executable, it may be because it does
+        * not understand/support the stub. Inform the user. */
+       if (   file_type->valid
+ 	  && (file_type->exec_format == _V2_EXEC_FORMAT_STUBCOFF))
+ 	{
+ 	  error (0, 0,
+ 		 "%s: Executable may have a non-standard stub, "
+ 		 "e.g. PMODE/DJ, CWSDSTUB",
+ 		 path);
+ 	}
+     }
+ }
+ 
+ #else  /* not __DJGPP__ */
+ 
+ static void
+ strip (const char *path)
+ {
+ }
+ 
+ #endif /* __DJGPP__ */
+ #endif /* MSDOS */
+ 
  /* Initialize the user and group ownership of the files to install. */
  
  static void
*** /develop/ports/orig/fileutils-4.0/src/ln.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/ln.c	Sun May 27 11:42:22 2001
***************
*** 31,36 ****
--- 31,54 ----
  #include "closeout.h"
  #include "error.h"
  
+ #ifdef  __DJGPP__
+ 
+ /* Versions of DJGPP > 2.03 support symlinks (currently only DJGPP CVS). If
+  * symlinks are supported, we can rely on DJGPP to DTRT. */
+ #if !(defined(HAVE_LSTAT) && defined(S_ISLNK))
+ 
+ /* DJGPP doesn't have S_ISLNK defined, because MS-DOS doesn't support links.
+  * However, DJGPP's `link' simulates hard links by copying, and we can
+  * have ``symbolic links'' for DJGPP .EXE programs.  Therefore, just
+  * for the purpose of this program, it makes sense to define S_ISLNK
+  * so we could have working `ln'.  */
+ 
+ #define S_ISLNK(x)  (0)     /* defined, but no file is a link */
+ 
+ #endif /* !(HAVE_LSTAT && S_ISLNK) */
+ 
+ #endif /* __DJGPP__ */
+ 
  int link ();			/* Some systems don't declare this anywhere. */
  
  #ifdef S_ISLNK
*** /dev/null	Sun Jul  1 14:57:02 2001
--- /develop/ports/gnu.dev/filutil4.0-rel/src/ls-msdos.c	Sun Jul  1 14:55:58 2001
***************
*** 0 ****
--- 1,358 ----
+ /*
+  * MSDOS-specific functions for `ls'.
+  *
+  * Written by Eli Zaretskii <eliz@is.elta.co.il>
+  *
+  * Copied from Fileutils 3.16 DJGPP port for use in Fileutils 4.0 DJGPP port
+  * by Richard Dawe <richdawe@bigfoot.com>. Modifications are indicated by
+  * '(richdawe) ...' comments.
+  */
+ 
+ #ifdef MSDOS
+ 
+ #include <string.h>
+ 
+ /*  dos_mode_string -- convert MS-DOS file attribute bits into a character
+     string.  The characters stored in STR are:
+ 
+     0   'r'  if file is read-only, '-' otherwise.
+     1   'h'  if file is hidden, '-' otherwise.
+     2   's'  if file has its system bit set, '-' otherwise.
+     3   'v'  if file is a volume label, '-' otherwise.
+     4   'd'  if file is a directory, '-' otherwise.
+     5   'm'  if file was modified since last backup, '-' otherwise.
+     
+     For instance, for a write-protected, hidden file the function
+     will return a string "rh----".  */
+ 
+ void
+ dos_mode_string (bits, str)
+     int bits;
+     char *str;
+ {
+   unsigned mask = 1 << 5;
+   
+   strcpy(str, "rhsvdm");          /* assume all bits set */
+   for (str += 5; mask; mask >>= 1, --str)
+     if ((bits & mask) == 0)
+       *str = '-';                 /* put hyphen instead of unused bit */
+ }
+ 
+ #ifdef __DJGPP__
+ 
+ /* What follows won't work with anything but DJGPP.  */
+ 
+ #include <sys/stat.h>
+ #include <dirent.h>
+ 
+ static int colorization_required;
+ 
+ /* Ls is a heavy user of `stat' whose full emulation on MS-DOS is
+    sometimes very expensive.  Let's punish the user as little as we
+    can by requesting the fastest possible version of `stat'.
+ 
+    The default bits, suitable for just displaying the names of the files
+    are defined on `djstart.c'; below are the bits required by various
+    Ls options. */
+ void set_stat_bits_for_ls (int need_time, int need_size,
+ 			   int need_long_format, int msdos_long_format,
+ 			   int indicate_type, int use_color, int show_hidden)
+ {
+ #ifndef _POSIX_SOURCE
+   if (need_time)
+     _djstat_flags &= ~_STAT_ROOT_TIME;
+   if (need_size)
+     _djstat_flags &= ~_STAT_DIRSIZE;
+   if (need_long_format)
+     {
+       _djstat_flags &= ~(_STAT_ROOT_TIME
+ 			 | _STAT_DIRSIZE);
+       if (msdos_long_format)
+ 	_djstat_flags &= ~_STAT_EXEC_EXT;
+       else
+ 	_djstat_flags &= ~(_STAT_EXEC_MAGIC
+ 			   | _STAT_EXEC_EXT);
+     }
+   if (indicate_type)
+     _djstat_flags &= ~(_STAT_EXEC_EXT
+ 		       | _STAT_EXEC_MAGIC);
+   if (use_color)
+     _djstat_flags &= ~_STAT_EXEC_EXT;
+ 
+   /* (richdawe) Default to skipping hidden files. */
+   __opendir_flags |= __OPENDIR_NO_HIDDEN;
+ 
+   /* Find hidden files only if user specified -a.  */
+   if (show_hidden)
+     {
+       /* (richdawe) Eli advised me that setting __OPENDIR_FIND_HIDDEN
+        * will not work, because of a bug in DJGPP 2.03's libc. We also need
+        * to clear __OPENDIR_NO_HIDDEN. */
+       __opendir_flags |= __OPENDIR_FIND_HIDDEN;
+       __opendir_flags &= ~__OPENDIR_NO_HIDDEN;
+ 
+       /* Find volume labels only if user specified both -a and -g.  */
+       if (msdos_long_format)
+ 	__opendir_flags |= __OPENDIR_FIND_LABEL;
+     }
+ 
+ #endif /* _POSIX_SOURCE */
+ 
+   /* Our screen redirector (below) wants to know if
+      colorization was actually required.  */
+   if (use_color)
+     colorization_required = 1;
+   else
+     colorization_required = 0;
+ }
+ 
+ /*  Screen write redirector.  We need this to support colorization
+     without requiring ANSI.SYS driver (or its work-alike) to be loaded.
+ 
+     This function uses the DJGPP filesystem extensions mechanism.  It is
+     installed as a handler for handle-based functions (read/write/close)
+     for the standard output (but actually only handles writes, only if
+     the standard output is connected to the terminal, and only if user
+     asked for colorization).  When a buffer is written to the screen by
+     low-level functions of the DJGPP C library, our handler will be
+     called.  For any request that doesn't require colored screen writes
+     we return a zero to the caller, in which case the caller will handle
+     the output in the usual way (by eventually calling DOS).
+ 
+     When colorization *is* required, the buffer is written directly to
+     the screen while converting the ANSI escape sequences into calls to
+     DJGPP conio functions which change text attributes.  A non-zero value is
+     then returned to the caller to signal that the output has been handled.
+ 
+     Warning: this function relies on the fact that `ls' disables the use
+     of TAB characters when colorization is required, and therefore it
+     does NOT expand TABs!  It also doesn't check for NULL characters in
+     the buffer, and might end the output prematurely if there are NULLs.  */
+ 
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <errno.h>
+ #include <unistd.h>
+ #include <conio.h>
+ #include <sys/fsext.h>
+ #include <go32.h>	/* for `_dos_ds' */
+ #include <sys/farptr.h>
+ 
+ static int norm_blink = -1, cur_blink = -1;
+ static unsigned char norm_attr = 0, cur_attr = 0;
+ static int isatty_stdout = -1;
+ 
+ /* Restore the BIOS blinking bit to its original value.  Called at exit.  */
+ static void
+ restore_blink_bit (void)
+ {
+   if (cur_blink != norm_blink)
+     {
+       if (norm_blink > 0)
+ 	blinkvideo ();
+       else
+ 	intensevideo ();
+     }
+ }
+ 
+ #define ESC '\033'
+ 
+ static int
+ msdos_screen_write (__FSEXT_Fnumber func, int *retval, va_list rest_args)
+ {
+   static char *cbuf = NULL;
+   static size_t cbuf_len = 0;
+   /* Only dark colors mentioned here, so that bold has visible effect.  */
+   static enum COLORS screen_color[] = {BLACK, RED, GREEN, BROWN,
+ 				       BLUE, MAGENTA, CYAN, LIGHTGRAY};
+   char *anchor, *p_next;
+   unsigned char fg, bg;
+ 
+   int handle;
+   char *buf;
+   size_t buflen;
+ 
+   /* Avoid direct screen writes unless colorization was actually requested.
+      Otherwise, we will break programs that catch I/O from their children.  */
+   handle = va_arg (rest_args, int);
+   if (!colorization_required || func != __FSEXT_write
+       || !(handle == STDOUT_FILENO ? isatty_stdout : isatty (handle)))
+     return 0;
+ 
+   buf = va_arg (rest_args, char *);
+   if (!buf)
+     {
+       errno = EINVAL;
+       *retval = -1;
+       return 1;
+     }
+ 
+   /* Allocate a sufficiently large buffer to hold the output.  */
+   buflen = va_arg (rest_args, size_t);
+   if (!cbuf)
+     {
+       struct text_info txtinfo;
+ 
+       cbuf_len = buflen + 1;
+       cbuf = (char *)xmalloc (cbuf_len);
+       gettextinfo (&txtinfo);
+       norm_attr = txtinfo.attribute; /* save the original text attribute */
+       cur_attr = norm_attr;
+       /* Does it normally blink when bg has its 3rd bit set?  */
+       norm_blink = (_farpeekb (_dos_ds, 0x465) & 0x20) ? 1 : 0;
+       cur_blink = norm_blink;
+     }
+   else if (buflen >= cbuf_len)
+     {
+       cbuf_len = buflen + 1;
+       cbuf = (char *)xrealloc (cbuf, cbuf_len);
+     }
+   memcpy (cbuf, buf, buflen);
+   cbuf[buflen] = '\0';
+ 
+   /* Current text attributes are used as baseline.  */
+   fg = cur_attr & 15;
+   bg = (cur_attr >> 4) & 15;
+ 
+   /* Walk the buffer, writing text directly to video RAM,
+      changing color attributes when an escape sequence is seen.  */
+   for (anchor = p_next = cbuf;
+        (p_next = memchr (p_next, ESC, buflen - (p_next - cbuf))) != 0; )
+     {
+       char *p = p_next;
+ 
+       /* (richdawe) Handle the null escape sequence (ESC-[m), which ls uses
+        * to restore the original colour. */
+       if ((p[1] == '[') && (p[2] == 'm'))
+ 	{
+ 	  textattr (norm_attr);
+ 	  p += 3;
+ 	  anchor = p_next = p;
+ 	  continue;
+ 	}
+       
+       if (p[1] == '[')	/* "Esc-[" sequence */
+ 	{
+ 	  /* If some chars seen since the last escape sequence,
+ 	     write it out to the screen using current text attributes.  */
+ 	  if (p > anchor)
+ 	    {
+ 	      *p = '\0';	/* `cputs' needs ASCIIZ string */
+ 	      cputs (anchor);
+ 	      *p = ESC;		/* restore the ESC character */
+ 	      anchor = p;
+ 	    }
+ 	  p += 2;		/* get past "Esc-[" sequence */
+ 	  p_next = p;
+ 	  while (*p != 'm')	/* `m' ends the escape sequence */
+ 	    {
+ 	      char *q;
+ 	      long code = strtol (p, &q, 10);
+ 
+ 	      /* Sanity checks:
+ 
+ 		   q > p unless p doesn't point to a number;
+ 		   ANSI codes are between 0 and 47;
+ 		   Each ANSI code ends with a `;' or an `m'.
+ 
+ 		 If any of the above is violated, we just ignore the bogon. */
+ 	      if (q == p || code > 47 || code < 0 || (*q != 'm' && *q != ';'))
+ 		{
+ 		  p_next = q;
+ 		  break;
+ 		}
+ 	      if (*q == ';')	/* more codes to follow */
+ 		q++;
+ 
+ 	      /* Convert ANSI codes to color fore- and background.  */
+ 	      switch (code)
+ 		{
+ 		  case 0:	/* all attributes off */
+ 		    fg = norm_attr & 15;
+ 		    bg = (norm_attr >> 4) & 15;
+ 		    break;
+ 		  case 1:	/* intensity on */
+ 		    fg |= 8;
+ 		    break;
+ 		  case 4:	/* underline on */
+ 		    fg |= 8;	/* we can't, so make it bold instead */
+ 		    break;
+ 		  case 5:	/* blink */
+ 		    if (cur_blink != 1)
+ 		      {
+ 			blinkvideo (); /* ensure we are'nt in bright bg mode */
+ 			cur_blink = 1;
+ 		      }
+ 		    bg |= 8;
+ 		    break;
+ 		  case 7:	/* reverse video */
+ 		    {
+ 		      unsigned char t = fg;
+ 		      fg = bg;
+ 		      bg = t;
+ 
+ 		      /* If it was blinking before, let it blink after.  */
+ 		      if (fg & 8)
+ 			bg |= 8;
+ 
+ 		      /* If the fg was bold, let the background be bold.  */
+ 		      if ((t & 8) && cur_blink != 0)
+ 			{
+ 			  intensevideo ();
+ 			  cur_blink = 0;
+ 			}
+ 		    }
+ 		    break;
+ 		  case 8:	/* concealed on */ 
+ 		    fg = (bg & 7) | 8;	/* make fg be like bg, only bright */
+ 		    break;
+ 		  case 30: case 31: case 32: case 33: /* foreground color */
+ 		  case 34: case 35: case 36: case 37:
+ 		    fg = (fg & 8) | (screen_color[code - 30] & 15);
+ 		    break;
+ 		  case 40: case 41: case 42: case 43: /* background color */
+ 		  case 44: case 45: case 46: case 47:
+ 		    bg = (bg & 8) | (screen_color[code - 40] & 15);
+ 		    break;
+ 		  default:
+ 		    p_next = q;	/* ignore unknown codes */
+ 		    break;
+ 		}
+ 	      p = q;
+ 	    }
+ 	  if (*p == 'm' && p > p_next)
+ 	    {
+ 	      /* They don't *really* want it invisible, do they?  */
+ 	      if (fg == (bg & 7))
+ 		fg |= 8;	/* make it concealed instead */
+ 
+ 	      /* Construct the text attribute and set it.  */
+ 	      cur_attr = (bg << 4) | fg;
+ 	      textattr (cur_attr);
+ 	      p_next = anchor = p + 1;
+ 	    }
+ 	  else
+ 	    break;
+ 	}
+       else
+ 	p_next++;
+     }
+ 
+   /* Output what's left in the buffer.  */
+   cputs (anchor);
+   *retval = buflen;
+   return 1;
+ }
+ 
+ /* This is called before `main' to install our STDOUT redirector.  */
+ 
+ static void __attribute__((constructor))
+ djgpp_ls_startup (void)
+ {
+   __FSEXT_set_function (STDOUT_FILENO, msdos_screen_write);
+   isatty_stdout = isatty (STDOUT_FILENO);
+   atexit (restore_blink_bit);
+ }
+ 
+ #endif  /* __DJGPP__ */
+ #endif  /* MSDOS */
*** /develop/ports/orig/fileutils-4.0/src/ls.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/ls.c	Sun Aug 12 18:23:30 2001
***************
*** 54,59 ****
--- 54,62 ----
  #ifdef GWINSZ_IN_SYS_IOCTL
  # include <sys/ioctl.h>
  #endif
+ #ifdef __DJGPP__
+ # include <pc.h>
+ #endif
  
  #include <stdio.h>
  #include <grp.h>
*************** struct fileinfo
*** 115,120 ****
--- 118,127 ----
      int linkok;
  
      enum filetype filetype;
+ #ifdef  MSDOS
+     /* On MS-DOS we also get DOS-specific file attribute bits. */
+     int msdos_attribs;
+ #endif	  
    };
  
  #define LEN_STR_PAIR(s) sizeof (s) - 1, s
*************** void strip_trailing_slashes ();
*** 139,144 ****
--- 146,155 ----
  char *xstrdup ();
  void invalid_arg ();
  
+ #ifdef  MSDOS
+ void dos_mode_string PARAMS ((int, char *));
+ #endif
+ 
  static size_t quote_name PARAMS ((FILE *out, const char *name,
  				  struct quoting_options const *options));
  static char *make_link_path PARAMS ((const char *path, const char *linkname));
*************** enum indicator_no
*** 369,380 ****
    {
      C_LEFT, C_RIGHT, C_END, C_NORM, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK,
      C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC
    };
  
  static const char *const indicator_name[]=
    {
      "lc", "rc", "ec", "no", "fi", "di", "ln", "pi", "so",
!     "bd", "cd", "mi", "or", "ex", NULL
    };
  
  struct col_ext_type
--- 380,398 ----
    {
      C_LEFT, C_RIGHT, C_END, C_NORM, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK,
      C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC
+ #ifdef MSDOS
+     , C_LABEL			/* MSDOS volume label */
+ #endif    
    };
  
  static const char *const indicator_name[]=
    {
      "lc", "rc", "ec", "no", "fi", "di", "ln", "pi", "so",
!     "bd", "cd", "mi", "or", "ex"
! #ifdef MSDOS
!     , "lb"			/* MSDOS volume label */
! #endif
!     , NULL    
    };
  
  struct col_ext_type
*************** static struct bin_str color_indicator[] 
*** 400,405 ****
--- 418,426 ----
      { 0, NULL },			/* mi: Missing file: undefined */
      { 0, NULL },			/* or: Orphanned symlink: undefined */
      { LEN_STR_PAIR ("01;32") }		/* ex: Executable: bright green */
+ #ifdef MSDOS
+     , { LEN_STR_PAIR ("37;07") }	/* lb: Volume Label: black on white */
+ #endif    
    };
  
  /* FIXME: comment  */
*************** static int show_help;
*** 498,503 ****
--- 519,530 ----
  /* If nonzero, print the version on standard output and exit.  */
  static int show_version;
  
+ #ifdef  MSDOS
+ /* If non-zero, use DOS-style permission mode, and don't show UID and GID
+  * in long format. */
+ static int msdos_long_format;
+ #endif
+ 
  static struct option const long_options[] =
  {
    {"all", no_argument, 0, 'a'},
*************** static struct option const long_options[
*** 531,536 ****
--- 558,566 ----
    {"sort", required_argument, 0, 10},
    {"tabsize", required_argument, 0, 'T'},
    {"time", required_argument, 0, 11},
+ #ifdef MSDOS
+   {"msdos-long-format", no_argument, 0, 'g'},
+ #endif  
    {"help", no_argument, &show_help, 1},
    {"version", no_argument, &show_version, 1},
    {"color", optional_argument, 0, 13},
*************** main (int argc, char **argv)
*** 709,715 ****
    if (print_with_color)
      {
        parse_ls_color ();
!       prep_non_filename_text ();
      }
  
    format_needs_stat = sort_type == sort_time || sort_type == sort_size
--- 739,747 ----
    if (print_with_color)
      {
        parse_ls_color ();
! 
!       if (print_with_color)
! 	prep_non_filename_text ();
      }
  
    format_needs_stat = sort_type == sort_time || sort_type == sort_size
*************** main (int argc, char **argv)
*** 717,722 ****
--- 749,766 ----
      || trace_links || trace_dirs || indicator_style != none
      || print_block_size || print_inode || print_with_color;
  
+ #if defined(__DJGPP__) && !defined(_POSIX_SOURCE)
+   /* Some members of `struct stat' are very expensive to compute on
+    * MSDOS.  This requests the fastest `stat' operation for given
+    * combination of options; see `ls-msdos.c'.    */
+   if (format_needs_stat)
+     set_stat_bits_for_ls (sort_type == sort_time,
+ 			  sort_type == sort_size || print_block_size,
+ 			  format == long_format, msdos_long_format,
+ 			  indicator_style != none, print_with_color,
+ 			  all_files);
+ #endif  /* __DJGPP__ && !_POSIX_SOURCE */
+   
    if (dired && format == long_format)
      {
        obstack_init (&dired_obstack);
*************** decode_switches (int argc, char **argv)
*** 887,892 ****
--- 931,940 ----
    }
  #endif
  
+ #ifdef __DJGPP__
+   line_length = ScreenCols ();
+ #endif
+   
    /* Using the TABSIZE environment variable is not POSIX-approved.
       Ignore it when POSIXLY_CORRECT is set.  */
    tabsize = 8;
*************** decode_switches (int argc, char **argv)
*** 945,950 ****
--- 993,1001 ----
  	  break;
  
  	case 'g':
+ #ifdef  MSDOS
+           msdos_long_format = 1;
+ #endif		
  	  /* No effect.  For BSD compatibility. */
  	  break;
  
*************** parse_ls_color (void)
*** 1413,1420 ****
    struct col_ext_type *ext;	/* Extension we are working on */
    struct col_ext_type *ext2;	/* Extra pointer */
  
!   if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0')
      return;
  
    ext = NULL;
    strcpy (label, "??");
--- 1464,1476 ----
    struct col_ext_type *ext;	/* Extension we are working on */
    struct col_ext_type *ext2;	/* Extra pointer */
  
!   if ((p = getenv ("LS_COLORS")) == NULL)
      return;
+   if (*p == '\0')
+     {
+       print_with_color = 0;
+       return;
+     }
  
    ext = NULL;
    strcpy (label, "??");
*************** gobble_file (const char *name, int expli
*** 1704,1709 ****
--- 1760,1772 ----
      {
        /* `path' is the absolute pathname of this file. */
  
+ #ifdef MSDOS
+       /* Any filename with a drive specification should be
+        * treated as an absolute pathname on MS-DOS.  */
+       if (name[1] == ':')
+ 	path = (char *)name;
+       else
+ #endif	    
        if (name[0] == '/' || dirname[0] == 0)
  	path = (char *) name;
        else
*************** gobble_file (const char *name, int expli
*** 1732,1737 ****
--- 1795,1821 ----
  	  return 0;
  	}
  
+ #ifdef MSDOS
+       /* Get the MS-DOS attribute bits if they requested them.  */
+       if (msdos_long_format && format == long_format)
+ 	{
+ 	  if (S_ISCHR (files[files_index].stat.st_mode))
+ 	    files[files_index].msdos_attribs = 0x20; /* Modified only */
+ 	  else if (S_ISLABEL (files[files_index].stat.st_mode))
+ 	    /* Argh!  `_chmod' fails for volume labels!!  */
+ 	    files[files_index].msdos_attribs = 0x28;
+ 	  else
+ 	    {
+ 	      char fullpath[PATH_MAX];
+ 
+ 	      FIXPATH (path, fullpath);
+ 	      files[files_index].msdos_attribs = _chmod (fullpath, 0, 0);
+ 	      if (files[files_index].msdos_attribs == -1)
+ 		files[files_index].msdos_attribs = 0x20;
+ 	    }
+ 	}
+ #endif /* MSDOS */
+       
  #ifdef S_ISLNK
        if (S_ISLNK (files[files_index].stat.st_mode)
  	  && (explicit_arg || format == long_format || print_with_color))
*************** extract_dirs_from_files (const char *dir
*** 1894,1899 ****
--- 1978,1989 ----
      if ((files[i].filetype == directory || files[i].filetype == arg_directory)
  	&& (!recursive || is_not_dot_or_dotdot (files[i].name)))
        {
+ #ifdef MSDOS
+ 	/* DOS-specific case of absolute pathnames.  */
+ 	if (files[i].name[1] == ':')
+ 	  queue_directory (files[i].name, files[i].linkname);
+ 	else
+ #endif	      
  	if (files[i].name[0] == '/' || dirname[0] == 0)
  	  {
  	    queue_directory (files[i].name, files[i].linkname);
*************** is_not_dot_or_dotdot (const char *name)
*** 1927,1932 ****
--- 2017,2027 ----
    char *t;
  
    t = strrchr (name, '/');
+ #ifdef MSDOS
+   /* We can have "d:." or "d:.."  */
+   if (!t && name[1] == ':')
+     t = (char *)(name + 1);
+ #endif  
    if (t)
      name = t + 1;
  
*************** print_long_format (const struct fileinfo
*** 2189,2194 ****
--- 2284,2294 ----
    const char *fmt;
    char *user_name;
  
+ #ifdef MSDOS
+   if (msdos_long_format)
+     dos_mode_string (f->msdos_attribs, modebuf);
+   else
+ #endif  /* MSDOS */  
  #if HAVE_ST_DM_MODE
    /* Cray DMF: look at the file's migrated, not real, status */
    mode_string (f->stat.st_dm_mode, modebuf);
*************** print_long_format (const struct fileinfo
*** 2253,2263 ****
--- 2353,2372 ----
        p += strlen (p);
      }
  
+ #ifdef MSDOS
+   if (msdos_long_format)
+     sprintf (p, "%s  ", modebuf);
+   else
+ #endif  
    /* The space between the mode and the number of links is the POSIX
       "optional alternate access method flag". */
    sprintf (p, "%s %3u ", modebuf, (unsigned int) f->stat.st_nlink);
    p += strlen (p);
  
+ #ifdef MSDOS
+   if (!msdos_long_format)
+     {
+ #endif  
    user_name = (numeric_ids ? NULL : getuser (f->stat.st_uid));
    if (user_name)
      sprintf (p, "%-8.8s ", user_name);
*************** print_long_format (const struct fileinfo
*** 2274,2279 ****
--- 2383,2391 ----
  	sprintf (p, "%-8u ", (unsigned int) f->stat.st_gid);
        p += strlen (p);
      }
+ #ifdef MSDOS
+     }
+ #endif  
  
    if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
      sprintf (p, "%3u, %3u ", (unsigned) major (f->stat.st_rdev),
*************** print_long_format (const struct fileinfo
*** 2281,2288 ****
    else
      {
        char hbuf[LONGEST_HUMAN_READABLE + 1];
        sprintf (p, "%8s ",
! 	       human_readable ((uintmax_t) f->stat.st_size, hbuf, 1,
  			       output_block_size < 0 ? output_block_size : 1));
      }
  
--- 2393,2407 ----
    else
      {
        char hbuf[LONGEST_HUMAN_READABLE + 1];
+       uintmax_t size = f->stat.st_size;
+ 
+       /* POSIX requires that the size be printed without a sign, even
+ 	 when negative.  Assume the typical case where negative sizes
+ 	 are actually positive values that have wrapped around.  */
+       size += (f->stat.st_size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
+ 
        sprintf (p, "%8s ",
! 	       human_readable (size, hbuf, 1,
  			       output_block_size < 0 ? output_block_size : 1));
      }
  
*************** print_type_indicator (unsigned int mode)
*** 2455,2460 ****
--- 2574,2586 ----
      DIRED_PUTCHAR ('=');
  #endif
  
+ #ifdef MSDOS
+ #ifdef S_ISLABEL     /* MS-DOS Volume label */
+   if (S_ISLABEL (mode))
+     DIRED_PUTCHAR ('+');
+ #endif
+ #endif
+   
    if (S_ISREG (mode) && indicator_style == classify
        && (mode & S_IXUGO))
      DIRED_PUTCHAR ('*');
*************** print_color_indicator (const char *name,
*** 2505,2510 ****
--- 2631,2643 ----
  	type = C_CHR;
  #endif
  
+ #ifdef MSDOS
+ #ifdef S_ISLABEL     /* MS-DOS Volume label */
+       else if (S_ISLABEL (mode))
+ 	type = C_LABEL;
+ #endif
+ #endif
+       
        if (type == C_FILE && (mode & S_IXUGO) != 0)
  	type = C_EXEC;
  
*************** print_color_indicator (const char *name,
*** 2519,2525 ****
--- 2652,2664 ----
  	  for (ext = col_ext_list; ext != NULL; ext = ext->next)
  	    {
  	      if ((size_t) ext->ext.len <= len
+ #ifdef MSDOS
+ 		  /* Don't let the letter case affect the colorization on
+ 		   * MSDOS. */
+ 		  && strncasecmp (name - ext->ext.len, ext->ext.string,
+ #else		  
  		  && strncmp (name - ext->ext.len, ext->ext.string,
+ #endif			      
  			      ext->ext.len) == 0)
  		break;
  	    }
*************** length_of_file_name_and_frills (const st
*** 2577,2582 ****
--- 2716,2726 ----
  #ifdef S_ISSOCK
  	       || S_ISSOCK (filetype)
  #endif
+ #ifdef MSDOS
+ #ifdef S_ISLABEL
+ 	       || S_ISLABEL (filetype)
+ #endif
+ #endif	       
  	)
  	len += 1;
      }
*************** attach (char *dest, const char *dirname,
*** 2810,2815 ****
--- 2954,2964 ----
      {
        while (*dirnamep)
  	*dest++ = *dirnamep++;
+ #ifdef  MSDOS
+       /* "d:" does NOT mean "d:/"  */
+       if (dirnamep <= dirname + 1
+ 	  || dirname[1] != ':' || dirname[2] != '\0')
+ #endif      
        /* Add '/' if `dirname' doesn't already end with it. */
        if (dirnamep > dirname && dirnamep[-1] != '/')
  	*dest++ = '/';
*** /develop/ports/orig/fileutils-4.0/src/mv.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/mv.c	Sun May 27 11:42:22 2001
*************** strip_trailing_slashes_2 (char *path)
*** 283,291 ****
  static int
  movefile (char *source, char *dest, int dest_is_dir, const struct cp_options *x)
  {
!   int dest_had_trailing_slash = strip_trailing_slashes_2 (dest);
    int fail;
  
    /* In addition to when DEST is a directory, if DEST has a trailing
       slash and neither SOURCE nor DEST is a directory, presume the target
       is DEST/`basename source`.  This converts `mv x y/' to `mv x y/x'.
--- 283,313 ----
  static int
  movefile (char *source, char *dest, int dest_is_dir, const struct cp_options *x)
  {
!   char source_fixed[PATH_MAX], dest_fixed[PATH_MAX];
!   int dest_had_trailing_slash;
    int fail;
  
+ #ifdef MSDOS
+   /* On MS-DOS, fix up paths like 'd:t.t' into an absolute path. MS-DOS also
+    * has one working directory per drive. Hence, the trailing slash check was
+    * moved to after this code, because 'd:' may become 'd:/' if it's the
+    * current working directory on d:. However, only do the fix-up if there
+    * is a drive letter without a path. */
+   if ((source[1] == ':') && (source[2] != '/'))
+     {
+       FIXPATH (source, source_fixed);
+       source = source_fixed;
+     }
+ 
+   if ((dest[1] == ':') && (dest[2] != '/'))
+     {
+       FIXPATH (dest, dest_fixed);
+       dest = dest_fixed;
+     }
+ #endif
+ 
+   dest_had_trailing_slash = strip_trailing_slashes_2 (dest);
+   
    /* In addition to when DEST is a directory, if DEST has a trailing
       slash and neither SOURCE nor DEST is a directory, presume the target
       is DEST/`basename source`.  This converts `mv x y/' to `mv x y/x'.
*** /develop/ports/orig/fileutils-4.0/src/remove.c	Wed Nov  4 02:58:20 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/remove.c	Sun May 27 11:42:22 2001
*************** The following two directories have the s
*** 865,876 ****
--- 865,916 ----
      {
        int need_save_cwd = user_specified_name;
        enum RM_status status;
+ #ifdef MSDOS
+       struct saved_cwd cwd;
+ #endif /* MSDOS */
  
        if (need_save_cwd)
  	need_save_cwd = (strchr (fs->filename, '/') != NULL);
  
+ #ifdef MSDOS
+       /* If a drive letter is specified, we need to save the cwd.
+        * Then we change onto the drive specified. This way we preserve
+        * the working directory on the current drive. We also preserve
+        * the working directory on the drive where the directory resides,
+        * by setting need_save_cwd. */
+       if (fs->filename[0] && fs->filename[1] == ':')
+ 	{
+ 	  char newdrive[3];
+ 
+ 	  need_save_cwd = 1;
+ 	  if (save_cwd (&cwd))
+ 	    return(RM_ERROR);
+ 
+ 	  strncpy(newdrive, fs->filename, 2);
+ 	  newdrive[2] = '\0';
+ 	  if (chdir(newdrive) < 0)
+ 	    {
+ 	      free(&cwd);
+ 	      return(RM_ERROR);
+ 	    }
+ 	}
+ #endif /* MSDOS */
+ 
        status = remove_dir (fs, need_save_cwd, x);
  
+ #ifdef MSDOS
+       /* Return to the original drive & working directory. */
+       if (fs->filename[1] == ':')
+ 	{
+ 	  if (restore_cwd (&cwd, NULL, NULL))
+ 	    {
+ 	      free_cwd (&cwd);
+ 	      return RM_ERROR;
+ 	    }
+ 	  free_cwd (&cwd);
+ 	}
+ #endif /* MSDOS */
+ 
  #ifdef ENABLE_CYCLE_CHECK
        {
  	struct active_dir_ent tmp;
*** /develop/ports/orig/fileutils-4.0/src/rm.c	Sat Sep 19 19:09:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/rm.c	Sun May 27 11:42:22 2001
*************** rm_option_init (struct rm_options *x)
*** 118,123 ****
--- 118,124 ----
  int
  main (int argc, char **argv)
  {
+   char *pathname = NULL;
    struct rm_options x;
    int fail = 0;
    int c;
*************** main (int argc, char **argv)
*** 158,163 ****
--- 159,171 ----
  	}
      }
  
+ #ifdef __DJGPP__
+   /* If they said `rm -r', let us find hidden files also,
+    * otherwise we cannot remove directories with such files.  */
+   if (x.recursive)
+     __opendir_flags |= __OPENDIR_FIND_HIDDEN;
+ #endif
+   
    if (show_version)
      {
        printf ("rm (%s) %s\n", GNU_PACKAGE, VERSION);
*************** main (int argc, char **argv)
*** 185,195 ****
      {
        struct File_spec fs;
        enum RM_status status;
! 
        /* Stripping slashes is harmless for rmdir;
  	 if the arg is not a directory, it will fail with ENOTDIR.  */
!       strip_trailing_slashes (argv[optind]);
!       fspec_init_file (&fs, argv[optind]);
        status = rm (&fs, 1, &x);
        assert (VALID_STATUS (status));
        if (status == RM_ERROR)
--- 193,215 ----
      {
        struct File_spec fs;
        enum RM_status status;
! #ifdef MSDOS
!       char fullname[PATH_MAX + 1];
! #endif
!             
        /* Stripping slashes is harmless for rmdir;
  	 if the arg is not a directory, it will fail with ENOTDIR.  */
!       pathname = argv[optind];
!       strip_trailing_slashes (pathname);
! #ifdef MSDOS
!      /* pathname = "d:" means current dir on drive d:  */
!      if (pathname[0] && pathname[1] == ':' && pathname[2] == '\0')
! 	{
! 	  FIXPATH (pathname, fullname);	/* convert into an absolute pathname */
! 	  pathname = fullname;
! 	}
! #endif      
!       fspec_init_file (&fs, pathname);
        status = rm (&fs, 1, &x);
        assert (VALID_STATUS (status));
        if (status == RM_ERROR)
*** /develop/ports/orig/fileutils-4.0/src/sys2.h	Sat Jul 25 17:31:38 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/src/sys2.h	Sun Aug 12 20:35:42 2001
***************
*** 114,121 ****
  #endif
  #define N_(Text) Text
  
- #define STREQ(a,b) (strcmp((a), (b)) == 0)
- 
  #ifndef HAVE_DECL_FREE
  void free ();
  #endif
--- 114,119 ----
***************
*** 220,222 ****
--- 218,260 ----
  #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
    ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
     && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
+ 
+ #ifdef MSDOS
+ /* MSDOS and compatible systems are case-insensitive in filenames.  */
+ # define STREQ(a,b) (strcasecmp((a), (b)) == 0)
+ /* Define a way to convert a pathname into absolute form.
+    Examples:
+                file		-> d:/dir/subdir/file
+ 	       d:path		-> d:/curdir/path
+ 	       /dir/subdir	-> x:/dir/subdir              */     
+ # ifdef __DJGPP__
+ #  define FIXPATH(x,y)  _fixpath(x,y)
+ # else  /* !__DJGPP__ */
+ #  error FIXPATH macro not defined on MSDOS!
+ # endif /* !__DJGPP__ */
+ #else  /* !MSDOS */
+ # define STREQ(a,b) (strcmp((a), (b)) == 0)     
+ #endif /* !MSDOS */
+ 
+ /* Richard Dawe <richdawe@bigfoot.com> - Backport some defines from
+  * Fileutils 4.1 to fix the problem in 'ls' with files > 2GB in
+  * the DJGPP port. */
+ #ifndef CHAR_BIT
+ # define CHAR_BIT 8
+ #endif
+ 
+ /* The extra casts work around common compiler bugs.  */
+ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+ /* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+    It is necessary at least when t == time_t.  */
+ #define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
+ 			      ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
+ #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+ 
+ #ifndef OFF_T_MIN
+ # define OFF_T_MIN TYPE_MINIMUM (off_t)
+ #endif
+ 
+ #ifndef OFF_T_MAX
+ # define OFF_T_MAX TYPE_MAXIMUM (off_t)
+ #endif
*** /develop/ports/orig/fileutils-4.0/tests/Fetish.pm	Sat Oct 17 14:47:22 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/Fetish.pm	Sun May 27 11:42:22 2001
*************** my %Zero_one_type = map {$_ => 1} qw (OU
*** 23,28 ****
--- 23,35 ----
  my $srcdir = $ENV{srcdir};
  my $Global_count = 1;
  
+ # (richdawe@bigfoot.com): If we're running in a DJGPP environment, set up
+ # $ENV{'SHELL'} to point to bash. If we don't do this, a bad shell might
+ # be used (e.g. command.com) and the tests will just fail.
+ if (defined($ENV{'DJDIR'})) {
+     $ENV{'SHELL'} = $ENV{'DJDIR'}.'/bin/bash.exe';
+ }
+ 
  # A file spec: a scalar or a reference to a single-keyed hash
  # ================
  # 'contents'               contents only (file name is derived from test name)
*** /develop/ports/orig/fileutils-4.0/tests/cp/Makefile.am	Sat Jun 27 22:24:08 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/Makefile.am	Sun May 27 12:06:50 2001
*************** TESTS = \
*** 5,8 ****
    backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
    same-file
  EXTRA_DIST = $(TESTS)
! TESTS_ENVIRONMENT = CP=../../src/cp RM=../../src/rm
--- 5,8 ----
    backup-1 no-deref-link1 no-deref-link2 no-deref-link3 backup-is-src \
    same-file
  EXTRA_DIST = $(TESTS)
! TESTS_ENVIRONMENT = CP=../../src/cp LN=../../src/ln RM=../../src/rm
*** /develop/ports/orig/fileutils-4.0/tests/cp/backup-1	Wed Jul  9 16:13:14 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/backup-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 7,14 ****
    $CP --version
  fi
  
! suffix=.b
! tmp=b1.$$
  tmp_backup="$tmp$suffix"
  temp_files="$tmp $tmp_backup"
  rm -f $temp_files
--- 7,14 ----
    $CP --version
  fi
  
! suffix=_b
! tmp=b1`echo $$ | sed -e 's:\(....\).*:\1:'`
  tmp_backup="$tmp$suffix"
  temp_files="$tmp $tmp_backup"
  rm -f $temp_files
*** /develop/ports/orig/fileutils-4.0/tests/cp/backup-is-src	Sat Aug 15 04:45:34 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/backup-is-src	Sun May 27 11:42:22 2001
*************** export LANG
*** 29,35 ****
  # This cp command should exit nonzero.
  $CP -b -V simple a~ a > out 2>&1 && fail=1
  
! sed "s,$CP:,XXX:," out > out2
  
  cat > exp <<\EOF
  XXX: backing up `a' would destroy source;  `a~' not copied
--- 29,35 ----
  # This cp command should exit nonzero.
  $CP -b -V simple a~ a > out 2>&1 && fail=1
  
! sed "s,^.*\(: backing up\),XXX\1," out > out2
  
  cat > exp <<\EOF
  XXX: backing up `a' would destroy source;  `a~' not copied
*** /develop/ports/orig/fileutils-4.0/tests/cp/no-deref-link1	Wed Jul  9 16:13:44 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/no-deref-link1	Sun May 27 11:42:22 2001
***************
*** 3,20 ****
  # cp from 3.16 fails this test
  
  : ${CP=cp}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
  fi
  
  rm -rf a b
  mkdir a b
  msg=bar
  echo $msg > a/foo
  cd b
! ln -s ../a/foo .
  cd ..
  
  fail=0
--- 3,24 ----
  # cp from 3.16 fails this test
  
  : ${CP=cp}
+ : ${LN=ln}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
+   $LN --version
  fi
  
+ SAVEDIR=$(pwd)
+ 
  rm -rf a b
  mkdir a b
  msg=bar
  echo $msg > a/foo
  cd b
! $SAVEDIR/$LN -s ../a/foo .
  cd ..
  
  fail=0
*** /develop/ports/orig/fileutils-4.0/tests/cp/no-deref-link2	Wed Jul  9 16:13:50 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/no-deref-link2	Sun May 27 11:42:22 2001
***************
*** 3,20 ****
  # cp from 3.16 fails this test
  
  : ${CP=cp}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
  fi
  
  rm -rf a b
  mkdir b
  msg=bar
  echo $msg > a
  cd b
! ln -s ../a .
  cd ..
  
  fail=0
--- 3,24 ----
  # cp from 3.16 fails this test
  
  : ${CP=cp}
+ : ${LN=ln}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
+   $LN --version
  fi
  
+ SAVEDIR=$(pwd)
+ 
  rm -rf a b
  mkdir b
  msg=bar
  echo $msg > a
  cd b
! $SAVEDIR/$LN -s ../a .
  cd ..
  
  fail=0
*** /develop/ports/orig/fileutils-4.0/tests/cp/no-deref-link3	Wed Jul  9 16:13:54 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/no-deref-link3	Sun May 27 11:42:22 2001
***************
*** 3,18 ****
  # cp from 3.16 fails this test
  
  : ${CP=cp}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
  fi
  
  rm -rf a b
  msg=bar
  echo $msg > a
! ln -s a b
  
  fail=0
  
--- 3,20 ----
  # cp from 3.16 fails this test
  
  : ${CP=cp}
+ : ${LN=ln}
  
  if test "$VERBOSE" = yes; then
    set -x
    $CP --version
+   $LN --version
  fi
  
  rm -rf a b
  msg=bar
  echo $msg > a
! $LN -s a b
  
  fail=0
  
*** /develop/ports/orig/fileutils-4.0/tests/cp/same-file	Sat Aug 29 20:04:46 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/cp/same-file	Sun May 27 11:42:22 2001
*************** LANG=C; export LANG
*** 16,25 ****
  VERSION_CONTROL=numbered; export VERSION_CONTROL
  
  pwd=`pwd`
! PATH=$pwd/../../src:$PATH
  
! actual=actual-$$
! expected=expected-$$
  trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
  
  exec 1> $actual
--- 16,25 ----
  VERSION_CONTROL=numbered; export VERSION_CONTROL
  
  pwd=`pwd`
! PATH="$pwd/../../src;$PATH"
  
! actual=act$$
! expected=exp$$
  trap "cd $pwd; rm -rf $actual $expected dir" 0 1 2 3 15
  
  exec 1> $actual
*************** for args in 'foo symlink' 'symlink foo' 
*** 52,65 ****
      (
        (
  	# echo 1>&2 $CP $options $args
! 	$CP $options $args 2>.err
  	echo $? $options
  
  	# Normalize the program name in the error output,
  	# and put brackets around the output.
! 	test -s .err && echo "[`sed 's/^[^:][^:]*:/cp:/' .err`]"
  	# Strip off all but the file names.
! 	ls="`ls -lG --ignore=.err . \
  	    | sed \
  	        -e '/^total /d' \
  		-e 's/^..............................................//'`"
--- 52,65 ----
      (
        (
  	# echo 1>&2 $CP $options $args
! 	$CP $options $args 2>_err
  	echo $? $options
  
  	# Normalize the program name in the error output,
  	# and put brackets around the output.
! 	test -s _err && echo "[`sed 's/^[^:][^:]*:/cp:/' _err`]"
  	# Strip off all but the file names.
! 	ls="`ls -lG --ignore=_err . \
  	    | sed \
  	        -e '/^total /d' \
  		-e 's/^..............................................//'`"
*** /develop/ports/orig/fileutils-4.0/tests/dircolors/Makefile.am	Sat Oct  3 06:53:40 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/dircolors/Makefile.am	Sun May 27 12:04:20 2001
*************** TESTS_ENVIRONMENT = \
*** 7,12 ****
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=dircolors
  
  TESTS = simple
--- 7,12 ----
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=../../src/dircolors
  
  TESTS = simple
*** /develop/ports/orig/fileutils-4.0/tests/dircolors/simple	Sat Oct  3 06:52:02 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/dircolors/simple	Sun May 27 11:42:22 2001
*************** require 5.003;
*** 15,20 ****
--- 15,21 ----
  use strict;
  
  (my $program_name = $0) =~ s|.*/||;
+ my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  
  # Turn off localisation of executable's ouput.
  @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
*************** use strict;
*** 22,35 ****
  my @Tests =
      (
       ['a', {IN => {k => "exec\n"}},
!       {ERR => "dircolors: k:1: invalid line;  missing second token\n"},
        {EXIT => 1}],
      );
  
  my $save_temps = $ENV{DEBUG};
  my $verbose = $ENV{VERBOSE};
  
- my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
  exit $fail;
  EOF
--- 23,35 ----
  my @Tests =
      (
       ['a', {IN => {k => "exec\n"}},
!       {ERR => "$prog: k:1: invalid line;  missing second token\n"},
        {EXIT => 1}],
      );
  
  my $save_temps = $ENV{DEBUG};
  my $verbose = $ENV{VERBOSE};
  
  my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
  exit $fail;
  EOF
*** /develop/ports/orig/fileutils-4.0/tests/ln/misc	Sat Mar 14 22:25:06 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ln/misc	Sun May 27 11:42:22 2001
***************
*** 1,7 ****
  #!/bin/sh
  
! PATH=../../../src:$PATH
! tmp=t2-ln.$$
  
  test_failure=0
  mkdir $tmp || test_failure=1
--- 1,12 ----
  #!/bin/sh
  
! PATH="../../../src;$PATH"
! tmp=t2-ln.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
! 
! if test "$VERBOSE" = yes; then
!   set -x
!   $LN --version
! fi
  
  test_failure=0
  mkdir $tmp || test_failure=1
*** /develop/ports/orig/fileutils-4.0/tests/ln/sf-1	Sat Jan 10 22:25:28 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ln/sf-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 8,14 ****
    $LN --version
  fi
  
! tmp=t-ln.$$
  
  # We're going to LN from a subdir.  Prepend ../ if $LN is not an
  # absolute file name.
--- 8,14 ----
    $LN --version
  fi
  
! tmp=t-ln.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  # We're going to LN from a subdir.  Prepend ../ if $LN is not an
  # absolute file name.
*** /develop/ports/orig/fileutils-4.0/tests/ls-2/Makefile.am	Sat Oct  3 06:57:58 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ls-2/Makefile.am	Sun May 27 12:04:42 2001
*************** TESTS_ENVIRONMENT = \
*** 7,12 ****
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=ls
  
  TESTS = quoting
--- 7,12 ----
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=../../src/ls
  
  TESTS = quoting
*** /develop/ports/orig/fileutils-4.0/tests/ls-2/quoting	Sat Oct  3 06:57:42 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ls-2/quoting	Sun May 27 11:42:22 2001
*************** require 5.003;
*** 15,20 ****
--- 15,21 ----
  use strict;
  
  (my $program_name = $0) =~ s|.*/||;
+ my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  
  # Turn off localisation of executable's ouput.
  @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
*************** my @Tests =
*** 47,53 ****
  my $save_temps = $ENV{SAVE_TEMPS};
  my $verbose = $ENV{VERBOSE};
  
- my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
  exit $fail;
  EOF
--- 48,53 ----
*** /develop/ports/orig/fileutils-4.0/tests/ls/rt-1	Wed May 27 14:34:24 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ls/rt-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 9,15 ****
    $LS --version
  fi
  
! tmp=t-ls.$$
  
  # We're going to run LS from a subdir.
  # Prepend ../ if $LS is a relative file name.
--- 9,15 ----
    $LS --version
  fi
  
! tmp=t-ls.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  # We're going to run LS from a subdir.
  # Prepend ../ if $LS is a relative file name.
*** /develop/ports/orig/fileutils-4.0/tests/ls/time-1	Sat May 30 23:32:42 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/ls/time-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 10,16 ****
    $LS --version
  fi
  
! tmp=t-ls.$$
  
  # We're going to run LS from a subdir.
  # Prepend ../ if $LS is a relative file name.
--- 10,16 ----
    $LS --version
  fi
  
! tmp=t-ls.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  # We're going to run LS from a subdir.
  # Prepend ../ if $LS is a relative file name.
*** /develop/ports/orig/fileutils-4.0/tests/mkdir/p-1	Sat Aug 16 19:38:32 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mkdir/p-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 11,17 ****
    $MKDIR --version
  fi
  
! temp_dir=$TMPDIR/t-mkdir.$$
  tmp=$temp_dir/a/b/c
  rm -rf $temp_dir
  
--- 11,17 ----
    $MKDIR --version
  fi
  
! temp_dir=$TMPDIR/t-mkdir.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  tmp=$temp_dir/a/b/c
  rm -rf $temp_dir
  
*** /develop/ports/orig/fileutils-4.0/tests/mkdir/p-2	Wed Jul  9 17:30:26 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mkdir/p-2	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 10,16 ****
    $MKDIR --version
  fi
  
! tmp=$TMPDIR/t-mkdir.$$
  temp_files=$tmp
  rm -rf $temp_files
  
--- 10,16 ----
    $MKDIR --version
  fi
  
! tmp=$TMPDIR/t-mkdir.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  temp_files=$tmp
  rm -rf $temp_files
  
*** /develop/ports/orig/fileutils-4.0/tests/mv/Makefile.am	Mon Oct  5 05:33:14 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mv/Makefile.am	Sun May 27 12:07:32 2001
*************** TESTS_ENVIRONMENT = \
*** 14,17 ****
    TOUCH=../../src/touch \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=mv
--- 14,17 ----
    TOUCH=../../src/touch \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=../../src/mv
*** /develop/ports/orig/fileutils-4.0/tests/mv/backup-is-src	Sat Aug 15 04:44:56 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mv/backup-is-src	Sun May 27 11:42:22 2001
*************** if test -z "$other_partition_tmpdir"; th
*** 15,20 ****
--- 15,21 ----
    exit 77
  fi
  
+ other_partition_tmpdir=`echo $other_partition_tmpdir | tr 'A-Z' 'a-z'`
  a="$other_partition_tmpdir/a"
  a2="$other_partition_tmpdir/a~"
  
*** /develop/ports/orig/fileutils-4.0/tests/mv/i-1	Sun Oct  4 03:04:48 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mv/i-1	Sun May 27 11:42:22 2001
*************** require 5.003;
*** 15,20 ****
--- 15,21 ----
  use strict;
  
  (my $program_name = $0) =~ s|.*/||;
+ my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  
  # Turn off localisation of executable's ouput.
  @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
*************** my @Tests =
*** 26,32 ****
       # Make sure a `n' reply to `mv -i...' aborts the move operation.
       [$test_a, '-i',
        {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
!       {ERR => "mv: overwrite `dst'? "},
        {POST => sub { -r 'src' or die "test $test_a failed\n"}},
        {EXIT => 1},
       ],
--- 27,33 ----
       # Make sure a `n' reply to `mv -i...' aborts the move operation.
       [$test_a, '-i',
        {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
!       {ERR => "$prog: overwrite `dst'? "},
        {POST => sub { -r 'src' or die "test $test_a failed\n"}},
        {EXIT => 1},
       ],
*************** my @Tests =
*** 35,41 ****
  my $save_temps = $ENV{DEBUG};
  my $verbose = $ENV{VERBOSE};
  
- my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
  my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
  exit $fail;
  EOF
--- 36,41 ----
*** /develop/ports/orig/fileutils-4.0/tests/mv/into-self	Sun Aug 16 05:04:58 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/mv/into-self	Sun May 27 11:42:22 2001
***************
*** 6,13 ****
  : ${RM=rm}
  : ${TOUCH=touch}
  
! dir=into-self-dir
! file=into-self-file
  
  test_failure=0
  
--- 6,13 ----
  : ${RM=rm}
  : ${TOUCH=touch}
  
! dir=toself-dir
! file=toself-file
  
  test_failure=0
  
*** /develop/ports/orig/fileutils-4.0/tests/rm/Makefile.am	Sun Nov  1 00:11:50 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/Makefile.am	Sun May 27 12:08:04 2001
*************** TESTS_ENVIRONMENT = \
*** 10,13 ****
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=rm
--- 10,13 ----
    srcdir=$(srcdir) \
    PERL="@PERL@" \
    PATH=../../src:$$PATH \
!   PROG=../../src/rm
*** /develop/ports/orig/fileutils-4.0/tests/rm/deep-1	Mon Dec 15 17:34:44 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/deep-1	Sun May 27 11:42:22 2001
*************** umask 022
*** 24,30 ****
  
  fail=0
  
! tmp=$RM_TMPDIR/t-rm.$$
  
  k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k
  k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20
--- 24,30 ----
  
  fail=0
  
! tmp=$RM_TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k
  k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20
*** /develop/ports/orig/fileutils-4.0/tests/rm/f-1	Sun Aug 31 18:17:46 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/f-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 9,15 ****
  fi
  
  : ${RM_TMPDIR=.}
! tmp=$RM_TMPDIR/t-rm.$$
  
  test_failure=0
  mkdir $tmp || test_failure=1
--- 9,15 ----
  fi
  
  : ${RM_TMPDIR=.}
! tmp=$RM_TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  test_failure=0
  mkdir $tmp || test_failure=1
*** /develop/ports/orig/fileutils-4.0/tests/rm/i-1	Sat Aug 15 04:43:44 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/i-1	Sun May 27 11:42:22 2001
*************** fi
*** 11,17 ****
  # Don't require use of TMPDIR.
  : ${RM_TMPDIR=.}
  
! tmp=$RM_TMPDIR/t-rm.$$
  
  test_failure=0
  mkdir $tmp || test_failure=1
--- 11,17 ----
  # Don't require use of TMPDIR.
  : ${RM_TMPDIR=.}
  
! tmp=$RM_TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  test_failure=0
  mkdir $tmp || test_failure=1
*** /develop/ports/orig/fileutils-4.0/tests/rm/ir-1	Tue Jan 13 15:42:46 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/ir-1	Sun May 27 11:42:22 2001
*************** fi
*** 11,17 ****
  # Don't require use of TMPDIR.
  : ${RM_TMPDIR=.}
  
! tmp=$RM_TMPDIR/t-rm.$$
  
  test_failure=0
  mkdir $tmp $tmp/a $tmp/b $tmp/c || test_failure=1
--- 11,17 ----
  # Don't require use of TMPDIR.
  : ${RM_TMPDIR=.}
  
! tmp=$RM_TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  test_failure=0
  mkdir $tmp $tmp/a $tmp/b $tmp/c || test_failure=1
*** /develop/ports/orig/fileutils-4.0/tests/rm/r-1	Sat Jun 27 06:40:22 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/r-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 12,18 ****
    $RM --version
  fi
  
! tmp=$TMPDIR/t-rm.$$
  
  test_failure=0
  
--- 12,18 ----
    $RM --version
  fi
  
! tmp=$TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  test_failure=0
  
*** /develop/ports/orig/fileutils-4.0/tests/rm/r-2	Sat Jun 27 06:39:58 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/r-2	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 10,16 ****
    set -x
  fi
  
! tmp=$TMPDIR/t-rm.$$
  
  mkdir $tmp $tmp/a $tmp/a/b
  > $tmp/a/f
--- 10,16 ----
    set -x
  fi
  
! tmp=$TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  mkdir $tmp $tmp/a $tmp/a/b
  > $tmp/a/f
*** /develop/ports/orig/fileutils-4.0/tests/rm/r-3	Mon Nov  3 04:48:54 1997
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/r-3	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 12,18 ****
    set -x
  fi
  
! tmp=$TMPDIR/t-rm.$$
  
  framework_fail=0
  mkdir $tmp || framework_fail=1
--- 12,18 ----
    set -x
  fi
  
! tmp=$TMPDIR/t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  framework_fail=0
  mkdir $tmp || framework_fail=1
*** /develop/ports/orig/fileutils-4.0/tests/rm/sunos-1	Thu Jan 22 14:30:44 1998
--- /develop/ports/gnu.dev/filutil4.0-rel/tests/rm/sunos-1	Sun May 27 11:42:22 2001
*************** if test "$VERBOSE" = yes; then
*** 12,18 ****
    $RM --version
  fi
  
! tmp=t-rm.$$
  
  # We're going to run RM from a subdir.
  # Prepend ../ if $RM is a relative file name.
--- 12,18 ----
    $RM --version
  fi
  
! tmp=t-rm.`echo $$ | sed -e 's:^\(...\).*$:\1:'`
  
  # We're going to run RM from a subdir.
  # Prepend ../ if $RM is a relative file name.
