changeset 255:ed27c3582f3b

GNU file utilities
author Jim Meyering <jim@meyering.net>
date Sun, 02 Oct 1994 05:35:03 +0000
parents 36d6e7c81e32
children 2d3eeca18f5d
files lib/Makefile.in lib/argmatch.c lib/backupfile.c lib/dirname.c lib/fileblocks.c lib/filemode.c lib/fsusage.c lib/ftruncate.c lib/full-write.c lib/getversion.c lib/idcache.c lib/isdir.c lib/makepath.c lib/mkdir.c lib/modechange.c lib/mountlist.c lib/rename.c lib/rmdir.c lib/safe-read.c lib/savedir.c lib/strdup.c lib/stripslash.c lib/userspec.c lib/xstrdup.c lib/yesno.c
diffstat 25 files changed, 186 insertions(+), 302 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Makefile.in	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/Makefile.in	Sun Oct 02 05:35:03 1994 +0000
@@ -23,21 +23,19 @@
 CC = @CC@
 AR = ar
 RANLIB = @RANLIB@
-DEFS = -DCONFIG_BROKETS @DEFS@
+DEFS = -Dlint @DEFS@
 CFLAGS = @CFLAGS@
 YACC = @YACC@
 
-prefix = @prefix@
-exec_prefix = $(prefix)
+exec_prefix = @exec_prefix@
 libdir = $(exec_prefix)/lib
-
 SOURCES = getdate.y posixtm.y \
 argmatch.c backupfile.c basename.c dirname.c eaccess.c \
 error.c filemode.c fsusage.c full-write.c getopt.c getopt1.c \
 getversion.c group-member.c idcache.c isdir.c makepath.c \
 modechange.c mountlist.c safe-read.c savedir.c \
 stripslash.c xgetcwd.c xmalloc.c xstrdup.c userspec.c yesno.c \
-fileblocks.c fnmatch.c ftruncate.c mkdir.c mktime.c rename.c stpcpy.c \
+fileblocks.c fnmatch.c ftruncate.c mkdir.c mktime.c rename.c rmdir.c stpcpy.c \
 strdup.c strstr.c alloca.c long-options.c
 
 OBJECTS = getdate.o posixtm.o \
@@ -49,19 +47,21 @@
 @LIBOBJS@ @ALLOCA@
 
 DISTFILES = Makefile.in backupfile.h getopt.h modechange.h \
-fnmatch.h fsusage.h mountlist.h pathmax.h safe-xstat.c.in safe-xstat.h.in \
+fnmatch.h fsusage.h mountlist.h pathmax.h safe-xstat.cin safe-xstat.hin \
 getdate.c posixtm.c $(SOURCES)
 
 all: libfu.a
 
-.SUFFIXES =
-.SUFFIXES = .c .o
+.SUFFIXES:
+.SUFFIXES: .c .o
 
 .c.o:
-	$(CC) -c $(CPPFLAGS) $(DEFS) -I.. -I$(srcdir) $(CFLAGS) $<
+	$(CC) -c $(CPPFLAGS) $(DEFS) -I. -I.. -I$(srcdir) $(CFLAGS) $<
 
 Makefile: ../config.status Makefile.in
-	CONFIG_FILES=$@ CONFIG_HEADERS= ../config.status
+	cd ..; CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
+
+installdirs:
 
 install: all
 
@@ -78,12 +78,13 @@
 mostlyclean: clean
 
 distclean: clean
-	rm -f Makefile *.tab.c getdate.c *posixtm.c
+	rm -f Makefile *.tab.c getdate.c *posixtm.c \
+	  safe-stat.c safe-stat.h safe-lstat.c safe-lstat.h
 
 realclean: distclean
-	rm -f TAGS safe-stat.c safe-stat.h safe-lstat.c safe-lstat.h 
+	rm -f TAGS
 
-distdir = ../`cat ../.fname`/lib 
+distdir = ../`cat ../distname`/$(subdir)
 dist: $(DISTFILES)
 	for file in $(DISTFILES); do \
 	  ln $$file $(distdir) \
@@ -98,21 +99,21 @@
 extract_stat = sed -e 's/@l@//g' -e 's/@L@//g'
 extract_lstat = sed -e 's/@l@/l/g' -e 's/@L@/L/g'
 
-safe-lstat.c: safe-xstat.c.in
-	$(extract_lstat) safe-xstat.c.in > $@-tmp
-	mv $@-tmp $@
+safe-lstat.c: safe-xstat.cin
+	$(extract_lstat) $(srcdir)/safe-xstat.cin > $@-t
+	mv $@-t $@
 
