Annotation of 3BSD/cmd/adb/input.c, revision 1.1

1.1     ! root        1: #
        !             2: /*
        !             3:  *
        !             4:  *     UNIX debugger
        !             5:  *
        !             6:  */
        !             7: 
        !             8: #include "defs.h"
        !             9: SCCSID(@(#)input.c     2.2);
        !            10: 
        !            11: INT            mkfault;
        !            12: CHAR           line[LINSIZ];
        !            13: INT            infile;
        !            14: CHAR           *lp;
        !            15: CHAR           peekc,lastc = EOR;
        !            16: INT            eof;
        !            17: 
        !            18: /* input routines */
        !            19: 
        !            20: eol(c)
        !            21: CHAR   c;
        !            22: {
        !            23:        return(c==EOR ORF c==';');
        !            24: }
        !            25: 
        !            26: rdc()
        !            27: {      REP     readchar();
        !            28:        PER     lastc==SP ORF lastc==TB
        !            29:        DONE
        !            30:        return(lastc);
        !            31: }
        !            32: 
        !            33: readchar()
        !            34: {
        !            35:        IF eof
        !            36:        THEN    lastc=EOF;
        !            37:        ELSE    IF lp==0
        !            38:                THEN    lp=line;
        !            39: #ifdef EDDT
        !            40:                        getcon(lp); eof=0; while (*lp++!=EOR);
        !            41: #else
        !            42:                        REP eof = read(infile,lp,1)==0;
        !            43:                            IF mkfault THEN error(0); FI
        !            44:                        PER eof==0 ANDF *lp++!=EOR DONE
        !            45: #endif
        !            46:                        *lp=0; lp=line;
        !            47:                FI
        !            48:                IF lastc = peekc THEN peekc=0;
        !            49:                ELIF lastc = *lp THEN lp++;
        !            50:                FI
        !            51:        FI
        !            52:        return(lastc);
        !            53: }
        !            54: 
        !            55: nextchar()
        !            56: {
        !            57:        IF eol(rdc())
        !            58:        THEN lp--; return(0);
        !            59:        ELSE return(lastc);
        !            60:        FI
        !            61: }
        !            62: 
        !            63: quotchar()
        !            64: {
        !            65:        IF readchar()=='\\'
        !            66:        THEN    return(readchar());
        !            67:        ELIF lastc=='\''
        !            68:        THEN    return(0);
        !            69:        ELSE    return(lastc);
        !            70:        FI
        !            71: }
        !            72: 
        !            73: getformat(deformat)
        !            74: STRING         deformat;
        !            75: {
        !            76:        REG STRING      fptr;
        !            77:        REG BOOL        quote;
        !            78:        fptr=deformat; quote=FALSE;
        !            79:        WHILE (quote ? readchar()!=EOR : !eol(readchar()))
        !            80:        DO  IF (*fptr++ = lastc)=='"'
        !            81:            THEN quote = ~quote;
        !            82:            FI
        !            83:        OD
        !            84:        lp--;
        !            85:        IF fptr!=deformat THEN *fptr++ = '\0'; FI
        !            86: }
        !            87: 
        !            88: #ifdef EDDT
        !            89: getcon(cs) register char *cs; {
        !            90: register char *p=cs;
        !            91: for(;;) {
        !            92:        putchar(*p++=getcnsl());
        !            93:        if (p[-1]=='\r') {putchar(p[-1]='\n'); *p++='\0'; return;}
        !            94:        if (p[-1]=='\\') {p[-1]=getcnsl(); continue;}
        !            95:        if (p[-1]=='#') {p -= 2; continue;}
        !            96:        if (p[-1]=='@') {putchar('\r'); putchar('\n'); p=cs; continue;}
        !            97: }}
        !            98:  
        !            99: getcnsl() {
        !           100: # define RXCS  32  /*  receiver control/staus */
        !           101: # define RXDB  33  /*  receiver data */
        !           102: # define RXCS_DONE  0x80  /*  receiver done */
        !           103: while ((mfpr(RXCS) & RXCS_DONE)==0);
        !           104: return (mfpr(RXDB) & 0177);
        !           105: }
        !           106: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.