Win32: Fix style

* Remove needless braces
* Add spaces
* Use C89 style variable declarations
This commit is contained in:
Takuro Ashie 2022-04-15 13:04:01 +09:00 committed by Daijiro Fukuda
parent 169da05c53
commit 599a1a98ec

View File

@ -854,25 +854,30 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
LONG preeditTextLength = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
LONG attrLength = ImmGetCompositionString(hIMC, GCS_COMPATTR, NULL, 0);
LONG clauseLength = ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, NULL, 0);
if (preeditTextLength > 0)
{
// get preedit data
int i;
int ctext = window->ctext;
int cblocks = window->cblocks;
int focusedBlock = 0;
int length = preeditTextLength / sizeof(WCHAR);
LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, 1);
LPSTR attributes = (LPSTR) _glfw_calloc(attrLength, 1);
DWORD *clauses = (DWORD*) _glfw_calloc(clauseLength, 1);
// get preedit data
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, buffer, preeditTextLength);
ImmGetCompositionString(hIMC, GCS_COMPATTR, attributes, attrLength);
ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, clauses, clauseLength);
// store preedit text
int ctext = window->ctext;
while (ctext < length + 1)
{
ctext = (ctext == 0) ? 1 : ctext * 2;
}
if (ctext != window->ctext)
{
unsigned int* preeditText = _glfw_realloc(window->preeditText, sizeof(unsigned int) * ctext);
if (preeditText == NULL)
{
_glfw_free(buffer);
@ -885,24 +890,20 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
}
window->ntext = length;
window->preeditText[length] = 0;
int i;
for (i = 0; i < length; i++)
{
window->preeditText[i] = buffer[i];
}
// store blocks
window->nblocks = clauseLength / sizeof(DWORD) - 1;
// last element of clauses is a block count, but
// text length is convenient.
clauses[window->nblocks] = length;
int cblocks = window->cblocks;
while (cblocks < window->nblocks)
{
cblocks = (cblocks == 0) ? 1 : cblocks * 2;
}
if (cblocks != window->cblocks)
{
int* blocks = _glfw_realloc(window->preeditAttributeBlocks, sizeof(int) * cblocks);
if (blocks == NULL)
{
_glfw_free(buffer);
@ -913,21 +914,21 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
window->preeditAttributeBlocks = blocks;
window->cblocks = cblocks;
}
int focusedBlock = 0;
for (i = 0; i < window->nblocks; i++)
{
window->preeditAttributeBlocks[i] = clauses[i + 1] - clauses[i];
if (attributes[clauses[i]] != ATTR_CONVERTED)
{
focusedBlock = i;
}
}
_glfw_free(buffer);
_glfw_free(attributes);
_glfw_free(clauses);
_glfwInputPreedit(window, focusedBlock);
_win32ChangeCursorPosition(hIMC, window);
}
ImmReleaseContext(hWnd, hIMC);
return TRUE;
}