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.24 by greg, Sat Jun 7 05:09:45 2025 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   *  getpath.c - function to search for file in a list of directories
6   *
7 < *  External symbols declared in rtio.h
7 > *  External symbols declared in paths.h
8   */
9  
10   #include "copyright.h"
11  
12   #include  <ctype.h>
13  
14 #include  "rtio.h"
14   #include  "paths.h"
15  
16  
# Line 33 | Line 32 | getpath        /* expand fname, return full path */
32          char  *cp;
33          int i;
34  
35 <        if (fname == NULL) { return(NULL); }
35 >        if (!fname | (fname == pname))
36 >                return(fname);
37  
38          pname[0] = '\0';                /* check for full specification */
39  
40 <        if (ISABS(fname)) { /* absolute path */
40 >        if (ISABS(fname)) {             /* absolute path */
41                  strlcpy(pname, fname, sizeof(pname));
42          } else {
43                  switch (*fname) {
44 <                        case '.':               /* relative to cwd */
44 >                        case '.':       /* relative to cwd */
45                                  strlcpy(pname, fname, sizeof(pname));
46                                  break;
47 <                        case '~':               /* relative to home directory */
47 >                        case '~':       /* relative to home directory */
48                                  fname++;
49                                  cp = uname;
50                                  for (i = 0; i < sizeof(uname) && *fname
# Line 60 | Line 60 | getpath        /* expand fname, return full path */
60          if (pname[0])           /* got it, check access if search requested */
61                  return(!searchpath || access(pname,mode)==0 ? pname : NULL);
62  
63 <        if (!searchpath) {                      /* no search */
63 >        if (!searchpath) {              /* no search? */
64                  strlcpy(pname, fname, sizeof(pname));
65                  return(pname);
66          }
# Line 100 | Line 100 | getpath(       /* expand fname, return full path */
100          char  *cp;
101          char fname[PATH_MAX];
102  
103 <        if (ffname == NULL)
104 <                return(NULL);
103 >        if (!ffname | (ffname == fname))
104 >                return(ffname);
105  
106          /* if we have a dot in the string, we assume there is a file name
107             extension present */
108          /* XXX We'd better test for .exe/.bat/.etc explicitly */
109 <        if (!(mode & X_OK) || (strrchr(ffname, '.') != NULL)) {
109 >        if (!(mode & X_OK) || strchr(ffname, '.') > ffname) {
110                  return core_getpath(ffname, searchpath, mode);
111          }
112  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines