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

Comparing ray/src/common/fropen.c (file contents):
Revision 2.2 by greg, Tue Jun 16 13:06:58 1992 UTC vs.
Revision 2.6 by greg, Thu Apr 14 04:44:45 1994 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include <stdio.h>
12  
13 < #ifndef DEFPATH
14 < #define DEFPATH         ":/usr/local/lib/ray"
15 < #endif
16 < #ifndef ULIBVAR
17 < #define ULIBVAR         "RAYPATH"
18 < #endif
13 > #include "paths.h"
14  
20 char  *libpath = NULL;          /* library search path */
15  
22
16   FILE *
17   fropen(fname)                   /* find file and open for reading */
18   register char  *fname;
19   {
20 <        extern char  *strcpy(), *getenv();
20 >        extern char  *strcpy(), *getlibpath();
21          FILE  *fp;
22 <        char  pname[256];
22 >        char  pname[MAXPATH];
23          register char  *sp, *cp;
24  
25          if (fname == NULL)
26                  return(NULL);
27  
28 <        if (fname[0] == '/' || fname[0] == '.') /* absolute path */
28 >        if (ISDIRSEP(fname[0]) || fname[0] == '.')      /* absolute path */
29                  return(fopen(fname, "r"));
37                
38        if (libpath == NULL) {                  /* get search path */
39                libpath = getenv(ULIBVAR);
40                if (libpath == NULL)
41                        libpath = DEFPATH;
42        }
30                                                  /* check search path */
31 <        sp = libpath;
31 >        sp = getlibpath();
32          do {
33                  cp = pname;
34 <                while (*sp && (*cp = *sp++) != ':')
35 <                        if (*cp == '\\') {              /* escape */
36 <                                if (*sp) *cp++ = *sp++;
37 <                        } else
51 <                                cp++;
52 <                if (cp > pname && cp[-1] != '/')
53 <                        *cp++ = '/';
34 >                while (*sp && (*cp = *sp++) != PATHSEP)
35 >                        cp++;
36 >                if (cp > pname && !ISDIRSEP(cp[-1]))
37 >                        *cp++ = DIRSEP;
38                  strcpy(cp, fname);
39                  if ((fp = fopen(pname, "r")) != NULL)
40                          return(fp);                     /* got it! */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines