Annotation of OpenXM_contrib2/asir2000/parse/glob.c, Revision 1.34
1.8 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.9 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.8 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.34 ! ohara 48: * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.33 2003/03/07 06:39:59 noro Exp $
1.8 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "al.h"
52: #include "parse.h"
1.24 noro 53: #include "ox.h"
1.31 ohara 54: #if defined(PARI)
1.1 noro 55: #include "genpari.h"
56: #endif
1.25 noro 57: #if !defined(VISUAL) && !defined(_PA_RISC1_1) && !defined(linux) && !defined(SYSV) && !defined(__CYGWIN__)
1.1 noro 58: #include <sgtty.h>
59: #endif
60:
61: #if defined(VISUAL)
62: #include <io.h>
63: #include <direct.h>
1.34 ! ohara 64: #else
! 65: #include <unistd.h>
! 66: #include <string.h>
! 67: #include <stdio.h>
1.1 noro 68: #endif
69:
1.19 noro 70: #if defined(SYSV) && !defined(_IBMR2)
1.1 noro 71: #include <sys/ttold.h>
72: #endif
73:
74: #if defined(VISUAL)
75: #define HISTORY asir_history
76: #endif
1.12 noro 77:
1.1 noro 78: #define MAXHIST 100
79:
80: extern int GC_free_space_divisor;
81: extern int GC_free_space_numerator;
82: extern FILE *asir_out;
83:
1.24 noro 84: INFILE asir_infile;
1.26 noro 85: JMP_BUF main_env,debug_env,timer_env,exec_env;
1.1 noro 86: int little_endian,debug_mode;
87: char *asir_libdir;
88: char *asir_pager;
89:
90: NODE usrf,sysf,noargsysf,ubinf,parif;
91: NODE ONENODE;
1.29 noro 92: int main_parser, allow_create_var, ox_do_copy, ox_do_count, ox_count_length;
1.1 noro 93: int ox_file_io, ox_need_conv;
94: char *ox_copy_bptr;
95: char *parse_strp;
96: SNODE parse_snode;
97: FUNC parse_targetf;
98: FILE *ox_istream,*ox_ostream;
99: int do_server_in_X11;
100: Obj LastVal;
101: char LastError[BUFSIZ];
1.15 noro 102: int timer_is_set;
103:
1.1 noro 104:
105: struct oV oVAR[] = {
106: {"x",0,0}, {"y",0,0}, {"z",0,0}, {"u",0,0},
107: {"v",0,0}, {"w",0,0}, {"p",0,0}, {"q",0,0},
108: {"r",0,0}, {"s",0,0}, {"t",0,0}, {"a",0,0},
109: {"b",0,0}, {"c",0,0}, {"d",0,0}, {"e",0,0},
110: {"f",0,0}, {"g",0,0}, {"h",0,0}, {"i",0,0},
111: {"j",0,0}, {"k",0,0}, {"l",0,0}, {"m",0,0},
112: {"n",0,0}, {"o",0,0},
113: {"_x",0,0}, {"_y",0,0}, {"_z",0,0}, {"_u",0,0},
114: {"_v",0,0}, {"_w",0,0}, {"_p",0,0}, {"_q",0,0},
115: {"_r",0,0}, {"_s",0,0}, {"_t",0,0}, {"_a",0,0},
116: {"_b",0,0}, {"_c",0,0}, {"_d",0,0}, {"_e",0,0},
117: {"_f",0,0}, {"_g",0,0}, {"_h",0,0}, {"_i",0,0},
118: {"_j",0,0}, {"_k",0,0}, {"_l",0,0}, {"_m",0,0},
119: {"_n",0,0}, {"_o",0,0}
120: };
121:
122: struct oVL oVLIST[52];
123:
124: VL CO = oVLIST;
125: VL ALG;
126:
127: struct oVS oGPVS,oAPVS,oEPVS;
128: VS GPVS = &oGPVS;
129: VS APVS = &oAPVS;
130: VS EPVS = &oEPVS;
131: VS CPVS;
132:
133: struct oF oF_TRUE,oF_FALSE;
134: F F_TRUE = &oF_TRUE;
135: F F_FALSE = &oF_FALSE;
136:
137: #if defined(VISUAL)
1.4 noro 138: char cppname[BUFSIZ] = "c:\\asir\\stdlib\\cpp ";
1.1 noro 139: #else
1.4 noro 140: char cppname[BUFSIZ] = "/lib/cpp ";
1.1 noro 141: #endif
1.4 noro 142: char asirname[BUFSIZ];
1.1 noro 143: char displayname[BUFSIZ];
144:
145: int Verbose;
146:
147: void glob_init() {
148: int i;
149:
150: for ( i = 0; i < 51; i++ ) {
151: VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = &oVLIST[i+1];
152: }
153: VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = 0;
154: reallocarray((char **)&GPVS->va,(int *)&GPVS->asize,(int *)&GPVS->n,(int)sizeof(struct oPV));
155: reallocarray((char **)&APVS->va,(int *)&APVS->asize,(int *)&APVS->n,(int)sizeof(struct oPV));
156: CPVS = GPVS;
157: MKNODE(ONENODE,mkfnode(1,I_FORMULA,ONE),0);
158: OID(F_TRUE)=O_F; FOP(F_TRUE)=AL_TRUE; F_TRUE->arg.dummy = 0;
159: OID(F_FALSE)=O_F; FOP(F_FALSE)=AL_FALSE; F_FALSE->arg.dummy = 0;
160: sprintf(asirname,"%s/asir_symtab",asir_libdir);
161: }
162:
1.24 noro 163: void input_init(FILE *fp,char *name)
1.1 noro 164: {
1.24 noro 165: asir_infile = (INFILE)CALLOC(sizeof(struct oINFILE),1);
1.1 noro 166: asir_infile->name = name; asir_infile->fp = fp;
167: asir_infile->ln = 1; NEXT(asir_infile) = 0;
168: }
169:
1.24 noro 170: void notdef(VL vl,Obj a,Obj b,Obj *c)
1.1 noro 171: {
172: error("undefined arithmetic operation.");
173: }
174:
175: int do_asirrc;
176: int do_file;
177: int do_message;
178: int do_fep;
179: int no_prompt;
180: int read_exec_file;
181: static int buserr_sav;
182: static char asir_history[BUFSIZ];
183:
184: extern int mpi_myid;
185:
1.5 noro 186: #if !defined(VISUAL_LIB)
187: void ExitAsir() {
188: exit(0);
189: }
190: #endif
191:
1.1 noro 192: /*
193: * status = 1 abnormal termination (error() etc.)
194: * status = 2 normal termination (end(), quit() etc.)
195: */
196:
1.24 noro 197: void asir_terminate(int status)
1.1 noro 198: {
1.21 noro 199: int t;
200:
1.1 noro 201: if ( read_exec_file ) {
1.21 noro 202: t = read_exec_file;
203: read_exec_file = 0;
204: if ( t == 1 )
1.26 noro 205: LONGJMP(main_env,status);
1.21 noro 206: else
1.26 noro 207: LONGJMP(exec_env,status);
1.1 noro 208: } else {
209: tty_reset();
1.33 noro 210: #if defined(MPI)
1.1 noro 211: if ( !mpi_myid )
212: close_allconnections();
213: mpi_finalize();
214: #else
1.20 noro 215: #if defined(SIGPIPE)
216: signal(SIGPIPE,SIG_IGN);
217: #endif
1.1 noro 218: close_allconnections();
219: #endif
220: if ( asir_out )
221: fflush(asir_out);
1.32 noro 222: #if FEP
1.13 saito 223: if ( do_fep ) {
224: stifle_history(MAXHIST);
225: write_history(asir_history);
226: }
227: #endif
1.1 noro 228: ExitAsir();
229: }
230: }
231:
232: void param_init() {
233: unsigned int et = 0xff;
234: extern int paristack;
235: if ( *((char *)&et) )
236: little_endian = 1;
237: else
238: little_endian = 0;
239: }
240:
241: void prompt() {
242: if ( !no_prompt && !do_fep && asir_infile->fp == stdin )
1.21 noro 243: fprintf(asir_out,"[%d] ",APVS->n);
1.1 noro 244: fflush(asir_out);
245: }
246:
1.24 noro 247: void sprompt(char *ptr)
1.1 noro 248: {
1.21 noro 249: sprintf(ptr,"[%d] ",APVS->n);
1.34 ! ohara 250: }
! 251:
! 252: #if !defined(VISUAL)
! 253: static int which(char *prog, char *path, char *buf, size_t size)
! 254: {
! 255: char *tok;
! 256: char delim[] = ":";
! 257: char *path2 = malloc(strlen(path)+1);
! 258: char *name = malloc(size);
! 259: int proglen = strlen(prog)+3; /* "/" + prog + " \0" */
! 260:
! 261: if (!name || !path2) {
! 262: return 0;
! 263: }
! 264: strcpy(path2, path);
! 265: tok = strtok(path2, delim);
! 266: while (tok != NULL) {
! 267: if (size >= strlen(tok)) {
! 268: sprintf(name, "%s/%s", tok, prog);
! 269: if (access(name, X_OK&R_OK) == 0) {
! 270: strcpy(buf, name);
! 271: strcat(buf, " ");
! 272: free(path2); free(name);
! 273: return 1;
! 274: }
! 275: tok = strtok(NULL, delim);
! 276: }
! 277: }
! 278: free(path2); free(name);
! 279: return 0;
! 280: }
! 281: #endif
! 282:
! 283: void cppname_init()
! 284: {
! 285: #if !defined(VISUAL)
! 286: if (access(cppname, X_OK&R_OK) != 0) {
! 287: which("cpp", "/lib:/usr/ccs/lib:/usr/bin", cppname, BUFSIZ) ||
! 288: which("cpp", getenv("PATH"), cppname, BUFSIZ);
! 289: }
! 290: #endif
1.1 noro 291: }
292:
293: FILE *in_fp;
294:
1.24 noro 295: void process_args(int ac,char **av)
1.1 noro 296: {
297: do_asirrc = 1;
1.33 noro 298: #if !defined(MPI)
1.1 noro 299: do_message = 1;
300: #endif
301: while ( ac > 0 ) {
302: if ( !strcmp(*av,"-heap") && (ac >= 2) ) {
303: void GC_expand_hp(int);
304:
305: GC_expand_hp(atoi(*(av+1))); av += 2; ac -= 2;
306: } else if ( !strcmp(*av,"-adj") && (ac >= 2) ) {
307: char *slash;
308:
309: slash = strrchr(*(av+1),'/');
310: if ( slash ) {
311: *slash = 0;
312: GC_free_space_numerator = atoi(slash+1);
313: }
314: GC_free_space_divisor = atoi(*(av+1));
315: av += 2; ac -= 2;
316: } else if ( !strcmp(*av,"-cpp") && (ac >= 2) ) {
317: strcpy(cppname,*(av+1)); av += 2; ac -= 2;
318: } else if ( !strcmp(*av,"-f") && (ac >= 2) ) {
319: in_fp = fopen(*(av+1),"r");
320: if ( !in_fp ) {
321: fprintf(stderr,"%s does not exist!",*(av+1));
322: asir_terminate(1);
323: }
324: do_file = 1;
325: av += 2; ac -= 2;
326: } else if ( !strcmp(*av,"-norc") ) {
327: do_asirrc = 0; av++; ac--;
328: } else if ( !strcmp(*av,"-nomessage") ) {
329: do_message = 0; av++; ac--;
330: } else if ( !strcmp(*av,"-terse") ) {
331: no_prompt = 0; av++; ac--;
1.11 noro 332: } else if ( !strcmp(*av,"-rootdir") && (ac >= 2) ) {
333: set_rootdir(*(av+1)); av += 2; ac -= 2;
1.1 noro 334: } else if ( !strcmp(*av,"-maxheap") && (ac >= 2) ) {
335: void GC_set_max_heap_size(int);
336:
337: GC_set_max_heap_size(atoi(*(av+1))); av += 2; ac -= 2;
338: #if !defined(VISUAL)
339: } else if ( !strcmp(*av,"-display") && (ac >= 2) ) {
340: strcpy(displayname,*(av+1)); av += 2; ac -= 2;
341: #endif
1.32 noro 342: #if FEP
1.13 saito 343: } else if ( !strcmp(*av,"-fep") ) {
344: do_fep = 1; av++; ac--;
345: #endif
1.31 ohara 346: #if defined(PARI)
1.1 noro 347: } else if ( !strcmp(*av,"-paristack") ) {
348: extern int paristack;
349:
350: paristack = atoi(*(av+1)); av += 2; ac -= 2;
351: #endif
352: } else {
353: fprintf(stderr,"%s : unknown option.\n",*av);
354: asir_terminate(1);
355: }
356: }
1.32 noro 357: #if FEP
1.13 saito 358: if ( do_fep ) {
359: char *home;
360: home = (char *)getenv("HOME");
361: if (!home)
362: home = ".";
363: sprintf (asir_history, "%s/.asir_history",home);
364: read_history(asir_history);
365: using_history();
366: }
367: #endif
1.1 noro 368: }
369:
370: #include <signal.h>
371:
372: void sig_init() {
373: #if !defined(VISUAL)
374: signal(SIGINT,int_handler);
375: #else
1.24 noro 376: void register_ctrlc_handler();
377:
1.1 noro 378: register_ctrlc_handler();
379: #endif
380: signal(SIGSEGV,segv_handler);
381:
1.23 noro 382: #if defined(SIGFPE)
1.1 noro 383: signal(SIGFPE,fpe_handler);
384: #endif
385:
1.23 noro 386: #if defined(SIGPIPE)
1.1 noro 387: signal(SIGPIPE,pipe_handler);
388: #endif
389:
1.23 noro 390: #if defined(SIGILL)
1.1 noro 391: signal(SIGILL,ill_handler);
392: #endif
393:
394: #if !defined(VISUAL)
395: signal(SIGBUS,bus_handler);
396: #endif
397: }
398:
399: static void (*old_int)(int);
400:
401: void asir_save_handler() {
402: old_int = signal(SIGINT,SIG_IGN);
403: signal(SIGINT,old_int);
404: }
405:
406: void asir_set_handler() {
407: signal(SIGINT,int_handler);
408: }
409:
410: void asir_reset_handler() {
411: signal(SIGINT,old_int);
412: }
413:
1.24 noro 414: void resetenv(char *s)
1.1 noro 415: {
416: extern FILE *outfile;
417:
418: fprintf(stderr,"%s\n",s);
419: while ( NEXT(asir_infile) )
420: closecurrentinput();
421: resetpvs();
422: #if !defined(VISUAL)
423: if ( do_server_in_X11 )
424: #endif
425: show_debug_window(0);
426: #if defined(VISUAL_LIB)
427: w_noflush_stderr(0);
428: #endif
429: asir_out = stdout;
1.31 ohara 430: #if defined(PARI)
1.1 noro 431: pari_outfile = stdout;
432: #endif
433: /* restore states */
434: reset_engine();
435: reset_io();
1.16 noro 436: #if !defined(VISUAL)
1.15 noro 437: reset_timer();
1.16 noro 438: #endif
1.26 noro 439: LONGJMP(main_env,1);
1.1 noro 440: }
441:
1.24 noro 442: void fatal(int n)
1.1 noro 443: {
444: resetenv("return to toplevel");
445: }
446:
447: FUNC registered_handler;
448: extern int ox_int_received, critical_when_signal;
449:
1.24 noro 450: void int_handler(int sig)
1.1 noro 451: {
452: extern NODE PVSS;
453:
454: if ( do_file ) {
455: ExitAsir();
456: }
457: if ( critical_when_signal ) {
458: ox_int_received = 1;
459: return;
460: }
1.12 noro 461: #if defined(VISUAL)
1.19 noro 462: suspend_timer();
1.1 noro 463: #endif
464: signal(SIGINT,SIG_IGN);
1.3 noro 465: #if !defined(VISUAL)
466: if ( do_server_in_X11 ) {
467: debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
468: restore_handler();
469: return;
470: }
1.1 noro 471: #endif
472: #if defined(linux)
473: #if 1
474: while ( stdin->_IO_read_ptr < stdin->_IO_read_end )
475: #else
476: while ( stdin->_gptr < stdin->_egptr )
477: #endif
478: getchar();
479: #endif
480: while ( 1 ) {
481: char buf[BUFSIZ];
482: char c;
483:
484: fprintf(stderr,"interrupt ?(q/t/c/d/u/w/?) "); fflush(stderr);
485: buf[0] = '\n';
486: while ( buf[0] == '\n' )
487: fgets(buf,BUFSIZ,stdin);
488: switch ( c = buf[0] ) {
489: case 'q':
490: while ( 1 ) {
491: fprintf(stderr,"Abort this session? (y or n) "); fflush(stderr);
492: fgets(buf,BUFSIZ,stdin);
493: if ( !strncmp(buf,"y",1) ) {
494: read_exec_file = 0;
495: fprintf(stderr,"Bye\n"); asir_terminate(1);
496: } else if ( !strncmp(buf,"n",1) ) {
497: restore_handler();
498: return;
499: }
500: }
501: break;
502: case 't':
503: case 'u':
504: while ( 1 ) {
505: fprintf(stderr,"Abort this computation? (y or n) "); fflush(stderr);
506: fgets(buf,BUFSIZ,stdin);
507: if ( !strncmp(buf,"y",1) )
508: break;
509: else if ( !strncmp(buf,"n",1) ) {
510: restore_handler();
511: return;
512: }
513: }
514: if ( debug_mode )
515: debug_mode = 0;
516: restore_handler();
517: if ( c == 'u' ) {
518: if ( registered_handler ) {
519: fprintf(stderr,
520: "Calling the registered exception handler...");
521: bevalf(registered_handler,0);
522: fprintf(stderr, "done.\n");
523: }
524: }
525: if ( read_exec_file ) {
526: read_exec_file = 0;
527: resetenv("initialization aborted; return to toplevel");
528: } else
529: resetenv("return to toplevel");
530: break;
531: case 'd':
532: #if 0
533: nextbp = 1; nextbplevel = -1;
534: #endif
535: debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
536: restore_handler();
537: return;
538: case 'c':
539: restore_handler();
540: return; break;
541: case 'w':
542: showpos(); break;
543: case '?':
544: fprintf(stderr, "q:quit t:toplevel c:continue d:debug u:call registered handler w:where\n");
545: break;
546: default:
547: break;
548: }
549: }
550: }
551:
552: void restore_handler() {
1.12 noro 553: #if defined(VISUAL)
1.19 noro 554: resume_timer();
1.1 noro 555: #endif
1.19 noro 556: #if defined(SIGINT)
1.1 noro 557: signal(SIGINT,int_handler);
558: #endif
559: }
560:
1.24 noro 561: void segv_handler(int sig)
1.1 noro 562: {
1.19 noro 563: #if defined(SIGSEGV)
1.1 noro 564: signal(SIGSEGV,segv_handler);
1.19 noro 565: error("internal error (SEGV)");
1.1 noro 566: #endif
567: }
568:
1.24 noro 569: void ill_handler(int sig)
1.1 noro 570: {
1.19 noro 571: #if defined(SIGILL)
1.1 noro 572: signal(SIGILL,ill_handler);
1.19 noro 573: error("illegal instruction (ILL)");
1.1 noro 574: #endif
575: }
576:
1.24 noro 577: void alrm_handler(int sig)
1.1 noro 578: {
579: fprintf(stderr,"interval timer expired (VTALRM)\n");
1.26 noro 580: LONGJMP(timer_env,1);
1.1 noro 581: }
582:
1.24 noro 583: void bus_handler(int sig)
1.1 noro 584: {
585: #if defined(SIGBUS)
586: signal(SIGBUS,bus_handler);
587: error("internal error (BUS ERROR)");
588: #endif
589: }
590:
1.24 noro 591: void fpe_handler(int sig)
1.1 noro 592: {
1.19 noro 593: #if defined(SIGFPE)
1.1 noro 594: signal(SIGFPE,fpe_handler);
1.19 noro 595: error("internal error (FPE)");
1.1 noro 596: #endif
597: }
598:
1.24 noro 599: void pipe_handler(int sig)
1.1 noro 600: {
601: #if defined(SIGPIPE)
602: signal(SIGPIPE,pipe_handler);
1.20 noro 603: end_critical();
1.1 noro 604: error("internal error (BROKEN PIPE)");
605: #endif
606: }
607:
608: void resize_buffer()
609: {
610: }
611:
612: void tty_init() {
613: }
614:
615: void tty_reset() {
616: }
617:
618: extern int evalstatline;
619:
1.24 noro 620: void set_lasterror(char *s)
1.1 noro 621: {
622: strncpy(LastError,s,BUFSIZ);
623: LastError[BUFSIZ-1] = 0;
624: }
625:
626: SNODE error_snode;
627:
1.24 noro 628: void error(char *s)
1.1 noro 629: {
630: SNODE *snp;
631:
1.16 noro 632: #if !defined(VISUAL)
1.15 noro 633: if ( timer_is_set )
634: alrm_handler(SIGVTALRM);
1.16 noro 635: #endif
1.1 noro 636: fprintf(stderr,"%s\n",s);
637: set_lasterror(s);
638: if ( CPVS != GPVS ) {
1.7 noro 639: if ( CPVS->usrf && CPVS->usrf && CPVS->usrf->f.usrf )
640: searchsn(&BDY(CPVS->usrf->f.usrf),evalstatline,&snp);
1.6 noro 641: if ( snp )
642: error_snode = *snp;
643: else
644: error_snode = 0;
1.1 noro 645: } else
646: error_snode = 0;
647: if ( do_file ) {
648: char errbuf[BUFSIZ*5]; /* sufficient to store stack information ? */
649:
650: sprintf(errbuf,"%s\n",s);
651: showpos_to_string(errbuf+strlen(errbuf));
652: set_lasterror(errbuf);
653: ExitAsir();
654: }
655: if ( debug_mode )
1.26 noro 656: LONGJMP(debug_env,1);
1.1 noro 657: if ( CPVS != GPVS )
658: if ( do_server_in_X11 || isatty(0) )
659: bp(error_snode);
660: if ( read_exec_file )
661: read_exec_file = 0;
662: resetenv("return to toplevel");
663: }
664:
665: #if !defined(VISUAL)
666: #include <sys/time.h>
667:
1.24 noro 668: void set_timer(int interval)
1.1 noro 669: {
670: struct itimerval it;
671:
672: it.it_interval.tv_sec = interval;
673: it.it_interval.tv_usec = 0;
674: it.it_value.tv_sec = interval;
675: it.it_value.tv_usec = 0;
676: setitimer(ITIMER_VIRTUAL,&it,0);
677: signal(SIGVTALRM,alrm_handler);
1.15 noro 678: timer_is_set = 1;
1.1 noro 679: }
680:
681: void reset_timer()
682: {
683: struct itimerval it;
684:
685: it.it_interval.tv_sec = 0;
686: it.it_interval.tv_usec = 0;
687: it.it_value.tv_sec = 0;
688: it.it_value.tv_usec = 0;
689: setitimer(ITIMER_VIRTUAL,&it,0);
690: signal(SIGVTALRM,SIG_IGN);
1.15 noro 691: timer_is_set = 0;
1.1 noro 692: }
693: #endif
694:
695: unsigned int get_asir_version();
1.14 noro 696: char *get_asir_distribution();
1.1 noro 697:
698: void copyright() {
1.17 noro 699: #if defined(INTERVAL)
700: printf("This is Risa/Asir + Interval Arithmetic, Version %d (%s Distribution).\n",
701: get_asir_version(), get_asir_distribution());
702: #else
1.14 noro 703: printf("This is Risa/Asir, Version %d (%s Distribution).\n",
704: get_asir_version(), get_asir_distribution());
1.17 noro 705: #endif
1.14 noro 706: printf("Copyright (C) 1994-2000, all rights reserved, FUJITSU LABORATORIES LIMITED.\n");
1.30 noro 707: printf("Copyright 2000-2003, Risa/Asir committers, http://www.openxm.org/.\n");
1.27 noro 708: printf("GC 6.1(alpha5) copyright 2001, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n");
1.32 noro 709: #if PARI
710: #if 0
1.28 noro 711: printf("PARI 2.2.4, copyright (C) 2002 The PARI Group.\n");
1.32 noro 712: #endif
713: printf("PARI 2.0.17, copyright 1989-1999, C. Batut, K. Belabas, D. Bernardi,\n");
714: printf(" H. Cohen and M. Olivier.\n");
715: #endif
1.1 noro 716: }
1.14 noro 717:
1.5 noro 718:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>