Annotation of researchv8dc/cmd/qed/putchar.c, revision 1.1.1.1

1.1       root        1: /*% cc -c -O %
                      2:  */
                      3: #include "vars.h"
                      4: #ifdef PDP11
                      5: typedef        long ulong;
                      6: #else
                      7: typedef        unsigned long ulong;
                      8: #endif
                      9: int    col;
                     10: putdn(i)
                     11: {
                     12:        putlong((ulong)i);
                     13:        putchar('\n');
                     14: }
                     15: #ifdef PDP11
                     16: /*
                     17:  *     In version 6, ldiv() is in the library. In version 7, it is separate:
                     18:        .globl  _ldiv, _ldivr
                     19:        _ldiv:
                     20:                mov     2(sp), r0
                     21:                mov     4(sp), r1
                     22:                div     6(sp), r0
                     23:                mov     r1,_ldivr
                     24:                rts     pc
                     25:        .bss
                     26:        _ldivr: .=.+2
                     27:  */
                     28: putlong(i)
                     29:        long i;
                     30: {
                     31:        register char r;
                     32:        extern int ldiv(), ldivr;
                     33: 
                     34:        /* the following pornography saves bundles of memory */
                     35:        i = ldiv(i,10);
                     36:        r = ldivr + '0';
                     37:        if (i)
                     38:                putlong(i);
                     39:        putchar(r);
                     40: }
                     41: #endif
                     42: #ifndef        PDP11
                     43: putlong(i)
                     44:        ulong i;
                     45: {
                     46:        register r;
                     47:        r = i%10;
                     48:        i /= 10;
                     49:        if(i)
                     50:                putlong(i);
                     51:        putchar('0'+r);
                     52: }
                     53: #endif
                     54: putl(sp)
                     55:        register char *sp;
                     56: {
                     57:        listf++;
                     58:        puts(sp);
                     59:        listf = FALSE;
                     60: }
                     61: puts(sp)
                     62:        register char *sp;
                     63: {
                     64:        col = 0;
                     65:        while (*sp)
                     66:                putchar(*sp++);
                     67:        putchar('\n');
                     68: }
                     69: display(lf)
                     70: {
                     71:        register int *a1;
                     72:        register int r;
                     73:        register char *p;
                     74:        register i;
                     75:        int nf;
                     76:        listf = (lf == 'l' || lf == 'L');
                     77:        nf = (lf == 'P' || lf == 'L');
                     78:        lf = listf;
                     79:        setdot();
                     80:        nonzero();
                     81:        a1 = addr1;
                     82:        r = (a1 - zero) & 077777;
                     83:        do{
                     84:                col = 0;
                     85:                if(nf){
                     86:                        putlong((ulong)r++);
                     87:                        for(i=0; i<NBUFS; i++)
                     88:                                if((*a1|01) == names[i]){
                     89:                                        putchar('\'');
                     90:                                        putchar(bname[i]);
                     91:                                }
                     92:                        listf = 0;
                     93:                        putchar('\t');
                     94:                        col = 8;
                     95:                        listf = lf;
                     96:                }
                     97:                for(p = getline(*a1++,linebuf);*p;putchar(*p++));
                     98:                putchar('\n');
                     99:        }while (a1 <= addr2);
                    100:        dot = addr2;
                    101:        listf = FALSE;
                    102: }
                    103: putct(c){
                    104:        putchar(c);
                    105:        putchar('\t');
                    106: }
                    107: putchar(c)
                    108: register char c;
                    109: {
                    110:        register char *lp;
                    111: 
                    112:        lp = linp;
                    113:        if (listf) {
                    114:                if (c=='\n') {
                    115:                        if(linp!=line && linp[-1]==' ') {
                    116:                                *lp++ = '\\';
                    117:                                *lp++ = 'n';
                    118:                        }
                    119:                } else {
                    120:                        if (col >= (72-4-2)) {
                    121:                                *lp++ = '\\';
                    122:                                *lp++ = '\n';
                    123:                                *lp++ = '\t';
                    124:                                col = 8;
                    125:                        }
                    126:                        col++;
                    127:                        if (c=='\b' || c=='\\' || c=='\t') {
                    128:                                *lp++ = '\\';
                    129:                                c = c=='\b'? 'b' : c=='\t'? 't' : '\\';
                    130:                                col++;
                    131:                        } else if ((c&0200) || c<' ' || c=='\177') {
                    132:                                *lp++ = '\\';
                    133:                                *lp++ = ((c>>6)&03)+'0';
                    134:                                *lp++ = ((c>>3)&07)+'0';
                    135:                                c     = ( c    &07)+'0';
                    136:                                col += 3;
                    137:                        }
                    138:                }
                    139:        }
                    140:        *lp++ = c;
                    141:        if(c == '\n' || lp >= &line[(sizeof line)-2-4]) {
                    142:                linp = lp;
                    143:                flush();
                    144:                lp = linp;
                    145:        }
                    146:        linp = lp;
                    147: }
                    148: flush()
                    149: {
                    150:        if(linp != line){
                    151:                write(1, line, linp-line);
                    152:                linp = line;
                    153:        }
                    154: }

unix.superglobalmegacorp.com

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