[PATCH] msvcrt: The '*' character should be interpreted as the beginning of the width specification

David Gow david at davidgow.net
Sun Nov 7 21:35:27 CST 2021


(Apologies if you get this twice: the list bounced my first attempt. 
I've subscribed now, which should help.)

In reply to Andrew Eikum:
>
> Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
> ---
>
> For example,
>
>     "%*0d", 1, ...
>
> becomes
>
>     "%10d", ...
>
> i.e. prints ten digits.

This doesn't seem to be quite correct to me.

I've written a test program and built it with MSVC 2019:
int main(int argc, char **argv)
{
         printf("%0*02d\n",1,0);
         printf("%0*02d\n",30,17);
         printf("%*1d\n", 1, 3);
         printf("%0*0d\n", 1, 2);
         printf("% *2d\n", 0, 7);
         return 0;
}

The output on windows (and wine with native ucrtbase.dll) is:
00
17
3
2
  7

The output with this patch is notably different:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<absurd number of zeros elided>0000017
           3
0000000002
  7

I've uploaded a binary for said test program here:
https://davidgow.net/stuff/TestPrintf.exe

Similarly, Age of Empires IV shows an incorrect timer with this patch 
(the text under "Gold Medal (Goal…)" should read 00:17):
https://davidgow.net/stuff/aoe4-printf-bigtime.jpg

I'll send an updated patch through which fixes this soon.

Cheers,
-- David



More information about the wine-devel mailing list