X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fsnprintb.c;h=baab61f4bc2ed026ff7cefbb4cd743b4be9528d4;hb=18017df38ebb626f6eed6f339641fd1298c326e7;hp=558c2cf8f591d047e04288f76d2919c57663a4bc;hpb=6c42153ad9362cc676ea66563bf400d7511b3b68;p=mmh diff --git a/sbr/snprintb.c b/sbr/snprintb.c index 558c2cf..baab61f 100644 --- a/sbr/snprintb.c +++ b/sbr/snprintb.c @@ -1,9 +1,6 @@ - /* * snprintb.c -- snprintf a %b string * - * $Id$ - * * 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. @@ -15,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; }