r15973 - gnucash/trunk/src - To identify the active locale on Windows, use g_win32_getlocale instead of setlocale.

Andreas Köhler andi5 at cvs.gnucash.org
Sat Apr 21 20:48:04 EDT 2007


Author: andi5
Date: 2007-04-21 20:48:03 -0400 (Sat, 21 Apr 2007)
New Revision: 15973
Trac: http://svn.gnucash.org/trac/changeset/15973

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/gnome/druid-hierarchy.c
   gnucash/trunk/src/report/locale-specific/us/gncmod-locale-reports-us.c
   gnucash/trunk/src/tax/us/gncmod-tax-us.c
Log:
To identify the active locale on Windows, use g_win32_getlocale instead of setlocale.


Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2007-04-21 22:20:18 UTC (rev 15972)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2007-04-22 00:48:03 UTC (rev 15973)
@@ -413,17 +413,25 @@
   if (get_form == SCM_UNDEFINED)
   {
     GNCModule module;
+    const gchar *tax_module;
     /* load the tax info */
 #ifdef LOCALE_SPECIFIC_TAX
-    const char *thislocale = setlocale(LC_ALL, NULL);
     /* This is a very simple hack that loads the (new, special) German
        tax definition file in a German locale, or (default) loads the
        previous US tax file. */
+    gboolean is_de_DE;
+# ifdef G_OS_WIN32
+    gchar *thislocale = g_win32_getlocale();
+    is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+    g_free(thislocale);
+# else /* !G_OS_WIN32 */
+    const char *thislocale = setlocale(LC_ALL, NULL);
     gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
-#else
+# endif /* G_OS_WIN32 */
+#else /* LOCALE_SPECIFIC_TAX */
     gboolean is_de_DE = FALSE;
 #endif /* LOCALE_SPECIFIC_TAX */
-    const char *tax_module = is_de_DE ? 
+    tax_module = is_de_DE ? 
       "gnucash/tax/de_DE" : 
       "gnucash/tax/us";
 

Modified: gnucash/trunk/src/gnome/druid-hierarchy.c
===================================================================
--- gnucash/trunk/src/gnome/druid-hierarchy.c	2007-04-21 22:20:18 UTC (rev 15972)
+++ gnucash/trunk/src/gnome/druid-hierarchy.c	2007-04-22 00:48:03 UTC (rev 15973)
@@ -188,7 +188,7 @@
 # ifdef G_OS_WIN32
     /* On win32, setlocale() doesn't say anything useful. Use
        glib's function instead. */
-    locale = g_strdup( *g_get_language_names() );
+    locale = g_win32_getlocale();
 # else
     /*
      * Mac OS X 10.1 and earlier, not only doesn't have LC_MESSAGES

Modified: gnucash/trunk/src/report/locale-specific/us/gncmod-locale-reports-us.c
===================================================================
--- gnucash/trunk/src/report/locale-specific/us/gncmod-locale-reports-us.c	2007-04-21 22:20:18 UTC (rev 15972)
+++ gnucash/trunk/src/report/locale-specific/us/gncmod-locale-reports-us.c	2007-04-22 00:48:03 UTC (rev 15973)
@@ -43,25 +43,32 @@
 
 int
 libgncmod_locale_reports_us_gnc_module_init(int refcount) {
+  const gchar *tax_module, *report_taxtxf, *report_locale;
   /* load the tax info */
 #ifdef LOCALE_SPECIFIC_TAX
-  const char *thislocale = setlocale(LC_ALL, NULL);
   /* This is a very simple hack that loads the (new, special) German
      tax definition file in a German locale, or (default) loads the
      previous US tax file. */
+# ifdef G_OS_WIN32
+  gchar *thislocale = g_win32_getlocale();
   gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
-#else
+  g_free(thislocale);
+# else /* !G_OS_WIN32 */
+  const char *thislocale = setlocale(LC_ALL, NULL);
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+# endif /* G_OS_WIN32 */
+#else /* !LOCALE_SPECIFIC_TAX */
   gboolean is_de_DE = FALSE;
 #endif /* LOCALE_SPECIFIC_TAX */
-  const char *tax_module = is_de_DE ?
-    "gnucash/tax/de_DE" :
-    "gnucash/tax/us";
-  const char *report_taxtxf = is_de_DE ?
-    "(use-modules (gnucash report taxtxf-de_DE))" :
-    "(use-modules (gnucash report taxtxf))";
-  const char *report_locale = is_de_DE ?
-    "(use-modules (gnucash report locale-specific de_DE))" :
-    "(use-modules (gnucash report locale-specific us))";
+  if (is_de_DE) {
+    tax_module = "gnucash/tax/de_DE";
+    report_taxtxf = "(use-modules (gnucash report taxtxf-de_DE))";
+    report_locale = "(use-modules (gnucash report locale-specific de_DE))";
+  } else {
+    tax_module = "gnucash/tax/us";
+    report_taxtxf = "(use-modules (gnucash report taxtxf))";
+    report_locale = "(use-modules (gnucash report locale-specific us))";
+  }
 
   /* The gchar* cast is only because the function declaration expects
      a non-const string -- probably an api error. */

Modified: gnucash/trunk/src/tax/us/gncmod-tax-us.c
===================================================================
--- gnucash/trunk/src/tax/us/gncmod-tax-us.c	2007-04-21 22:20:18 UTC (rev 15972)
+++ gnucash/trunk/src/tax/us/gncmod-tax-us.c	2007-04-22 00:48:03 UTC (rev 15973)
@@ -30,12 +30,20 @@
 char *
 libgncmod_tax_us_gnc_module_path(void) {
 #ifdef LOCALE_SPECIFIC_TAX
+# ifdef G_OS_WIN32
+  gchar *thislocale = g_win32_getlocale();
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+  g_free(thislocale);
+# else /* !G_OS_WIN32 */
   const char *thislocale = setlocale(LC_ALL, NULL);
-  if (strncmp(thislocale, "de_DE", 5) == 0)
-    return g_strdup("gnucash/tax/de_DE");
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+# endif /* G_OS_WIN32 */
+  if (is_de_DE)
+     return g_strdup("gnucash/tax/de_DE");
   else
-#endif
-    return g_strdup("gnucash/tax/us");
+     return g_strdup("gnucash/tax/us");
+#endif /* LOCALE_SPECIFIC_TAX */
+  return g_strdup("gnucash/tax/us");
 }
 
 char *
@@ -57,11 +65,18 @@
      tax definition file in a German locale, or (default) loads the
      previous US tax file. */
 #ifdef LOCALE_SPECIFIC_TAX
+# ifdef G_OS_WIN32
+  gchar *thislocale = g_win32_getlocale();
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+  g_free(thislocale);
+# else /* !G_OS_WIN32 */
   const char *thislocale = setlocale(LC_ALL, NULL);
-  if (strncmp(thislocale, "de_DE", 5) == 0)
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+# endif /* G_OS_WIN32 */
+  if (is_de_DE)
     lmod("(gnucash tax de_DE)");
   else
-#endif
+#endif /* LOCALE_SPECIFIC_TAX */
     lmod("(gnucash tax us)");
   return TRUE;
 }



More information about the gnucash-changes mailing list