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
9f0983dd
Commit
9f0983dd
authored
Nov 19, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Use RtlLocaleNameToLcid().
parent
7ac7a902
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
36 deletions
+14
-36
locale.c
dlls/kernel32/locale.c
+7
-36
locale.c
dlls/kernel32/tests/locale.c
+7
-0
No files found.
dlls/kernel32/locale.c
View file @
9f0983dd
...
...
@@ -1182,32 +1182,12 @@ BOOL WINAPI GetUserPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buffe
*/
LCID
WINAPI
LocaleNameToLCID
(
LPCWSTR
name
,
DWORD
flags
)
{
struct
locale_name
locale_name
;
static
int
once
;
if
(
flags
&&
!
once
++
)
FIXME
(
"unsupported flags %x
\n
"
,
flags
);
if
(
name
==
LOCALE_NAME_USER_DEFAULT
)
return
GetUserDefaultLCID
();
LCID
lcid
;
/* string parsing */
parse_locale_name
(
name
,
&
locale_name
);
TRACE
(
"found lcid %x for %s, matches %d
\n
"
,
locale_name
.
lcid
,
debugstr_w
(
name
),
locale_name
.
matches
);
if
(
!
locale_name
.
matches
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
locale_name
.
matches
==
1
)
WARN
(
"locale %s not recognized, defaulting to %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
locale_name
.
lang
)
);
return
locale_name
.
lcid
;
if
(
!
name
)
return
GetUserDefaultLCID
();
if
(
!
set_ntstatus
(
RtlLocaleNameToLcid
(
name
,
&
lcid
,
2
)))
return
0
;
if
(
!
(
flags
&
LOCALE_ALLOW_NEUTRAL_NAMES
))
lcid
=
ConvertDefaultLocale
(
lcid
);
return
lcid
;
}
...
...
@@ -2570,18 +2550,9 @@ BOOL WINAPI IsValidLocale( LCID lcid, DWORD flags )
*/
BOOL
WINAPI
IsValidLocaleName
(
LPCWSTR
locale
)
{
struct
locale_name
locale_name
;
if
(
!
locale
)
return
FALSE
;
/* string parsing */
parse_locale_name
(
locale
,
&
locale_name
);
TRACE
(
"found lcid %x for %s, matches %d
\n
"
,
locale_name
.
lcid
,
debugstr_w
(
locale
),
locale_name
.
matches
);
LCID
lcid
;
return
locale_name
.
matches
>
0
;
return
!
RtlLocaleNameToLcid
(
locale
,
&
lcid
,
2
)
;
}
/******************************************************************************
...
...
dlls/kernel32/tests/locale.c
View file @
9f0983dd
...
...
@@ -2856,6 +2856,9 @@ static void test_LocaleNameToLCID(void)
ok
(
lcid
==
MAKELCID
(
MAKELANGID
(
LANG_SPANISH
,
SUBLANG_SPANISH_MODERN
),
SORT_DEFAULT
),
"Got wrong lcid for es-es: 0x%x
\n
"
,
lcid
);
/* english neutral name */
lcid
=
pLocaleNameToLCID
(
enW
,
LOCALE_ALLOW_NEUTRAL_NAMES
);
ok
(
lcid
==
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_NEUTRAL
),
SORT_DEFAULT
)
||
broken
(
lcid
==
0
)
/* Vista */
,
"got 0x%04x
\n
"
,
lcid
);
lcid
=
pLocaleNameToLCID
(
enW
,
0
);
ok
(
lcid
==
MAKELCID
(
MAKELANGID
(
LANG_ENGLISH
,
SUBLANG_ENGLISH_US
),
SORT_DEFAULT
)
||
broken
(
lcid
==
0
)
/* Vista */
,
"got 0x%04x
\n
"
,
lcid
);
...
...
@@ -2871,6 +2874,7 @@ static void test_LocaleNameToLCID(void)
*
buffer
=
0
;
ret
=
pLCIDToLocaleName
(
lcid
,
buffer
,
ARRAY_SIZE
(
buffer
),
0
);
ok
(
ret
>
0
,
"%s: got %d
\n
"
,
wine_dbgstr_w
(
ptr
->
name
),
ret
);
todo_wine_if
(
ptr
->
todo
)
ok
(
!
lstrcmpW
(
ptr
->
sname
,
buffer
),
"%s: got wrong locale name %s
\n
"
,
wine_dbgstr_w
(
ptr
->
name
),
wine_dbgstr_w
(
buffer
));
...
...
@@ -4740,6 +4744,7 @@ static void test_GetLocaleInfoEx(void)
static
void
test_IsValidLocaleName
(
void
)
{
static
const
WCHAR
enusW
[]
=
{
'e'
,
'n'
,
'-'
,
'U'
,
'S'
,
0
};
static
const
WCHAR
enW
[]
=
{
'e'
,
'n'
,
0
};
static
const
WCHAR
zzW
[]
=
{
'z'
,
'z'
,
0
};
static
const
WCHAR
zz_zzW
[]
=
{
'z'
,
'z'
,
'-'
,
'Z'
,
'Z'
,
0
};
static
const
WCHAR
zzzzW
[]
=
{
'z'
,
'z'
,
'z'
,
'z'
,
0
};
...
...
@@ -4753,6 +4758,8 @@ static void test_IsValidLocaleName(void)
ret
=
pIsValidLocaleName
(
enusW
);
ok
(
ret
,
"IsValidLocaleName failed
\n
"
);
ret
=
pIsValidLocaleName
(
enW
);
ok
(
ret
||
broken
(
!
ret
),
"IsValidLocaleName failed
\n
"
);
ret
=
pIsValidLocaleName
(
zzW
);
ok
(
!
ret
||
broken
(
ret
),
"IsValidLocaleName should have failed
\n
"
);
ret
=
pIsValidLocaleName
(
zz_zzW
);
...
...
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