Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

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

Requested reviews:
  Rodolfo Ochoa (rodolfo-ochoa)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/143794

Quick-and-dirty fix for IsValidLocaleName() and Windows XP.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/143794
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/zorbautils/locale.cpp'
--- src/zorbautils/locale.cpp	2013-01-10 02:03:05 +0000
+++ src/zorbautils/locale.cpp	2013-01-18 00:06:24 +0000
@@ -186,6 +186,27 @@
   return zstring( info.get() );
 }
 
+/**
+ * IsValidLocaleName() is available only on Windows Vista and later so we can't
+ * call it directly since we might be running on Windows XP.  Hence, check to
+ * see if it's available and call it indirectly if so.
+ */
+static BOOL Zorba_IsValidLocaleName( LPCWSTR lpLocaleName ) {
+  typedef int (WINAPI *IsValidLocaleName_type)( LPCWSTR );
+
+  static IsValidLocaleName_type IsValidLocaleName_ptr;
+  static bool init;
+
+  if ( !init ) {
+    IsValidLocaleName_ptr = (IsValidLocaleName_type)::GetProcAddress(
+      ::GetModuleHandle( TEXT( "kernel32.dll" ) ), "IsValidLocaleName"
+    );
+    init = true;
+  }
+
+  return IsValidLocaleName_ptr ? IsValidLocaleName_ptr( lpLocaleName ) : 0;
+}
+
 #else /* WIN32 */
 
 /**
@@ -1282,7 +1303,7 @@
 bool is_supported( iso639_1::type lang, iso3166_1::type country ) {
 #ifdef WIN32
   unique_ptr<WCHAR[]> const wlocale_name( get_wlocale_name( lang, country ) );
-  return !!::IsValidLocaleName( wlocale_name.get() );
+  return !!::Zorba_IsValidLocaleName( wlocale_name.get() );
 #else
   if ( locale_t const loc = get_unix_locale_t( lang, country ) ) {
     ::freelocale( loc );

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to