diff options
author | June McEnroe <june@causal.agency> | 2020-01-27 15:59:46 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-01-27 15:59:46 -0500 |
commit | a0c11b5432eed2d7bfc24f489425b030b5346bfc (patch) | |
tree | 0931d5b16e9ead764b57f7f90813ad7ab53eca60 | |
parent | Skip notes not listed in args (diff) | |
download | notemap-a0c11b5432eed2d7bfc24f489425b030b5346bfc.tar.gz notemap-a0c11b5432eed2d7bfc24f489425b030b5346bfc.zip |
Encode trailing whitespace in quote-printable properly
-rw-r--r-- | notemap.c | 5 |
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); |