[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.2.1.2.1 and 1.48

version 1.36.2.1.2.1, 2005/12/29 16:25:46 version 1.48, 2011/02/15 16:29:09
Line 54  __RCSID("$NetBSD$");
Line 54  __RCSID("$NetBSD$");
 #include "extern.h"  #include "extern.h"
   
 #ifdef __weak_alias  #ifdef __weak_alias
 __weak_alias(getcwd,_getcwd)  __weak_alias(getcwd,_sys_getcwd)
   __weak_alias(_getcwd,_sys_getcwd)
 __weak_alias(realpath,_realpath)  __weak_alias(realpath,_realpath)
   
   #undef getcwd
   #define getcwd _sys_getcwd
   #if !defined(_FORTIFY_SOURCE)
   char *_sys_getcwd(char *, size_t);
   #endif
   
 #endif  #endif
   
 /*  /*
Line 74  realpath(const char *path, char *resolve
Line 82  realpath(const char *path, char *resolve
         char *p, wbuf[2][MAXPATHLEN];          char *p, wbuf[2][MAXPATHLEN];
         size_t len;          size_t len;
   
         _DIAGASSERT(path != NULL);  
         _DIAGASSERT(resolved != NULL);          _DIAGASSERT(resolved != NULL);
   
           /* POSIX sez we must test for this */
           if (path == NULL) {
                   errno = EINVAL;
                   return NULL;
           }
   
         /*          /*
          * Build real path one by one with paying an attention to .,           * Build real path one by one with paying an attention to .,
          * .. and symbolic link.           * .. and symbolic link.
Line 96  realpath(const char *path, char *resolve
Line 109  realpath(const char *path, char *resolve
   
         /* If relative path, start from current working directory. */          /* If relative path, start from current working directory. */
         if (*path != '/') {          if (*path != '/') {
                 if (getcwd(resolved, MAXPATHLEN) == NULL) {                  /* check for resolved pointer to appease coverity */
                   if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) {
                         p[0] = '.';                          p[0] = '.';
                         p[1] = 0;                          p[1] = 0;
                         return (NULL);                          return (NULL);
Line 159  loop:
Line 173  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. */  
                 while (*q == '/')  
                         q++;  
   
                 if (*q == 0  && errno == ENOENT)  
                         return (resolved);  
   
                 return (NULL);                  return (NULL);
         }          }
         if (S_ISLNK(sb.st_mode)) {          if (S_ISLNK(sb.st_mode)) {

Legend:
Removed from v.1.36.2.1.2.1  
changed lines
  Added in v.1.48

CVSweb <webmaster@jp.NetBSD.org>