-safe-lstat.h: safe-xstat.h.in
-	$(extract_lstat) safe-xstat.h.in > $@-tmp
-	mv $@-tmp $@
+safe-lstat.h: safe-xstat.hin
+	$(extract_lstat) $(srcdir)/safe-xstat.hin > $@-t
+	mv $@-t $@
 
-safe-stat.c: safe-xstat.c.in
-	$(extract_stat) safe-xstat.c.in > $@-tmp
-	mv $@-tmp $@
+safe-stat.c: safe-xstat.cin
+	$(extract_stat) $(srcdir)/safe-xstat.cin > $@-t
+	mv $@-t $@
 
-safe-stat.h: safe-xstat.h.in
-	$(extract_stat) safe-xstat.h.in > $@-tmp
-	mv $@-tmp $@
+safe-stat.h: safe-xstat.hin
+	$(extract_stat) $(srcdir)/safe-xstat.hin > $@-t
+	mv $@-t $@
 
 safe-stat.o: safe-stat.h
 safe-lstat.o: safe-lstat.h
--- a/lib/argmatch.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/argmatch.c	Sun Oct 02 05:35:03 1994 +0000
@@ -18,14 +18,7 @@
 /* Written by David MacKenzie <djm@ai.mit.edu> */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <stdio.h>
--- a/lib/backupfile.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/backupfile.c	Sun Oct 02 05:35:03 1994 +0000
@@ -19,14 +19,7 @@
    Some algorithms adapted from GNU Emacs. */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <stdio.h>
@@ -45,24 +38,24 @@
 #include <strings.h>
 #endif
 
-#ifdef DIRENT
+#ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #define NLENGTH(direct) (strlen((direct)->d_name))
-#else /* not DIRENT */
+#else /* not HAVE_DIRENT_H */
 #define dirent direct
 #define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef SYSNDIR
+#ifdef HAVE_SYS_NDIR_H
 #include <sys/ndir.h>
-#endif /* SYSNDIR */
-#ifdef SYSDIR
+#endif /* HAVE_SYS_NDIR_H */
+#ifdef HAVE_SYS_DIR_H
 #include <sys/dir.h>
-#endif /* SYSDIR */
-#ifdef NDIR
+#endif /* HAVE_SYS_DIR_H */
+#ifdef HAVE_NDIR_H
 #include <ndir.h>
-#endif /* NDIR */
-#endif /* DIRENT */
+#endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
 
-#ifdef VOID_CLOSEDIR
+#ifdef CLOSEDIR_VOID
 /* Fake a return value. */
 #define CLOSEDIR(d) (closedir (d), 0)
 #else
--- a/lib/dirname.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/dirname.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #ifdef STDC_HEADERS
--- a/lib/fileblocks.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/fileblocks.c	Sun Oct 02 05:35:03 1994 +0000
@@ -18,14 +18,7 @@
 /* Written by Brian L. Matthews, blm@6sceng.UUCP. */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_SOURCE)
--- a/lib/filemode.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/filemode.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,11 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (emacs) || defined (CONFIG_BROKETS)
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -41,38 +37,18 @@
 #endif
 #endif
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISBLK
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISBLK
-#endif
-#ifdef S_ISCHR
 #undef S_ISCHR
-#endif
-#ifdef S_ISDIR
 #undef S_ISDIR
-#endif
-#ifdef S_ISFIFO
 #undef S_ISFIFO
-#endif
-#ifdef S_ISLNK
 #undef S_ISLNK
-#endif
-#ifdef S_ISMPB
 #undef S_ISMPB
-#endif
-#ifdef S_ISMPC
 #undef S_ISMPC
-#endif
-#ifdef S_ISNWK
 #undef S_ISNWK
-#endif
-#ifdef S_ISREG
 #undef S_ISREG
-#endif
-#ifdef S_ISSOCK
 #undef S_ISSOCK
-#endif
-#endif	/* STAT_MACROS_BROKEN.  */
+#endif /* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISBLK) && defined(S_IFBLK)
 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
--- a/lib/fsusage.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/fsusage.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
--- a/lib/ftruncate.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/ftruncate.c	Sun Oct 02 05:35:03 1994 +0000
@@ -2,24 +2,12 @@
    This file is in the public domain.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
 #include <fcntl.h>
 
-#include <errno.h>
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
 #ifdef F_CHSIZE
 
 int
@@ -36,7 +24,7 @@
 /* By William Kucharski <kucharsk@netcom.com>.  */
 
 #include <sys/stat.h>
-
+#include <errno.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -96,6 +84,11 @@
 
 #else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */
 
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+
 int
 ftruncate (fd, length)
      int fd;
--- a/lib/full-write.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/full-write.c	Sun Oct 02 05:35:03 1994 +0000
@@ -19,14 +19,7 @@
    */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -47,7 +40,7 @@
 full_write (desc, ptr, len)
      int desc;
      char *ptr;
