X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Frealpath.c;h=be14a426f854f5d640a24a90a756d2a5cf305050;hb=98a6e4055a1fa624c592ac06f79287d55196ca37;hp=b39257d0ada28183db43d96900ed6753a757de55;hpb=716cfba952c1dc0d2cf5c968971f3780ba728a89;p=chise%2Fxemacs-chise.git.1 diff --git a/src/realpath.c b/src/realpath.c index b39257d..be14a42 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -28,16 +28,17 @@ Boston, MA 02111-1307, USA. */ #include #include #include +#include + #ifdef HAVE_UNISTD_H #include #endif -#ifdef _POSIX_VERSION -#include /* for PATH_MAX */ -#else -#include /* for MAXPATHLEN */ + +#if defined (HAVE_SYS_PARAM_H) +#include #endif -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE #include #endif @@ -74,10 +75,10 @@ xrealpath (const char *path, char resolved_path []) #endif /* Make a copy of the source path since we may need to modify it. */ - strcpy(copy_path, path); + strcpy (copy_path, path); path = copy_path; max_path = copy_path + PATH_MAX - 2; -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE /* ** In NT we have two different cases: (1) the path name begins ** with a drive letter, e.g., "C:"; and (2) the path name begins @@ -153,21 +154,20 @@ xrealpath (const char *path, char resolved_path []) continue; } - if (path[1] == '.') + /* Handle ".." */ + if (path[1] == '.' && + (path[2] == '\0' || path[2] == '/')) { - if (path[2] == '\0' || path[2] == '/') - { - path += 2; - - /* Ignore ".." at root. */ - if (new_path == resolved_path + 1) - continue; - - /* Handle ".." by backing up. */ - while ((--new_path)[-1] != '/') - ; - continue; - } + path += 2; + + /* Ignore ".." at root. */ + if (new_path == resolved_path + 1) + continue; + + /* Handle ".." by backing up. */ + while ((--new_path)[-1] != '/') + ; + continue; } } @@ -185,7 +185,7 @@ xrealpath (const char *path, char resolved_path []) #ifdef S_IFLNK /* See if latest pathname component is a symlink. */ *new_path = '\0'; - n = readlink(resolved_path, link_path, PATH_MAX - 1); + n = readlink (resolved_path, link_path, PATH_MAX - 1); if (n < 0) {