=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/glob.c,v retrieving revision 1.81 retrieving revision 1.91 diff -u -p -r1.81 -r1.91 --- OpenXM_contrib2/asir2000/parse/glob.c 2012/05/09 06:17:13 1.81 +++ OpenXM_contrib2/asir2000/parse/glob.c 2015/08/19 05:29:23 1.91 @@ -45,20 +45,17 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.80 2011/06/16 08:17:15 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.90 2015/08/14 13:51:56 fujimoto Exp $ */ #include "ca.h" #include "al.h" #include "parse.h" #include "ox.h" -#if defined(PARI) -#include "genpari.h" -#endif -#if !defined(VISUAL) && !defined(_PA_RISC1_1) && !defined(linux) && !defined(SYSV) && !defined(__CYGWIN__) && !defined(__INTERIX) && !defined(__FreeBSD__) +#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(_PA_RISC1_1) && !defined(linux) && !defined(SYSV) && !defined(__CYGWIN__) && !defined(__INTERIX) && !defined(__FreeBSD__) #include #endif -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #include #include #else @@ -71,7 +68,7 @@ #include #endif -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) #define HISTORY asir_history #endif @@ -84,6 +81,7 @@ JMP_BUF main_env,debug_env,timer_env,exec_env; int little_endian,debug_mode,no_debug_on_error; char *asir_libdir; char *asir_contrib_dir; +char *asir_private_dir; char *asir_pager; NODE usrf,sysf,noargsysf,ubinf,parif; @@ -145,7 +143,7 @@ struct oF oF_TRUE,oF_FALSE; F F_TRUE = &oF_TRUE; F F_FALSE = &oF_FALSE; -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) char cppname[BUFSIZ] = "c:\\asir\\stdlib\\cpp "; #else char cppname[BUFSIZ] = "/lib/cpp "; @@ -227,12 +225,20 @@ void asir_terminate(int status) LONGJMP(asir_infile->jmpbuf,status); else { if ( user_quit_handler ) { - if ( !do_terse ) + if ( !do_terse ) { fprintf(stderr,"Calling the registered quit callbacks..."); +#if defined(__MINGW32__) + fflush(stderr); +#endif + } for ( n = user_quit_handler; n; n = NEXT(n) ) bevalf((FUNC)BDY(n),0); - if ( !do_terse ) + if ( !do_terse ) { fprintf(stderr, "done.\n"); +#if defined(__MINGW32__) + fflush(stderr); +#endif + } } tty_reset(); #if defined(MPI) @@ -284,7 +290,7 @@ void sprompt(char *ptr) sprintf(ptr,"[%d] ",APVS->n); } -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) static int which(char *prog, char *path, char *buf, size_t size) { char *tok; @@ -317,7 +323,7 @@ static int which(char *prog, char *path, char *buf, si void cppname_init() { -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) char *oxhome; char oxcpp[BUFSIZ]; #define OXCPP "/bin/ox_cpp" @@ -372,6 +378,9 @@ void process_args(int ac,char **av) in_fp = fopen(*(av+1),"r"); if ( !in_fp ) { fprintf(stderr,"%s does not exist!\n",*(av+1)); +#if defined(__MINGW32__) + fflush(stderr); +#endif asir_terminate(1); } do_file = 1; @@ -391,7 +400,7 @@ void process_args(int ac,char **av) void GC_set_max_heap_size(int); GC_set_max_heap_size(atoi(*(av+1))); av += 2; ac -= 2; -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) } else if ( !strcmp(*av,"-display") && (ac >= 2) ) { strcpy(displayname,*(av+1)); av += 2; ac -= 2; #endif @@ -399,14 +408,11 @@ void process_args(int ac,char **av) } else if ( !strcmp(*av,"-fep") ) { do_fep = 1; av++; ac--; #endif -#if defined(PARI) - } else if ( !strcmp(*av,"-paristack") ) { - extern int paristack; - - paristack = atoi(*(av+1)); av += 2; ac -= 2; -#endif } else { fprintf(stderr,"%s : unknown option.\n",*av); +#if defined(__MINGW32__) + fflush(stderr); +#endif asir_terminate(1); } } @@ -426,7 +432,7 @@ void process_args(int ac,char **av) #include void sig_init() { -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) signal(SIGINT,int_handler); #else void register_ctrlc_handler(); @@ -447,7 +453,7 @@ void sig_init() { signal(SIGILL,ill_handler); #endif -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) signal(SIGBUS,bus_handler); #endif } @@ -477,21 +483,21 @@ void resetenv(char *s) while ( NEXT(asir_infile) ) closecurrentinput(); resetpvs(); -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) if ( do_server_in_X11 ) #endif show_debug_window(0); #if defined(VISUAL_LIB) w_noflush_stderr(0); #endif - asir_out = stdout; -#if defined(PARI) - pari_outfile = stdout; +#if defined(__MINGW32__) + fflush(stderr); #endif + asir_out = stdout; /* restore states */ reset_engine(); reset_io(); -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) reset_timer(); #endif LONGJMP(main_env,1); @@ -503,6 +509,8 @@ void fatal(int n) } extern int ox_int_received, critical_when_signal; +extern int in_gc, caught_intr; +extern int ox_get_pari_result; void int_handler(int sig) { @@ -513,15 +521,19 @@ void int_handler(int sig) if ( do_file ) { ExitAsir(); } - if ( critical_when_signal ) { + if ( !ox_get_pari_result && critical_when_signal ) { ox_int_received = 1; return; } -#if defined(VISUAL) + if ( in_gc ) { + caught_intr = 1; + return; + } +#if defined(VISUAL) || defined(__MINGW32__) suspend_timer(); #endif signal(SIGINT,SIG_IGN); -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) if ( do_server_in_X11 ) { debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0); restore_handler(); @@ -555,6 +567,9 @@ void int_handler(int sig) fgets(buf,BUFSIZ,stdin); if ( !strncmp(buf,"y",1) ) { fprintf(stderr,"Bye\n"); +#if defined(__MINGW32__) + fflush(stderr); +#endif /* for terminating myself */ asir_infile = 0; asir_terminate(1); @@ -581,13 +596,21 @@ void int_handler(int sig) restore_handler(); if ( c == 'u' ) { if ( user_int_handler ) { - if ( !do_terse ) + if ( !do_terse ) { fprintf(stderr, "Calling the registered exception callbacks..."); +#if defined(__MINGW32__) + fflush(stderr); +#endif + } for ( t = user_int_handler; t; t = NEXT(t) ) bevalf((FUNC)BDY(t),0); - if ( !do_terse ) + if ( !do_terse ) { fprintf(stderr, "done.\n"); +#if defined(__MINGW32__) + fflush(stderr); +#endif + } } } resetenv("return to toplevel"); @@ -607,6 +630,9 @@ void int_handler(int sig) break; case '?': fprintf(stderr, "q:quit t:toplevel c:continue d:debug u:call registered handler w:where\n"); +#if defined(__MINGW32__) + fflush(stderr); +#endif break; default: break; @@ -615,7 +641,7 @@ void int_handler(int sig) } void restore_handler() { -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) resume_timer(); #endif #if defined(SIGINT) @@ -650,6 +676,9 @@ void ill_handler(int sig) void alrm_handler(int sig) { fprintf(stderr,"interval timer expired (VTALRM)\n"); +#if defined(__MINGW32__) + fflush(stderr); +#endif LONGJMP(timer_env,1); } @@ -703,11 +732,14 @@ void error(char *s) { SNODE *snp=0; -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) if ( !error_in_timer && timer_is_set ) alrm_handler(SIGNAL_FOR_TIMER); #endif fprintf(stderr,"%s\n",s); +#if defined(__MINGW32__) + fflush(stderr); +#endif set_lasterror(s); if ( CPVS != GPVS ) { if ( CPVS && CPVS->usrf && CPVS->usrf->f.usrf ) @@ -736,15 +768,18 @@ void error(char *s) resetenv("return to toplevel"); } -void toplevel(char *s) +void goto_toplevel(char *s) { SNODE *snp=0; -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) if ( timer_is_set ) alrm_handler(SIGNAL_FOR_TIMER); #endif fprintf(stderr,"%s\n",s); +#if defined(__MINGW32__) + fflush(stderr); +#endif if ( do_file ) { char errbuf[BUFSIZ*5]; /* sufficient to store stack information ? */ @@ -755,7 +790,7 @@ void toplevel(char *s) resetenv("return to toplevel"); } -#if !defined(VISUAL) +#if !defined(VISUAL) && !defined(__MINGW32__) #include void set_timer(int interval) @@ -790,22 +825,11 @@ char *get_asir_distribution(); char *get_gcversion() { -#if defined(GC7) - return "GC 7.2 alpha6 copyright 1988-2011, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n"; -#else - return "GC 6.8 copyright 1988-2006, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n"; -#endif + return "GC 7.2 copyright 1988-2012, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n"; } char *get_pariversion() { -#if PARI -#if 0 - return PARIVERSION", Copyright (C) 2000-2005 The PARI Group.\n"; -#else - return "PARI 2.0.17, copyright 1989-1999, C. Batut, K. Belabas, D. Bernardi,\n H. Cohen and M. Olivier.\n"; -#endif -#endif return ""; } @@ -842,3 +866,19 @@ char *scopyright() } return notice; } + +#if defined(VISUAL) || defined(__MINGW32__) +void check_intr() +{ + extern int recv_intr; + if ( recv_intr ) { + if ( recv_intr == 1 ) { + recv_intr = 0; + int_handler(0); + } else { + recv_intr = 0; + ox_usr1_handler(0); + } + } +} +#endif