Annotation of researchv9/cmd/adb/comm/input.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *
                      3:  *     UNIX debugger
                      4:  *
                      5:  */
                      6: 
                      7: #include "defs.h"
                      8: 
                      9: char   line[LINSIZ];
                     10: extern int     infile;
                     11: char   *lp;
                     12: char   peekc,lastc = EOR;
                     13: int    eof;
                     14: 
                     15: /* input routines */
                     16: 
                     17: eol(c)
                     18: char   c;
                     19: {
                     20:        return(c==EOR || c==';');
                     21: }
                     22: 
                     23: int
                     24: rdc()
                     25: {
                     26:        do {
                     27:                readchar();
                     28:        } while (lastc==SPC || lastc==TB);
                     29:        return(lastc);
                     30: }
                     31: 
                     32: reread()
                     33: {
                     34:        peekc = lastc;
                     35: }
                     36: 
                     37: clrinp()
                     38: {
                     39: 
                     40:        lp = 0;
                     41:        peekc = 0;
                     42: }
                     43: 
                     44: int
                     45: readchar()
                     46: {
                     47:        register char *p;
                     48:        if (eof)
                     49:                lastc=0;
                     50:        else if (peekc) {
                     51:                lastc = peekc;
                     52:                peekc = 0;
                     53:        }
                     54:        else {
                     55:                if (lp==0) {
                     56:                        for (p = line; p < &line[LINSIZ-1]; p++) {
                     57:                                eof = read(infile, p, 1) <= 0;
                     58:                                if (mkfault) {
                     59:                                        eof = 0;
                     60:                                        error(0);
                     61:                                }
                     62:                                if (eof) {
                     63:                                        p--;
                     64:                                        break;
                     65:                                }
                     66:                                if (*p == EOR) {
                     67:                                        if (p <= line)
                     68:                                                break;
                     69:                                        if (p[-1] != '\\')
                     70:                                                break;
                     71:                                        p -= 2;
                     72:                                }
                     73:                        }
                     74:                        *++p = 0;
                     75:                        lp = line;
                     76:                }
                     77:                if ((lastc = *lp) != 0)
                     78:                        lp++;
                     79:        }
                     80:        return(lastc);
                     81: }
                     82: 
                     83: nextchar()
                     84: {
                     85:        if (eol(rdc())) {
                     86:                reread();
                     87:                return(0);
                     88:        }
                     89:        return(lastc);
                     90: }
                     91: 
                     92: quotchar()
                     93: {
                     94:        if (readchar()=='\\')
                     95:                return(readchar());
                     96:        else if (lastc=='\'')
                     97:                return(0);
                     98:        else
                     99:                return(lastc);
                    100: }
                    101: 
                    102: getformat(deformat)
                    103: char *deformat;
                    104: {
                    105:        register char *fptr;
                    106:        register BOOL   quote;
                    107: 
                    108:        fptr=deformat;
                    109:        quote=FALSE;
                    110:        while ((quote ? readchar()!=EOR : !eol(readchar())))
                    111:                if ((*fptr++ = lastc)=='"')
                    112:                        quote = ~quote;
                    113:        lp--;
                    114:        if (fptr!=deformat)
                    115:                *fptr = '\0';
                    116: }

unix.superglobalmegacorp.com

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