Mercurial > hg > Applications > mh
view sbr/sprintb.c @ 3:f89a9a79e124
utf-8
author | kono |
---|---|
date | Wed, 20 Apr 2005 00:25:01 +0900 |
parents | bce86c4163a3 |
children | 441a2190cfae |
line wrap: on
line source
/* sprintb.c - sprintf a %b string */ #ifndef lint static char ident[] = "@(#)$Id$"; #endif /* lint */ #include "../h/mh.h" #include <stdio.h> char *sprintb (buffer, v, bits) register char *buffer, *bits; register unsigned v; { register int i, j; register char c, *bp; (void) sprintf (buffer, bits && *bits == 010 ? "0%o" : "0x%x", v); bp = buffer + strlen (buffer); if (bits && *++bits) { j = 0; *bp++ = '<'; while (i = *bits++) if (v & (1 << (i - 1))) { if (j++) *bp++ = ','; for (; (c = *bits) > 32; bits++) *bp++ = c; } else for (; *bits > 32; bits++) continue; *bp++ = '>'; *bp = 0; } return buffer; }