[PATCH 2/2] msvcrt: Introduce vfwprintf helper function.
Gijs Vermeulen
gijsvrm at gmail.com
Sun Sep 24 18:24:18 CDT 2017
Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
---
dlls/msvcrt/file.c | 67 ++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 35 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 7f3048f534..52db66d050 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -5062,6 +5062,35 @@ static int vfprintf_helper(MSVCRT_FILE* file, const char *format, __ms_va_list v
return ret;
}
+static int vfwprintf_helper(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist,
+ MSVCRT__locale_t locale, BOOL secure)
+{
+ BOOL tmp_buf;
+ int ret;
+
+ if(secure)
+ if(!MSVCRT_CHECK_PMT(file != NULL)) return -1;
+
+ MSVCRT__lock_file(file);
+ tmp_buf = add_std_buffer(file);
+
+ if(!secure)
+ ret = pf_printf_w(puts_clbk_file_w, file, format, NULL, 0, arg_clbk_valist, NULL, &valist);
+ else
+ {
+ if(!locale)
+ ret = pf_printf_w(puts_clbk_file_w, file, format, NULL,
+ MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER, arg_clbk_valist, NULL, &valist);
+ else
+ ret = pf_printf_w(puts_clbk_file_w, file, format, locale, 0, arg_clbk_valist, NULL, &valist);
+ }
+
+ if(tmp_buf) remove_std_buffer(file);
+ MSVCRT__unlock_file(file);
+
+ return ret;
+}
+
/*********************************************************************
* vfprintf (MSVCRT.@)
*/
@@ -5083,16 +5112,7 @@ int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list
*/
int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist)
{
- BOOL tmp_buf;
- int ret;
-
- MSVCRT__lock_file(file);
- tmp_buf = add_std_buffer(file);
- ret = pf_printf_w(puts_clbk_file_w, file, format, NULL, 0, arg_clbk_valist, NULL, &valist);
- if(tmp_buf) remove_std_buffer(file);
- MSVCRT__unlock_file(file);
-
- return ret;
+ return vfwprintf_helper(file, format, valist, NULL, FALSE);
}
/*********************************************************************
@@ -5100,19 +5120,7 @@ int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms
*/
int CDECL MSVCRT_vfwprintf_s(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list valist)
{
- BOOL tmp_buf;
- int ret;
-
- if (!MSVCRT_CHECK_PMT( file != NULL )) return -1;
-
- MSVCRT__lock_file(file);
- tmp_buf = add_std_buffer(file);
- ret = pf_printf_w(puts_clbk_file_w, file, format, NULL,
- MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER, arg_clbk_valist, NULL, &valist);
- if(tmp_buf) remove_std_buffer(file);
- MSVCRT__unlock_file(file);
-
- return ret;
+ return vfwprintf_helper(file, format, valist, NULL, TRUE);
}
/*********************************************************************
@@ -5236,18 +5244,7 @@ int CDECL MSVCRT__vfprintf_l(MSVCRT_FILE* file, const char *format,
int CDECL MSVCRT__vfwprintf_l(MSVCRT_FILE* file, const MSVCRT_wchar_t *format,
MSVCRT__locale_t locale, __ms_va_list valist)
{
- BOOL tmp_buf;
- int ret;
-
- if (!MSVCRT_CHECK_PMT( file != NULL )) return -1;
-
- MSVCRT__lock_file(file);
- tmp_buf = add_std_buffer(file);
- ret = pf_printf_w(puts_clbk_file_w, file, format, locale, 0, arg_clbk_valist, NULL, &valist);
- if(tmp_buf) remove_std_buffer(file);
- MSVCRT__unlock_file(file);
-
- return ret;
+ return vfwprintf_helper(file, format, valist, locale, TRUE);
}
/*********************************************************************
--
2.14.1.windows.1
More information about the wine-patches
mailing list