]>
diplodocus.org Git - nmh/blob - sbr/snprintb.c
1 /* snprintb.c -- snprintf a %b string
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
12 snprintb (char *buffer
, size_t n
, unsigned v
, char *bits
)
18 snprintf (buffer
, n
, bits
&& *bits
== 010 ? "0%o" : "0x%x", v
);
23 if (bits
&& *++bits
) {
26 while ((i
= *bits
++) && n
> 1)
27 if (v
& (1 << (i
- 1))) {
32 for (; (c
= *bits
) > 32 && n
> 1; bits
++) {
38 for (; *bits
> 32; bits
++)