version 1.8, 2001/10/09 01:36:24 |
version 1.11, 2004/03/02 08:28:49 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.7 2001/08/20 09:14:14 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.10 2004/03/02 07:44:02 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 95 char *ASIRLOADPATH[32]; |
|
Line 95 char *ASIRLOADPATH[32]; |
|
|
|
char *getenv(); |
char *getenv(); |
void Pget_rootdir(); |
void Pget_rootdir(); |
|
char *search_executable(char *name); |
|
|
extern char *asir_libdir; |
extern char *asir_libdir; |
extern char *asir_pager; |
extern char *asir_pager; |
extern int read_exec_file; |
extern int read_exec_file; |
extern int main_parser; |
extern int main_parser; |
extern jmp_buf exec_env; |
extern JMP_BUF exec_env; |
|
|
|
char *search_executable(char *name) |
|
{ |
|
char *c,*s,*ret; |
|
int len,nlen; |
|
char dir[BUFSIZ],path[BUFSIZ]; |
|
struct stat buf; |
|
|
|
nlen = strlen(name); |
|
for ( s = (char *)getenv("PATH"); *s; ) { |
|
c = (char *)index(s,':'); |
|
len = c ? c-s : strlen(dir); |
|
if ( len >= BUFSIZ ) continue; |
|
strncpy(dir,s,len); s = c+1; dir[len] = 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) ) { |
|
len = strlen(path)+1; |
|
ret = (char *)MALLOC(len); |
|
strcpy(ret,path); |
|
return ret; |
|
} |
|
} |
|
return 0; |
|
} |
|
|
void env_init() { |
void env_init() { |
char *e,*p,*q; |
char *e,*p,*q; |
int i,l; |
int i,l,japanese; |
char *getenv(); |
char *getenv(); |
char *oxhome; |
char *oxhome; |
char rootname[BUFSIZ]; |
char rootname[BUFSIZ]; |
Line 125 void env_init() { |
|
Line 152 void env_init() { |
|
} |
} |
} |
} |
if ( !(asir_pager = getenv("PAGER")) ) { |
if ( !(asir_pager = getenv("PAGER")) ) { |
asir_pager = (char *)malloc(strlen(MORE)+1); |
japanese = 0; |
strcpy(asir_pager,MORE); |
if ( (e = getenv("LANGUAGE")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LC_ALL")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LC_CTYPE")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LANG")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
if ( japanese ) |
|
asir_pager = search_executable("jless"); |
|
if ( !asir_pager ) { |
|
/* default: more */ |
|
asir_pager = (char *)malloc(strlen(MORE)+1); |
|
strcpy(asir_pager,MORE); |
|
} |
} |
} |
if ( e = getenv("ASIRLOADPATH" ) ) |
if ( e = getenv("ASIRLOADPATH" ) ) |
for ( i = 0; ; i++, e = p+1 ) { |
for ( i = 0; ; i++, e = p+1 ) { |
Line 319 void load_and_execfile(char *name) |
|
Line 360 void load_and_execfile(char *name) |
|
save_prresult = prresult; |
save_prresult = prresult; |
fp = fopen(name,"rb"); |
fp = fopen(name,"rb"); |
input_init(fp,name); |
input_init(fp,name); |
if ( !setjmp(exec_env) ) { |
if ( !SETJMP(exec_env) ) { |
/* XXX : information for asir_teriminate() */ |
/* XXX : information for asir_teriminate() */ |
read_exec_file = 2; |
read_exec_file = 2; |
read_eval_loop(); |
read_eval_loop(); |