* everything down and push the last character back.
*/
if (i == cc - 1) {
- ungetc('\n', in);
+ /*
+ * If we're at the end of the input, there might be
+ * more room in inbuf; if so, add it there. Otherwise
+ * push it back to the input.
+ */
+ if (cc < sizeof(inbuf))
+ inbuf[cc++] = '\n';
+ else
+ ungetc('\n', in);
skipnl = 1;
} else {
/* This only works as long as sizeof(inbuf) == 3 */
EOF
#
-# Force some text to be base64
+# Force some text to be base64, to test out the encoder. Try at different
+# line lengths to check out the padding on the
#
cat > "$draft" <<EOF
check "$draft" "$expected"
+cat > "$draft" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+------
+#<text/plain *b64
+This is a test of a mëssage with a shørt line.
+EOF
+
+run_prog mhbuild "$draft"
+
+cat > "$expected" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+MIME-Version: 1.0
+Content-Type: text/plain; charset="UTF-8"
+Content-Transfer-Encoding: base64
+
+VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
+EOF
+
+check "$draft" "$expected"
+
exit ${failed:-0}