2 ** snprintb.c -- snprintf a %b string
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
13 snprintb(char *buffer, size_t n, unsigned v, char *bits)
18 snprintf(buffer, n, bits && *bits == 010 ? "0%o" : "0x%x", v);
19 bp = buffer + strlen(buffer);
21 if (bits && *++bits) {
25 if (v & (1 << (i - 1))) {
28 for (; (c = *bits) > 32; bits++)
31 for (; *bits > 32; bits++)