--- ray/src/common/fropen.c 1990/12/08 09:28:15 1.1 +++ ray/src/common/fropen.c 1992/06/16 13:06:58 2.2 @@ -1,4 +1,4 @@ -/* Copyright (c) 1990 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -17,13 +17,14 @@ static char SCCSid[] = "$SunId$ LBL"; #define ULIBVAR "RAYPATH" #endif +char *libpath = NULL; /* library search path */ + FILE * fropen(fname) /* find file and open for reading */ register char *fname; { extern char *strcpy(), *getenv(); - static char *searchpath; FILE *fp; char pname[256]; register char *sp, *cp; @@ -34,17 +35,20 @@ register char *fname; if (fname[0] == '/' || fname[0] == '.') /* absolute path */ return(fopen(fname, "r")); - if (searchpath == NULL) { /* get search path */ - searchpath = getenv(ULIBVAR); - if (searchpath == NULL) - searchpath = DEFPATH; + if (libpath == NULL) { /* get search path */ + libpath = getenv(ULIBVAR); + if (libpath == NULL) + libpath = DEFPATH; } /* check search path */ - sp = searchpath; + sp = libpath; do { cp = pname; while (*sp && (*cp = *sp++) != ':') - cp++; + if (*cp == '\\') { /* escape */ + if (*sp) *cp++ = *sp++; + } else + cp++; if (cp > pname && cp[-1] != '/') *cp++ = '/'; strcpy(cp, fname);