hputchar: fix flag to reset hadnewline and improve comments - webdump - HTML to plain-text converter for webpages (HTM) git clone git://git.codemadness.org/webdump (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 9f4c3a0a47eb2bb127db5a270dfa27ad368deb6a (DIR) parent a75a21256774e9ccda82f79ad7989f44bfa81e6a (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Mon, 11 Sep 2023 19:01:30 +0200 hputchar: fix flag to reset hadnewline and improve comments This flag is an extra safety, it can probably be removed. Diffstat: M webdump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- (DIR) diff --git a/webdump.c b/webdump.c @@ -701,6 +701,7 @@ printansi(const char *s) if (rbuflen + len + 1 < sizeof(rbuf)) { memcpy(rbuf + rbuflen, s, len); rbuflen += len; + /* NOTE: nbytesline and ncells are not counted for markup */ } } else { fputs(s, stdout); @@ -791,7 +792,8 @@ hputchar(int c) cur->hasdata = 1; if (c == '\n') { - if (nbytesline <= 0) + /* previous line had characters, so not a repeated newline */ + if (nbytesline > 0) hadnewline = 0; /* start a new line, no chars on this line yet */