]> diplodocus.org Git - nmh/blobdiff - sbr/encode_rfc2047.c
uip: Replace some ints that are only ever 0 or 1 with bool.
[nmh] / sbr / encode_rfc2047.c
index 238882dc2cbd6998c1499260593a819632cb6239..e7ccd308ab0bd962be121558a90948742bb0ddb4 100644 (file)
@@ -9,6 +9,8 @@
 #include <h/mhparse.h>
 #include <h/addrsbr.h>
 #include <h/utils.h>
+#include "base64.h"
+#include "unquote.h"
 
 /*
  * List of headers that contain addresses and as a result require special
@@ -158,7 +160,7 @@ static int
 field_encode_quoted(const char *name, char **value, const char *charset,
                    int ascii, int encoded, int phraserules)
 {
-    int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column, newline = 1;
+    int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column;
     int charsetlen = strlen(charset), utf8;
     char *output = NULL, *p, *q = NULL;
 
@@ -173,6 +175,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
 
     utf8 = strcasecmp(charset, "UTF-8") == 0;
 
+    bool newline = true;
     while (*p != '\0') {
        /*
         * Start a new line, if it's time
@@ -223,7 +226,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
            tokenlen = snprintf(q, outlen - (q - output), "=?%s?Q?", charset);
            q += tokenlen;
            column = prefixlen + tokenlen;
-           newline = 0;
+           newline = false;
        }
 
        /*
@@ -264,7 +267,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
            continue;
 
        if (column >= ENCODELINELIMIT - 2) {
-           newline = 1;
+           newline = true;
        } else if (utf8) {
            /*
             * Okay, this is a bit weird, but to explain a bit more ...
@@ -280,7 +283,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
             * allow for the encoded output.
             */
            if (column + (utf8len(p) * 3) > ENCODELINELIMIT - 2) {
-               newline = 1;
+               newline = true;
            }
        }
     }
@@ -797,8 +800,8 @@ do_reformat:
     output = NULL;
 
 out:
-    mh_xfree(tmpbuf);
-    mh_xfree(output);
+    free(tmpbuf);
+    free(output);
 
     return errflag > 0;
 }