[PATCH 04/10] ucrtbase: Handle the swprintf style termination and return values

Piotr Caban piotr.caban at gmail.com
Mon Nov 2 08:25:31 CST 2015


Hi,

I don't like the code I've proposed in last email. Something like this 
seems to be nicer:
static int puts_clbk_str_c99_a(void *ctx, int len, const char *str)
{
     struct _str_ctx_a *out = ctx;

     if(!out->buf)
         return len;

     if(out->len < len) {
         memcpy(out->buf, str, out->len);
         out->buf += out->len;
         out->len = 0;
         return len;
     }

     memcpy(out->buf, str, len);
     out->buf += len;
     out->len -= len;
     return len;
}

/*********************************************************************
  *              __stdio_common_vsprintf (MSVCRT.@)
  */
int CDECL MSVCRT__stdio_common_vsprintf( unsigned __int64 options, char 
*str, MSVCRT_size_t len, const char *format,
                                          MSVCRT__locale_t locale, 
__ms_va_list valist )
{
     static const char nullbyte = '\0';
     struct _str_ctx_a ctx = {len, str};
     int ret;

     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);
     puts_clbk_str_a(&ctx, 1, &nullbyte);

     if(options & UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
         return ret>len ? -1 : ret;
     if(ret>=len) {
         if(len) str[len-1] = 0;
         return (options & UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR) 
? ret : -2;
     }
     return ret;
}
if you think that your initial code is better please let me know. 
Probably in this code UCRTBASE_PRINTF_TERMINATION_MASK define is not needed.

On 11/02/15 13:45, Martin Storsjö wrote:
> After thinking another few minutes about it - sure, this is fine for me.
> Should I resend the full patchset, or only 4->10 (at least some of them
> will need some conflict resolution)? If I resend the full patchset, I
> guess I can fold in your sign-offs in 1-3 (as long as I don't modify
> those patches)?
I can sign the patches after you resend them myself (I don't know what's 
the policy in this case).

Thanks,
Piotr



More information about the wine-devel mailing list