[BACK]Return to glob.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Annotation of OpenXM_contrib2/asir2000/parse/glob.c, Revision 1.14

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.14    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.13 2000/12/22 10:03:31 saito Exp $
1.8       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "al.h"
                     52: #include "parse.h"
                     53: #if PARI
                     54: #include "genpari.h"
                     55: #endif
1.12      noro       56: #if !defined(VISUAL) && !defined(_PA_RISC1_1) && !defined(linux) && !defined(SYSV)
1.1       noro       57: #include <sgtty.h>
                     58: #endif
                     59:
                     60: #if defined(VISUAL)
                     61: #include <io.h>
                     62: #include <direct.h>
                     63: #endif
                     64:
                     65: #if defined(SYSV)
                     66: #include <sys/ttold.h>
                     67: #endif
                     68:
                     69: #if defined(VISUAL)
                     70: #define HISTORY asir_history
                     71: #endif
1.12      noro       72:
1.1       noro       73: #define MAXHIST 100
                     74:
                     75: extern int GC_free_space_divisor;
                     76: extern int GC_free_space_numerator;
                     77: extern FILE *asir_out;
                     78:
                     79: IN asir_infile;
                     80: jmp_buf env,debug_env,timer_env;
                     81: int little_endian,debug_mode;
                     82: char *asir_libdir;
                     83: char *asir_pager;
                     84:
                     85: NODE usrf,sysf,noargsysf,ubinf,parif;
                     86: NODE ONENODE;
                     87: int main_parser, ox_do_copy, ox_do_count, ox_count_length;
                     88: int ox_file_io, ox_need_conv;
                     89: char *ox_copy_bptr;
                     90: char *parse_strp;
                     91: SNODE parse_snode;
                     92: FUNC parse_targetf;
                     93: FILE *ox_istream,*ox_ostream;
                     94: int do_server_in_X11;
                     95: Obj LastVal;
                     96: char LastError[BUFSIZ];
                     97:
                     98: struct oV oVAR[] = {
                     99:        {"x",0,0}, {"y",0,0}, {"z",0,0}, {"u",0,0},
                    100:        {"v",0,0}, {"w",0,0}, {"p",0,0}, {"q",0,0},
                    101:        {"r",0,0}, {"s",0,0}, {"t",0,0}, {"a",0,0},
                    102:        {"b",0,0}, {"c",0,0}, {"d",0,0}, {"e",0,0},
                    103:        {"f",0,0}, {"g",0,0}, {"h",0,0}, {"i",0,0},
                    104:        {"j",0,0}, {"k",0,0}, {"l",0,0}, {"m",0,0},
                    105:        {"n",0,0}, {"o",0,0},
                    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: };
                    114:
                    115: struct oVL oVLIST[52];
                    116:
                    117: VL CO = oVLIST;
                    118: VL ALG;
                    119:
                    120: struct oVS oGPVS,oAPVS,oEPVS;
                    121: VS GPVS = &oGPVS;
                    122: VS APVS = &oAPVS;
                    123: VS EPVS = &oEPVS;
                    124: VS CPVS;
                    125:
                    126: struct oF oF_TRUE,oF_FALSE;
                    127: F F_TRUE = &oF_TRUE;
                    128: F F_FALSE = &oF_FALSE;
                    129:
                    130: #if defined(__SVR4) && defined(sun)
1.4       noro      131: char cppname[BUFSIZ] = "/usr/ccs/lib/cpp ";
1.1       noro      132: #else
                    133: #if defined(__FreeBSD__) || defined(__NetBSD__)
1.4       noro      134: char cppname[BUFSIZ] = "/usr/bin/cpp ";
1.1       noro      135: #else
                    136: #if defined(VISUAL)
1.4       noro      137: char cppname[BUFSIZ] = "c:\\asir\\stdlib\\cpp ";
1.1       noro      138: #else
1.4       noro      139: char cppname[BUFSIZ] = "/lib/cpp ";
1.1       noro      140: #endif
                    141: #endif
                    142: #endif
