--- ray/src/common/fropen.c 1992/06/16 13:06:58 2.2 +++ ray/src/common/fropen.c 1995/03/01 10:40:17 2.7 @@ -10,47 +10,31 @@ static char SCCSid[] = "$SunId$ LBL"; #include -#ifndef DEFPATH -#define DEFPATH ":/usr/local/lib/ray" -#endif -#ifndef ULIBVAR -#define ULIBVAR "RAYPATH" -#endif +#include "paths.h" -char *libpath = NULL; /* library search path */ - FILE * -fropen(fname) /* find file and open for reading */ +frlibopen(fname) /* find file and open for reading */ register char *fname; { - extern char *strcpy(), *getenv(); + extern char *strcpy(), *getlibpath(); FILE *fp; - char pname[256]; + char pname[MAXPATH]; register char *sp, *cp; if (fname == NULL) return(NULL); - if (fname[0] == '/' || fname[0] == '.') /* absolute path */ + if (ISDIRSEP(fname[0]) || fname[0] == '.') /* absolute path */ return(fopen(fname, "r")); - - if (libpath == NULL) { /* get search path */ - libpath = getenv(ULIBVAR); - if (libpath == NULL) - libpath = DEFPATH; - } /* check search path */ - sp = libpath; + sp = getlibpath(); do { cp = pname; - while (*sp && (*cp = *sp++) != ':') - if (*cp == '\\') { /* escape */ - if (*sp) *cp++ = *sp++; - } else - cp++; - if (cp > pname && cp[-1] != '/') - *cp++ = '/'; + while (*sp && (*cp = *sp++) != PATHSEP) + cp++; + if (cp > pname && !ISDIRSEP(cp[-1])) + *cp++ = DIRSEP; strcpy(cp, fname); if ((fp = fopen(pname, "r")) != NULL) return(fp); /* got it! */