Commit a6a8a034 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

imm32: Get rid of some casts in attributes helper, document arguments.

parent a7ba23b5
...@@ -1231,33 +1231,40 @@ static INT CopyCompStringIMEtoClient(const InputContextData *data, const void *s ...@@ -1231,33 +1231,40 @@ static INT CopyCompStringIMEtoClient(const InputContextData *data, const void *s
return ret; return ret;
} }
static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT slen, LPBYTE ssource, INT sslen, /* Composition string encoding is defined by context, returned attributes correspond to string, converted according to
LPBYTE target, INT tlen, BOOL unicode ) passed mode. String length is in characters, attributes are in byte arrays. */
static INT CopyCompAttrIMEtoClient(const InputContextData *data, const BYTE *src, INT src_len, const void *comp_string,
INT str_len, BYTE *dst, INT dst_len, BOOL unicode)
{ {
union
{
const void *str;
const WCHAR *strW;
const char *strA;
} string;
INT rc; INT rc;
string.str = comp_string;
if (is_himc_ime_unicode(data) && !unicode) if (is_himc_ime_unicode(data) && !unicode)
{ {
rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)ssource, sslen, NULL, 0, NULL, NULL); rc = WideCharToMultiByte(CP_ACP, 0, string.strW, str_len, NULL, 0, NULL, NULL);
if (tlen) if (dst_len)
{ {
const BYTE *src = source;
LPBYTE dst = target;
int i, j = 0, k = 0; int i, j = 0, k = 0;
if (rc < tlen) if (rc < dst_len)
tlen = rc; dst_len = rc;
for (i = 0; i < sslen; ++i) for (i = 0; i < str_len; ++i)
{ {
int len; int len;
len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)ssource + i, 1, len = WideCharToMultiByte(CP_ACP, 0, string.strW + i, 1, NULL, 0, NULL, NULL);
NULL, 0, NULL, NULL);
for (; len > 0; --len) for (; len > 0; --len)
{ {
dst[j++] = src[k]; dst[j++] = src[k];
if (j >= tlen) if (j >= dst_len)
goto end; goto end;
} }
++k; ++k;
...@@ -1268,23 +1275,21 @@ static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT sl ...@@ -1268,23 +1275,21 @@ static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT sl
} }
else if (!is_himc_ime_unicode(data) && unicode) else if (!is_himc_ime_unicode(data) && unicode)
{ {
rc = MultiByteToWideChar(CP_ACP, 0, (LPSTR)ssource, sslen, NULL, 0); rc = MultiByteToWideChar(CP_ACP, 0, string.strA, str_len, NULL, 0);
if (tlen) if (dst_len)
{ {
const BYTE *src = source;
LPBYTE dst = target;
int i, j = 0; int i, j = 0;
if (rc < tlen) if (rc < dst_len)
tlen = rc; dst_len = rc;
for (i = 0; i < sslen; ++i) for (i = 0; i < str_len; ++i)
{ {
if (IsDBCSLeadByte(((LPSTR)ssource)[i])) if (IsDBCSLeadByte(string.strA[i]))
continue; continue;
dst[j++] = src[i]; dst[j++] = src[i];
if (j >= tlen) if (j >= dst_len)
break; break;
} }
rc = j; rc = j;
...@@ -1292,8 +1297,8 @@ static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT sl ...@@ -1292,8 +1297,8 @@ static INT CopyCompAttrIMEtoClient(InputContextData *data, LPBYTE source, INT sl
} }
else else
{ {
memcpy( target, source, min(slen,tlen)); memcpy(dst, src, min(src_len, dst_len));
rc = slen; rc = src_len;
} }
return rc; return rc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment