diff options
Diffstat (limited to 'app/wlib/mswlib/gwin32.c')
-rw-r--r-- | app/wlib/mswlib/gwin32.c | 155 |
1 files changed, 77 insertions, 78 deletions
diff --git a/app/wlib/mswlib/gwin32.c b/app/wlib/mswlib/gwin32.c index 6b0c7f3..c537439 100644 --- a/app/wlib/mswlib/gwin32.c +++ b/app/wlib/mswlib/gwin32.c @@ -13,16 +13,15 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Modified by the GLib Team and others 1997-2000. See the AUTHORS * file for a list of people on the GLib Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. + * GLib at ftp://ftp.gtk.org/pub/gtk/. * * Ported to standard C by Martin Fischer 2009 * @@ -40,7 +39,7 @@ #include <errno.h> #include <ctype.h> #if defined(_MSC_VER) || defined(__DMC__) -# include <io.h> +#include <io.h> #endif /* _MSC_VER || __DMC__ */ #ifndef SUBLANG_SERBIAN_LATIN_BA @@ -48,17 +47,17 @@ #endif #if _MSC_VER > 1300 - #define stricmp _stricmp - #define strnicmp _strnicmp - #define strdup _strdup +#define stricmp _stricmp +#define strnicmp _strnicmp +#define strdup _strdup #endif /** - * This function gets the current thread locale from Windows - without any + * This function gets the current thread locale from Windows - without any * encoding info - and returns it as a string of the above form for use in forming * file names etc. The setlocale() function in the Microsoft C library uses locale * names of the form "English_United States.1252" etc. We want the - * UNIXish standard form "en_US", "zh_TW" etc. The returned string should be + * UNIXish standard form "en_US", "zh_TW" etc. The returned string should be * deallocated with free(). * * \return newly-allocated locale name. @@ -67,80 +66,80 @@ char * g_win32_getlocale (void) { - LCID lcid; - LANGID langid; - char *ev; - char *loc; - int primary, sub; - char iso639[10]; - char iso3166[10]; - const char *script = NULL; + LCID lcid; + LANGID langid; + char *ev; + char *loc; + int primary, sub; + char iso639[10]; + char iso3166[10]; + const char *script = NULL; - /* Let the user override the system settings through environment - * variables, as on POSIX systems. Note that in GTK+ applications - * since GTK+ 2.10.7 setting either LC_ALL or LANG also sets the - * Win32 locale and C library locale through code in gtkmain.c. - */ - if (((ev = getenv ("LC_ALL")) != NULL && ev[0] != '\0') - || ((ev = getenv ("LC_MESSAGES")) != NULL && ev[0] != '\0') - || ((ev = getenv ("LANG")) != NULL && ev[0] != '\0')) - return strdup (ev); + /* Let the user override the system settings through environment + * variables, as on POSIX systems. Note that in GTK+ applications + * since GTK+ 2.10.7 setting either LC_ALL or LANG also sets the + * Win32 locale and C library locale through code in gtkmain.c. + */ + if (((ev = getenv ("LC_ALL")) != NULL && ev[0] != '\0') + || ((ev = getenv ("LC_MESSAGES")) != NULL && ev[0] != '\0') + || ((ev = getenv ("LANG")) != NULL && ev[0] != '\0')) { + return strdup (ev); + } - lcid = GetThreadLocale (); + lcid = GetThreadLocale (); - if (!GetLocaleInfo (lcid, LOCALE_SISO639LANGNAME, iso639, sizeof (iso639)) || - !GetLocaleInfo (lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof (iso3166))) - return strdup ("C"); - - /* Strip off the sorting rules, keep only the language part. */ - langid = LANGIDFROMLCID (lcid); + if (!GetLocaleInfo (lcid, LOCALE_SISO639LANGNAME, iso639, sizeof (iso639)) || + !GetLocaleInfo (lcid, LOCALE_SISO3166CTRYNAME, iso3166, sizeof (iso3166))) { + return strdup ("C"); + } - /* Split into language and territory part. */ - primary = PRIMARYLANGID (langid); - sub = SUBLANGID (langid); + /* Strip off the sorting rules, keep only the language part. */ + langid = LANGIDFROMLCID (lcid); - /* Handle special cases */ - switch (primary) - { - case LANG_AZERI: - switch (sub) - { - case SUBLANG_AZERI_LATIN: - script = "@Latn"; - break; - case SUBLANG_AZERI_CYRILLIC: - script = "@Cyrl"; - break; - } - break; - case LANG_SERBIAN: /* LANG_CROATIAN == LANG_SERBIAN */ - switch (sub) - { - case SUBLANG_SERBIAN_LATIN: - case 0x06: /* Serbian (Latin) - Bosnia and Herzegovina */ - script = "@Latn"; - break; + /* Split into language and territory part. */ + primary = PRIMARYLANGID (langid); + sub = SUBLANGID (langid); + + /* Handle special cases */ + switch (primary) { + case LANG_AZERI: + switch (sub) { + case SUBLANG_AZERI_LATIN: + script = "@Latn"; + break; + case SUBLANG_AZERI_CYRILLIC: + script = "@Cyrl"; + break; + } + break; + case LANG_SERBIAN: /* LANG_CROATIAN == LANG_SERBIAN */ + switch (sub) { + case SUBLANG_SERBIAN_LATIN: + case 0x06: /* Serbian (Latin) - Bosnia and Herzegovina */ + script = "@Latn"; + break; + } + break; + case LANG_UZBEK: + switch (sub) { + case SUBLANG_UZBEK_LATIN: + script = "@Latn"; + break; + case SUBLANG_UZBEK_CYRILLIC: + script = "@Cyrl"; + break; + } + break; } - break; - case LANG_UZBEK: - switch (sub) - { - case SUBLANG_UZBEK_LATIN: - script = "@Latn"; - break; - case SUBLANG_UZBEK_CYRILLIC: - script = "@Cyrl"; - break; + + loc = malloc( strlen( iso639 ) + strlen( iso3166 ) + (script ? strlen( + script ) : 0) + 2 ); + strcpy( loc, iso639 ); + strcat( loc, "_" ); + strcat( loc, iso3166 ); + if( script ) { + strcat( loc, script ); } - break; - } - - loc = malloc( strlen( iso639 ) + strlen( iso3166 ) + (script ? strlen( script ) : 0) + 2 ); - strcpy( loc, iso639 ); - strcat( loc, "_" ); - strcat( loc, iso3166 ); - if( script ) - strcat( loc, script ); - return loc; + return loc; } |