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.12 by greg, Mon Jun 30 18:18:22 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Find and open a Radiance library file.
6 + *
7 + *  External symbols declared in standard.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include <stdio.h>
13  
14 < #ifndef DEFPATH
14 < #define DEFPATH         ":/usr/local/lib/ray"
15 < #endif
16 < #ifndef ULIBVAR
17 < #define ULIBVAR         "RAYPATH"
18 < #endif
14 > #include "paths.h"
15  
20 char  *libpath = NULL;          /* library search path */
16  
22
17   FILE *
18 < fropen(fname)                   /* find file and open for reading */
18 > frlibopen(fname)                /* find file and open for reading */
19   register char  *fname;
20   {
21 <        extern char  *strcpy(), *getenv();
21 >        extern char  *getrlibpath();
22          FILE  *fp;
23 <        char  pname[256];
23 >        char  pname[PATH_MAX];
24          register char  *sp, *cp;
25  
26          if (fname == NULL)
27                  return(NULL);
28  
29 <        if (fname[0] == '/' || fname[0] == '.') /* absolute path */
29 >        if (ISDIRSEP(fname[0]) || fname[0] == '.')      /* absolute path */
30                  return(fopen(fname, "r"));
37                
38        if (libpath == NULL) {                  /* get search path */
39                libpath = getenv(ULIBVAR);
40                if (libpath == NULL)
41                        libpath = DEFPATH;
42        }
31                                                  /* check search path */
32 <        sp = libpath;
32 >        sp = getrlibpath();
33          do {
34                  cp = pname;
35 <                while (*sp && (*cp = *sp++) != ':')
36 <                        if (*cp == '\\') {              /* escape */
37 <                                if (*sp) *cp++ = *sp++;
38 <                        } else
51 <                                cp++;
52 <                if (cp > pname && cp[-1] != '/')
53 <                        *cp++ = '/';
35 >                while (*sp && (*cp = *sp++) != PATHSEP)
36 >                        cp++;
37 >                if (cp > pname && !ISDIRSEP(cp[-1]))
38 >                        *cp++ = DIRSEP;
39                  strcpy(cp, fname);
40                  if ((fp = fopen(pname, "r")) != NULL)
41                          return(fp);                     /* got it! */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines