.
authorJim Meyering <jim@meyering.net>
Sun, 2 Oct 1994 02:09:38 +0000 (02:09 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 2 Oct 1994 02:09:38 +0000 (02:09 +0000)
lib/Makefile.in
lib/backupfile.c
lib/mkdir.c
lib/savedir.c

index 5737aa4..b84df8b 100644 (file)
@@ -23,14 +23,12 @@ VPATH = @srcdir@
 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 @@ 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.. -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) $(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
index 2ef0f0b..36094af 100644 (file)
 #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
index b1eb473..3726cbb 100644 (file)
@@ -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
 
 #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 @@ extern int errno;
 
 #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 @@ mkdir (dpath, dmode)
 
   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 (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.  */
+      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);
     }
 }
index b831c1f..cdf1288 100644 (file)
 #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