about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--notemap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/notemap.c b/notemap.c
index 5f35794..c7f116f 100644
--- a/notemap.c
+++ b/notemap.c
@@ -246,14 +246,14 @@ static void append(
 
 	int ch;
 	int len = 0;
+	bool ws = false;
 	while (EOF != (ch = fgetc(note))) {
 		if (len == 76 && ch != '\n') {
 			fprintf(msg, "=\r\n");
 			len = 0;
 		}
 		if (ch == '\n') {
-			// TODO: Check if last character was space or tab.
-			fprintf(msg, "\r\n");
+			fprintf(msg, "%s\r\n", (ws ? "=\r\n" : ""));
 			len = 0;
 		} else if (ch == '\t' || (ch >= ' ' && ch <= '~' && ch != '=')) {
 			fprintf(msg, "%c", ch);
@@ -262,6 +262,7 @@ static void append(
 			fprintf(msg, "=%02X", ch);
 			len += 3;
 		}
+		ws = (ch == '\t' || ch == ' ');
 	}
 	if (ferror(note)) err(EX_IOERR, "%s", path);
 	fclose(note);