SDL_mixer: readsbk.c: change READSTR() macro into a procedure. (from timidity++).

From fc47a703fc3fc9886d43a1a3de091a45b28b557e Mon Sep 17 00:00:00 2001
From: sezero <[EMAIL REDACTED]>
Date: Thu, 31 Jul 2025 05:56:10 +0300
Subject: [PATCH] readsbk.c: change READSTR() macro into a procedure. (from
 timidity++).

---
 src/timidity/readsbk.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/timidity/readsbk.c b/src/timidity/readsbk.c
index d5f9cbec..b4fc2ccc 100644
--- a/src/timidity/readsbk.c
+++ b/src/timidity/readsbk.c
@@ -44,7 +44,18 @@ static int READW(Uint16 *vp, SDL_IOStream *io)
 	return 1;
 }
 
-#define READSTR(var,io)	SDL_ReadIO(io, var, 20)
+static int READSTR(char *str, SDL_IOStream *io)
+{
+	int n;
+	if (SDL_ReadIO(io, str, 20) != 20) return -1;
+	str[19] = '\0';
+	n = (int) SDL_strlen(str);
+	while (n > 0 && str[n - 1] == ' ')
+		n--;
+	str[n] = '\0';
+	return n;
+}
+
 #define READID(var,io)	SDL_ReadIO(io, var, 4)
 #define READB(var,io)	SDL_ReadIO(io, var, 1)
 #define SKIPB(io)	SDL_SeekIO(io, 1, SDL_IO_SEEK_CUR);