From 71bc2c8f58712c4d9b8709a5039e735fb1844f71 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 25 Aug 2024 18:20:20 +0100 Subject: [PATCH] bugfix: remove newlines from debugger input (#1407) The "fd" command didn't work in the debugger. This was because the "d" was followed in the input buffer by \n rather than \0. The Windows version of console_get replaces the terminating \r with \0. amiberry's version uses fgets, which doesn't do this; it did adjust the length value returned, but the debugger code doesn't look at the length. Make it actually strip the newline characters when adjusting the length. --- src/osdep/writelog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/osdep/writelog.cpp b/src/osdep/writelog.cpp index 504eab64b..9961af9d3 100644 --- a/src/osdep/writelog.cpp +++ b/src/osdep/writelog.cpp @@ -409,7 +409,11 @@ int console_get (TCHAR *out, int maxlen) return -1; } int len = strlen(out); - return len - 1; + while (len > 0 && (out[len - 1] == '\r' || out[len - 1] == '\n')) { + out[len - 1] = 0; + len--; + } + return len; #endif }