Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
85489a53
Commit
85489a53
authored
Feb 17, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imm32: Rewrite ImmGetIMEFileName(A|W).
parent
8b0b5337
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
73 deletions
+27
-73
imm.c
dlls/imm32/imm.c
+27
-60
imm32.c
dlls/imm32/tests/imm32.c
+0
-13
No files found.
dlls/imm32/imm.c
View file @
85489a53
...
...
@@ -1802,82 +1802,49 @@ DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBu
}
/***********************************************************************
*
ImmGetIMEFileNameA (IMM32.@)
*
ImmGetIMEFileNameA (IMM32.@)
*/
UINT
WINAPI
ImmGetIMEFileNameA
(
HKL
h
KL
,
LPSTR
lpszFileName
,
UINT
uBufLen
)
UINT
WINAPI
ImmGetIMEFileNameA
(
HKL
h
kl
,
char
*
bufferA
,
UINT
lengthA
)
{
LPWSTR
bufW
=
NULL
;
UINT
wBufLen
=
uBufLen
;
UINT
rc
;
WCHAR
*
bufferW
;
DWORD
lengthW
;
if
(
uBufLen
&&
lpszFileName
)
bufW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
uBufLen
*
sizeof
(
WCHAR
));
else
/* We need this to get the number of byte required */
{
bufW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATH
*
sizeof
(
WCHAR
));
wBufLen
=
MAX_PATH
;
}
rc
=
ImmGetIMEFileNameW
(
hKL
,
bufW
,
wBufLen
);
TRACE
(
"hkl %p, bufferA %p, lengthA %d
\n
"
,
hkl
,
bufferA
,
lengthA
);
if
(
rc
>
0
)
{
if
(
uBufLen
&&
lpszFileName
)
rc
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufW
,
-
1
,
lpszFileName
,
uBufLen
,
NULL
,
NULL
);
else
/* get the length */
rc
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufW
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
}
if
(
!
(
lengthW
=
ImmGetIMEFileNameW
(
hkl
,
NULL
,
0
)))
return
0
;
if
(
!
(
bufferW
=
malloc
(
(
lengthW
+
1
)
*
sizeof
(
WCHAR
)
)))
return
0
;
lengthW
=
ImmGetIMEFileNameW
(
hkl
,
bufferW
,
lengthW
+
1
);
lengthA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
lengthW
,
bufferA
,
bufferA
?
lengthA
:
0
,
NULL
,
NULL
);
if
(
bufferA
)
bufferA
[
lengthA
]
=
0
;
free
(
bufferW
);
HeapFree
(
GetProcessHeap
(),
0
,
bufW
);
return
rc
;
return
lengthA
;
}
/***********************************************************************
* ImmGetIMEFileNameW (IMM32.@)
*/
UINT
WINAPI
ImmGetIMEFileNameW
(
HKL
hKL
,
LPWSTR
lpszFileName
,
UINT
uBufLen
)
UINT
WINAPI
ImmGetIMEFileNameW
(
HKL
hkl
,
WCHAR
*
buffer
,
UINT
length
)
{
HKEY
hkey
;
DWORD
length
;
DWORD
rc
;
WCHAR
regKey
[
ARRAY_SIZE
(
layouts_formatW
)
+
8
];
wsprintfW
(
regKey
,
layouts_formatW
,
(
ULONG_PTR
)
hKL
);
rc
=
RegOpenKeyW
(
HKEY_LOCAL_MACHINE
,
regKey
,
&
hkey
);
if
(
rc
!=
ERROR_SUCCESS
)
{
SetLastError
(
rc
);
return
0
;
}
WCHAR
path
[
MAX_PATH
];
HKEY
hkey
=
0
;
DWORD
size
;
length
=
0
;
rc
=
RegGetValueW
(
hkey
,
NULL
,
L"Ime File"
,
RRF_RT_REG_SZ
,
NULL
,
NULL
,
&
length
);
TRACE
(
"hkl %p, buffer %p, length %u
\n
"
,
hkl
,
buffer
,
length
);
if
(
rc
!=
ERROR_SUCCESS
)
{
RegCloseKey
(
hkey
);
SetLastError
(
rc
);
return
0
;
}
if
(
length
>
uBufLen
*
sizeof
(
WCHAR
)
||
!
lpszFileName
)
{
RegCloseKey
(
hkey
);
if
(
lpszFileName
)
{
SetLastError
(
ERROR_INSUFFICIENT_BUFFER
);
return
0
;
}
else
return
length
/
sizeof
(
WCHAR
);
}
swprintf
(
path
,
ARRAY_SIZE
(
path
),
layouts_formatW
,
(
ULONG
)(
ULONG_PTR
)
hkl
);
if
(
RegOpenKeyW
(
HKEY_LOCAL_MACHINE
,
path
,
&
hkey
))
return
0
;
RegGetValueW
(
hkey
,
NULL
,
L"Ime File"
,
RRF_RT_REG_SZ
,
NULL
,
lpszFileName
,
&
length
);
size
=
ARRAY_SIZE
(
path
)
*
sizeof
(
WCHAR
);
if
(
RegGetValueW
(
hkey
,
NULL
,
L"Ime File"
,
RRF_RT_REG_SZ
,
NULL
,
path
,
&
size
))
*
path
=
0
;
RegCloseKey
(
hkey
);
RegCloseKey
(
hkey
);
size
=
wcslen
(
path
);
if
(
!
buffer
)
return
size
;
return
length
/
sizeof
(
WCHAR
);
lstrcpynW
(
buffer
,
path
,
length
);
return
wcslen
(
buffer
);
}
/***********************************************************************
...
...
dlls/imm32/tests/imm32.c
View file @
85489a53
...
...
@@ -2945,60 +2945,47 @@ static void test_ImmGetIMEFileName(void)
ret
=
ImmGetIMEFileNameA
(
hkl
,
bufferA
,
100
);
ok
(
!
ret
,
"ImmGetIMEFileNameA returned %lu
\n
"
,
ret
);
ret
=
GetLastError
();
todo_wine
ok
(
ret
==
0xdeadbeef
,
"got error %lu
\n
"
,
ret
);
if
(
!
(
hkl
=
ime_install
()))
goto
cleanup
;
memset
(
bufferW
,
0xcd
,
sizeof
(
bufferW
)
);
ret
=
ImmGetIMEFileNameW
(
hkl
,
bufferW
,
2
);
todo_wine
ok
(
ret
==
1
,
"ImmGetIMEFileNameW returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
wcscmp
(
bufferW
,
L"W"
),
"got bufferW %s
\n
"
,
debugstr_w
(
bufferW
)
);
memset
(
bufferA
,
0xcd
,
sizeof
(
bufferA
)
);
ret
=
ImmGetIMEFileNameA
(
hkl
,
bufferA
,
2
);
ok
(
ret
==
0
,
"ImmGetIMEFileNameA returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
bufferA
,
""
),
"got bufferA %s
\n
"
,
debugstr_a
(
bufferA
)
);
swprintf
(
expectW
,
ARRAY_SIZE
(
expectW
),
L"WINE%04X.I"
,
ime_count
-
1
);
memset
(
bufferW
,
0xcd
,
sizeof
(
bufferW
)
);
ret
=
ImmGetIMEFileNameW
(
hkl
,
bufferW
,
11
);
todo_wine
ok
(
ret
==
10
,
"ImmGetIMEFileNameW returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
wcscmp
(
bufferW
,
expectW
),
"got bufferW %s
\n
"
,
debugstr_w
(
bufferW
)
);
memset
(
bufferA
,
0xcd
,
sizeof
(
bufferA
)
);
ret
=
ImmGetIMEFileNameA
(
hkl
,
bufferA
,
11
);
ok
(
ret
==
0
,
"ImmGetIMEFileNameA returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
bufferA
,
""
),
"got bufferA %s
\n
"
,
debugstr_a
(
bufferA
)
);
swprintf
(
expectW
,
ARRAY_SIZE
(
expectW
),
L"WINE%04X.IM"
,
ime_count
-
1
);
memset
(
bufferW
,
0xcd
,
sizeof
(
bufferW
)
);
ret
=
ImmGetIMEFileNameW
(
hkl
,
bufferW
,
12
);
todo_wine
ok
(
ret
==
11
,
"ImmGetIMEFileNameW returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
wcscmp
(
bufferW
,
expectW
),
"got bufferW %s
\n
"
,
debugstr_w
(
bufferW
)
);
snprintf
(
expectA
,
ARRAY_SIZE
(
expectA
),
"WINE%04X.IME"
,
ime_count
-
1
);
memset
(
bufferA
,
0xcd
,
sizeof
(
bufferA
)
);
ret
=
ImmGetIMEFileNameA
(
hkl
,
bufferA
,
12
);
todo_wine
ok
(
ret
==
12
,
"ImmGetIMEFileNameA returned %lu
\n
"
,
ret
);
todo_wine
ok
(
!
strcmp
(
bufferA
,
expectA
),
"got bufferA %s
\n
"
,
debugstr_a
(
bufferA
)
);
swprintf
(
expectW
,
ARRAY_SIZE
(
expectW
),
L"WINE%04X.IME"
,
ime_count
-
1
);
memset
(
bufferW
,
0xcd
,
sizeof
(
bufferW
)
);
ret
=
ImmGetIMEFileNameW
(
hkl
,
bufferW
,
13
);
todo_wine
ok
(
ret
==
12
,
"ImmGetIMEFileNameW returned %lu
\n
"
,
ret
);
ok
(
!
wcscmp
(
bufferW
,
expectW
),
"got bufferW %s
\n
"
,
debugstr_w
(
bufferW
)
);
memset
(
bufferA
,
0xcd
,
sizeof
(
bufferA
)
);
ret
=
ImmGetIMEFileNameA
(
hkl
,
bufferA
,
13
);
todo_wine
ok
(
ret
==
12
,
"ImmGetIMEFileNameA returned %lu
\n
"
,
ret
);
ok
(
!
strcmp
(
bufferA
,
expectA
),
"got bufferA %s
\n
"
,
debugstr_a
(
bufferA
)
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment