From ae894ca4024fd8d58fa535c88e017af32866bf5b Mon Sep 17 00:00:00 2001 From: Stephen Lane-Walsh Date: Tue, 9 Dec 2025 16:19:16 -0500 Subject: [PATCH] Fix: READ() removing last character of file When a file does not end with a newline, READ() erroneously strips off the last character of the last line. This simply checks that it is a newline before removing it. --- tdishr/TdiIo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tdishr/TdiIo.c b/tdishr/TdiIo.c index 3df35d0059..9d3b4276cb 100644 --- a/tdishr/TdiIo.c +++ b/tdishr/TdiIo.c @@ -436,7 +436,10 @@ int Tdi1Read(opcode_t opcode __attribute__((unused)), ans = fgets(line, sizeof(line), unit); if (ans) { - line_d.length = strlen(line) - 1; + line_d.length = strlen(line); + if (line_d.length > 0 && line[line_d.length - 1] == '\n') { + --line_d.length; + } line_d.pointer = line; status = MdsCopyDxXd(&line_d, out_ptr); }