]>
diplodocus.org Git - nmh/blob - sbr/snprintb.c
3 * snprintb.c -- snprintf a %b string
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
16 snprintb (char *buffer
, size_t n
, unsigned v
, char *bits
)
21 snprintf (buffer
, n
, bits
&& *bits
== 010 ? "0%o" : "0x%x", v
);
22 bp
= buffer
+ strlen(buffer
);
24 if (bits
&& *++bits
) {
28 if (v
& (1 << (i
- 1))) {
31 for (; (c
= *bits
) > 32; bits
++)
35 for (; *bits
> 32; bits
++)