Annotation of 43BSDReno/contrib/mh/sbr/sprintb.c, revision 1.1

1.1     ! root        1: /* sprintb.c - sprintf a %b string */
        !             2: 
        !             3: #include "../h/mh.h"
        !             4: #include <stdio.h>
        !             5: 
        !             6: 
        !             7: char   *sprintb (buffer, v, bits)
        !             8: register char  *buffer,
        !             9:                *bits;
        !            10: register unsigned   v;
        !            11: {
        !            12:     register int    i,
        !            13:                     j;
        !            14:     register char   c,
        !            15:                    *bp;
        !            16: 
        !            17:     (void) sprintf (buffer, bits && *bits == 010 ? "0%o" : "0x%x", v);
        !            18:     bp = buffer + strlen (buffer);
        !            19: 
        !            20:     if (bits && *++bits) {
        !            21:        j = 0;
        !            22:        *bp++ = '<';
        !            23:        while (i = *bits++)
        !            24:            if (v & (1 << (i - 1))) {
        !            25:                if (j++)
        !            26:                    *bp++ = ',';
        !            27:                for (; (c = *bits) > 32; bits++)
        !            28:                    *bp++ = c;
        !            29:            }
        !            30:            else
        !            31:                for (; *bits > 32; bits++)
        !            32:                    continue;
        !            33:        *bp++ = '>';
        !            34:        *bp = NULL;
        !            35:     }
        !            36: 
        !            37:     return buffer;
        !            38: }

unix.superglobalmegacorp.com

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