Annotation of OpenXM_contrib2/asir2000/parse/glob.c, Revision 1.37
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.37 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.36 2003/05/16 07:56:16 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;
1.35 noro 131: VS CPVS,MPVS;
132:
133: NODE MODULE_LIST;
134: MODULE CUR_MODULE;
1.36 noro 135: char *CUR_FUNC;
1.1 noro 136:
137: struct oF oF_TRUE,oF_FALSE;
138: F F_TRUE = &oF_TRUE;
139: F F_FALSE = &oF_FALSE;
140:
141: #if defined(VISUAL)
1.4 noro 142: char cppname[BUFSIZ] = "c:\\asir\\stdlib\\cpp ";
1.1 noro 143: #else
1.4 noro 144: char cppname[BUFSIZ] = "/lib/cpp ";
1.1 noro 145: #endif
1.4 noro 146: char asirname[BUFSIZ];
1.1 noro 147: char displayname[BUFSIZ];
148:
149: int Verbose;
150:
151: void glob_init() {
152: int i;
153:
154: for ( i = 0; i < 51; i++ ) {
155: VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = &oVLIST[i+1];
156: }
157: VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = 0;
158: reallocarray((char **)&GPVS->va,(int *)&GPVS->asize,(int *)&GPVS->n,(int)sizeof(struct oPV));
159: reallocarray((char **)&APVS->va,(int *)&APVS->asize,(int *)&APVS->n,(int)sizeof(struct oPV));
160: CPVS = GPVS;
161: MKNODE(ONENODE,mkfnode(1,I_FORMULA,ONE),0);
162: OID(F_TRUE)=O_F; FOP(F_TRUE)=AL_TRUE; F_TRUE->arg.dummy = 0;
163: OID(F_FALSE)=O_F; FOP(F_FALSE)=AL_FALSE; F_FALSE->arg.dummy = 0;
164: sprintf(asirname,"%s/asir_symtab",asir_libdir);
165: }
166:
1.24 noro 167: void input_init(FILE *fp,char *name)
1.1 noro 168: {
1.24 noro 169: asir_infile = (INFILE)CALLOC(sizeof(struct oINFILE),1);
1.1 noro 170: asir_infile->name = name; asir_infile->fp = fp;
171: asir_infile->ln = 1; NEXT(asir_infile) = 0;
172: }
173:
1.24 noro 174: void notdef(VL vl,Obj a,Obj b,Obj *c)
1.1 noro 175: {
176: error("undefined arithmetic operation.");
177: }
178:
179: int do_asirrc;
180: int do_file;
181: int do_message;
182: int do_fep;
183: int no_prompt;
184: int read_exec_file;
185: static int buserr_sav;
186: static char asir_history[BUFSIZ];
187:
188: extern int mpi_myid;
189:
1.5 noro 190: #if !defined(VISUAL_LIB)
191: void ExitAsir() {
192: exit(0);
193: }
194: #endif
195:
1.1 noro 196: /*
197: * status = 1 abnormal termination (error() etc.)
198: * status = 2 normal termination (end(), quit() etc.)
199: */
200:
1.24 noro 201: void asir_terminate(int status)
1.1 noro 202: {
1.21 noro 203: int t;
204:
1.1 noro 205: if ( read_exec_file ) {
1.21 noro 206: t = read_exec_file;
207: read_exec_file = 0;
208: if ( t == 1 )
1.26 noro 209: LONGJMP(main_env,status);
1.21 noro 210: else
1.26 noro 211: LONGJMP(exec_env,status);
1.1 noro 212: } else {
213: tty_reset();
1.33 noro 214: #if defined(MPI)
1.1 noro 215: if ( !mpi_myid )
216: close_allconnections();
217: mpi_finalize();
218: #else
1.20 noro 219: #if defined(SIGPIPE)
220: signal(SIGPIPE,SIG_IGN);
221: #endif
1.1 noro 222: close_allconnections();
223: #endif
224: if ( asir_out )
225: fflush(asir_out);
1.32 noro 226: #if FEP
1.13 saito 227: if ( do_fep ) {
228: stifle_history(MAXHIST);
229: write_history(asir_history);
230: }
231: #endif
1.1 noro 232: ExitAsir();
233: }
234: }
235:
236: void param_init() {
237: unsigned int et = 0xff;
238: extern int paristack;
239: if ( *((char *)&et) )
240: little_endian = 1;
241: else
242: little_endian = 0;
243: }
244:
245: void prompt() {
246: if ( !no_prompt && !do_fep && asir_infile->fp == stdin )
1.21 noro 247: fprintf(asir_out,"[%d] ",APVS->n);
1.1 noro 248: fflush(asir_out);
249: }
250:
1.24 noro 251: void sprompt(char *ptr)
1.1 noro 252: {
1.21 noro 253: sprintf(ptr,"[%d] ",APVS->n);
1.34 ohara 254: }
255:
256: #if !defined(VISUAL)
257: static int which(char *prog, char *path, char *buf, size_t size)
258: {
259: char *tok;
260: char delim[] = ":";
261: char *path2 = malloc(strlen(path)+1);
262: char *name = malloc(size);
263: int proglen = strlen(prog)+3; /* "/" + prog + " \0" */
264:
265: if (!name || !path2) {
266: return 0;
267: }
268: strcpy(path2, path);
269: tok = strtok(path2, delim);
270: while (tok != NULL) {
271: if (size >= strlen(tok)) {
272: sprintf(name, "%s/%s", tok, prog);
273: if (access(name, X_OK&R_OK) == 0) {
274: strcpy(buf, name);
275: strcat(buf, " ");
276: free(path2); free(name);
277: return 1;
278: }
279: tok = strtok(NULL, delim);
280: }
281: }
282: free(path2); free(name);
283: return 0;
284: }
285: #endif
286:
287: void cppname_init()
288: {
289: #if !defined(VISUAL)
290: if (access(cppname, X_OK&R_OK) != 0) {
291: which("cpp", "/lib:/usr/ccs/lib:/usr/bin", cppname, BUFSIZ) ||
292: which("cpp", getenv("PATH"), cppname, BUFSIZ);
293: }
294: #endif
1.1 noro 295: }
296:
297: FILE *in_fp;
298:
1.24 noro 299: void process_args(int ac,char **av)
1.1 noro 300: {
301: do_asirrc = 1;
1.33 noro 302: #if !defined(MPI)
1.1 noro 303: do_message = 1;
304: #endif
305: while ( ac > 0 ) {
306: if ( !strcmp(*av,"-heap") && (ac >= 2) ) {
307: void GC_expand_hp(int);
308:
309: GC_expand_hp(atoi(*(av+1))); av += 2; ac -= 2;
310: } else if ( !strcmp(*av,"-adj") && (ac >= 2) ) {
311: char *slash;
312:
313: slash = strrchr(*(av+1),'/');
314: if ( slash ) {
315: *slash = 0;
316: GC_free_space_numerator = atoi(slash+1);
317: }
318: GC_free_space_divisor = atoi(*(av+1));
319: av += 2; ac -= 2;
320: } else if ( !strcmp(*av,"-cpp") && (ac >= 2) ) {
321: strcpy(cppname,*(av+1)); av += 2; ac -= 2;
322: } else if ( !strcmp(*av,"-f") && (ac >= 2) ) {
323: in_fp = fopen(*(av+1),"r");
324: if ( !in_fp ) {
325: fprintf(stderr,"%s does not exist!",*(av+1));
326: asir_terminate(1);
327: }
328: do_file = 1;
329: av += 2; ac -= 2;
330: } else if ( !strcmp(*av,"-norc") ) {
331: do_asirrc = 0; av++; ac--;
332: } else if ( !strcmp(*av,"-nomessage") ) {
333: do_message = 0; av++; ac--;
334: } else if ( !strcmp(*av,"-terse") ) {
335: no_prompt = 0; av++; ac--;
1.11 noro 336: } else if ( !strcmp(*av,"-rootdir") && (ac >= 2) ) {
337: set_rootdir(*(av+1)); av += 2; ac -= 2;
1.1 noro 338: } else if ( !strcmp(*av,"-maxheap") && (ac >= 2) ) {
339: void GC_set_max_heap_size(int);
340:
341: GC_set_max_heap_size(atoi(*(av+1))); av += 2; ac -= 2;
342: #if !defined(VISUAL)
343: } else if ( !strcmp(*av,"-display") && (ac >= 2) ) {
344: strcpy(displayname,*(av+1)); av += 2; ac -= 2;
345: #endif
1.32 noro 346: #if FEP
1.13 saito 347: } else if ( !strcmp(*av,"-fep") ) {
348: do_fep = 1; av++; ac--;
349: #endif
1.31 ohara 350: #if defined(PARI)
1.1 noro 351: } else if ( !strcmp(*av,"-paristack") ) {
352: extern int paristack;
353:
354: paristack = atoi(*(av+1)); av += 2; ac -= 2;
355: #endif
356: } else {
357: fprintf(stderr,"%s : unknown option.\n",*av);
358: asir_terminate(1);
359: }
360: }
1.32 noro 361: #if FEP
1.13 saito 362: if ( do_fep ) {
363: char *home;
364: home = (char *)getenv("HOME");
365: if (!home)
366: home = ".";
367: sprintf (asir_history, "%s/.asir_history",home);
368: read_history(asir_history);
369: using_history();
370: }
371: #endif
1.1 noro 372: }
373:
374: #include <signal.h>
375:
376: void sig_init() {
377: #if !defined(VISUAL)
378: signal(SIGINT,int_handler);
379: #else
1.24 noro 380: void register_ctrlc_handler();
381:
1.1 noro 382: register_ctrlc_handler();
383: #endif
384: signal(SIGSEGV,segv_handler);
385:
1.23 noro 386: #if defined(SIGFPE)
1.1 noro 387: signal(SIGFPE,fpe_handler);
388: #endif
389:
1.23 noro 390: #if defined(SIGPIPE)
1.1 noro 391: signal(SIGPIPE,pipe_handler);
392: #endif
393:
1.23 noro 394: #if defined(SIGILL)
1.1 noro 395: signal(SIGILL,ill_handler);
396: #endif
397:
398: #if !defined(VISUAL)
399: signal(SIGBUS,bus_handler);
400: #endif
401: }
402:
403: static void (*old_int)(int);
404:
405: void asir_save_handler() {
406: old_int = signal(SIGINT,SIG_IGN);
407: signal(SIGINT,old_int);
408: }
409:
410: void asir_set_handler() {
411: signal(SIGINT,int_handler);
412: }
413:
414: void asir_reset_handler() {
415: signal(SIGINT,old_int);
416: }
417:
1.24 noro 418: void resetenv(char *s)
1.1 noro 419: {
420: extern FILE *outfile;
421:
422: fprintf(stderr,"%s\n",s);
423: while ( NEXT(asir_infile) )
424: closecurrentinput();
425: resetpvs();
426: #if !defined(VISUAL)
427: if ( do_server_in_X11 )
428: #endif
429: show_debug_window(0);
430: #if defined(VISUAL_LIB)
431: w_noflush_stderr(0);
432: #endif
433: asir_out = stdout;
1.31 ohara 434: #if defined(PARI)
1.1 noro 435: pari_outfile = stdout;
436: #endif
437: /* restore states */
438: reset_engine();
439: reset_io();
1.16 noro 440: #if !defined(VISUAL)
1.15 noro 441: reset_timer();
1.16 noro 442: #endif
1.26 noro 443: LONGJMP(main_env,1);
1.1 noro 444: }
445:
1.24 noro 446: void fatal(int n)
1.1 noro 447: {
448: resetenv("return to toplevel");
449: }
450:
451: FUNC registered_handler;
452: extern int ox_int_received, critical_when_signal;
453:
1.24 noro 454: void int_handler(int sig)
1.1 noro 455: {
456: extern NODE PVSS;
457:
458: if ( do_file ) {
459: ExitAsir();
460: }
461: if ( critical_when_signal ) {
462: ox_int_received = 1;
463: return;
464: }
1.12 noro 465: #if defined(VISUAL)
1.19 noro 466: suspend_timer();
1.1 noro 467: #endif
468: signal(SIGINT,SIG_IGN);
1.3 noro 469: #if !defined(VISUAL)
470: if ( do_server_in_X11 ) {
471: debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
472: restore_handler();
473: return;
474: }
1.1 noro 475: #endif
476: #if defined(linux)
477: #if 1
478: while ( stdin->_IO_read_ptr < stdin->_IO_read_end )
479: #else
480: while ( stdin->_gptr < stdin->_egptr )
481: #endif
482: getchar();
483: #endif
484: while ( 1 ) {
485: char buf[BUFSIZ];
486: char c;
487:
488: fprintf(stderr,"interrupt ?(q/t/c/d/u/w/?) "); fflush(stderr);
489: buf[0] = '\n';
490: while ( buf[0] == '\n' )
491: fgets(buf,BUFSIZ,stdin);
492: switch ( c = buf[0] ) {
493: case 'q':
494: while ( 1 ) {
495: fprintf(stderr,"Abort this session? (y or n) "); fflush(stderr);
496: fgets(buf,BUFSIZ,stdin);
497: if ( !strncmp(buf,"y",1) ) {
498: read_exec_file = 0;
499: fprintf(stderr,"Bye\n"); asir_terminate(1);
500: } else if ( !strncmp(buf,"n",1) ) {
501: restore_handler();
502: return;
503: }
504: }
505: break;
506: case 't':
507: case 'u':
508: while ( 1 ) {
509: fprintf(stderr,"Abort this computation? (y or n) "); fflush(stderr);
510: fgets(buf,BUFSIZ,stdin);
511: if ( !strncmp(buf,"y",1) )
512: break;
513: else if ( !strncmp(buf,"n",1) ) {
514: restore_handler();
515: return;
516: }
517: }
518: if ( debug_mode )
519: debug_mode = 0;
520: restore_handler();
521: if ( c == 'u' ) {
522: if ( registered_handler ) {
523: fprintf(stderr,
524: "Calling the registered exception handler...");
525: bevalf(registered_handler,0);
526: fprintf(stderr, "done.\n");
527: }
528: }
529: if ( read_exec_file ) {
530: read_exec_file = 0;
531: resetenv("initialization aborted; return to toplevel");
532: } else
533: resetenv("return to toplevel");
534: break;
535: case 'd':
536: #if 0
537: nextbp = 1; nextbplevel = -1;
538: #endif
539: debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
540: restore_handler();
541: return;
542: case 'c':
543: restore_handler();
544: return; break;
545: case 'w':
546: showpos(); break;
547: case '?':
548: fprintf(stderr, "q:quit t:toplevel c:continue d:debug u:call registered handler w:where\n");
549: break;
550: default:
551: break;
552: }
553: }
554: }
555:
556: void restore_handler() {
1.12 noro 557: #if defined(VISUAL)
1.19 noro 558: resume_timer();
1.1 noro 559: #endif
1.19 noro 560: #if defined(SIGINT)
1.1 noro 561: signal(SIGINT,int_handler);
562: #endif
563: }
564:
1.24 noro 565: void segv_handler(int sig)
1.1 noro 566: {
1.19 noro 567: #if defined(SIGSEGV)
1.1 noro 568: signal(SIGSEGV,segv_handler);
1.19 noro 569: error("internal error (SEGV)");
1.1 noro 570: #endif
571: }
572:
1.24 noro 573: void ill_handler(int sig)
1.1 noro 574: {
1.19 noro 575: #if defined(SIGILL)
1.1 noro 576: signal(SIGILL,ill_handler);
1.19 noro 577: error("illegal instruction (ILL)");
1.1 noro 578: #endif
579: }
580:
1.24 noro 581: void alrm_handler(int sig)
1.1 noro 582: {
583: fprintf(stderr,"interval timer expired (VTALRM)\n");
1.26 noro 584: LONGJMP(timer_env,1);
1.1 noro 585: }
586:
1.24 noro 587: void bus_handler(int sig)
1.1 noro 588: {
589: #if defined(SIGBUS)
590: signal(SIGBUS,bus_handler);
591: error("internal error (BUS ERROR)");
592: #endif
593: }
594:
1.24 noro 595: void fpe_handler(int sig)
1.1 noro 596: {
1.19 noro 597: #if defined(SIGFPE)
1.1 noro 598: signal(SIGFPE,fpe_handler);
1.19 noro 599: error("internal error (FPE)");
1.1 noro 600: #endif
601: }
602:
1.24 noro 603: void pipe_handler(int sig)
1.1 noro 604: {
605: #if defined(SIGPIPE)
606: signal(SIGPIPE,pipe_handler);
1.20 noro 607: end_critical();
1.1 noro 608: error("internal error (BROKEN PIPE)");
609: #endif
610: }
611:
612: void resize_buffer()
613: {
614: }
615:
616: void tty_init() {
617: }
618:
619: void tty_reset() {
620: }
621:
622: extern int evalstatline;
623:
1.24 noro 624: void set_lasterror(char *s)
1.1 noro 625: {
626: strncpy(LastError,s,BUFSIZ);
627: LastError[BUFSIZ-1] = 0;
628: }
629:
630: SNODE error_snode;
631:
1.24 noro 632: void error(char *s)
1.1 noro 633: {
1.37 ! noro 634: SNODE *snp=0;
1.1 noro 635:
1.16 noro 636: #if !defined(VISUAL)
1.15 noro 637: if ( timer_is_set )
638: alrm_handler(SIGVTALRM);
1.16 noro 639: #endif
1.1 noro 640: fprintf(stderr,"%s\n",s);
641: set_lasterror(s);
642: if ( CPVS != GPVS ) {
1.37 ! noro 643: if ( CPVS && CPVS->usrf && CPVS->usrf->f.usrf )
1.7 noro 644: searchsn(&BDY(CPVS->usrf->f.usrf),evalstatline,&snp);
1.6 noro 645: if ( snp )
646: error_snode = *snp;
647: else
648: error_snode = 0;
1.1 noro 649: } else
650: error_snode = 0;
651: if ( do_file ) {
652: char errbuf[BUFSIZ*5]; /* sufficient to store stack information ? */
653:
654: sprintf(errbuf,"%s\n",s);
655: showpos_to_string(errbuf+strlen(errbuf));
656: set_lasterror(errbuf);
657: ExitAsir();
658: }
659: if ( debug_mode )
1.26 noro 660: LONGJMP(debug_env,1);
1.1 noro 661: if ( CPVS != GPVS )
662: if ( do_server_in_X11 || isatty(0) )
663: bp(error_snode);
664: if ( read_exec_file )
665: read_exec_file = 0;
666: resetenv("return to toplevel");
667: }
668:
669: #if !defined(VISUAL)
670: #include <sys/time.h>
671:
1.24 noro 672: void set_timer(int interval)
1.1 noro 673: {
674: struct itimerval it;
675:
676: it.it_interval.tv_sec = interval;
677: it.it_interval.tv_usec = 0;
678: it.it_value.tv_sec = interval;
679: it.it_value.tv_usec = 0;
680: setitimer(ITIMER_VIRTUAL,&it,0);
681: signal(SIGVTALRM,alrm_handler);
1.15 noro 682: timer_is_set = 1;
1.1 noro 683: }
684:
685: void reset_timer()
686: {
687: struct itimerval it;
688:
689: it.it_interval.tv_sec = 0;
690: it.it_interval.tv_usec = 0;
691: it.it_value.tv_sec = 0;
692: it.it_value.tv_usec = 0;
693: setitimer(ITIMER_VIRTUAL,&it,0);
694: signal(SIGVTALRM,SIG_IGN);
1.15 noro 695: timer_is_set = 0;
1.1 noro 696: }
697: #endif
698:
699: unsigned int get_asir_version();
1.14 noro 700: char *get_asir_distribution();
1.1 noro 701:
702: void copyright() {
1.17 noro 703: #if defined(INTERVAL)
704: printf("This is Risa/Asir + Interval Arithmetic, Version %d (%s Distribution).\n",
705: get_asir_version(), get_asir_distribution());
706: #else
1.14 noro 707: printf("This is Risa/Asir, Version %d (%s Distribution).\n",
708: get_asir_version(), get_asir_distribution());
1.17 noro 709: #endif
1.14 noro 710: printf("Copyright (C) 1994-2000, all rights reserved, FUJITSU LABORATORIES LIMITED.\n");
1.30 noro 711: printf("Copyright 2000-2003, Risa/Asir committers, http://www.openxm.org/.\n");
1.27 noro 712: printf("GC 6.1(alpha5) copyright 2001, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n");
1.32 noro 713: #if PARI
714: #if 0
1.28 noro 715: printf("PARI 2.2.4, copyright (C) 2002 The PARI Group.\n");
1.32 noro 716: #endif
717: printf("PARI 2.0.17, copyright 1989-1999, C. Batut, K. Belabas, D. Bernardi,\n");
718: printf(" H. Cohen and M. Olivier.\n");
719: #endif
1.1 noro 720: }
1.14 noro 721:
1.5 noro 722:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>