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: }

Defined functions

sprintb defined in line 7; used 1 times
Last modified: 1985-09-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 736
Valid CSS Valid XHTML 1.0 Strict