1 |
< |
/* Copyright (c) 1990 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
17 |
|
#define ULIBVAR "RAYPATH" |
18 |
|
#endif |
19 |
|
|
20 |
+ |
char *libpath = NULL; /* library search path */ |
21 |
|
|
22 |
+ |
|
23 |
|
FILE * |
24 |
|
fropen(fname) /* find file and open for reading */ |
25 |
|
register char *fname; |
26 |
|
{ |
27 |
|
extern char *strcpy(), *getenv(); |
26 |
– |
static char *searchpath; |
28 |
|
FILE *fp; |
29 |
|
char pname[256]; |
30 |
|
register char *sp, *cp; |
35 |
|
if (fname[0] == '/' || fname[0] == '.') /* absolute path */ |
36 |
|
return(fopen(fname, "r")); |
37 |
|
|
38 |
< |
if (searchpath == NULL) { /* get search path */ |
39 |
< |
searchpath = getenv(ULIBVAR); |
40 |
< |
if (searchpath == NULL) |
41 |
< |
searchpath = DEFPATH; |
38 |
> |
if (libpath == NULL) { /* get search path */ |
39 |
> |
libpath = getenv(ULIBVAR); |
40 |
> |
if (libpath == NULL) |
41 |
> |
libpath = DEFPATH; |
42 |
|
} |
43 |
|
/* check search path */ |
44 |
< |
sp = searchpath; |
44 |
> |
sp = libpath; |
45 |
|
do { |
46 |
|
cp = pname; |
47 |
|
while (*sp && (*cp = *sp++) != ':') |
48 |
< |
cp++; |
48 |
> |
if (*cp == '\\') { /* escape */ |
49 |
> |
if (*sp) *cp++ = *sp++; |
50 |
> |
} else |
51 |
> |
cp++; |
52 |
|
if (cp > pname && cp[-1] != '/') |
53 |
|
*cp++ = '/'; |
54 |
|
strcpy(cp, fname); |