Annotation of researchv10no/cmd/adb/null/mchio.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * read or print machine-dependent data structures
        !             3:  * generic non-cross-machine version
        !             4:  */
        !             5: 
        !             6: #include "defs.h"
        !             7: 
        !             8: /*
        !             9:  * read an ASCII expression
        !            10:  */
        !            11: 
        !            12: extern char lastc;
        !            13: 
        !            14: WORD
        !            15: ascval()
        !            16: {
        !            17:        long l;
        !            18:        register char *p;
        !            19:        register int i;
        !            20: 
        !            21:        l = 0;
        !            22:        p = (char *)&l;
        !            23:        i = sizeof(l);
        !            24:        while (quotchar()) {
        !            25:                if (--i >= 0)
        !            26:                        *p++ = lastc;
        !            27:        }
        !            28:        return ((WORD)l);
        !            29: }
        !            30: 
        !            31: /*
        !            32:  * read a floating point number
        !            33:  * the result must fit in a WORD
        !            34:  */
        !            35: 
        !            36: WORD
        !            37: fpin(buf)
        !            38: char *buf;
        !            39: {
        !            40:        union {
        !            41:                WORD w;
        !            42:                float f;
        !            43:        } x;
        !            44:        double atof();
        !            45: 
        !            46:        x.f = atof(buf);
        !            47:        return (x.w);
        !            48: }
        !            49: 
        !            50: /*
        !            51:  * print a floating point number
        !            52:  */
        !            53: 
        !            54: #define        FPWID   32
        !            55: 
        !            56: fpout(flag, va)
        !            57: char flag;
        !            58: char *va;
        !            59: {
        !            60:        char buf[FPWID+1];
        !            61:        char *gcvt();
        !            62: 
        !            63:        if (flag == 'f')
        !            64:                printf("%-16s", gcvt((double)*(float *)va, 9, buf));
        !            65:        else
        !            66:                printf("%-32s", gcvt(*(double *)va, 18, buf));
        !            67: }
        !            68: 
        !            69: /*
        !            70:  * print a date
        !            71:  */
        !            72: 
        !            73: printdate(tvec)
        !            74: WORD tvec;
        !            75: {
        !            76:        char *p;
        !            77:        char *ctime();
        !            78: 
        !            79:        p = ctime((long *)&tvec);
        !            80:        p[strlen(p)-1] = 0;             /* stomp on newline */
        !            81:        printf("%-25s", p);
        !            82: }

unix.superglobalmegacorp.com

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