Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Rodolfo Ochoa
Approved revision: 11041
Merged at revision: 11190
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 40 lines (+22/-1)
1 file modified
src/zorbautils/locale.cpp (+22/-1)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Rodolfo Ochoa Approve
Paul J. Lucas Approve
Review via email: mp+143794@code.launchpad.net

Commit message

Quick-and-dirty fix for IsValidLocaleName() and Windows XP.

Description of the change

Quick-and-dirty fix for IsValidLocaleName() and Windows XP.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job pjl-misc-2013-01-18T20-29-03.161Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/zorbautils/locale.cpp'
2--- src/zorbautils/locale.cpp 2013-01-10 02:03:05 +0000
3+++ src/zorbautils/locale.cpp 2013-01-18 00:06:24 +0000
4@@ -186,6 +186,27 @@
5 return zstring( info.get() );
6 }
7
8+/**
9+ * IsValidLocaleName() is available only on Windows Vista and later so we can't
10+ * call it directly since we might be running on Windows XP. Hence, check to
11+ * see if it's available and call it indirectly if so.
12+ */
13+static BOOL Zorba_IsValidLocaleName( LPCWSTR lpLocaleName ) {
14+ typedef int (WINAPI *IsValidLocaleName_type)( LPCWSTR );
15+
16+ static IsValidLocaleName_type IsValidLocaleName_ptr;
17+ static bool init;
18+
19+ if ( !init ) {
20+ IsValidLocaleName_ptr = (IsValidLocaleName_type)::GetProcAddress(
21+ ::GetModuleHandle( TEXT( "kernel32.dll" ) ), "IsValidLocaleName"
22+ );
23+ init = true;
24+ }
25+
26+ return IsValidLocaleName_ptr ? IsValidLocaleName_ptr( lpLocaleName ) : 0;
27+}
28+
29 #else /* WIN32 */
30
31 /**
32@@ -1282,7 +1303,7 @@
33 bool is_supported( iso639_1::type lang, iso3166_1::type country ) {
34 #ifdef WIN32
35 unique_ptr<WCHAR[]> const wlocale_name( get_wlocale_name( lang, country ) );
36- return !!::IsValidLocaleName( wlocale_name.get() );
37+ return !!::Zorba_IsValidLocaleName( wlocale_name.get() );
38 #else
39 if ( locale_t const loc = get_unix_locale_t( lang, country ) ) {
40 ::freelocale( loc );

Subscribers

People subscribed via source and target branches