| version 1.6, 2003/02/14 22:29:17 |
version 1.12, 2018/03/29 01:32:54 |
|
|
| * 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/asir_lib.c,v 1.5 2001/10/09 01:36:23 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/asir_lib.c,v 1.11 2015/08/14 13:51:56 fujimoto Exp $ |
| */ |
*/ |
| #include "ca.h" |
#include "ca.h" |
| #include "parse.h" |
#include "parse.h" |
|
|
| #endif |
#endif |
| |
|
| #if defined(PARI) |
#if defined(PARI) |
| #include "genpari.h" |
# include "genpari.h" |
| |
# if !(PARI_VERSION_CODE > 131588 ) |
| extern jmp_buf environnement; |
extern jmp_buf environnement; |
| |
# endif |
| #endif |
#endif |
| |
|
| extern jmp_buf env; |
extern jmp_buf env; |
| Line 68 int Call_Asir(char *,pointer *); |
|
| Line 69 int Call_Asir(char *,pointer *); |
|
| |
|
| void Init_Asir(int argc,char **argv) |
void Init_Asir(int argc,char **argv) |
| { |
{ |
| FILE *ifp; |
FILE *ifp; |
| char ifname[BUFSIZ]; |
char ifname[BUFSIZ]; |
| extern int GC_dont_gc; |
extern int GC_dont_gc; |
| extern int read_exec_file; |
extern int do_asirrc; |
| extern int do_asirrc; |
char *getenv(); |
| char *getenv(); |
static asirlib_initialized=0; |
| static asirlib_initialized=0; |
|
| |
|
| if ( asirlib_initialized ) |
if ( asirlib_initialized ) |
| return; |
return; |
| asirlib_initialized = 1; |
GC_init(); |
| do_file = 1; |
asirlib_initialized = 1; |
| |
do_file = 1; |
| #if defined(PARI) |
#if defined(PARI) |
| risa_pari_init(); |
risa_pari_init(); |
| #endif |
#endif |
| srandom((int)get_current_time()); |
srandom((int)get_current_time()); |
| /* mt_sgenrand((unsigned long)get_current_time()); */ |
/* mt_sgenrand((unsigned long)get_current_time()); */ |
| |
|
| #if defined(THINK_C) |
#if defined(THINK_C) |
| param_init(); |
param_init(); |
| #endif |
#endif |
| rtime_init(); |
rtime_init(); |
| env_init(); |
env_init(); |
| endian_init(); |
endian_init(); |
| #if !defined(VISUAL) && !defined(THINK_C) |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(THINK_C) |
| /* check_key(); */ |
/* check_key(); */ |
| #endif |
#endif |
| GC_init(); |
process_args(--argc,++argv); |
| process_args(--argc,++argv); |
copyright(); |
| copyright(); |
output_init(); |
| output_init(); |
arf_init(); |
| arf_init(); |
nglob_init(); |
| nglob_init(); |
glob_init(); |
| glob_init(); |
sig_init(); |
| sig_init(); |
tty_init(); |
| tty_init(); |
debug_init(); |
| debug_init(); |
pf_init(); |
| pf_init(); |
sysf_init(); |
| sysf_init(); |
parif_init(); |
| parif_init(); |
|
| #if defined(UINIT) |
#if defined(UINIT) |
| reg_sysf(); |
reg_sysf(); |
| #endif |
#endif |
| #if defined(THINK_C) |
#if defined(THINK_C) |
| sprintf(ifname,"asirrc"); |
sprintf(ifname,"asirrc"); |
| #else |
#else |
| sprintf(ifname,"%s/.asirrc",getenv("HOME")); |
sprintf(ifname,"%s/.asirrc",getenv("HOME")); |
| #endif |
#endif |
| if ( do_asirrc && (ifp = fopen(ifname,"r")) ) { |
if ( do_asirrc && (ifp = fopen(ifname,"r")) ) { |
| input_init(ifp,ifname); |
input_init(ifp,ifname); |
| if ( !setjmp(env) ) { |
if ( !setjmp(asir_infile->jmpbuf) ) |
| read_exec_file = 1; |
read_eval_loop(); |
| read_eval_loop(); |
fclose(ifp); |
| read_exec_file = 0; |
} else |
| } |
error(".asirrc not found"); |
| fclose(ifp); |
input_init(0,"string"); |
| } else |
|
| error(".asirrc not found"); |
|
| input_init(0,"string"); |
|
| } |
} |
| |
|
| int Call_Asir(char *cmd,pointer *result) |
int Call_Asir(char *cmd,pointer *result) |
| { |
{ |
| SNODE snode; |
SNODE snode; |
| pointer val; |
pointer val; |
| #if defined(PARI) |
#if defined(PARI) |
| void recover(int); |
void recover(int); |
| |
|
| recover(0); |
recover(0); |
| if ( setjmp(environnement) ) { |
# if !(PARI_VERSION_CODE > 131588) |
| avma = top; recover(1); |
if ( setjmp(environnement) ) { |
| error("PARI error"); |
avma = top; recover(1); |
| } |
error("PARI error"); |
| |
} |
| |
# endif |
| #endif |
#endif |
| if ( setjmp(env) ) { |
if ( setjmp(env) ) { |
| *result = 0; |
*result = 0; |
| return -1; |
return -1; |
| } |
} |
| parse_strp = cmd; |
parse_strp = cmd; |
| if ( mainparse(&snode) ) { |
if ( mainparse(&snode) ) { |
| *result = 0; |
*result = 0; |
| return -1; |
return -1; |
| } |
} |
| val = evalstat(snode); |
val = evalstat(snode); |
| if ( NEXT(asir_infile) ) { |
if ( NEXT(asir_infile) ) { |
| while ( NEXT(asir_infile) ) { |
while ( NEXT(asir_infile) ) { |
| if ( mainparse(&snode) ) { |
if ( mainparse(&snode) ) { |
| *result = val; |
*result = val; |
| return -1; |
return -1; |
| } |
} |
| nextbp = 0; |
nextbp = 0; |
| val = evalstat(snode); |
val = evalstat(snode); |
| } |
} |
| } |
} |
| *result = val; |
*result = val; |
| return 0; |
return 0; |
| } |
} |