[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.4

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

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