-     int len;
+     size_t len;
 {
   int total_written;
 
--- a/lib/getversion.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/getversion.c	Sun Oct 02 05:35:03 1994 +0000
@@ -18,14 +18,7 @@
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu> */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include "backupfile.h"
--- a/lib/idcache.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/idcache.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <stdio.h>
--- a/lib/isdir.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/isdir.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -31,11 +24,9 @@
 
 #include "safe-stat.h"
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
-#endif
-#endif	/* STAT_MACROS_BROKEN.  */
+#endif /* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
--- a/lib/makepath.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/makepath.c	Sun Oct 02 05:35:03 1994 +0000
@@ -19,14 +19,7 @@
    Jim Meyering <meyering@cs.utexas.edu>.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #ifdef __GNUC__
@@ -50,11 +43,9 @@
 #include <unistd.h>
 #endif
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
-#endif
-#endif	/* STAT_MACROS_BROKEN.  */
+#endif /* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
--- a/lib/mkdir.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/mkdir.c	Sun Oct 02 05:35:03 1994 +0000
@@ -1,4 +1,4 @@
-/* mkrmdir.c -- BSD compatible directory functions for System V
+/* mkdir.c -- BSD compatible make directory function for System V
    Copyright (C) 1988, 1990 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -28,22 +28,23 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
 #include <errno.h>
-#ifndef STDC_HEADERS
+#ifndef errno
 extern int errno;
 #endif
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
 #endif
-#endif	/* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 #endif
 
-/* mkdir and rmdir adapted from GNU tar.  */
+#include "safe-stat.h"
+
+/* mkdir adapted from GNU tar.  */
 
 /* Make directory DPATH, with permission mode DMODE.
 
@@ -64,9 +65,9 @@
   int cpid, status;
   struct stat statbuf;
 
-  if (stat (dpath, &statbuf) == 0)
+  if (SAFE_STAT (dpath, &statbuf) == 0)
     {
-      errno = EEXIST;		/* stat worked, so it already exists.  */
+      errno = EEXIST;		/* stat worked, it already exists */
       return -1;
     }
 
@@ -77,70 +78,36 @@
   cpid = fork ();
   switch (cpid)
     {
-    case -1:			/* Cannot fork.  */
-      return -1;		/* errno is set already.  */
+    case -1:			/* cannot fork */
+      return -1;		/* errno already set */
 
-    case 0:			/* Child process.  */
+    case 0:			/* child process */
+
       /* Cheap hack to set mode of new directory.  Since this child
-	 process is going away anyway, we zap its umask.
-	 This won't suffice to set SUID, SGID, etc. on this
-	 directory, so the parent process calls chmod afterward.  */
-      status = umask (0);	/* Get current umask.  */
-      umask (status | (0777 & ~dmode));	/* Set for mkdir.  */
+	 process is going away anyway, we zap its umask.  This won't
+	 suffice to set SUID, SGID, etc. on this directory, so the parent
+	 process calls chmod afterward.  */
+
+      status = umask (0);
+      umask (status | (0777 & ~dmode));
       execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
       _exit (1);
 
-    default:			/* Parent process.  */
-      while (wait (&status) != cpid) /* Wait for kid to finish.  */
+    default:			/* parent process */
+
+      /* Wait for kid to finish.  */
+
+      while (wait (&status) != cpid)
 	/* Do nothing.  */ ;
 
       if (status & 0xFFFF)
 	{
-	  errno = EIO;		/* /bin/mkdir failed.  */
+
+	  /* /bin/mkdir failed.  */
+
+	  errno = EIO;
 	  return -1;
 	}
       return chmod (dpath, dmode);
     }
 }
-
-/* Remove directory DPATH.
-   Return 0 if successful, -1 if not.  */
-
-int
-rmdir (dpath)
-     char *dpath;
-{
-  int cpid, status;
-  struct stat statbuf;
-
-  if (stat (dpath, &statbuf) != 0)
-    return -1;			/* stat set errno.  */
-
-  if (!S_ISDIR (statbuf.st_mode))
-    {
-      errno = ENOTDIR;
-      return -1;
-    }
-
-  cpid = fork ();
-  switch (cpid)
-    {
-    case -1:			/* Cannot fork.  */
-      return -1;		/* errno is set already.  */
-
-    case 0:			/* Child process.  */
-      execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
-      _exit (1);
-
-    default:			/* Parent process.  */
-      while (wait (&status) != cpid) /* Wait for kid to finish.  */
-	/* Do nothing.  */ ;
-
-      if (status & 0xFFFF)
-	{
-	  errno = EIO;		/* /bin/rmdir failed.  */
-	  return -1;
-	}
-      return 0;
-    }
-}
--- a/lib/modechange.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/modechange.c	Sun Oct 02 05:35:03 1994 +0000
@@ -25,14 +25,7 @@
    performance gain. */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -49,11 +42,9 @@
 #define NULL 0
 #endif
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
-#endif
-#endif	/* STAT_MACROS_BROKEN.  */
+#endif /* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
--- a/lib/mountlist.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/mountlist.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <stdio.h>
--- a/lib/rename.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/rename.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -33,11 +26,9 @@
 extern int errno;
 #endif
 
