2011/12/30 JonY <[email protected]>:
> On 12/30/2011 11:50, Chris Sutcliffe wrote:
>> On 29 December 2011 19:27, Chris Sutcliffe wrote:
>>> Using the latest update to the mingw-w64 packages in Cygwin, I've run
>>> in to an issue where swprintf is truncating an included string.
>>
>> The issue is with the new __mingw_*printf functions that were added.
>> Using this code:
>>
>> #include <windows.h>
>> #include <stdio.h>
>>
>> int main(void)
>> {
>>   WCHAR test[20], teststr[4096], tmp[4096];
>>
>>   wcscpy(test, TEXT("test"));
>>   swprintf(teststr, TEXT("This is a %s"), test);
>>   swprintf(tmp, TEXT("%s - %d | %s - %d"), test, wcslen(test),
>> teststr, wcslen(teststr));
>>
>>   MessageBox(GetDesktopWindow(), tmp, L"Test", MB_OK | MB_TOPMOST);
>>
>>   return 0;
>> }
>>
>> compiled via:
>>
>> i686-w64-mingw32-g++ -U__USE_MINGW_ANSI_STDIO -DUNICODE test.cpp -o test
>>
>> all is good.  However, if you compile the code via:
>>
>> i686-w64-mingw32-g++ -D__USE_MINGW_ANSI_STDIO -DUNICODE test.cpp -o test
>>
>> you will see the issue I am encountering.
>>
>> Cheers,
>>
>> Chris
>>
>
> Thanks for the bug report, will investigate.

Hmm, not sure if this is related to swprintf and mingw-POSIX variant.
I would assume the bug here is the use of %s for a wide-string. Using

   wcscpy(test, TEXT("test"));
   swprintf(teststr, TEXT("This is a %ws"), test);

Works as desired.

Kai

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to