X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Frealpath.c;fp=src%2Frealpath.c;h=b39257d0ada28183db43d96900ed6753a757de55;hp=f81bab663d12ce0b99bbb23dd37a7406d3ee299d;hb=716cfba952c1dc0d2cf5c968971f3780ba728a89;hpb=d74da9234cc42e8018b1500105c3892a5c46d5e3 diff --git a/src/realpath.c b/src/realpath.c index f81bab6..b39257d 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -43,20 +43,24 @@ Boston, MA 02111-1307, USA. */ #include /* for S_IFLNK */ -#ifndef PATH_MAX -#ifdef _POSIX_VERSION -#define PATH_MAX _POSIX_PATH_MAX -#else -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif +#if !defined (HAVE_GETCWD) && defined (HAVE_GETWD) +#undef getcwd +#define getcwd(buffer, len) getwd (buffer) #endif + +#ifndef PATH_MAX +# if defined (_POSIX_PATH_MAX) +# define PATH_MAX _POSIX_PATH_MAX +# elif defined (MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif #endif #define MAX_READLINKS 32 +char * xrealpath (const char *path, char resolved_path []); char * xrealpath (const char *path, char resolved_path []) { @@ -99,7 +103,7 @@ xrealpath (const char *path, char resolved_path []) */ else if (*path == '/') { - getcwd(new_path, PATH_MAX - 1); + getcwd (new_path, PATH_MAX - 1); new_path += 3; path++; } @@ -109,21 +113,17 @@ xrealpath (const char *path, char resolved_path []) */ else { - getcwd(new_path, PATH_MAX - 1); + getcwd (new_path, PATH_MAX - 1); new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; } #else - /* If it's a relative pathname use getwd for starters. */ + /* If it's a relative pathname use getcwd for starters. */ if (*path != '/') { -#ifdef HAVE_GETCWD - getcwd(new_path, PATH_MAX - 1); -#else - getwd(new_path); -#endif + getcwd (new_path, PATH_MAX - 1); new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/';