X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmakepath.c;h=661f58b0fdba73b9fd6b5b7f8ab24d219627824f;hb=f35597f9dd9799bd46a6cbb35c3bbe6e9cc6dd7a;hp=9066874cd9197feb1f692045f66d72f5e76bfacb;hpb=32545ade5ca173c6f965614592ee239971346eb8;p=gnulib.git diff --git a/lib/makepath.c b/lib/makepath.c index 9066874cd..661f58b0f 100644 --- a/lib/makepath.c +++ b/lib/makepath.c @@ -59,17 +59,17 @@ char *alloca (); #include #endif -#ifndef STDC_HEADERS +#ifndef errno extern int errno; #endif -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include -#ifndef index -#define index strchr -#endif +#ifdef HAVE_STRING_H +# include #else -#include +# include +# ifndef strchr +# define strchr index +# endif #endif #ifdef __MSDOS__ @@ -78,7 +78,7 @@ typedef int gid_t; #endif #include "makepath.h" -#include "safe-stat.h" + void error (); /* Ensure that the directory ARGPATH exists. @@ -99,6 +99,16 @@ void error (); Return 0 if ARGPATH exists as a directory with the proper ownership and permissions when done, otherwise 1. */ +#if __STDC__ +int +make_path (const char *argpath, + int mode, + int parent_mode, + uid_t owner, + gid_t group, + int preserve_existing, + const char *verbose_fmt_string) +#else int make_path (argpath, mode, parent_mode, owner, group, preserve_existing, verbose_fmt_string) @@ -109,6 +119,7 @@ make_path (argpath, mode, parent_mode, owner, group, preserve_existing, gid_t group; int preserve_existing; const char *verbose_fmt_string; +#endif { char *dirpath; /* A copy we can scribble NULs on. */ struct stat stats; @@ -120,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. */ @@ -151,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)) { @@ -208,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);