1.4       noro      143: char asirname[BUFSIZ];
1.1       noro      144: char displayname[BUFSIZ];
                    145:
                    146: int Verbose;
                    147:
                    148: void glob_init() {
                    149:        int i;
                    150:
                    151:        for ( i = 0; i < 51; i++ ) {
                    152:                VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = &oVLIST[i+1];
                    153:        }
                    154:        VR(&oVLIST[i]) = &oVAR[i]; NEXT(&oVLIST[i]) = 0;
                    155:        reallocarray((char **)&GPVS->va,(int *)&GPVS->asize,(int *)&GPVS->n,(int)sizeof(struct oPV));
                    156:        reallocarray((char **)&APVS->va,(int *)&APVS->asize,(int *)&APVS->n,(int)sizeof(struct oPV));
                    157:        CPVS = GPVS;
                    158:        MKNODE(ONENODE,mkfnode(1,I_FORMULA,ONE),0);
                    159:        OID(F_TRUE)=O_F; FOP(F_TRUE)=AL_TRUE; F_TRUE->arg.dummy = 0;
                    160:        OID(F_FALSE)=O_F; FOP(F_FALSE)=AL_FALSE; F_FALSE->arg.dummy = 0;
                    161:        sprintf(asirname,"%s/asir_symtab",asir_libdir);
                    162: }
                    163:
                    164: void input_init(fp,name)
                    165: FILE *fp;
                    166: char *name;
                    167: {
                    168:        asir_infile = (IN)CALLOC(sizeof(struct oIN),1);
                    169:        asir_infile->name = name; asir_infile->fp = fp;
                    170:        asir_infile->ln = 1; NEXT(asir_infile) = 0;
                    171: }
                    172:
                    173: void notdef(vl,a,b,c)
                    174: VL vl;
                    175: Obj a,b,*c;
                    176: {
                    177:        *c = 0;
                    178:        error("undefined arithmetic operation.");
                    179: }
                    180:
                    181: int kernelmode;
                    182: int do_asirrc;
                    183: int do_file;
                    184: int do_message;
                    185: int do_fep;
                    186: int no_prompt;
                    187: int read_exec_file;
                    188: static int buserr_sav;
                    189: static char asir_history[BUFSIZ];
                    190:
                    191: extern int mpi_myid;
                    192:
1.5       noro      193: #if !defined(VISUAL_LIB)
                    194: void ExitAsir() {
                    195:        exit(0);
                    196: }
                    197: #endif
                    198:
1.1       noro      199: /*
                    200:  * status = 1 abnormal termination (error() etc.)
                    201:  * status = 2 normal termination (end(), quit() etc.)
                    202:  */
                    203:
                    204: void asir_terminate(status)
                    205: int status;
                    206: {
                    207:        if ( read_exec_file ) {
                    208:                read_exec_file = 0; longjmp(env,status);
                    209:        } else {
                    210:                tty_reset();
                    211: #if MPI
                    212:                if ( !mpi_myid )
                    213:                        close_allconnections();
                    214:                mpi_finalize();
                    215: #else
                    216:                close_allconnections();
                    217: #endif
                    218:                if ( kernelmode )
                    219:                        fputc(0xff,asir_out);
                    220:                if ( asir_out )
                    221:                        fflush(asir_out);
1.13      saito     222: #if FEP
                    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 )
                    243:                fprintf(asir_out,"[%d]%c",APVS->n,kernelmode?0xfe:' ');
                    244:        fflush(asir_out);
                    245: }
                    246:
                    247: void sprompt(ptr)
                    248: char *ptr;
                    249: {
                    250:        sprintf(ptr,"[%d]%c",APVS->n,kernelmode?0xfe:' ');
                    251: }
                    252:
                    253: FILE *in_fp;
                    254:
                    255: void process_args(ac,av)
                    256: int ac;
                    257: char **av;
                    258: {
                    259:        do_asirrc = 1;
                    260: #if !MPI
                    261:        do_message = 1;
                    262: #endif
                    263:        while ( ac > 0 ) {
                    264:                if ( !strcmp(*av,"-heap") && (ac >= 2) ) {
                    265:                        void GC_expand_hp(int);
                    266:
                    267:                        GC_expand_hp(atoi(*(av+1))); av += 2; ac -= 2;
                    268:                } else if ( !strcmp(*av,"-adj") && (ac >= 2) ) {
                    269:                        char *slash;
                    270:
                    271:                        slash = strrchr(*(av+1),'/');
                    272:                        if ( slash ) {
                    273:                                *slash = 0;
                    274:                                GC_free_space_numerator = atoi(slash+1);
                    275:                        }
                    276:                        GC_free_space_divisor = atoi(*(av+1));
                    277:                        av += 2; ac -= 2;
                    278:                } else if ( !strcmp(*av,"-cpp") && (ac >= 2) ) {
                    279:                        strcpy(cppname,*(av+1)); av += 2; ac -= 2;
                    280:                } else if ( !strcmp(*av,"-f") && (ac >= 2) ) {
                    281:                        in_fp = fopen(*(av+1),"r");
                    282:                        if ( !in_fp ) {
                    283:                                fprintf(stderr,"%s does not exist!",*(av+1));
                    284:                                asir_terminate(1);
                    285:                        }
                    286:                        do_file = 1;
                    287:                        av += 2; ac -= 2;
                    288:                } else if ( !strcmp(*av,"-kernel") ) {
                    289:                        kernelmode = 1; av++; ac--;
                    290:                } else if ( !strcmp(*av,"-norc") ) {
                    291:                        do_asirrc = 0; av++; ac--;
                    292:                } else if ( !strcmp(*av,"-nomessage") ) {
                    293:                        do_message = 0; av++; ac--;
                    294:                } else if ( !strcmp(*av,"-terse") ) {
                    295:                        no_prompt = 0; av++; ac--;
1.11      noro      296:                } else if ( !strcmp(*av,"-rootdir") && (ac >= 2) ) {
                    297:                        set_rootdir(*(av+1)); av += 2; ac -= 2;
1.1       noro      298:                } else if ( !strcmp(*av,"-maxheap") && (ac >= 2) ) {
                    299:                        void GC_set_max_heap_size(int);
                    300:
                    301:                        GC_set_max_heap_size(atoi(*(av+1))); av += 2; ac -= 2;
                    302: #if !defined(VISUAL)
                    303:                } else if ( !strcmp(*av,"-display") && (ac >= 2) ) {
                    304:                        strcpy(displayname,*(av+1)); av += 2; ac -= 2;
                    305: #endif
1.13      saito     306: #if FEP
                    307:                } else if ( !strcmp(*av,"-fep") ) {
                    308:                        do_fep = 1; av++; ac--;
                    309: #endif
1.1       noro      310: #if PARI
                    311:                } else if ( !strcmp(*av,"-paristack") ) {
                    312:                        extern int paristack;
                    313:
                    314:                        paristack = atoi(*(av+1)); av += 2; ac -= 2;
                    315: #endif
                    316:                } else {
                    317:                        fprintf(stderr,"%s : unknown option.\n",*av);
                    318:                        asir_terminate(1);
                    319:                }
                    320:        }
1.13      saito     321: #if FEP
                    322:        if ( do_fep ) {
                    323:                char *home;
                    324:                home = (char *)getenv("HOME");
                    325:                if (!home)
                    326:                        home = ".";
                    327:                sprintf (asir_history, "%s/.asir_history",home);
                    328:                read_history(asir_history);
                    329:                using_history();
                    330:        }
                    331: #endif
1.1       noro      332: }
                    333:
                    334: #include <signal.h>
                    335:
                    336: void sig_init() {
                    337: #if !defined(VISUAL)
                    338:        signal(SIGINT,int_handler);
                    339: #else
                    340:        register_ctrlc_handler();
                    341: #endif
                    342:        signal(SIGSEGV,segv_handler);
                    343:
                    344: #if defined SIGFPE
                    345:        signal(SIGFPE,fpe_handler);
                    346: #endif
                    347:
                    348: #if defined SIGPIPE
                    349:        signal(SIGPIPE,pipe_handler);
                    350: #endif
                    351:
                    352: #if defined SIGILL
                    353:        signal(SIGILL,ill_handler);
                    354: #endif
                    355:
                    356: #if !defined(VISUAL)
                    357:        signal(SIGBUS,bus_handler);
                    358: #endif
                    359: }
                    360:
                    361: static void (*old_int)(int);
                    362:
                    363: void asir_save_handler() {
                    364:        old_int = signal(SIGINT,SIG_IGN);
                    365:        signal(SIGINT,old_int);
                    366: }
                    367:
                    368: void asir_set_handler() {
                    369:        signal(SIGINT,int_handler);
                    370: }
                    371:
                    372: void asir_reset_handler() {
                    373:        signal(SIGINT,old_int);
                    374: }
                    375:
                    376: void resetenv(s)
                    377: char *s;
                    378: {
                    379:        extern FILE *outfile;
                    380:
                    381:        fprintf(stderr,"%s\n",s);
                    382:        while ( NEXT(asir_infile) )
                    383:                closecurrentinput();
                    384:        resetpvs();
                    385: #if !defined(VISUAL)
                    386:        if ( do_server_in_X11 )
                    387: #endif
                    388:                show_debug_window(0);
                    389: #if defined(VISUAL_LIB)
                    390:        w_noflush_stderr(0);
                    391: #endif
                    392:        asir_out = stdout;
                    393: #if PARI
                    394:        pari_outfile = stdout;
                    395: #endif
                    396:        /* restore states */
                    397:        reset_engine();
                    398:        reset_io();
                    399:        longjmp(env,1);
                    400: }
                    401:
                    402: void fatal(n)
                    403: int n;
                    404: {
                    405:        resetenv("return to toplevel");
                    406: }
                    407:
                    408: FUNC registered_handler;
                    409: extern int ox_int_received, critical_when_signal;
                    410:
                    411: void int_handler(sig)
                    412: int sig;
                    413: {
                    414:        extern NODE PVSS;
                    415:
                    416:        if ( do_file ) {
                    417:                ExitAsir();
                    418:        }
                    419:        if ( critical_when_signal ) {
                    420:                ox_int_received = 1;
                    421:                return;
                    422:        }
1.12      noro      423: #if defined(VISUAL)
1.1       noro      424:        suspend_timer(); signal(SIGINT,SIG_IGN);
                    425: #endif
                    426: #if defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
                    427:        signal(SIGINT,SIG_IGN);
1.3       noro      428: #endif
                    429: #if !defined(VISUAL)
                    430:     if ( do_server_in_X11 ) {
                    431:                debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
                    432:                restore_handler();
                    433:                return;
                    434:        }
1.1       noro      435: #endif
                    436: #if defined(linux)
                    437: #if 1
                    438:        while ( stdin->_IO_read_ptr < stdin->_IO_read_end )
                    439: #else
                    440:        while ( stdin->_gptr < stdin->_egptr )
                    441: #endif
                    442:                getchar();
                    443: #endif
                    444:        while ( 1 ) {
                    445:                char buf[BUFSIZ];
                    446:                char c;
                    447:
                    448:                fprintf(stderr,"interrupt ?(q/t/c/d/u/w/?) "); fflush(stderr);
                    449:                if ( kernelmode )
                    450:                        fputc('\0',stderr);
                    451:                buf[0] = '\n';
                    452:                while ( buf[0] == '\n' )
                    453:                        fgets(buf,BUFSIZ,stdin);
                    454:                switch ( c = buf[0] ) {
                    455:                        case 'q':
                    456:                                while ( 1 ) {
                    457:                                        fprintf(stderr,"Abort this session? (y or n) "); fflush(stderr);
                    458:                                        fgets(buf,BUFSIZ,stdin);
                    459:                                        if ( !strncmp(buf,"y",1) ) {
                    460:                                                read_exec_file = 0;
                    461:                                                fprintf(stderr,"Bye\n"); asir_terminate(1);
                    462:                                        } else if ( !strncmp(buf,"n",1) ) {
                    463:                                                restore_handler();
                    464:                                                return;
                    465:                                        }
                    466:                                }
                    467:                                break;
                    468:                        case 't':
                    469:                        case 'u':
                    470:                                while ( 1 ) {
                    471:                                        fprintf(stderr,"Abort this computation? (y or n) "); fflush(stderr);
                    472:                                        fgets(buf,BUFSIZ,stdin);
                    473:                                        if ( !strncmp(buf,"y",1) )
                    474:                                                break;
                    475:                                        else if ( !strncmp(buf,"n",1) ) {
                    476:                                                restore_handler();
                    477:                                                return;
                    478:                                        }
                    479:                                }
                    480:                                if ( debug_mode )
                    481:                                        debug_mode = 0;
                    482:                                if ( kernelmode )
                    483:                                        fputc('\0',stderr);
                    484:                                restore_handler();
                    485:                                if ( c == 'u' ) {
                    486:                                        if ( registered_handler ) {
                    487:                                                fprintf(stderr,
                    488:                                                        "Calling the registered exception handler...");
                    489:                                                bevalf(registered_handler,0);
                    490:                                                fprintf(stderr, "done.\n");
                    491:                                        }
                    492:                                }
                    493:                                if ( read_exec_file ) {
                    494:                                        read_exec_file = 0;
                    495:                                        resetenv("initialization aborted; return to toplevel");
                    496:                                } else
                    497:                                        resetenv("return to toplevel");
                    498:                                break;
                    499:                        case 'd':
                    500: #if 0
                    501:                                nextbp = 1; nextbplevel = -1;
                    502: #endif
                    503:                                debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
                    504:                                restore_handler();
                    505:                                return;
                    506:                        case 'c':
                    507:                                if ( kernelmode )
                    508:                                        fputc('\0',stderr);
                    509:                                restore_handler();
                    510:                                return; break;
                    511:                        case 'w':
                    512:                                showpos(); break;
                    513:                        case '?':
                    514:                                fprintf(stderr, "q:quit t:toplevel c:continue d:debug u:call registered handler w:where\n");
                    515:                                break;
                    516:                        default:
                    517:                                break;
                    518:                }
                    519:        }
                    520: }
                    521:
                    522: void restore_handler() {
1.12      noro      523: #if defined(VISUAL)
1.1       noro      524:        resume_timer(); signal(SIGINT,int_handler);
                    525: #endif
                    526: #if defined(_PA_RISC1_1) || defined(linux) || defined(__svr4__)
                    527:        signal(SIGINT,int_handler);
                    528: #endif
                    529: }
                    530:
                    531: void segv_handler(sig)
                    532: int sig;
                    533: {
1.12      noro      534: #if defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
1.1       noro      535:        signal(SIGSEGV,segv_handler);
                    536: #endif
                    537:        error("internal error (SEGV)");
                    538: }
                    539:
                    540: void ill_handler(sig)
                    541: int sig;
                    542: {
1.12      noro      543: #if defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
1.1       noro      544:        signal(SIGILL,ill_handler);
                    545: #endif
                    546:        error("illegal instruction (ILL)");
                    547: }
                    548:
                    549: void alrm_handler(sig)
                    550: int sig;
                    551: {
                    552:        fprintf(stderr,"interval timer expired (VTALRM)\n");
                    553:        longjmp(timer_env,1);
                    554: }
                    555:
                    556: void bus_handler(sig)
                    557: int sig;
                    558: {
                    559: #if defined(SIGBUS)
                    560:        signal(SIGBUS,bus_handler);
                    561:        error("internal error (BUS ERROR)");
                    562: #endif
                    563: }
                    564:
                    565: void fpe_handler(sig)
                    566: int sig;
                    567: {
1.12      noro      568: #if defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
1.1       noro      569:        signal(SIGFPE,fpe_handler);
                    570: #endif
                    571:        error("internal error (FPE)");
                    572: }
                    573:
                    574: void pipe_handler(sig)
                    575: int sig;
                    576: {
                    577: #if defined(SIGPIPE)
                    578:        signal(SIGPIPE,pipe_handler);
                    579:        error("internal error (BROKEN PIPE)");
                    580: #endif
                    581: }
                    582:
                    583: void resize_buffer()
                    584: {
                    585: }
                    586:
                    587: void tty_init() {
                    588: }
                    589:
                    590: void tty_reset() {
                    591: }
                    592:
                    593: extern int evalstatline;
                    594:
                    595: void set_lasterror(s)
                    596: char *s;
                    597: {
                    598:        strncpy(LastError,s,BUFSIZ);
                    599:        LastError[BUFSIZ-1] = 0;
                    600: }
                    601:
                    602: SNODE error_snode;
                    603:
                    604: void error(s)
                    605: char *s;
                    606: {
                    607:        SNODE *snp;
                    608:
                    609:        fprintf(stderr,"%s\n",s);
                    610:        set_lasterror(s);
                    611:        if ( CPVS != GPVS ) {
1.7       noro      612:                if ( CPVS->usrf && CPVS->usrf && CPVS->usrf->f.usrf )
                    613:                        searchsn(&BDY(CPVS->usrf->f.usrf),evalstatline,&snp);
1.6       noro      614:                if ( snp )
                    615:                        error_snode = *snp;
                    616:                else
                    617:                        error_snode = 0;
1.1       noro      618:        } else
                    619:                error_snode = 0;
                    620:        if ( do_file ) {
                    621:                char errbuf[BUFSIZ*5]; /* sufficient to store stack information ? */
                    622:
                    623:                sprintf(errbuf,"%s\n",s);
                    624:                showpos_to_string(errbuf+strlen(errbuf));
                    625:                set_lasterror(errbuf);
                    626:                ExitAsir();
                    627:        }
                    628:        if ( debug_mode )
                    629:                longjmp(debug_env,1);
                    630:        if ( CPVS != GPVS )
                    631:                if ( do_server_in_X11 || isatty(0) )
                    632:                        bp(error_snode);
                    633:        if ( read_exec_file )
                    634:                read_exec_file = 0;
                    635:        resetenv("return to toplevel");
                    636: }
                    637:
                    638: #if !defined(VISUAL)
                    639: #include <sys/time.h>
                    640:
                    641: void set_timer(interval)
                    642: int interval;
                    643: {
                    644:        struct itimerval it;
                    645:
                    646:        it.it_interval.tv_sec = interval;
                    647:        it.it_interval.tv_usec = 0;
                    648:        it.it_value.tv_sec = interval;
                    649:        it.it_value.tv_usec = 0;
                    650:        setitimer(ITIMER_VIRTUAL,&it,0);
                    651:        signal(SIGVTALRM,alrm_handler);
                    652: }
                    653:
                    654: void reset_timer()
                    655: {
                    656:        struct itimerval it;
                    657:
                    658:        it.it_interval.tv_sec = 0;
                    659:        it.it_interval.tv_usec = 0;
                    660:        it.it_value.tv_sec = 0;
                    661:        it.it_value.tv_usec = 0;
                    662:        setitimer(ITIMER_VIRTUAL,&it,0);
                    663:        signal(SIGVTALRM,SIG_IGN);
                    664: }
                    665: #endif
                    666:
                    667: unsigned int get_asir_version();
1.14    ! noro      668: char *get_asir_distribution();
1.1       noro      669:
                    670: void copyright() {
1.14    ! noro      671:        printf("This is Risa/Asir, Version %d (%s Distribution).\n",
        !           672:                get_asir_version(), get_asir_distribution());
        !           673:        printf("Copyright (C) 1994-2000, all rights reserved, FUJITSU LABORATORIES LIMITED.\n");
        !           674:        printf("Copyright 2000,2001, Risa/Asir committers, http://www.openxm.org/.\n");
        !           675:        printf("GC 5.3, copyright 1999, H-J. Boehm, A. J. Demers, Xerox, SGI, HP.\n");
        !           676:        printf("PARI 2.0.17(beta), copyright (C) 1989-1999,\n");
        !           677:        printf("     C. Batut, K. Belabas, D. Bernardi, H. Cohen and M. Olivier.\n");
1.1       noro      678: }
1.14    ! noro      679:
1.5       noro      680:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>