summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-11-12 16:43:57 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-11-12 16:43:57 +0100
commit1e0610fe243fcfafd23ff821129cf4f35148ac64 (patch)
tree2089958de552235be618c4e732b5edbe8faf2e87 /win32
parentbe2985335305f921599cfdd25b7830ded1ca395e (diff)
parenta08a2b48b489572db89940027206020ee714afa5 (diff)
downloadphp-git-1e0610fe243fcfafd23ff821129cf4f35148ac64.tar.gz
Merge branch 'PHP-8.0'
* PHP-8.0: Strip trailing line breaks and periods from Windows error messages
Diffstat (limited to 'win32')
-rw-r--r--win32/winutil.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/win32/winutil.c b/win32/winutil.c
index 530dc4f0f6..a14416a6ce 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -24,7 +24,7 @@
PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
{/*{{{*/
- wchar_t *bufw = NULL;
+ wchar_t *bufw = NULL, *pw;
char *buf;
DWORD ret = FormatMessageW(
@@ -36,6 +36,10 @@ PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
return "";
}
+ /* strip trailing line breaks and periods */
+ for (pw = bufw + wcslen(bufw) - 1; pw >= bufw && (*pw == L'\r' || *pw == L'\n' || *pw == L'.'); pw--);
+ pw[1] = L'\0';
+
buf = php_win32_cp_conv_w_to_any(bufw, ret, PHP_WIN32_CP_IGNORE_LEN_P);
LocalFree(bufw);