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

1.7     ! noro        1: /* $OpenXM: OpenXM_contrib2/asir2000/parse/glob.c,v 1.6 2000/06/05 03:21:58 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:
1.5       noro      155: #if !defined(VISUAL_LIB)
                    156: void ExitAsir() {
                    157:        exit(0);
                    158: }
                    159: #endif
                    160:
1.1       noro      161: /*
                    162:  * status = 1 abnormal termination (error() etc.)
                    163:  * status = 2 normal termination (end(), quit() etc.)
                    164:  */
                    165:
                    166: void asir_terminate(status)
                    167: int status;
                    168: {
                    169:        if ( read_exec_file ) {
                    170:                read_exec_file = 0; longjmp(env,status);
                    171:        } else {
                    172:                tty_reset();
                    173: #if INET && !defined(THINK_C)
                    174: #if MPI
                    175:                if ( !mpi_myid )
                    176:                        close_allconnections();
                    177:                mpi_finalize();
                    178: #else
                    179:                close_allconnections();
                    180: #endif
                    181: #endif
                    182:                if ( kernelmode )
                    183:                        fputc(0xff,asir_out);
                    184:                if ( asir_out )
                    185:                        fflush(asir_out);
                    186: #if defined(THINK_C) && !defined(__MWERKS__)
                    187:                *((int *)0x8) = buserr_sav;
                    188:                while ( NEXT(asir_infile) )
                    189:                closecurrentinput();
                    190:                console_options.pause_atexit = 0;
                    191:                resetDir();
                    192:                write_hist(HISTORY);
                    193: #endif
                    194:                ExitAsir();
                    195:        }
                    196: }
                    197:
                    198: void param_init() {
                    199:        unsigned int et = 0xff;
                    200:        extern int paristack;
                    201: #if defined(THINK_C)
                    202:        char name[BUFSIZ];
                    203:        int c;
                    204:        int val;
                    205:        FILE *fp;
                    206:        int stacksize;
                    207:
                    208: #include <Memory.h>
                    209:        GC_free_space_divisor = 4; stacksize = 0x40000;
                    210:        if ( fp = fopen("params","r") ) {
                    211:                while ( 1 ) {
                    212:                        c = fgetc(fp);
                    213:                        if ( c == EOF )
                    214:                                break;
                    215:                        else
                    216:                                ungetc(c,fp);
                    217:                        fscanf(fp,"%s %d",name,&val);
                    218:                        if ( !strcmp(name,"stacksize") )
                    219:                                stacksize = val;
                    220:                        else if ( !strcmp(name,"adj") )
                    221:                                GC_free_space_divisor = val;
                    222: #if PARI
                    223:                        else if ( !strcmp(name,"paristack") )
                    224:                                paristack = val;
                    225: #endif
                    226:                }
                    227:                fclose(fp);
                    228:        }
                    229: #if defined(__MWERKS__)
                    230:        {
                    231:                Ptr al;
                    232:                al = LMGetApplLimit();
                    233:                LMSetApplLimit(al-stacksize);
                    234:        }
                    235: #else
                    236:        ApplLimit = (Ptr)((char *)ApplLimit-stacksize);
                    237:        console_options.title = "\pAsir";
                    238: #endif
                    239: #endif
                    240:        if ( *((char *)&et) )
                    241:                little_endian = 1;
                    242:        else
                    243:                little_endian = 0;
                    244: }
                    245:
                    246: void prompt() {
                    247:        if ( !no_prompt && !do_fep && asir_infile->fp == stdin )
                    248:                fprintf(asir_out,"[%d]%c",APVS->n,kernelmode?0xfe:' ');
                    249:        fflush(asir_out);
                    250: }
                    251:
                    252: void sprompt(ptr)
                    253: char *ptr;
                    254: {
                    255:        sprintf(ptr,"[%d]%c",APVS->n,kernelmode?0xfe:' ');
                    256: }
                    257:
                    258: #if 0 && !defined(THINK_C) && !defined(VISUAL) && !defined(_PA_RISC1_1)
                    259: static struct tchars tc;
                    260: static char oldeof;
                    261: struct winsize wsize;
                    262: int ttywidth;
                    263: char *upperbuf,*lowerbuf;
                    264: #endif
                    265:
                    266: FILE *in_fp;
                    267:
                    268: void process_args(ac,av)
                    269: int ac;
                    270: char **av;
                    271: {
                    272: #if !defined(THINK_C)
                    273:        do_asirrc = 1;
                    274: #if !MPI
                    275:        do_message = 1;
                    276: #endif
                    277:        while ( ac > 0 ) {
                    278:                if ( !strcmp(*av,"-heap") && (ac >= 2) ) {
                    279:                        void GC_expand_hp(int);
                    280:
                    281:                        GC_expand_hp(atoi(*(av+1))); av += 2; ac -= 2;
                    282:                } else if ( !strcmp(*av,"-adj") && (ac >= 2) ) {
                    283:                        char *slash;
                    284:
                    285:                        slash = strrchr(*(av+1),'/');
                    286:                        if ( slash ) {
                    287:                                *slash = 0;
                    288:                                GC_free_space_numerator = atoi(slash+1);
                    289:                        }
                    290:                        GC_free_space_divisor = atoi(*(av+1));
                    291:                        av += 2; ac -= 2;
                    292:                } else if ( !strcmp(*av,"-cpp") && (ac >= 2) ) {
                    293:                        strcpy(cppname,*(av+1)); av += 2; ac -= 2;
                    294:                } else if ( !strcmp(*av,"-f") && (ac >= 2) ) {
                    295:                        in_fp = fopen(*(av+1),"r");
                    296:                        if ( !in_fp ) {
                    297:                                fprintf(stderr,"%s does not exist!",*(av+1));
                    298:                                asir_terminate(1);
                    299:                        }
                    300:                        do_file = 1;
                    301:                        av += 2; ac -= 2;
                    302:                } else if ( !strcmp(*av,"-kernel") ) {
                    303:                        kernelmode = 1; av++; ac--;
                    304:                } else if ( !strcmp(*av,"-norc") ) {
                    305:                        do_asirrc = 0; av++; ac--;
                    306:                } else if ( !strcmp(*av,"-nomessage") ) {
                    307:                        do_message = 0; av++; ac--;
                    308:                } else if ( !strcmp(*av,"-terse") ) {
                    309:                        no_prompt = 0; av++; ac--;
                    310:                } else if ( !strcmp(*av,"-maxheap") && (ac >= 2) ) {
                    311:                        void GC_set_max_heap_size(int);
                    312:
                    313:                        GC_set_max_heap_size(atoi(*(av+1))); av += 2; ac -= 2;
                    314: #if !defined(VISUAL)
                    315:                } else if ( !strcmp(*av,"-display") && (ac >= 2) ) {
                    316:                        strcpy(displayname,*(av+1)); av += 2; ac -= 2;
                    317: #endif
                    318: #if PARI
                    319:                } else if ( !strcmp(*av,"-paristack") ) {
                    320:                        extern int paristack;
                    321:
                    322:                        paristack = atoi(*(av+1)); av += 2; ac -= 2;
                    323: #endif
                    324:                } else {
                    325:                        fprintf(stderr,"%s : unknown option.\n",*av);
                    326:                        asir_terminate(1);
                    327:                }
                    328:        }
                    329: #endif
                    330: #if (defined(THINK_C) && !defined(__MWERKS__))
                    331:        init_hist(MAXHIST);
                    332:        read_hist(HISTORY);
                    333: #endif
                    334: }
                    335:
                    336: #include <signal.h>
                    337:
                    338: void sig_init() {
                    339: #if !defined(VISUAL)
                    340:        signal(SIGINT,int_handler);
                    341: #else
                    342:        register_ctrlc_handler();
                    343: #endif
                    344:        signal(SIGSEGV,segv_handler);
                    345:
                    346: #if defined SIGFPE
                    347:        signal(SIGFPE,fpe_handler);
                    348: #endif
                    349:
                    350: #if defined SIGPIPE
                    351:        signal(SIGPIPE,pipe_handler);
                    352: #endif
                    353:
                    354: #if defined SIGILL
                    355:        signal(SIGILL,ill_handler);
                    356: #endif
                    357:
                    358: #if defined(THINK_C)
                    359:        buserr_sav = *((int *)0x8);
                    360:        *((int *)0x8) = (int)bus_handler;
                    361: #else /* THINK_C */
                    362:
                    363: #if !defined(VISUAL)
                    364:        signal(SIGBUS,bus_handler);
                    365: #endif
                    366:
                    367: #if 0
                    368: #if !defined(VISUAL) && !defined(_PA_RISC1_1)
                    369:        signal(SIGWINCH,winch_handler);
                    370: #endif
                    371: #endif
                    372:
                    373: #endif /* THINK_C */
                    374: }
                    375:
                    376: static void (*old_int)(int);
                    377:
                    378: void asir_save_handler() {
                    379:        old_int = signal(SIGINT,SIG_IGN);
                    380:        signal(SIGINT,old_int);
                    381: }
                    382:
                    383: void asir_set_handler() {
                    384:        signal(SIGINT,int_handler);
                    385: }
                    386:
                    387: void asir_reset_handler() {
                    388:        signal(SIGINT,old_int);
                    389: }
                    390:
                    391: void resetenv(s)
                    392: char *s;
                    393: {
                    394:        extern FILE *outfile;
                    395:
                    396:        fprintf(stderr,"%s\n",s);
                    397:        while ( NEXT(asir_infile) )
                    398:                closecurrentinput();
                    399:        resetpvs();
                    400: #if !defined(VISUAL)
                    401:        if ( do_server_in_X11 )
                    402: #endif
                    403:                show_debug_window(0);
                    404: #if defined(VISUAL_LIB)
                    405:        w_noflush_stderr(0);
                    406: #endif
                    407:        asir_out = stdout;
                    408: #if PARI
                    409:        pari_outfile = stdout;
                    410: #endif
                    411:        /* restore states */
                    412:        reset_engine();
                    413:        reset_io();
                    414:        longjmp(env,1);
                    415: }
                    416:
                    417: void fatal(n)
                    418: int n;
                    419: {
                    420:        resetenv("return to toplevel");
                    421: }
                    422:
                    423: FUNC registered_handler;
                    424: extern int ox_int_received, critical_when_signal;
                    425:
                    426: void int_handler(sig)
                    427: int sig;
                    428: {
                    429:        extern NODE PVSS;
                    430:
                    431:        if ( do_file ) {
                    432:                ExitAsir();
                    433:        }
                    434:        if ( critical_when_signal ) {
                    435:                ox_int_received = 1;
                    436:                return;
                    437:        }
                    438: #if defined(THINK_C) || defined(VISUAL)
                    439:        suspend_timer(); signal(SIGINT,SIG_IGN);
                    440: #endif
                    441: #if defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
                    442:        signal(SIGINT,SIG_IGN);
1.3       noro      443: #endif
                    444: #if !defined(VISUAL)
                    445:     if ( do_server_in_X11 ) {
                    446:                debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
                    447:                restore_handler();
                    448:                return;
                    449:        }
1.1       noro      450: #endif
                    451: #if defined(linux)
                    452: #if 1
                    453:        while ( stdin->_IO_read_ptr < stdin->_IO_read_end )
                    454: #else
                    455:        while ( stdin->_gptr < stdin->_egptr )
                    456: #endif
                    457:                getchar();
                    458: #endif
                    459:        while ( 1 ) {
                    460:                char buf[BUFSIZ];
                    461:                char c;
                    462:
                    463:                fprintf(stderr,"interrupt ?(q/t/c/d/u/w/?) "); fflush(stderr);
                    464:                if ( kernelmode )
                    465:                        fputc('\0',stderr);
                    466:                buf[0] = '\n';
                    467:                while ( buf[0] == '\n' )
                    468:                        fgets(buf,BUFSIZ,stdin);
                    469:                switch ( c = buf[0] ) {
                    470:                        case 'q':
                    471:                                while ( 1 ) {
                    472:                                        fprintf(stderr,"Abort this session? (y or n) "); fflush(stderr);
                    473:                                        fgets(buf,BUFSIZ,stdin);
                    474:                                        if ( !strncmp(buf,"y",1) ) {
                    475:                                                read_exec_file = 0;
                    476:                                                fprintf(stderr,"Bye\n"); asir_terminate(1);
                    477:                                        } else if ( !strncmp(buf,"n",1) ) {
                    478:                                                restore_handler();
                    479:                                                return;
                    480:                                        }
                    481:                                }
                    482:                                break;
                    483:                        case 't':
                    484:                        case 'u':
                    485:                                while ( 1 ) {
                    486:                                        fprintf(stderr,"Abort this computation? (y or n) "); fflush(stderr);
                    487:                                        fgets(buf,BUFSIZ,stdin);
                    488:                                        if ( !strncmp(buf,"y",1) )
                    489:                                                break;
                    490:                                        else if ( !strncmp(buf,"n",1) ) {
                    491:                                                restore_handler();
                    492:                                                return;
                    493:                                        }
                    494:                                }
                    495:                                if ( debug_mode )
                    496:                                        debug_mode = 0;
                    497:                                if ( kernelmode )
                    498:                                        fputc('\0',stderr);
                    499:                                restore_handler();
                    500:                                if ( c == 'u' ) {
                    501:                                        if ( registered_handler ) {
                    502:                                                fprintf(stderr,
                    503:                                                        "Calling the registered exception handler...");
                    504:                                                bevalf(registered_handler,0);
                    505:                                                fprintf(stderr, "done.\n");
                    506:                                        }
                    507:                                }
                    508:                                if ( read_exec_file ) {
                    509:                                        read_exec_file = 0;
                    510:                                        resetenv("initialization aborted; return to toplevel");
                    511:                                } else
                    512:                                        resetenv("return to toplevel");
                    513:                                break;
                    514:                        case 'd':
                    515: #if 0
                    516:                                nextbp = 1; nextbplevel = -1;
                    517: #endif
                    518:                                debug(PVSS?((VS)BDY(PVSS))->usrf->f.usrf->body:0);
                    519:                                restore_handler();
                    520:                                return;
                    521:                        case 'c':
                    522:                                if ( kernelmode )
                    523:                                        fputc('\0',stderr);
                    524:                                restore_handler();
                    525:                                return; break;
                    526:                        case 'w':
                    527:                                showpos(); break;
                    528:                        case '?':
                    529:                                fprintf(stderr, "q:quit t:toplevel c:continue d:debug u:call registered handler w:where\n");
                    530:                                break;
                    531:                        default:
                    532:                                break;
                    533:                }
                    534:        }
                    535: }
                    536:
                    537: void restore_handler() {
                    538: #if defined(THINK_C) || defined(VISUAL)
                    539:        resume_timer(); signal(SIGINT,int_handler);
                    540: #endif
                    541: #if defined(_PA_RISC1_1) || defined(linux) || defined(__svr4__)
                    542:        signal(SIGINT,int_handler);
                    543: #endif
                    544: }
                    545:
                    546: void segv_handler(sig)
                    547: int sig;
                    548: {
                    549: #if defined(THINK_C) || defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
                    550:        signal(SIGSEGV,segv_handler);
                    551: #endif
                    552:        error("internal error (SEGV)");
                    553: }
                    554:
                    555: void ill_handler(sig)
                    556: int sig;
                    557: {
                    558: #if defined(THINK_C) || defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
                    559:        signal(SIGILL,ill_handler);
                    560: #endif
                    561:        error("illegal instruction (ILL)");
                    562: }
                    563:
                    564: void alrm_handler(sig)
                    565: int sig;
                    566: {
                    567:        fprintf(stderr,"interval timer expired (VTALRM)\n");
                    568:        longjmp(timer_env,1);
                    569: }
                    570:
                    571: void bus_handler(sig)
                    572: int sig;
                    573: {
                    574: #if defined(SIGBUS)
                    575:        signal(SIGBUS,bus_handler);
                    576:        error("internal error (BUS ERROR)");
                    577: #endif
                    578: }
                    579:
                    580: void fpe_handler(sig)
                    581: int sig;
                    582: {
                    583: #if defined(THINK_C) || defined(_PA_RISC1_1) || defined(linux) || defined(VISUAL) || defined(__svr4__)
                    584:        signal(SIGFPE,fpe_handler);
                    585: #endif
                    586:        error("internal error (FPE)");
                    587: }
                    588:
                    589: void winch_handler(sig)
                    590: int sig;
                    591: {
                    592: #if 0
                    593: #if !defined(THINK_C) && !defined(VISUAL) && !defined(_PA_RISC1_1) && !defined(__svr4__)
                    594:        if ( isatty(1) ) {
                    595:                struct winsize t;
                    596:
                    597:                if ( ioctl(1,TIOCGWINSZ,&t) == -1 )
                    598:                        perror("TIOCGWINSZ");
                    599:                if ( t.ws_col != wsize.ws_col || t.ws_row != wsize.ws_row ) {
                    600:                        resize_buffer();
                    601:                        if ( killpg(getpgrp(0),SIGWINCH) == -1 )
                    602:                                perror("killpg");
                    603:                }
                    604:        }
                    605: #endif
                    606: #endif
                    607: }
                    608:
                    609: void pipe_handler(sig)
                    610: int sig;
                    611: {
                    612: #if defined(SIGPIPE)
                    613:        signal(SIGPIPE,pipe_handler);
                    614:        error("internal error (BROKEN PIPE)");
                    615: #endif
                    616: }
                    617:
                    618: void resize_buffer()
                    619: {
                    620: #if 0 && !defined(THINK_C) && !defined(VISUAL) && !defined(_PA_RISC1_1)
                    621:        if ( isatty(1) ) {
                    622:                if ( ioctl(1,TIOCGWINSZ,&wsize) == -1 )
                    623:                        perror("TIOCGWINSZ");
                    624:                if ( wsize.ws_col > 2 ) {
                    625:                        ttywidth = wsize.ws_col - 2;
                    626:                        upperbuf = (char *)MALLOC(wsize.ws_col);
                    627:                        lowerbuf = (char *)MALLOC(wsize.ws_col);
                    628:                }
                    629:        }
                    630: #endif
                    631: }
                    632:
                    633: void tty_init() {
                    634: #if 0 && !defined(THINK_C) && !defined(VISUAL) && !defined(_PA_RISC1_1)
                    635:        if ( isatty(0) ) {
                    636:                if ( ioctl(0,TIOCGETC,&tc) == -1 )
                    637:                        perror("TIOCGETC");
                    638:                oldeof = tc.t_eofc; tc.t_eofc = 0xff;
                    639:                if ( ioctl(0,TIOCSETC,&tc) == -1 )
                    640:                        perror("TIOCSETC");
                    641:                setpgrp(0, getpid());
                    642:        }
                    643:        resize_buffer();
                    644: #endif
                    645: }
                    646:
                    647: void tty_reset() {
                    648: #if 0 && !defined(THINK_C) && !defined(VISUAL) && !defined(_PA_RISC1_1)
                    649:        if ( oldeof ) {
                    650:                tc.t_eofc = oldeof;
                    651:                if ( ioctl(0,TIOCSETC,&tc) == -1 )
                    652:                        perror("TIOCSETC");
                    653:        }
                    654: #endif
                    655: }
                    656:
                    657: extern int evalstatline;
                    658:
                    659: void set_lasterror(s)
                    660: char *s;
                    661: {
                    662:        strncpy(LastError,s,BUFSIZ);
                    663:        LastError[BUFSIZ-1] = 0;
                    664: }
                    665:
                    666: SNODE error_snode;
                    667:
                    668: void error(s)
                    669: char *s;
                    670: {
                    671:        SNODE *snp;
                    672:
                    673:        fprintf(stderr,"%s\n",s);
                    674:        set_lasterror(s);
                    675:        if ( CPVS != GPVS ) {
1.7     ! noro      676:                if ( CPVS->usrf && CPVS->usrf && CPVS->usrf->f.usrf )
        !           677:                        searchsn(&BDY(CPVS->usrf->f.usrf),evalstatline,&snp);
1.6       noro      678:                if ( snp )
                    679:                        error_snode = *snp;
                    680:                else
                    681:                        error_snode = 0;
1.1       noro      682:        } else
                    683:                error_snode = 0;
                    684:        if ( do_file ) {
                    685:                char errbuf[BUFSIZ*5]; /* sufficient to store stack information ? */
                    686:
                    687:                sprintf(errbuf,"%s\n",s);
                    688:                showpos_to_string(errbuf+strlen(errbuf));
                    689:                set_lasterror(errbuf);
                    690:                ExitAsir();
                    691:        }
                    692:        if ( debug_mode )
                    693:                longjmp(debug_env,1);
                    694:        if ( CPVS != GPVS )
                    695:                if ( do_server_in_X11 || isatty(0) )
                    696:                        bp(error_snode);
                    697:        if ( read_exec_file )
                    698:                read_exec_file = 0;
                    699:        resetenv("return to toplevel");
                    700: }
                    701:
                    702: #if !defined(VISUAL)
                    703: #include <sys/time.h>
                    704:
                    705: void set_timer(interval)
                    706: int interval;
                    707: {
                    708:        struct itimerval it;
                    709:
                    710:        it.it_interval.tv_sec = interval;
                    711:        it.it_interval.tv_usec = 0;
                    712:        it.it_value.tv_sec = interval;
                    713:        it.it_value.tv_usec = 0;
                    714:        setitimer(ITIMER_VIRTUAL,&it,0);
                    715:        signal(SIGVTALRM,alrm_handler);
                    716: }
                    717:
                    718: void reset_timer()
                    719: {
                    720:        struct itimerval it;
                    721:
                    722:        it.it_interval.tv_sec = 0;
                    723:        it.it_interval.tv_usec = 0;
                    724:        it.it_value.tv_sec = 0;
                    725:        it.it_value.tv_usec = 0;
                    726:        setitimer(ITIMER_VIRTUAL,&it,0);
                    727:        signal(SIGVTALRM,SIG_IGN);
                    728: }
                    729: #endif
                    730:
                    731: unsigned int get_asir_version();
                    732:
                    733: void copyright() {
1.2       noro      734:        printf("This is Risa/Asir, Version %d.\n",get_asir_version());
1.1       noro      735:        printf("Copyright (C) FUJITSU LABORATORIES LIMITED.\n");
1.2       noro      736:        printf("1994-1999. All rights reserved.\n");
1.1       noro      737: }
1.5       noro      738:

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