Annotation of 41BSD/cmd/csh/sh.print.c, revision 1.1

1.1     ! root        1: static char *sccsid = "@(#)sh.print.c 4.1 10/9/80";
        !             2: 
        !             3: #include "sh.h"
        !             4: 
        !             5: /*
        !             6:  * C Shell
        !             7:  */
        !             8: 
        !             9: p60ths(l)
        !            10:        long l;
        !            11: {
        !            12: 
        !            13:        l += 3;
        !            14:        printf("%d.%d", (int) (l / 60), (int) ((l % 60) / 6));
        !            15: }
        !            16: 
        !            17: psecs(l)
        !            18:        long l;
        !            19: {
        !            20:        register int i;
        !            21: 
        !            22:        i = l / 3600;
        !            23:        if (i) {
        !            24:                printf("%d:", i);
        !            25:                i = l % 3600;
        !            26:                p2dig(i / 60);
        !            27:                goto minsec;
        !            28:        }
        !            29:        i = l;
        !            30:        printf("%d", i / 60);
        !            31: minsec:
        !            32:        i %= 60;
        !            33:        printf(":");
        !            34:        p2dig(i);
        !            35: }
        !            36: 
        !            37: p2dig(i)
        !            38:        register int i;
        !            39: {
        !            40: 
        !            41:        printf("%d%d", i / 10, i % 10);
        !            42: }
        !            43: 
        !            44: char   linbuf[128];
        !            45: char   *linp = linbuf;
        !            46: 
        !            47: putchar(c)
        !            48:        register int c;
        !            49: {
        !            50: 
        !            51:        if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) {
        !            52:                putchar('^');
        !            53:                if (c == 0177)
        !            54:                        c = '?';
        !            55:                else
        !            56:                        c |= 'A' - 1;
        !            57:        }
        !            58:        c &= TRIM;
        !            59:        *linp++ = c;
        !            60:        if (c == '\n' || linp >= &linbuf[sizeof linbuf - 2])
        !            61:                flush();
        !            62: }
        !            63: 
        !            64: draino()
        !            65: {
        !            66: 
        !            67:        linp = linbuf;
        !            68: }
        !            69: 
        !            70: flush()
        !            71: {
        !            72:        register int unit;
        !            73:        int lmode = 0;
        !            74: 
        !            75: #include <sys/ioctl.h>
        !            76: 
        !            77:        if (linp == linbuf)
        !            78:                return;
        !            79:        if (haderr)
        !            80:                unit = didfds ? 2 : SHDIAG;
        !            81:        else
        !            82:                unit = didfds ? 1 : SHOUT;
        !            83: #ifdef TIOCLGET
        !            84:        if (didfds==0 && ioctl(unit, TIOCLGET, &lmode)==0 &&
        !            85:            lmode & LFLUSHO) {
        !            86:                lmode = LFLUSHO;
        !            87:                ioctl(unit, TIOCLBIC, &lmode);
        !            88:                write(unit, "\n", 1);
        !            89:        }
        !            90: #endif
        !            91:        write(unit, linbuf, linp - linbuf);
        !            92:        linp = linbuf;
        !            93: }
        !            94: 
        !            95: plist(vp)
        !            96:        register struct varent *vp;
        !            97: {
        !            98: 
        !            99:        if (setintr)
        !           100:                sigrelse(SIGINT);
        !           101:        for (vp = vp->link; vp != 0; vp = vp->link) {
        !           102:                int len = blklen(vp->vec);
        !           103: 
        !           104:                printf(vp->name);
        !           105:                printf("\t");
        !           106:                if (len != 1)
        !           107:                        putchar('(');
        !           108:                blkpr(vp->vec);
        !           109:                if (len != 1)
        !           110:                        putchar(')');
        !           111:                printf("\n");
        !           112:        }
        !           113:        if (setintr)
        !           114:                sigrelse(SIGINT);
        !           115: }

unix.superglobalmegacorp.com

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