mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-common: Fix vkd3d_strdup_{w16, w32}_utf8() functions.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6a3c75d0d1
commit
0055aa67f1
@ -107,8 +107,8 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
|
||||
{
|
||||
const uint16_t *src = wstr;
|
||||
size_t dst_size = 0;
|
||||
char *dst, *utf8;
|
||||
uint32_t c;
|
||||
char *dst;
|
||||
|
||||
while (*src)
|
||||
{
|
||||
@ -121,14 +121,15 @@ static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
|
||||
if (!(dst = vkd3d_malloc(dst_size)))
|
||||
return NULL;
|
||||
|
||||
utf8 = dst;
|
||||
src = wstr;
|
||||
while (*src)
|
||||
{
|
||||
if (!(c = vkd3d_utf16_read(&src)))
|
||||
continue;
|
||||
vkd3d_utf8_append(&dst, c);
|
||||
vkd3d_utf8_append(&utf8, c);
|
||||
}
|
||||
*dst = 0;
|
||||
*utf8 = 0;
|
||||
|
||||
return dst;
|
||||
}
|
||||
@ -137,7 +138,7 @@ static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr)
|
||||
{
|
||||
const uint32_t *src = wstr;
|
||||
size_t dst_size = 0;
|
||||
char *dst;
|
||||
char *dst, *utf8;
|
||||
|
||||
while (*src)
|
||||
dst_size += vkd3d_utf8_len(*src++);
|
||||
@ -146,10 +147,11 @@ static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr)
|
||||
if (!(dst = vkd3d_malloc(dst_size)))
|
||||
return NULL;
|
||||
|
||||
utf8 = dst;
|
||||
src = wstr;
|
||||
while (*src)
|
||||
vkd3d_utf8_append(&dst, *src++);
|
||||
*dst = 0;
|
||||
vkd3d_utf8_append(&utf8, *src++);
|
||||
*utf8 = 0;
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user