]> diplodocus.org Git - nmh/blobdiff - sbr/base64.c
popsbr.c: Alter traverse() to check action callback's result.
[nmh] / sbr / base64.c
index 8591384fbdcc4fb2f1e880d54d4e9b1c0f3e3970..8426fb2f3aa72c72e582891289cdb0c11a7a4bf4 100644 (file)
@@ -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;
         }
     }