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.5 by greg, Tue Sep 8 09:09:24 1992 UTC vs.
Revision 2.6 by greg, Tue Sep 8 10:04:34 1992 UTC

# Line 8 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   *  getpath.c - function to search for file in a list of directories
9   */
10  
11 < #include "paths.h"
11 > #include  "paths.h"
12  
13   #define  NULL           0
14  
# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17   extern struct passwd  *getpwnam();
18   #endif
19  
20 < extern char  *strcpy(), *strcat();
20 > extern char  *strcpy(), *strcat(), *getenv();
21  
22  
23   char *
# Line 29 | Line 29 | int  mode;
29   #ifndef  NIX
30          struct passwd  *pwent;
31   #endif
32 <        static char  pname[256];
32 >        static char  pname[MAXPATH];
33          register char  *cp;
34  
35          if (fname == NULL)
36                  return(NULL);
37  
38          switch (*fname) {
39 <        case DIRSEP:                            /* relative to root */
39 >        CASEDIRSEP:                             /* relative to root */
40          case '.':                               /* relative to cwd */
41                  strcpy(pname, fname);
42                  return(pname);
43   #ifndef NIX
44          case '~':                               /* relative to home directory */
45                  fname++;
46 <                if (*fname == '\0' || *fname == DIRSEP) {       /* ours */
46 >                if (*fname == '\0' || ISDIRSEP(*fname)) {       /* ours */
47                          if ((cp = getenv("HOME")) == NULL)
48                                  return(NULL);
49                          strcpy(pname, cp);
# Line 53 | Line 53 | int  mode;
53                  cp = pname;                                     /* user */
54                  do
55                          *cp++ = *fname++;
56 <                while (*fname && *fname != DIRSEP);
56 >                while (*fname && !ISDIRSEP(*fname));
57                  *cp = '\0';
58                  if ((pwent = getpwnam(pname)) == NULL)
59                          return(NULL);
# Line 72 | Line 72 | int  mode;
72                  cp = pname;
73                  while (*searchpath && (*cp = *searchpath++) != PATHSEP)
74                          cp++;
75 <                if (cp > pname && cp[-1] != DIRSEP)
75 >                if (cp > pname && !ISDIRSEP(cp[-1]))
76                          *cp++ = DIRSEP;
77                  strcpy(cp, fname);
78                  if (access(pname, mode) == 0)           /* file accessable? */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines