=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/load.c,v retrieving revision 1.22 retrieving revision 1.32 diff -u -p -r1.22 -r1.32 --- OpenXM_contrib2/asir2000/parse/load.c 2012/12/17 07:20:45 1.22 +++ OpenXM_contrib2/asir2000/parse/load.c 2017/02/07 08:30:31 1.32 @@ -45,12 +45,12 @@ * 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.21 2006/09/13 02:26:13 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.31 2016/08/30 02:29:11 noro Exp $ */ #include "ca.h" #include "parse.h" -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #include #include #include @@ -70,7 +70,7 @@ #include #endif -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #include #endif @@ -80,8 +80,9 @@ #endif char **ASIRLOADPATH; +int ASIRLOADPATH_LEN; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #define ENVDELIM ';' #define MORE "more < " #else @@ -102,6 +103,7 @@ char *search_executable(char *name); extern char *asir_libdir; extern char *asir_contrib_dir; +extern char *asir_private_dir; extern char *asir_pager; extern int main_parser; extern JMP_BUF exec_env; @@ -124,7 +126,7 @@ char *search_executable(char *name) if ( len+nlen+1 >= BUFSIZ ) continue; sprintf(path,"%s/%s",dir,name); if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR) -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) && !access(path,X_OK) #endif ) { @@ -143,40 +145,48 @@ void env_init() { char *getenv(); char *oxhome; char rootname[BUFSIZ]; + size_t len; + if ( oxhome = getenv("OpenXM_HOME") ) { + len = strlen(oxhome); + }else { +#if defined(VISUAL) || defined(__MINGW32__) + get_rootdir(rootname,sizeof(rootname)); + len = strlen(rootname); + oxhome = rootname; +#endif + } + if ( !(asir_libdir = getenv("ASIR_LIBDIR")) ) { - if ( oxhome = getenv("OpenXM_HOME") ) { - asir_libdir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir")+1); + if ( oxhome ) { + asir_libdir = (char *)malloc(len+strlen("/lib/asir")+1); sprintf(asir_libdir,"%s/lib/asir",oxhome); } else { -#if defined(VISUAL) - get_rootdir(rootname,sizeof(rootname)); - asir_libdir = (char *)malloc(strlen(rootname)+strlen("/lib")+1); - sprintf(asir_libdir,"%s/lib",rootname); -#else asir_libdir = (char *)malloc(strlen(ASIR_LIBDIR)+1); strcpy(asir_libdir,ASIR_LIBDIR); -#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); + if ( oxhome ) { + asir_contrib_dir = (char *)malloc(len+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 } } + asir_private_dir = NULL; +#if defined(VISUAL) || defined(__MINGW32__) + if ( e = getenv("APPDATA") ) { + asir_private_dir = (char *)malloc(strlen(e)+strlen("/OpenXM/lib/asir-contrib")+1); + sprintf(asir_private_dir,"%s/OpenXM/lib/asir-contrib",e); + } +#endif + if ( !(asir_pager = getenv("PAGER")) ) { +#if 0 japanese = 0; if ( (e = getenv("LANGUAGE")) && (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; @@ -188,6 +198,8 @@ void env_init() { (!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; if ( japanese ) asir_pager = search_executable("jless"); +#endif + asir_pager = search_executable("less"); if ( !asir_pager ) { /* default: more */ asir_pager = (char *)malloc(strlen(MORE)+1); @@ -200,7 +212,8 @@ void env_init() { if ( !p ) break; } - i += 4; + i += 5; + ASIRLOADPATH_LEN=i; ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i); for ( l = 0; lfp); if ( !EPVS->va ) - reallocarray((char **)&EPVS->va,(int *)&EPVS->asize,(int *)&EPVS->n,(int)sizeof(struct oPV)); + asir_reallocarray((char **)&EPVS->va,(int *)&EPVS->asize,(int *)&EPVS->n,(int)sizeof(struct oPV)); } void execasirfile(char *name)