summaryrefslogtreecommitdiff
path: root/lib/makepath.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-05-13 13:30:10 +0000
committerJim Meyering <jim@meyering.net>1995-05-13 13:30:10 +0000
commitc093a8e789c971345200ac85d72f1bb09d6718e9 (patch)
tree54276e8c17b441808c5b25e214f1178d812a3b7f /lib/makepath.c
parent7ce06ceca7d2d1ded70035175710879e9d0d9771 (diff)
downloadcoreutils-c093a8e789c971345200ac85d72f1bb09d6718e9.tar.xz
(make_path): Use stat, not SAFE_STAT.
Use strchr, not index. Adjust defines accordingly.
Diffstat (limited to 'lib/makepath.c')
-rw-r--r--lib/makepath.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/makepath.c b/lib/makepath.c
index b59211672..496c852b1 100644
--- a/lib/makepath.c
+++ b/lib/makepath.c
@@ -59,17 +59,17 @@ char *alloca ();
#include <errno.h>
#endif
-#ifndef STDC_HEADERS
+#ifndef errno
extern int errno;
#endif
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#include <string.h>
-#ifndef index
-#define index strchr
-#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
#else
-#include <strings.h>
+# include <strings.h>
+# ifndef strchr
+# define strchr index
+# endif
#endif
#ifdef __MSDOS__
@@ -99,7 +99,7 @@ void error ();
Return 0 if ARGPATH exists as a directory with the proper
ownership and permissions when done, otherwise 1. */
-#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
+#if __STDC__
int
make_path (const char *argpath,
int mode,
@@ -131,7 +131,7 @@ make_path (argpath, mode, parent_mode, owner, group, preserve_existing,
dirpath = (char *) alloca (strlen (argpath) + 1);
strcpy (dirpath, argpath);
- if (SAFE_STAT (dirpath, &stats))
+ if (stat (dirpath, &stats))
{
char *slash;
int tmp_mode; /* Initial perms for leading dirs. */
@@ -162,10 +162,10 @@ make_path (argpath, mode, parent_mode, owner, group, preserve_existing,
slash = dirpath;
while (*slash == '/')
slash++;
- while ((slash = index (slash, '/')))
+ while ((slash = strchr (slash, '/')))
{
*slash = '\0';
- if (SAFE_STAT (dirpath, &stats))
+ if (stat (dirpath, &stats))
{
if (mkdir (dirpath, tmp_mode))
{
@@ -219,7 +219,7 @@ make_path (argpath, mode, parent_mode, owner, group, preserve_existing,
/* The path could end in "/." or contain "/..", so test
if we really have to create the directory. */
- if (SAFE_STAT (dirpath, &stats) && mkdir (dirpath, mode))
+ if (stat (dirpath, &stats) && mkdir (dirpath, mode))
{
error (0, errno, "cannot create directory `%s'", dirpath);
umask (oldmask);