X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fsnprintb.c;h=655831c2e3a4e815dd1b1979fb7609d1f613e84a;hp=5f3f1243bc1967007ed551f5f273ac3a846269ed;hb=ced6090a330d3d83d0bce709f756aa3d7d65fea4;hpb=5dd6771b28c257af405d7248639ed0e3bcdce38b diff --git a/sbr/snprintb.c b/sbr/snprintb.c index 5f3f124..655831c 100644 --- a/sbr/snprintb.c +++ b/sbr/snprintb.c @@ -1,11 +1,10 @@ - /* - * 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. - */ +** 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 @@ -13,28 +12,27 @@ char * 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; }