[Bug 2075] New: vsnprintf: glibc and win32 not compatible

Wine Bugs wine-bugs at winehq.org
Sun Mar 7 19:29:47 CST 2004


http://bugs.winehq.org/show_bug.cgi?id=2075

           Summary: vsnprintf: glibc and win32 not compatible
           Product: Wine
           Version: unspecified
          Platform: PC
               URL: http://msdn.microsoft.com/library/default.asp?url=/libra
                    ry/en-
                    us/vclib/html/_crt_format_specification_fields_.2d_.prin
                    tf_and_wprintf_functions.asp
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: major
          Priority: P2
         Component: wine-misc
        AssignedTo: wine-bugs at winehq.org
        ReportedBy: uh_ja at gmx.net


Format specifiers of the glibc vsnprintf are not compatible with its win32
counterpart.  URL links to a short description at msdn.  Compare to "man
vsnprintf".  Wine calls glibc's vanilla vsnprintf.

Similar bug reports are #321 and #427.

An example of a conflict follows:

Warcraft III uses *snprintf to create a single player profile.  Currently under
wine, creation of a single player profile fails to produce correct data because
*snprintf produces an invalid file, and single player campaign will subsequently
not show.  Warcraft makes a call similar to this to store a special value:

snprintf(s, size, "%I64d", x);

glibc vsnprintf interprets "%I64d" to be:

I: Internationlize number format
64: pad number to 64 digits
d: int type

Therefore, an internationlized int padded to 64 digits.


A win32 vsnprintf should interpret "%I64d" to be:

I64: "64-bit integer"
d: int

Therefore, a "64-bit int".

An incorrect statement in a Warcraft III profile "Campaign.w3p" produced using
glibc's vsnprintf:
Human=                                                                1
(64 padded, and wrong integer type)


Here I hack together a workaround to handle the special Warcraft III case:
int MSVCRT_vsnprintf(char *str, size_t size, const char  *format, va_list ap)
{
    int x;
    TRACE("(%p=\"%s\",%d,%p=\"%s\",%p)\n", str, str, size, format, format, ap);
    if (strcmp(format, "%I64d")==0) {
        x = vsnprintf(str, size, "%lld", ap);
    } else {
        x = vsnprintf(str, size, format, ap);
    }
    TRACE("retval=\"%s\"\n", str);

    return x;
}

And if this is called for _vsnprintf, the output is as follows:
Human=-4035225266123964415
(a long long int)

Creating a single player profile using the hack produces a correct profile, and
the single player campaign buttons are displayed.

This is just one issue with the different vsprintf format standards.  I'm sure
there are many subtle bugs like this, if you consider the conflicts and other
unhandled statements.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the wine-bugs mailing list