changeset 314:2a9addedba6a

.
author Jim Meyering <jim@meyering.net>
date Sun, 02 Oct 1994 02:09:38 +0000
parents 9cf2ec9abdb7
children 21c5085366d5
files lib/Makefile.in lib/backupfile.c lib/mkdir.c lib/savedir.c
diffstat 4 files changed, 69 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -23,14 +23,12 @@
 CC = @CC@
 AR = ar
 RANLIB = @RANLIB@
-DEFS = -DCONFIG_BROKETS -Dlint @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 \
@@ -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.. -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) $(srcdir)/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) $(srcdir)/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) $(srcdir)/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) $(srcdir)/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/backupfile.c
+++ b/lib/backupfile.c
@@ -45,24 +45,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/mkdir.c
+++ b/lib/mkdir.c
@@ -1,4 +1,4 @@
-/* mkdir.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,14 +28,15 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
 #include <errno.h>
-#ifndef STDC_HEADERS
+#ifndef errno
 extern int errno;
 #endif
 
 #ifdef STAT_MACROS_BROKEN
 #undef S_ISDIR
-#endif /* STAT_MACROS_BROKEN.  */
+#endif
 
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
@@ -43,7 +44,7 @@
 
 #include "safe-stat.h"
 
-/* mkdir and rmdir adapted from GNU tar.  */
+/* mkdir adapted from GNU tar.  */
 
 /* Make directory DPATH, with permission mode DMODE.
 
@@ -66,7 +67,7 @@
 
   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 (SAFE_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/savedir.c
+++ b/lib/savedir.c
@@ -34,24 +34,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