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.2 by greg, Wed Mar 25 10:57:29 1992 UTC vs.
Revision 2.3 by greg, Tue Jun 16 13:29:35 1992 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  <pwd.h>
14  
15 + #ifndef DIRSEP
16 + #define DIRSEP          '/'
17 + #endif
18 + #ifndef PATHSEP
19 + #define PATHSEP         ':'
20 + #endif
21 +
22   extern char  *strcpy(), *strcat(), *getenv();
23   extern struct passwd  *getpwnam();
24  
# Line 30 | Line 37 | int  mode;
37                  return(NULL);
38  
39          switch (*fname) {
40 <        case '/':                               /* relative to root */
40 >        case DIRSEP:                            /* relative to root */
41          case '.':                               /* relative to cwd */
42                  strcpy(pname, fname);
43                  return(pname);
44 + #ifndef NIX
45          case '~':                               /* relative to home directory */
46                  fname++;
47 <                if (*fname == '\0' || *fname == '/') {          /* ours */
47 >                if (*fname == '\0' || *fname == DIRSEP) {       /* ours */
48                          if ((cp = getenv("HOME")) == NULL)
49                                  return(NULL);
50                          strcpy(pname, cp);
# Line 46 | Line 54 | int  mode;
54                  cp = pname;                                     /* user */
55                  do
56                          *cp++ = *fname++;
57 <                while (*fname && *fname != '/');
57 >                while (*fname && *fname != DIRSEP);
58                  *cp = '\0';
59                  if ((pwent = getpwnam(pname)) == NULL)
60                          return(NULL);
61                  strcpy(pname, pwent->pw_dir);
62                  strcat(pname, fname);
63                  return(pname);
64 + #endif
65          }
66  
67          if (searchpath == NULL) {                       /* don't search */
# Line 62 | Line 71 | int  mode;
71                                                          /* check search path */
72          do {
73                  cp = pname;
74 <                while (*searchpath && (*cp = *searchpath++) != ':')
75 <                        if (*cp == '\\') {              /* escape */
76 <                                if (*searchpath)
77 <                                        *cp++ = *searchpath++;
69 <                        } else
70 <                                cp++;
71 <                if (cp > pname && cp[-1] != '/')
72 <                        *cp++ = '/';
74 >                while (*searchpath && (*cp = *searchpath++) != PATHSEP)
75 >                        cp++;
76 >                if (cp > pname && cp[-1] != DIRSEP)
77 >                        *cp++ = DIRSEP;
78                  strcpy(cp, fname);
79                  if (access(pname, mode) == 0)           /* file accessable? */
80                          return(pname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines