Mercurial > hg > Applications > mh
view sbr/sprintb.c @ 17:76d91e545ea8 default tip
addrsbr and dtimep fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 Nov 2014 14:49:25 +0900 |
parents | 441a2190cfae |
children |
line wrap: on
line source
/* sprintb.c - sprintf a %b string */ #ifndef lint static char ident[] = "@(#)$Id: sprintb.c,v 1.1.1.1 2005/04/18 14:46:06 kono Exp $"; #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; }