summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-10-02 05:35:03 +0000
committerJim Meyering <jim@meyering.net>1994-10-02 05:35:03 +0000
commit80b012a9c4e32ce7f476f73402b33cc6fe7c09d5 (patch)
tree61ed6d18cd0fcfb21370ba7b106ede5343573684
parentd086d0976e0bec90c4aceeb16e7edf130e10054a (diff)
downloadgnulib-80b012a9c4e32ce7f476f73402b33cc6fe7c09d5.tar.gz
GNU file utilitiesFILEUTILS-3_9h
-rw-r--r--lib/Makefile.in51
-rw-r--r--lib/argmatch.c7
-rw-r--r--lib/backupfile.c27
-rw-r--r--lib/dirname.c7
-rw-r--r--lib/fileblocks.c7
-rw-r--r--lib/filemode.c28
-rw-r--r--lib/fsusage.c7
-rw-r--r--lib/ftruncate.c19
-rw-r--r--lib/full-write.c9
-rw-r--r--lib/getversion.c7
-rw-r--r--lib/idcache.c7
-rw-r--r--lib/isdir.c13
-rw-r--r--lib/makepath.c13
-rw-r--r--lib/mkdir.c87
-rw-r--r--lib/modechange.c13
-rw-r--r--lib/mountlist.c7
-rw-r--r--lib/rename.c13
-rw-r--r--lib/rmdir.c95
-rw-r--r--lib/safe-read.c7
-rw-r--r--lib/savedir.c27
-rw-r--r--lib/strdup.c7
-rw-r--r--lib/stripslash.c7
-rw-r--r--lib/userspec.c7
-rw-r--r--lib/xstrdup.c7
-rw-r--r--lib/yesno.c7
25 files changed, 185 insertions, 301 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 45780d8919..b84df8b5fc 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -23,21 +23,19 @@ VPATH = @srcdir@
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 @@ stripslash.o xgetcwd.o xmalloc.o xstrdup.o userspec.o yesno.o \
@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 @@ clean:
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 @@ libfu.a: $(OBJECTS)
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
diff --git a/lib/argmatch.c b/lib/argmatch.c
index 17e088b7e8..154736f239 100644
--- a/lib/argmatch.c
+++ b/lib/argmatch.c
@@ -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>
diff --git a/lib/backupfile.c b/lib/backupfile.c
index 2ef0f0b48d..288803453d 100644
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -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
diff --git a/lib/dirname.c b/lib/dirname.c
index cb53eb406d..9290614805 100644
--- a/lib/dirname.c
+++ b/lib/dirname.c
@@ -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
diff --git a/lib/fileblocks.c b/lib/fileblocks.c
index ee82f7596e..83ac04fd6e 100644
--- a/lib/fileblocks.c
+++ b/lib/fileblocks.c
@@ -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)
diff --git a/lib/filemode.c b/lib/filemode.c
index 8b99228077..e88fc1249e 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -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)
diff --git a/lib/fsusage.c b/lib/fsusage.c
index d60a4c6a73..9bef62aba7 100644
--- a/lib/fsusage.c
+++ b/lib/fsusage.c
@@ -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>
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 04156b76db..1272ee74f6 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -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 @@ ftruncate (fd, length)
/* 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 @@ ftruncate (fd, length)
#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;
diff --git a/lib/full-write.c b/lib/full-write.c
index 6e2e446830..339fb1a483 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -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 @@ int
full_write (desc, ptr, len)
int desc;
char *ptr;
- int len;
+ size_t len;
{
int total_written;
diff --git a/lib/getversion.c b/lib/getversion.c
index 78fda75404..10b60aa25f 100644
--- a/lib/getversion.c
+++ b/lib/getversion.c
@@ -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"
diff --git a/lib/idcache.c b/lib/idcache.c
index bafae7483e..34dcc07c56 100644
--- a/lib/idcache.c
+++ b/lib/idcache.c
@@ -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>
diff --git a/lib/isdir.c b/lib/isdir.c
index b1dbc2d70a..dbc9bd07df 100644
--- a/lib/isdir.c
+++ b/lib/isdir.c
@@ -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)
diff --git a/lib/makepath.c b/lib/makepath.c
index e109865c55..f0303fa8f5 100644
--- a/lib/makepath.c
+++ b/lib/makepath.c
@@ -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 @@ char *alloca ();
#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)
diff --git a/lib/mkdir.c b/lib/mkdir.c
index 28c8932653..3726cbbcc1 100644
--- a/lib/mkdir.c
+++ b/lib/mkdir.c
@@ -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 @@ mkdir (dpath, dmode)
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 @@ mkdir (dpath, dmode)
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. */
- /* Do nothing. */ ;
+ default: /* parent process */
- if (status & 0xFFFF)
- {
- errno = EIO; /* /bin/mkdir failed. */
- return -1;
- }
- return chmod (dpath, dmode);
- }
-}
-
-/* Remove directory DPATH.
- Return 0 if successful, -1 if not. */
+ /* Wait for kid to finish. */
-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. */
+ while (wait (&status) != cpid)
/* Do nothing. */ ;
if (status & 0xFFFF)
{
- errno = EIO; /* /bin/rmdir failed. */
+
+ /* /bin/mkdir failed. */
+
+ errno = EIO;
return -1;
}
- return 0;
+ return chmod (dpath, dmode);
}
}
diff --git a/lib/modechange.c b/lib/modechange.c
index e1212e90a3..8eb8dc55db 100644
--- a/lib/modechange.c
+++ b/lib/modechange.c
@@ -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 @@ char *malloc ();
#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)
diff --git a/lib/mountlist.c b/lib/mountlist.c
index aaf28ea79c..a39461d878 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -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>
diff --git a/lib/rename.c b/lib/rename.c
index cd291b4905..63193973b6 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -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)
diff --git a/lib/rmdir.c b/lib/rmdir.c
new file mode 100644
index 0000000000..f10b3969e6
--- /dev/null
+++ b/lib/rmdir.c
@@ -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;
+ }
+}
diff --git a/lib/safe-read.c b/lib/safe-read.c
index 2e131e1f2c..22e705aedb 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -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>
diff --git a/lib/savedir.c b/lib/savedir.c
index b831c1fe92..32c793b607 100644
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -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
diff --git a/lib/strdup.c b/lib/strdup.c
index cc0db6f6ae..1d60f13948 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -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
diff --git a/lib/stripslash.c b/lib/stripslash.c
index 5f40364110..67330e5756 100644
--- a/lib/stripslash.c
+++ b/lib/stripslash.c
@@ -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)
diff --git a/lib/userspec.c b/lib/userspec.c
index 75000e8fd3..67f1583335 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -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__
diff --git a/lib/xstrdup.c b/lib/xstrdup.c
index 4c5749e02d..27cd0c6738 100644
--- a/lib/xstrdup.c
+++ b/lib/xstrdup.c
@@ -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)
diff --git a/lib/yesno.c b/lib/yesno.c
index 5e413ec071..c6897777e8 100644
--- a/lib/yesno.c
+++ b/lib/yesno.c
@@ -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>