X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fsnprintb.c;h=ce7bf8acda74f77f7efc3ef1ea379a5ecdf594ae;hb=e1b2a81e2b5f77605973a47734a895cd3e83b73c;hp=06140c8fb53c5b02dd7b2594ea913e60e23d3529;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b;p=mmh diff --git a/sbr/snprintb.c b/sbr/snprintb.c index 06140c8..ce7bf8a 100644 --- a/sbr/snprintb.c +++ b/sbr/snprintb.c @@ -1,38 +1,38 @@ - /* - * snprintb.c -- snprintf a %b string - * - * $Id$ - */ +** snprintb.c -- snprintf a %b string +** +** This code is Copyright (c) 2002, by the authors of nmh. See the +** COPYRIGHT file in the root directory of the nmh distribution for +** complete copyright information. +*/ #include char * -snprintb (char *buffer, size_t n, unsigned v, char *bits) +snprintb(char *buffer, size_t n, unsigned v, char *bits) { - register int i, j; - register char c, *bp; + register int i, j; + register char c, *bp; - snprintf (buffer, n, bits && *bits == 010 ? "0%o" : "0x%x", v); - bp = buffer + strlen(buffer); + snprintf(buffer, n, 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; - } + 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; + return buffer; }