# HG changeset patch # User Jim Meyering # Date 781076103 0 # Node ID ed27c3582f3bd7a1384af0c23223a20f56b69378 # Parent 36d6e7c81e3263c8c401b94082f0d1e9c3b1f8f3 GNU file utilities diff -r 36d6e7c81e32 -r ed27c3582f3b lib/Makefile.in --- 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 diff -r 36d6e7c81e32 -r ed27c3582f3b lib/argmatch.c --- 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 */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use 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 -#else -#include "config.h" -#endif #endif #include diff -r 36d6e7c81e32 -r ed27c3582f3b lib/backupfile.c --- 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 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 -#else -#include "config.h" -#endif #endif #include @@ -45,24 +38,24 @@ #include #endif -#ifdef DIRENT +#ifdef HAVE_DIRENT_H #include #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 -#endif /* SYSNDIR */ -#ifdef SYSDIR +#endif /* HAVE_SYS_NDIR_H */ +#ifdef HAVE_SYS_DIR_H #include -#endif /* SYSDIR */ -#ifdef NDIR +#endif /* HAVE_SYS_DIR_H */ +#ifdef HAVE_NDIR_H #include -#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 -r 36d6e7c81e32 -r ed27c3582f3b lib/dirname.c --- 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 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 -#else -#include "config.h" -#endif #endif #ifdef STDC_HEADERS diff -r 36d6e7c81e32 -r ed27c3582f3b lib/fileblocks.c --- 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 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 -#else -#include "config.h" -#endif #endif #if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_SOURCE) diff -r 36d6e7c81e32 -r ed27c3582f3b lib/filemode.c --- 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 -#else -#include "config.h" -#endif #endif #include @@ -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 -r 36d6e7c81e32 -r ed27c3582f3b lib/fsusage.c --- 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 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 -#else -#include "config.h" -#endif #endif #include diff -r 36d6e7c81e32 -r ed27c3582f3b lib/ftruncate.c --- 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 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 -#else -#include "config.h" -#endif #endif #include #include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif - #ifdef F_CHSIZE int @@ -36,7 +24,7 @@ /* By William Kucharski . */ #include - +#include #ifdef HAVE_UNISTD_H #include #endif @@ -96,6 +84,11 @@ #else /* not F_CHSIZE nor F_FREESP nor HAVE_CHSIZE */ +#include +#ifndef errno +extern int errno; +#endif + int ftruncate (fd, length) int fd; diff -r 36d6e7c81e32 -r ed27c3582f3b lib/full-write.c --- 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 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 -#else -#include "config.h" -#endif #endif #include @@ -47,7 +40,7 @@ full_write (desc, ptr, len) int desc; char *ptr; - int len; + size_t len; { int total_written; diff -r 36d6e7c81e32 -r ed27c3582f3b lib/getversion.c --- 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 */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use 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 -#else -#include "config.h" -#endif #endif #include "backupfile.h" diff -r 36d6e7c81e32 -r ed27c3582f3b lib/idcache.c --- 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 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 -#else -#include "config.h" -#endif #endif #include diff -r 36d6e7c81e32 -r ed27c3582f3b lib/isdir.c --- 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 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 -#else -#include "config.h" -#endif #endif #include @@ -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 -r 36d6e7c81e32 -r ed27c3582f3b lib/makepath.c --- 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 . */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use 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 -#else -#include "config.h" -#endif #endif #ifdef __GNUC__ @@ -50,11 +43,9 @@ #include #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 -r 36d6e7c81e32 -r ed27c3582f3b lib/mkdir.c --- 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 #include + #include -#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; - } -} diff -r 36d6e7c81e32 -r ed27c3582f3b lib/modechange.c --- 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 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 -#else -#include "config.h" -#endif #endif #include @@ -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) diff -r 36d6e7c81e32 -r ed27c3582f3b lib/mountlist.c --- 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 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 -#else -#include "config.h" -#endif #endif #include diff -r 36d6e7c81e32 -r ed27c3582f3b lib/rename.c --- 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 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 -#else -#include "config.h" -#endif #endif #include @@ -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 -r 36d6e7c81e32 -r ed27c3582f3b lib/rmdir.c --- /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 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 +#else +#include "config.h" +#endif +#endif + +#include +#include + +#include +#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 -r 36d6e7c81e32 -r ed27c3582f3b lib/safe-read.c --- 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 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 -#else -#include "config.h" -#endif #endif #include diff -r 36d6e7c81e32 -r ed27c3582f3b lib/savedir.c --- 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 . */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use 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 -#else -#include "config.h" -#endif #endif #include @@ -34,24 +27,24 @@ #include #endif -#ifdef DIRENT +#ifdef HAVE_DIRENT_H #include #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 -#endif /* SYSNDIR */ -#ifdef SYSDIR +#endif /* HAVE_SYS_NDIR_H */ +#ifdef HAVE_SYS_DIR_H #include -#endif /* SYSDIR */ -#ifdef NDIR +#endif /* HAVE_SYS_DIR_H */ +#ifdef HAVE_NDIR_H #include -#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 -r 36d6e7c81e32 -r ed27c3582f3b lib/strdup.c --- 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 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 -#else -#include "config.h" -#endif #endif #ifdef STDC_HEADERS diff -r 36d6e7c81e32 -r ed27c3582f3b lib/stripslash.c --- 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 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 -#else -#include "config.h" -#endif #endif #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) diff -r 36d6e7c81e32 -r ed27c3582f3b lib/userspec.c --- 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 . */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use 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 -#else -#include "config.h" -#endif #endif #ifdef __GNUC__ diff -r 36d6e7c81e32 -r ed27c3582f3b lib/xstrdup.c --- 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 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 -#else -#include "config.h" -#endif #endif #if defined(STDC_HEADERS) || defined(HAVE_STRING_H) diff -r 36d6e7c81e32 -r ed27c3582f3b lib/yesno.c --- 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 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 -#else -#include "config.h" -#endif #endif #include