mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Handle invalid Unicode strings for %S format like MS does
svn path=/trunk/; revision=8802
This commit is contained in:
parent
896376d3c1
commit
77eb2df0b2
1 changed files with 14 additions and 3 deletions
|
@ -679,9 +679,20 @@ static int stringw(FILE *f, const wchar_t* sw, int len, int field_width, int pre
|
||||||
}
|
}
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (putc((unsigned char)(*sw++), f) == EOF)
|
#define MB_CUR_MAX 1
|
||||||
return -1;
|
char mb[MB_CUR_MAX];
|
||||||
done++;
|
int mbcount, j;
|
||||||
|
mbcount = wctomb(mb, *sw++);
|
||||||
|
if (mbcount <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (j = 0; j < mbcount; j++)
|
||||||
|
{
|
||||||
|
if (putc(mb[j], f) == EOF)
|
||||||
|
return -1;
|
||||||
|
done++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (len < field_width--)
|
while (len < field_width--)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue