commit f3d448a743143b22dcb9ab7e20dc16149d55907b
parent b5cdcadb391b8f27bced0273013ae5ba2189cde9
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:
1 file changed, 3 insertions(+), 8 deletions(-)
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');
}
}