msvcrt: Refactor pf_printf to take options as flags instead of as BOOL parameter.
Signed-off-by: Martin Storsjo <martin@martin.st> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b09aadd202
commit
1c8412d9e5
|
@ -519,7 +519,7 @@ static int puts_clbk_console_w(void *ctx, int len, const MSVCRT_wchar_t *str)
|
|||
*/
|
||||
int CDECL _vcprintf(const char* format, __ms_va_list valist)
|
||||
{
|
||||
return pf_printf_a(puts_clbk_console_a, NULL, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
return pf_printf_a(puts_clbk_console_a, NULL, format, NULL, 0, arg_clbk_valist, NULL, &valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -543,7 +543,7 @@ int CDECL _cprintf(const char* format, ...)
|
|||
*/
|
||||
int CDECL _vcwprintf(const MSVCRT_wchar_t* format, __ms_va_list valist)
|
||||
{
|
||||
return pf_printf_w(puts_clbk_console_w, NULL, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
return pf_printf_w(puts_clbk_console_w, NULL, format, NULL, 0, arg_clbk_valist, NULL, &valist);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -4921,7 +4921,7 @@ int CDECL MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, __ms_va_list va
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, NULL, 0, arg_clbk_valist, NULL, &valist);
|
||||
if(tmp_buf) remove_std_buffer(file);
|
||||
MSVCRT__unlock_file(file);
|
||||
|
||||
|
@ -4940,7 +4940,8 @@ int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, &valist);
|
||||
ret = pf_printf_a(puts_clbk_file_a, 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);
|
||||
|
||||
|
@ -4957,7 +4958,7 @@ int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_w(puts_clbk_file_w, file, format, NULL, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
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);
|
||||
|
||||
|
@ -4976,7 +4977,8 @@ int CDECL MSVCRT_vfwprintf_s(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_w(puts_clbk_file_w, file, format, NULL, FALSE, TRUE, arg_clbk_valist, NULL, &valist);
|
||||
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);
|
||||
|
||||
|
@ -4996,7 +4998,7 @@ int CDECL MSVCRT__stdio_common_vfprintf(unsigned __int64 options, MSVCRT_FILE *f
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, locale, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
ret = pf_printf_a(puts_clbk_file_a, file, format, locale, 0, arg_clbk_valist, NULL, &valist);
|
||||
if(tmp_buf) remove_std_buffer(file);
|
||||
MSVCRT__unlock_file(file);
|
||||
|
||||
|
@ -5016,7 +5018,7 @@ int CDECL MSVCRT__vfwprintf_l(MSVCRT_FILE* file, const MSVCRT_wchar_t *format,
|
|||
|
||||
MSVCRT__lock_file(file);
|
||||
tmp_buf = add_std_buffer(file);
|
||||
ret = pf_printf_w(puts_clbk_file_w, file, format, locale, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
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);
|
||||
|
||||
|
|
|
@ -1082,9 +1082,9 @@ typedef union _printf_arg
|
|||
} printf_arg;
|
||||
typedef printf_arg (*args_clbk)(void*, int, int, __ms_va_list*);
|
||||
int pf_printf_a(puts_clbk_a, void*, const char*, MSVCRT__locale_t,
|
||||
BOOL, BOOL, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
|
||||
DWORD, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
|
||||
int pf_printf_w(puts_clbk_w, void*, const MSVCRT_wchar_t*, MSVCRT__locale_t,
|
||||
BOOL, BOOL, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
|
||||
DWORD, args_clbk, void*, __ms_va_list*) DECLSPEC_HIDDEN;
|
||||
printf_arg arg_clbk_valist(void*, int, int, __ms_va_list*) DECLSPEC_HIDDEN;
|
||||
|
||||
#define MSVCRT_FLT_MIN 1.175494351e-38F
|
||||
|
@ -1133,6 +1133,9 @@ extern char* __cdecl __unDName(char *,const char*,int,malloc_func_t,free_func_t,
|
|||
#define UCRTBASE_PRINTF_TERMINATION_MASK (UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION | \
|
||||
UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR)
|
||||
|
||||
#define MSVCRT_PRINTF_POSITIONAL_PARAMS (0x0100)
|
||||
#define MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER (0x0200)
|
||||
|
||||
#define UCRTBASE_SCANF_SECURECRT (0x0001)
|
||||
#define UCRTBASE_SCANF_LEGACY_WIDE_SPECIFIERS (0x0002)
|
||||
#define UCRTBASE_SCANF_LEGACY_MSVCRT_COMPATIBILITY (0x0004)
|
||||
|
|
|
@ -336,7 +336,7 @@ static inline void FUNC_NAME(pf_fixup_exponent)(char *buf)
|
|||
}
|
||||
|
||||
int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const APICHAR *fmt,
|
||||
MSVCRT__locale_t locale, BOOL positional_params, BOOL invoke_invalid_param_handler,
|
||||
MSVCRT__locale_t locale, DWORD options,
|
||||
args_clbk pf_args, void *args_ctx, __ms_va_list *valist)
|
||||
{
|
||||
MSVCRT_pthreadlocinfo locinfo;
|
||||
|
@ -344,6 +344,8 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
|
|||
APICHAR buf[32];
|
||||
int written = 0, pos, i;
|
||||
FUNC_NAME(pf_flags) flags;
|
||||
BOOL positional_params = options & MSVCRT_PRINTF_POSITIONAL_PARAMS;
|
||||
BOOL invoke_invalid_param_handler = options & MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER;
|
||||
|
||||
TRACE("Format is: %s\n", FUNC_NAME(debugstr)(fmt));
|
||||
|
||||
|
@ -701,8 +703,8 @@ static int FUNC_NAME(create_positional_ctx)(void *args_ctx, const APICHAR *forma
|
|||
printf_arg *args = args_ctx;
|
||||
int i, j;
|
||||
|
||||
i = FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk_str), &puts_ctx, format, NULL, TRUE, FALSE,
|
||||
arg_clbk_type, args_ctx, NULL);
|
||||
i = FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk_str), &puts_ctx, format, NULL,
|
||||
MSVCRT_PRINTF_POSITIONAL_PARAMS, arg_clbk_type, args_ctx, NULL);
|
||||
if(i < 0)
|
||||
return i;
|
||||
|
||||
|
|
|
@ -688,7 +688,7 @@ int CDECL MSVCRT_vsnprintf( char *str, MSVCRT_size_t len,
|
|||
struct _str_ctx_a ctx = {len, str};
|
||||
int ret;
|
||||
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, FALSE, FALSE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, 0,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
return ret;
|
||||
|
@ -727,7 +727,7 @@ int CDECL MSVCRT__stdio_common_vsprintf( unsigned __int64 options, char *str, MS
|
|||
if (options & ~UCRTBASE_PRINTF_TERMINATION_MASK)
|
||||
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
||||
ret = pf_printf_a(puts_clbk_str_c99_a,
|
||||
&ctx, format, locale, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
&ctx, format, locale, 0, arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
|
||||
if(options & UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
||||
|
@ -749,7 +749,7 @@ int CDECL MSVCRT_vsnprintf_l( char *str, MSVCRT_size_t len, const char *format,
|
|||
struct _str_ctx_a ctx = {len, str};
|
||||
int ret;
|
||||
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, FALSE, FALSE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, 0,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
return ret;
|
||||
|
@ -796,7 +796,7 @@ int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
|
|||
|
||||
ctx.len = len;
|
||||
ctx.buf = str;
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, FALSE, TRUE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
|
||||
|
@ -848,8 +848,9 @@ int CDECL MSVCRT_vsnprintf_s( char *str, MSVCRT_size_t sizeOfBuffer,
|
|||
/*********************************************************************
|
||||
* __stdio_common_vsnprintf_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL MSVCRT__stdio_common_vsnprintf_s( unsigned __int64 options, char *str, MSVCRT_size_t sizeOfBuffer, MSVCRT_size_t count, const char *format,
|
||||
MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
int CDECL MSVCRT__stdio_common_vsnprintf_s( unsigned __int64 options,
|
||||
char *str, MSVCRT_size_t sizeOfBuffer, MSVCRT_size_t count,
|
||||
const char *format, MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
{
|
||||
return MSVCRT_vsnprintf_s_l(str, sizeOfBuffer, count, format, locale, valist);
|
||||
}
|
||||
|
@ -857,8 +858,9 @@ int CDECL MSVCRT__stdio_common_vsnprintf_s( unsigned __int64 options, char *str,
|
|||
/*********************************************************************
|
||||
* __stdio_common_vsprintf_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL MSVCRT__stdio_common_vsprintf_s( unsigned __int64 options, char *str, MSVCRT_size_t count, const char *format,
|
||||
MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
int CDECL MSVCRT__stdio_common_vsprintf_s( unsigned __int64 options,
|
||||
char *str, MSVCRT_size_t count, const char *format,
|
||||
MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
{
|
||||
return MSVCRT_vsnprintf_s_l(str, INT_MAX, count, format, locale, valist);
|
||||
}
|
||||
|
@ -905,10 +907,12 @@ int CDECL MSVCRT__vscprintf_p_l(const char *format,
|
|||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return ret;
|
||||
} else if(ret == 0) {
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, FALSE, TRUE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
||||
MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_valist, NULL, &args);
|
||||
} else {
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, TRUE, TRUE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
||||
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_positional, args_ctx, NULL);
|
||||
}
|
||||
|
||||
|
@ -987,7 +991,7 @@ int CDECL MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
|
|||
struct _str_ctx_w ctx = {len, str};
|
||||
int ret;
|
||||
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, FALSE, FALSE,
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, 0,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_w(&ctx, 1, &nullbyte);
|
||||
return ret;
|
||||
|
@ -1004,7 +1008,7 @@ int CDECL MSVCRT_vsnwprintf_l(MSVCRT_wchar_t *str, MSVCRT_size_t len,
|
|||
struct _str_ctx_w ctx = {len, str};
|
||||
int ret;
|
||||
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, FALSE, FALSE,
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, 0,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_w(&ctx, 1, &nullbyte);
|
||||
return ret;
|
||||
|
@ -1029,10 +1033,11 @@ int CDECL MSVCRT_vswprintf_p_l(MSVCRT_wchar_t *buffer, MSVCRT_size_t length,
|
|||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return ret;
|
||||
} else if(ret == 0)
|
||||
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, FALSE, TRUE,
|
||||
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_valist, NULL, &args);
|
||||
else
|
||||
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, TRUE, TRUE,
|
||||
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale,
|
||||
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_positional, args_ctx, NULL);
|
||||
|
||||
puts_clbk_str_w(&puts_ctx, 1, &nullbyte);
|
||||
|
@ -1065,7 +1070,7 @@ int CDECL MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t *str, MSVCRT_size_t sizeOfBuffer
|
|||
|
||||
ctx.len = len;
|
||||
ctx.buf = str;
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, FALSE, TRUE,
|
||||
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_w(&ctx, 1, &nullbyte);
|
||||
|
||||
|
@ -1170,8 +1175,9 @@ static int puts_clbk_str_c99_w(void *ctx, int len, const MSVCRT_wchar_t *str)
|
|||
/*********************************************************************
|
||||
* __stdio_common_vswprintf (MSVCRT.@)
|
||||
*/
|
||||
int CDECL MSVCRT__stdio_common_vswprintf( unsigned __int64 options, MSVCRT_wchar_t *str, MSVCRT_size_t len, const MSVCRT_wchar_t *format,
|
||||
MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
int CDECL MSVCRT__stdio_common_vswprintf( unsigned __int64 options,
|
||||
MSVCRT_wchar_t *str, MSVCRT_size_t len, const MSVCRT_wchar_t *format,
|
||||
MSVCRT__locale_t locale, __ms_va_list valist )
|
||||
{
|
||||
static const MSVCRT_wchar_t nullbyte = '\0';
|
||||
struct _str_ctx_w ctx = {len, str};
|
||||
|
@ -1180,7 +1186,7 @@ int CDECL MSVCRT__stdio_common_vswprintf( unsigned __int64 options, MSVCRT_wchar
|
|||
if (options & ~UCRTBASE_PRINTF_TERMINATION_MASK)
|
||||
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
||||
ret = pf_printf_w(puts_clbk_str_c99_w,
|
||||
&ctx, format, locale, FALSE, FALSE, arg_clbk_valist, NULL, &valist);
|
||||
&ctx, format, locale, 0, arg_clbk_valist, NULL, &valist);
|
||||
puts_clbk_str_w(&ctx, 1, &nullbyte);
|
||||
|
||||
if(options & UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
||||
|
@ -1367,10 +1373,11 @@ int CDECL MSVCRT_vsprintf_p_l(char *buffer, MSVCRT_size_t length, const char *fo
|
|||
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||
return ret;
|
||||
} else if(ret == 0)
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, FALSE, TRUE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_valist, NULL, &args);
|
||||
else
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale, TRUE, TRUE,
|
||||
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
||||
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
||||
arg_clbk_positional, args_ctx, NULL);
|
||||
|
||||
puts_clbk_str_a(&puts_ctx, 1, &nullbyte);
|
||||
|
|
Loading…
Reference in New Issue