[BACK]Return to getcwd.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gen

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/gen/getcwd.c between version 1.36 and 1.36.2.1

version 1.36, 2005/01/30 22:37:32 version 1.36.2.1, 2005/08/14 22:08:44
Line 69  char *
Line 69  char *
 realpath(const char *path, char *resolved)  realpath(const char *path, char *resolved)
 {  {
         struct stat sb;          struct stat sb;
         int idx = 0, n, nlnk = 0, serrno = errno;          int idx = 0, n, nlnk = 0;
         const char *q;          const char *q;
         char *p, wbuf[2][MAXPATHLEN];          char *p, wbuf[2][MAXPATHLEN];
         size_t len;          size_t len;
Line 159  loop:
Line 159  loop:
          * target to unresolved path.           * target to unresolved path.
          */           */
         if (lstat(resolved, &sb) == -1) {          if (lstat(resolved, &sb) == -1) {
                 /* Allow nonexistent component if this is the last one. */  
                 if (*q == 0 && errno == ENOENT) {  
                         errno = serrno;  
                         return (resolved);  
                 }  
                 return (NULL);                  return (NULL);
         }          }
         if (S_ISLNK(sb.st_mode)) {          if (S_ISLNK(sb.st_mode)) {
Line 193  loop:
Line 188  loop:
                         p = resolved;                          p = resolved;
                 goto loop;                  goto loop;
         }          }
           if (*q == '/' && !S_ISDIR(sb.st_mode)) {
                   errno = ENOTDIR;
                   return (NULL);
           }
   
         /* Advance both resolved and unresolved path. */          /* Advance both resolved and unresolved path. */
         p += 1 + q - path;          p += 1 + q - path;

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.36.2.1

CVSweb <webmaster@jp.NetBSD.org>