Annotation of 43BSDReno/sys/kdb/Old/kdb_input.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1986 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  *
        !             6:  *     @(#)kdb_input.c 7.4 (Berkeley) 9/6/89
        !             7:  */
        !             8: 
        !             9: #include "../kdb/defs.h"
        !            10: 
        !            11: char   line[LINSIZ];
        !            12: char   *lp;
        !            13: char   peekc,lastc = EOR;
        !            14: 
        !            15: /* input routines */
        !            16: 
        !            17: eol(c)
        !            18:        char c;
        !            19: {
        !            20:        return (c==EOR || c==';');
        !            21: }
        !            22: 
        !            23: rdc()
        !            24: {
        !            25:        do
        !            26:                (void) readchar();
        !            27:        while (lastc==SP || lastc==TB);
        !            28:        return (lastc);
        !            29: }
        !            30: 
        !            31: readchar()
        !            32: {
        !            33:        static char *erase = "\b \b";
        !            34: 
        !            35:        if (lp==0) {
        !            36:                lp=line;
        !            37:                do {
        !            38:                        (void) kdbreadc(lp);
        !            39:                        if (mkfault)
        !            40:                                error((char *)0);
        !            41:                        switch (*lp) {
        !            42:                        case CTRL('h'): case 0177:
        !            43:                                if (lp > line)
        !            44:                                        kdbwrite(erase, 3), lp--;
        !            45:                                break;
        !            46:                        case CTRL('u'):
        !            47:                                while (lp > line) 
        !            48:                                        kdbwrite(erase, 3), lp--;
        !            49:                                break;
        !            50:                        case CTRL('r'):
        !            51:                                kdbwrite("^R\n", 3);
        !            52:                                if (lp > line)
        !            53:                                        kdbwrite(line, lp-line);
        !            54:                                break;
        !            55:                        case CTRL('w'):
        !            56:                                if (lp <= line)
        !            57:                                        break;
        !            58:                                do {
        !            59:                                        if (!isspace(*lp))
        !            60:                                                goto erasenb;
        !            61:                                        kdbwrite(erase, 3);
        !            62:                                } while (--lp > line);
        !            63:                                break;
        !            64:                        erasenb:
        !            65:                                do
        !            66:                                        kdbwrite(erase, 3);
        !            67:                                while (--lp > line && !isspace(*lp));
        !            68:                                break;
        !            69:                        default:
        !            70:                                echo(*lp++);
        !            71:                                break;
        !            72:                        }
        !            73:                } while (lp == line || lp[-1] != EOR);
        !            74:                *lp=0; lp=line;
        !            75:        }
        !            76:        if (lastc = peekc)
        !            77:                peekc=0;
        !            78:        else  if (lastc = *lp)
        !            79:                lp++;
        !            80:        return (lastc);
        !            81: }
        !            82: 
        !            83: static
        !            84: echo(c)
        !            85:        char c;
        !            86: {
        !            87:        char buf[2];
        !            88: 
        !            89:        if (c==0177 || (c<SP && c != TB && c != EOR)) {
        !            90:                buf[0] = '^';
        !            91:                buf[1] = c ^ 0100;
        !            92:                kdbwrite(buf, 2);
        !            93:        } else
        !            94:                kdbwrite(&c, 1);
        !            95: }
        !            96: 
        !            97: nextchar()
        !            98: {
        !            99: 
        !           100:        if (eol(rdc())) {
        !           101:                lp--;
        !           102:                return (0);
        !           103:        }
        !           104:        return (lastc);
        !           105: }
        !           106: 
        !           107: quotchar()
        !           108: {
        !           109: 
        !           110:        if (readchar()=='\\')
        !           111:                return (readchar());
        !           112:        if (lastc=='\'')
        !           113:                return (0);
        !           114:        return (lastc);
        !           115: }
        !           116: 
        !           117: getformat(deformat)
        !           118:        char *deformat;
        !           119: {
        !           120:        register char *fptr;
        !           121:        register int quote;
        !           122: 
        !           123:        fptr=deformat; quote=0;
        !           124:        while ((quote ? readchar()!=EOR : !eol(readchar())))
        !           125:                if ((*fptr++ = lastc)=='"')
        !           126:                        quote = ~quote;
        !           127:        lp--;
        !           128:        if (fptr!=deformat)
        !           129:                *fptr++ = '\0';
        !           130: }

unix.superglobalmegacorp.com

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