Correct way to temporarily chop linebreak and generate debug output.

This commit is contained in:
Sven Geuer 2026-04-14 23:29:34 +02:00
parent b8c2189ff3
commit eb92cf8f11
No known key found for this signature in database
GPG key ID: ADF50EDAF8ADD585

19
io.c
View file

@ -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 );
}