From 41a259df6be6dc7d9c22071824ecbc25a34f27e8 Mon Sep 17 00:00:00 2001 From: decomp worker 3 Date: Fri, 2 Oct 2026 15:15:35 -0500 Subject: [PATCH] match(wprintf 9/9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __wpformatter → 100%: drop wideLength temp; narrow #s length via *buff_ptr (MSL stale-pointer form used by matched TP/SS sources). DOL 26116613… --- libs/MSL/src/MSL_Common/wprintf.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libs/MSL/src/MSL_Common/wprintf.c b/libs/MSL/src/MSL_Common/wprintf.c index 331c0022..2d639bd3 100644 --- a/libs/MSL/src/MSL_Common/wprintf.c +++ b/libs/MSL/src/MSL_Common/wprintf.c @@ -1120,32 +1120,28 @@ static int __wpformatter(void* (*write_proc)(void*, const wchar_t*, size_t), case 's': if (format.argument_options == wchar_argument) { wchar_t* wcs_ptr = va_arg(args, wchar_t*); - int wideLength; if (wcs_ptr == NULL) { wcs_ptr = L""; } if (format.alternate_form) { - wchar_t first = *wcs_ptr++; - wideLength = (unsigned char)first; + num_chars = (unsigned char)*wcs_ptr++; - if (format.precision_specified && wideLength > format.precision) { - wideLength = format.precision; + if (format.precision_specified && num_chars > format.precision) { + num_chars = format.precision; } } else if (format.precision_specified) { - wideLength = format.precision; + num_chars = format.precision; - if ((string_end = wmemchr((wchar_t*)wcs_ptr, 0, wideLength)) != 0) { - wideLength = string_end - wcs_ptr; + if ((string_end = wmemchr(wcs_ptr, 0, num_chars)) != 0) { + num_chars = string_end - wcs_ptr; } } else { - wideLength = wcslen(wcs_ptr); + num_chars = wcslen(wcs_ptr); } - num_chars = wideLength; - buff_ptr = wcs_ptr; break; } else { @@ -1156,7 +1152,7 @@ static int __wpformatter(void* (*write_proc)(void*, const wchar_t*, size_t), } if (format.alternate_form) { - num_chars = (unsigned char)*(const wchar_t*)wcs_ptr; + num_chars = (unsigned char)*buff_ptr; if (format.precision_specified && num_chars > format.precision) { num_chars = format.precision; -- 2.49.1