=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/load.c,v retrieving revision 1.11 retrieving revision 1.19 diff -u -p -r1.11 -r1.19 --- OpenXM_contrib2/asir2000/parse/load.c 2004/03/02 08:28:49 1.11 +++ OpenXM_contrib2/asir2000/parse/load.c 2006/02/05 08:28:04 1.19 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.10 2004/03/02 07:44:02 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.18 2005/03/28 09:20:38 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -79,7 +79,7 @@ #define MALLOC(x) GC_malloc((x)+4) #endif -char *ASIRLOADPATH[32]; +char **ASIRLOADPATH; #if defined(VISUAL) #define ENVDELIM ';' @@ -90,14 +90,18 @@ char *ASIRLOADPATH[32]; #endif #ifndef ASIR_LIBDIR -#define ASIR_LIBDIR "." +#define ASIR_LIBDIR "/usr/local/lib/asir" #endif +#ifndef ASIR_CONTRIB_DIR +#define ASIR_CONTRIB_DIR "/usr/local/lib/asir-contrib" +#endif char *getenv(); void Pget_rootdir(); char *search_executable(char *name); extern char *asir_libdir; +extern char *asir_contrib_dir; extern char *asir_pager; extern int read_exec_file; extern int main_parser; @@ -111,15 +115,20 @@ char *search_executable(char *name) struct stat buf; nlen = strlen(name); - for ( s = (char *)getenv("PATH"); *s; ) { + for ( s = (char *)getenv("PATH"); s; ) { c = (char *)index(s,':'); - len = c ? c-s : strlen(dir); + len = c ? c-s : strlen(s); if ( len >= BUFSIZ ) continue; - strncpy(dir,s,len); s = c+1; dir[len] = 0; + strncpy(dir,s,len); dir[len] = 0; + if ( c ) s = c+1; + else s = 0; if ( len+nlen+1 >= BUFSIZ ) continue; sprintf(path,"%s/%s",dir,name); if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR) - && !access(path,X_OK) ) { +#if !defined(VISUAL) + && !access(path,X_OK) +#endif + ) { len = strlen(path)+1; ret = (char *)MALLOC(len); strcpy(ret,path); @@ -151,6 +160,23 @@ void env_init() { #endif } } + + if ( !(asir_contrib_dir = getenv("ASIR_CONTRIB_DIR")) ) { + if ( oxhome = getenv("OpenXM_HOME") ) { + asir_contrib_dir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir-contrib")+1); + sprintf(asir_contrib_dir,"%s/lib/asir-contrib",oxhome); + } else { +#if defined(VISUAL) + get_rootdir(rootname,sizeof(rootname)); + asir_contrib_dir = (char *)malloc(strlen(rootname)+strlen("/lib-asir-contrib")+1); + sprintf(asir_contrib_dir,"%s/lib-asir-contrib",rootname); +#else + asir_contrib_dir = (char *)malloc(strlen(ASIR_CONTRIB_DIR)+1); + strcpy(asir_contrib_dir,ASIR_CONTRIB_DIR); +#endif + } + } + if ( !(asir_pager = getenv("PAGER")) ) { japanese = 0; if ( (e = getenv("LANGUAGE")) && @@ -169,9 +195,18 @@ void env_init() { strcpy(asir_pager,MORE); } } - if ( e = getenv("ASIRLOADPATH" ) ) + if ( e = getenv("ASIRLOADPATH" ) ) { for ( i = 0; ; i++, e = p+1 ) { p = (char *)index(e,ENVDELIM); + if ( !p ) + break; + } + i += 4; + ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i); + for ( l = 0; l