-#ifdef	STAT_MACROS_BROKEN
-#ifdef S_ISDIR
+#ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
-#endif
-#endif	/* STAT_MACROS_BROKEN.  */
+#endif /* STAT_MACROS_BROKEN.  */
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/rmdir.c	Sun Oct 02 05:35:03 1994 +0000
@@ -0,0 +1,95 @@
+/* rmdir.c -- BSD compatible remove directory function for System V
+   Copyright (C) 1988, 1990 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+   (which it would do because it found this file in $srcdir).  */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+
+#ifdef STAT_MACROS_BROKEN
+#undef S_ISDIR
+#endif
+
+#if !defined(S_ISDIR) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
+#include "safe-stat.h"
+
+/* rmdir adapted from GNU tar.  */
+
+/* Remove directory DPATH.
+   Return 0 if successful, -1 if not.  */
+
+int
+rmdir (dpath)
+     char *dpath;
+{
+  int cpid, status;
+  struct stat statbuf;
+
+  if (SAFE_STAT (dpath, &statbuf) != 0)
+    return -1;			/* errno already set */
+
+  if (!S_ISDIR (statbuf.st_mode))
+    {
+      errno = ENOTDIR;
+      return -1;
+    }
+
+  cpid = fork ();
+  switch (cpid)
+    {
+    case -1:			/* cannot fork */
+      return -1;		/* errno already set */
+
+    case 0:			/* child process */
+      execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
+      _exit (1);
+
+    default:			/* parent process */
+
+      /* Wait for kid to finish.  */
+
+      while (wait (&status) != cpid)
+	/* Do nothing.  */ ;
+
+      if (status & 0xFFFF)
+	{
+
+	  /* /bin/rmdir failed.  */
+
+	  errno = EIO;
+	  return -1;
+	}
+      return 0;
+    }
+}
--- a/lib/safe-read.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/safe-read.c	Sun Oct 02 05:35:03 1994 +0000
@@ -17,14 +17,7 @@
    */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
--- a/lib/savedir.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/savedir.c	Sun Oct 02 05:35:03 1994 +0000
@@ -18,14 +18,7 @@
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <sys/types.h>
@@ -34,24 +27,24 @@
 #include <unistd.h>
 #endif
 
-#ifdef DIRENT
+#ifdef HAVE_DIRENT_H
 #include <dirent.h>
 #define NLENGTH(direct) (strlen((direct)->d_name))
-#else /* not DIRENT */
+#else /* not HAVE_DIRENT_H */
 #define dirent direct
 #define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef SYSNDIR
+#ifdef HAVE_SYS_NDIR_H
 #include <sys/ndir.h>
-#endif /* SYSNDIR */
-#ifdef SYSDIR
+#endif /* HAVE_SYS_NDIR_H */
+#ifdef HAVE_SYS_DIR_H
 #include <sys/dir.h>
-#endif /* SYSDIR */
-#ifdef NDIR
+#endif /* HAVE_SYS_DIR_H */
+#ifdef HAVE_NDIR_H
 #include <ndir.h>
-#endif /* NDIR */
-#endif /* DIRENT */
+#endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
 
-#ifdef VOID_CLOSEDIR
+#ifdef CLOSEDIR_VOID
 /* Fake a return value. */
 #define CLOSEDIR(d) (closedir (d), 0)
 #else
--- a/lib/strdup.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/strdup.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #ifdef STDC_HEADERS
--- a/lib/stripslash.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/stripslash.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
--- a/lib/userspec.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/userspec.c	Sun Oct 02 05:35:03 1994 +0000
@@ -18,14 +18,7 @@
 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #ifdef __GNUC__
--- a/lib/xstrdup.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/xstrdup.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
--- a/lib/yesno.c	Fri Aug 19 22:32:41 1994 +0000
+++ b/lib/yesno.c	Sun Oct 02 05:35:03 1994 +0000
@@ -16,14 +16,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#if defined (CONFIG_BROKETS)
-/* We use <config.h> instead of "config.h" so that a compilation
-   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
-   (which it would do because it found this file in $srcdir).  */
 #include <config.h>
-#else
-#include "config.h"
-#endif
 #endif
 
 #include <stdio.h>