Hi Piotr,

That does look a lot better, thanks!
I've sent an updated version.

Sincerely,
Gijs

2017-10-13 17:48 GMT+02:00 Piotr Caban <piotr.caban@gmail.com>:
Hi Gijs,

I think support for MSVCRT_PRINTF_POSITIONAL_PARAMS flag may be integrated into helper. Thanks to it you will be able to implement vfprintf_p without changing all helper callers. I'm thinking about something like this:

static int vfprintf_helper(DWORD options, MSVCRT_FILE* file, const char *format,
        MSVCRT__locale_t locale, __ms_va_list valist)
{
    printf_arg args_ctx[MSVCRT__ARGMAX+1];
    BOOL tmp_buf;
    int ret;

    if(!MSVCRT_CHECK_PMT( file != NULL )) return -1;
    if(!MSVCRT_CHECK_PMT( format != NULL )) return -1;

    if(options & MSVCRT_PRINTF_POSITIONAL_PARAMS) {
        memset(args_ctx, 0, sizeof(args_ctx));
        ret = create_positional_ctx_a(args_ctx, format, valist);
        if(ret < 0) {
            MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
            *MSVCRT__errno() = MSVCRT_EINVAL;
            return ret;
        } else if(!ret)
            otions &= ~MSVCRT_PRINTF_POSITIONAL_PARAMS;
    }

    MSVCRT__lock_file(file);
    tmp_buf = add_std_buffer(file);
    ret = pf_printf_a(puts_clbk_file_a, file, format, locale, options,
            options & MSVCRT_PRINTF_POSITIONAL_PARAMS ? arg_clbk_positional : arg_clbk_valist,
            options & MSVCRT_PRINTF_POSITIONAL_PARAMS ? args_ctx : NULL, &valist);
    if(tmp_buf) remove_std_buffer(file);
    MSVCRT__unlock_file(file);

    return ret;
}

Thanks,
Piotr