ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/getpath.c
(Generate patch)

Comparing ray/src/common/getpath.c (file contents):
Revision 2.21 by greg, Sat Dec 28 18:05:14 2019 UTC vs.
Revision 2.22 by greg, Mon Nov 22 18:23:56 2021 UTC

# Line 33 | Line 33 | getpath        /* expand fname, return full path */
33          char  *cp;
34          int i;
35  
36 <        if (fname == NULL) { return(NULL); }
36 >        if (!fname | (fname == pname))
37 >                return(fname);
38  
39          pname[0] = '\0';                /* check for full specification */
40  
41 <        if (ISABS(fname)) { /* absolute path */
41 >        if (ISABS(fname)) {             /* absolute path */
42                  strlcpy(pname, fname, sizeof(pname));
43          } else {
44                  switch (*fname) {
45 <                        case '.':               /* relative to cwd */
45 >                        case '.':       /* relative to cwd */
46                                  strlcpy(pname, fname, sizeof(pname));
47                                  break;
48 <                        case '~':               /* relative to home directory */
48 >                        case '~':       /* relative to home directory */
49                                  fname++;
50                                  cp = uname;
51                                  for (i = 0; i < sizeof(uname) && *fname
# Line 60 | Line 61 | getpath        /* expand fname, return full path */
61          if (pname[0])           /* got it, check access if search requested */
62                  return(!searchpath || access(pname,mode)==0 ? pname : NULL);
63  
64 <        if (!searchpath) {                      /* no search */
64 >        if (!searchpath) {              /* no search? */
65                  strlcpy(pname, fname, sizeof(pname));
66                  return(pname);
67          }
# Line 100 | Line 101 | getpath(       /* expand fname, return full path */
101          char  *cp;
102          char fname[PATH_MAX];
103  
104 <        if (ffname == NULL)
105 <                return(NULL);
104 >        if (!fname | (fname == pname))
105 >                return(fname);
106  
107          /* if we have a dot in the string, we assume there is a file name
108             extension present */
109          /* XXX We'd better test for .exe/.bat/.etc explicitly */
110 <        if (!(mode & X_OK) || (strrchr(ffname, '.') != NULL)) {
110 >        if (!(mode & X_OK) || strchr(ffname, '.') > ffname) {
111                  return core_getpath(ffname, searchpath, mode);
112          }
113  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines