From eb92cf8f11e80a59c1712409584447ba8bada68d Mon Sep 17 00:00:00 2001 From: Sven Geuer <68420948@users.noreply.github.com> Date: Tue, 14 Apr 2026 23:29:34 +0200 Subject: [PATCH] Correct way to temporarily chop linebreak and generate debug output. --- io.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/io.c b/io.c index 49e76d2..d334f2f 100644 --- a/io.c +++ b/io.c @@ -56,12 +56,21 @@ int readline(PTSTREAM *pts) { *p = 0; if( args_info.verbose_flag ) { - /* Copy line of data into dstr without trailing newline */ - int len = strlen(buf); - buf[len - 2] = 0; - if (strcmp(buf, "")) + /* Move i to end of line, ignoring line break ('\n' or '\r\n') */ + if (i > 0) + if (buf[i-1] == '\n') { + i--; + if (i > 0) + if (buf[i-1] == '\r') + i--; + } + /* Output non-empty line, temporarily choping line break */ + if (i > 0) { + c = buf[i]; + buf[i] = '\0'; message( " <- %s\n", buf ); - buf[len - 2] = '\r'; + buf[i] = c; + } } return strlen( buf ); }