Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
596f8d67
Commit
596f8d67
authored
May 29, 2009
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Jun 01, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mlang: Suppress country data in rfc1766, with tests.
parent
e84ae0e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
27 deletions
+57
-27
mlang.c
dlls/mlang/mlang.c
+38
-13
mlang.c
dlls/mlang/tests/mlang.c
+19
-14
No files found.
dlls/mlang/mlang.c
View file @
596f8d67
...
...
@@ -1137,29 +1137,54 @@ HRESULT WINAPI IsConvertINetStringAvailable(
static
inline
HRESULT
lcid_to_rfc1766A
(
LCID
lcid
,
LPSTR
rfc1766
,
INT
len
)
{
INT
n
=
GetLocaleInfoA
(
lcid
,
LOCALE_SISO639LANGNAME
,
rfc1766
,
len
);
CHAR
buffer
[
MAX_RFC1766_NAME
];
INT
n
=
GetLocaleInfoA
(
lcid
,
LOCALE_SISO639LANGNAME
,
buffer
,
MAX_RFC1766_NAME
);
INT
i
;
if
(
n
)
{
rfc1766
[
n
-
1
]
=
'-'
;
n
+=
GetLocaleInfoA
(
lcid
,
LOCALE_SISO3166CTRYNAME
,
rfc1766
+
n
,
len
-
n
);
LCMapStringA
(
LOCALE_USER_DEFAULT
,
LCMAP_LOWERCASE
,
rfc1766
,
n
,
rfc1766
,
len
);
return
S_OK
;
i
=
PRIMARYLANGID
(
lcid
);
if
((((
i
==
LANG_ENGLISH
)
||
(
i
==
LANG_CHINESE
)
||
(
i
==
LANG_ARABIC
))
&&
(
SUBLANGID
(
lcid
)
==
SUBLANG_DEFAULT
))
||
(
SUBLANGID
(
lcid
)
>
SUBLANG_DEFAULT
))
{
buffer
[
n
-
1
]
=
'-'
;
i
=
GetLocaleInfoA
(
lcid
,
LOCALE_SISO3166CTRYNAME
,
buffer
+
n
,
MAX_RFC1766_NAME
-
n
);
if
(
!
i
)
buffer
[
n
-
1
]
=
'\0'
;
}
else
i
=
0
;
LCMapStringA
(
LOCALE_USER_DEFAULT
,
LCMAP_LOWERCASE
,
buffer
,
n
+
i
,
rfc1766
,
len
);
return
((
n
+
i
)
>
len
)
?
E_INVALIDARG
:
S_OK
;
}
return
E_FAIL
;
}
static
inline
HRESULT
lcid_to_rfc1766W
(
LCID
lcid
,
LPWSTR
rfc1766
,
INT
len
)
{
INT
n
=
GetLocaleInfoW
(
lcid
,
LOCALE_SISO639LANGNAME
,
rfc1766
,
len
);
INT
save
=
n
;
WCHAR
buffer
[
MAX_RFC1766_NAME
];
INT
n
=
GetLocaleInfoW
(
lcid
,
LOCALE_SISO639LANGNAME
,
buffer
,
MAX_RFC1766_NAME
);
INT
i
;
if
(
n
)
{
rfc1766
[
n
-
1
]
=
'-'
;
n
+=
GetLocaleInfoW
(
lcid
,
LOCALE_SISO3166CTRYNAME
,
rfc1766
+
n
,
len
-
n
);
if
(
n
==
save
)
rfc1766
[
n
-
1
]
=
'\0'
;
LCMapStringW
(
LOCALE_USER_DEFAULT
,
LCMAP_LOWERCASE
,
rfc1766
,
n
,
rfc1766
,
len
);
return
S_OK
;
i
=
PRIMARYLANGID
(
lcid
);
if
((((
i
==
LANG_ENGLISH
)
||
(
i
==
LANG_CHINESE
)
||
(
i
==
LANG_ARABIC
))
&&
(
SUBLANGID
(
lcid
)
==
SUBLANG_DEFAULT
))
||
(
SUBLANGID
(
lcid
)
>
SUBLANG_DEFAULT
))
{
buffer
[
n
-
1
]
=
'-'
;
i
=
GetLocaleInfoW
(
lcid
,
LOCALE_SISO3166CTRYNAME
,
buffer
+
n
,
MAX_RFC1766_NAME
-
n
);
if
(
!
i
)
buffer
[
n
-
1
]
=
'\0'
;
}
else
i
=
0
;
LCMapStringW
(
LOCALE_USER_DEFAULT
,
LCMAP_LOWERCASE
,
buffer
,
n
+
i
,
rfc1766
,
len
);
return
((
n
+
i
)
>
len
)
?
E_INVALIDARG
:
S_OK
;
}
return
E_FAIL
;
}
...
...
dlls/mlang/tests/mlang.c
View file @
596f8d67
...
...
@@ -940,25 +940,30 @@ static void test_Rfc1766ToLcid(void)
static
void
test_GetRfc1766FromLcid
(
IMultiLanguage2
*
iML2
)
{
CHAR
expected
[
MAX_RFC1766_NAME
];
CHAR
buffer
[
MAX_RFC1766_NAME
+
1
];
DWORD
i
;
HRESULT
hr
;
BSTR
rfcstr
;
LCID
lcid
;
static
WCHAR
kok
[]
=
{
'k'
,
'o'
,
'k'
,
0
};
for
(
i
=
0
;
i
<
sizeof
(
lcid_table
)
/
sizeof
(
lcid_table
[
0
]);
i
++
)
{
buffer
[
0
]
=
'\0'
;
hr
=
IMultiLanguage2_GetLcidFromRfc1766
(
iML2
,
&
lcid
,
kok
);
/*
* S_FALSE happens when 'kok' instead matches to a different Rfc1766 name
* for example 'ko' so it is not a failure but does not give us what
* we are looking for
*/
if
(
hr
!=
S_FALSE
)
{
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
rfcstr
=
NULL
;
hr
=
IMultiLanguage2_GetRfc1766FromLcid
(
iML2
,
lcid_table
[
i
].
lcid
,
&
rfcstr
);
ok
(
hr
==
lcid_table
[
i
].
hr
,
"#%02d: HRESULT 0x%x (expected 0x%x)
\n
"
,
i
,
hr
,
lcid_table
[
i
].
hr
);
if
(
hr
!=
S_OK
)
continue
;
/* no result-string created */
WideCharToMultiByte
(
CP_ACP
,
0
,
rfcstr
,
-
1
,
buffer
,
sizeof
(
buffer
),
NULL
,
NULL
);
LCMapStringA
(
LOCALE_USER_DEFAULT
,
LCMAP_LOWERCASE
,
lcid_table
[
i
].
rfc1766
,
lstrlenA
(
lcid_table
[
i
].
rfc1766
)
+
1
,
expected
,
MAX_RFC1766_NAME
);
ok
(
!
lstrcmpA
(
buffer
,
expected
),
"#%02d: got '%s' (expected '%s')
\n
"
,
i
,
buffer
,
expected
);
hr
=
IMultiLanguage2_GetRfc1766FromLcid
(
iML2
,
lcid
,
&
rfcstr
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok_w2
(
"Expected
\"
%s
\"
, got
\"
%s
\"
n"
,
kok
,
rfcstr
);
SysFreeString
(
rfcstr
);
}
}
...
...
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