X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8a14191c0a0ad15bb8f35b49748c75c1e0a8c2f4..bb0b14bdb72ac3b3fbee4ba4ff4da0b7848089bf:/sbr/base64.c diff --git a/sbr/base64.c b/sbr/base64.c index 8591384f..8426fb2f 100644 --- a/sbr/base64.c +++ b/sbr/base64.c @@ -1,5 +1,4 @@ -/* - * base64.c -- routines for converting to base64 +/* base64.c -- routines for converting to base64 * * This code is Copyright (c) 2012, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -124,17 +123,16 @@ writeBase64 (const unsigned char *in, size_t length, unsigned char *out) for (cc = 0; length > 0 && cc < 3; ++cc, --length) /* empty */ ; - if (cc == 0) { + if (cc == 0) break; - } else { - bits = (in[0] & 0xff) << 16; - if (cc > 1) { - bits |= (in[1] & 0xff) << 8; - if (cc > 2) { - bits |= in[2] & 0xff; - } - } - } + + bits = (in[0] & 0xff) << 16; + if (cc > 1) { + bits |= (in[1] & 0xff) << 8; + if (cc > 2) { + bits |= in[2] & 0xff; + } + } for (bp = out + 4; bp > out; bits >>= 6) *--bp = nib2b64[bits & 0x3f]; @@ -177,17 +175,16 @@ writeBase64raw (const unsigned char *in, size_t length, unsigned char *out) for (cc = 0; length > 0 && cc < 3; ++cc, --length) /* empty */ ; - if (cc == 0) { + if (cc == 0) break; - } else { - bits = (in[0] & 0xff) << 16; - if (cc > 1) { - bits |= (in[1] & 0xff) << 8; - if (cc > 2) { - bits |= in[2] & 0xff; - } - } - } + + bits = (in[0] & 0xff) << 16; + if (cc > 1) { + bits |= (in[1] & 0xff) << 8; + if (cc > 2) { + bits |= in[2] & 0xff; + } + } for (bp = out + 4; bp > out; bits >>= 6) *--bp = nib2b64[bits & 0x3f]; @@ -301,12 +298,10 @@ test_end: break; case '=': - if (++skip > 3) { - self_delimiting = 1; - break; - } else { + if (++skip <= 3) goto test_end; - } + self_delimiting = 1; + break; } }