fix escape regression in gphtextnl() and simplify the code - stagit-gopher - A git gopher frontend. (mirror) HTML git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit f3d448a743143b22dcb9ab7e20dc16149d55907b DIR parent b5cdcadb391b8f27bced0273013ae5ba2189cde9 HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Sat, 27 Jan 2018 16:24:38 +0100 fix escape regression in gphtextnl() and simplify the code Thanks Christoph for the report! Diffstat: M stagit-gopher.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- DIR diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -299,21 +299,16 @@ gphtextnl(FILE *fp, const char *s, size_t len) size_t i, n = 0; for (i = 0; s[i] && i < len; i++) { - if (s[i] == '\n') - n = 0; - /* escape with 't' at the start of a line */ - if (!n && (s[i] == 't' || s[i] == '[')) { + if (!n && (s[i] == 't' || s[i] == '[')) fputc('t', fp); - n = 1; - } switch (s[i]) { + case '\t': fputs(" ", fp); case '\r': break; - case '\t': fputs(" ", fp); break; default: fputc(s[i], fp); } - n++; + n = (s[i] != '\n'); } }