--- ray/src/common/fropen.c 1992/09/08 09:09:23 2.4 +++ ray/src/common/fropen.c 2003/06/30 18:18:22 2.12 @@ -1,47 +1,40 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: fropen.c,v 2.12 2003/06/30 18:18:22 greg Exp $"; #endif - /* * Find and open a Radiance library file. + * + * External symbols declared in standard.h */ +#include "copyright.h" + #include #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(); + extern char *getrlibpath(); FILE *fp; - char pname[256]; + char pname[PATH_MAX]; register char *sp, *cp; if (fname == NULL) return(NULL); - if (fname[0] == DIRSEP || 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 = getrlibpath(); do { cp = pname; while (*sp && (*cp = *sp++) != PATHSEP) cp++; - if (cp > pname && cp[-1] != DIRSEP) + if (cp > pname && !ISDIRSEP(cp[-1])) *cp++ = DIRSEP; strcpy(cp, fname); if ((fp = fopen(pname, "r")) != NULL)