version 1.19, 2006/02/05 08:28:04 |
version 1.24, 2014/03/30 10:48:16 |
|
|
* 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.18 2005/03/28 09:20:38 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.23 2013/06/13 18:42:11 ohara Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
|
|
#ifdef MALLOC |
#ifdef MALLOC |
#undef MALLOC |
#undef MALLOC |
#define MALLOC(x) GC_malloc((x)+4) |
#define MALLOC(x) Risa_GC_malloc((x)+4) |
#endif |
#endif |
|
|
char **ASIRLOADPATH; |
char **ASIRLOADPATH; |
Line 102 char *search_executable(char *name); |
|
Line 102 char *search_executable(char *name); |
|
|
|
extern char *asir_libdir; |
extern char *asir_libdir; |
extern char *asir_contrib_dir; |
extern char *asir_contrib_dir; |
|
extern char *asir_private_dir; |
extern char *asir_pager; |
extern char *asir_pager; |
extern int read_exec_file; |
|
extern int main_parser; |
extern int main_parser; |
extern JMP_BUF exec_env; |
extern JMP_BUF exec_env; |
|
|
Line 177 void env_init() { |
|
Line 177 void env_init() { |
|
} |
} |
} |
} |
|
|
|
asir_private_dir = NULL; |
|
#if defined(VISUAL) |
|
if ( e = getenv("APPDATA") ) { |
|
asir_private_dir = (char *)malloc(strlen(e)+strlen("/asir/lib-asir-contrib")+1); |
|
sprintf(asir_private_dir,"%s/asir/lib-asir-contrib",e); |
|
} |
|
#endif |
|
|
if ( !(asir_pager = getenv("PAGER")) ) { |
if ( !(asir_pager = getenv("PAGER")) ) { |
japanese = 0; |
japanese = 0; |
if ( (e = getenv("LANGUAGE")) && |
if ( (e = getenv("LANGUAGE")) && |
Line 220 void env_init() { |
|
Line 228 void env_init() { |
|
} |
} |
|
|
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
|
if (asir_private_dir) ASIRLOADPATH[i++] = asir_private_dir; |
if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir; |
if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir; |
if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir; |
if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir; |
ASIRLOADPATH[i] = NULL; |
ASIRLOADPATH[i] = NULL; |
} |
} |
|
|
|
#if defined(VISUAL) |
|
#define R_OK 4 |
|
#endif |
|
|
void searchasirpath(char *name,char **pathp) |
void searchasirpath(char *name,char **pathp) |
{ |
{ |
char **p; |
char **p; |
char *q; |
char *q; |
int l; |
size_t l; |
#if !defined(VISUAL) |
int ret; |
struct stat sbuf; |
struct stat sbuf; |
|
|
if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':') |
if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':') |
|| !ASIRLOADPATH[0] ) { |
|| !ASIRLOADPATH[0] ) { |
if ( access(name,R_OK) >= 0 ) { |
if ( access(name,R_OK) >= 0 ) { |
stat(name,&sbuf); |
ret = stat(name,&sbuf); |
if ( (sbuf.st_mode & S_IFMT) != S_IFDIR ) |
if ( ret == 0 && (sbuf.st_mode & S_IFMT) != S_IFDIR ) |
*pathp = name; |
*pathp = name; |
else |
else |
*pathp = 0; |
*pathp = 0; |
Line 248 void searchasirpath(char *name,char **pathp) |
|
Line 261 void searchasirpath(char *name,char **pathp) |
|
l = strlen(*p)+strlen(name)+2; |
l = strlen(*p)+strlen(name)+2; |
q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name); |
q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name); |
if ( access(q,R_OK) >= 0 ) { |
if ( access(q,R_OK) >= 0 ) { |
stat(q,&sbuf); |
ret = stat(q,&sbuf); |
if ( (sbuf.st_mode & S_IFMT) != S_IFDIR ) { |
if ( ret == 0 && (sbuf.st_mode & S_IFMT) != S_IFDIR ) { |
*pathp = (char *)MALLOC(l); strcpy(*pathp,q); |
*pathp = (char *)MALLOC(l); strcpy(*pathp,q); |
return; |
return; |
} |
} |
Line 257 void searchasirpath(char *name,char **pathp) |
|
Line 270 void searchasirpath(char *name,char **pathp) |
|
} |
} |
*pathp = 0; |
*pathp = 0; |
} |
} |
#else |
|
if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':') |
|
|| !ASIRLOADPATH[0] ) |
|
*pathp = name; |
|
else { |
|
for ( p = ASIRLOADPATH; *p; p++ ) { |
|
l = strlen(*p)+strlen(name)+2; |
|
q = (char *)ALLOCA(l); sprintf(q,"%s/%s",*p,name); |
|
if ( access(q,04) >= 0 ) { |
|
*pathp = (char *)MALLOC(l); strcpy(*pathp,q); |
|
return; |
|
} |
|
} |
|
*pathp = 0; |
|
} |
|
#endif |
|
} |
} |
|
|
#define DELIM '/' |
#define DELIM '/' |
Line 385 void loadasirfile(char *name0) |
|
Line 382 void loadasirfile(char *name0) |
|
void execasirfile(char *name) |
void execasirfile(char *name) |
{ |
{ |
loadasirfile(name); |
loadasirfile(name); |
read_exec_file = 1; |
if ( !SETJMP(asir_infile->jmpbuf) ) { |
read_eval_loop(); |
asir_infile->ready_for_longjmp = 1; |
read_exec_file = 0; |
|
} |
|
|
|
void load_and_execfile(char *name) |
|
{ |
|
FILE *fp; |
|
INFILE save_asir_infile; |
|
int save_prresult; |
|
extern prresult; |
|
|
|
savepvs(); |
|
save_asir_infile = asir_infile; |
|
save_prresult = prresult; |
|
asir_infile = 0; |
|
loadasirfile(name); |
|
if ( !SETJMP(exec_env) ) { |
|
/* XXX : information for asir_teriminate() */ |
|
read_exec_file = 2; |
|
read_eval_loop(); |
read_eval_loop(); |
read_exec_file = 0; |
|
} |
} |
restorepvs(); |
closecurrentinput(); |
asir_infile = save_asir_infile; |
|
prresult = save_prresult; |
|
} |
} |
|
|
static NODE objfile = 0; |
static NODE objfile = 0; |