gnucash stable: [gnc-locale-name] Use setlocale(LC_MONETARY, NULL) to retrieve name.
John Ralls
jralls at code.gnucash.org
Mon Jun 23 21:19:06 EDT 2025
Updated via https://github.com/Gnucash/gnucash/commit/d8c68cce (commit)
from https://github.com/Gnucash/gnucash/commit/29b1330e (commit)
commit d8c68cce9e1bd99c812942720758ac6645fe9d57
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Jun 23 18:12:06 2025 -0700
[gnc-locale-name] Use setlocale(LC_MONETARY, NULL) to retrieve name.
Instead of setlocale(LC_ALL, NULL). The uses for the string either create
an ICU locale or sort between German and US TXF reports. On some OSes
where the user has different locales set for one or more categories LC_ALL
produces a dump of all of the LC_FOO variables and their values. That's
not useful for comparing to de_DE and it's too long for ICU, which
crashes.
Meanwhile in dialog-print-checks the RV of setlocale was ignored,
rendering the call a no-op.
diff --git a/gnucash/gnome/dialog-print-check.c b/gnucash/gnome/dialog-print-check.c
index c351cfbf87..5e0cb64451 100644
--- a/gnucash/gnome/dialog-print-check.c
+++ b/gnucash/gnome/dialog-print-check.c
@@ -2074,7 +2074,6 @@ draw_date_format(GtkPrintContext *context, const gchar *date_format,
const gchar *c;
GString *cdn_fmt;
- setlocale(LC_ALL, NULL);
if ( !data->print_date_format ) return;
date_desc = pango_font_description_copy_static(default_desc);
diff --git a/libgnucash/core-utils/gnc-locale-utils.c b/libgnucash/core-utils/gnc-locale-utils.c
index 033122a479..966e67b98f 100644
--- a/libgnucash/core-utils/gnc-locale-utils.c
+++ b/libgnucash/core-utils/gnc-locale-utils.c
@@ -156,7 +156,7 @@ gchar *gnc_locale_name (void)
# ifdef G_OS_WIN32
return g_win32_getlocale();
# else /* !G_OS_WIN32 */
- return g_strdup (setlocale(LC_ALL, NULL));
+ return g_strdup (setlocale(LC_MONETARY, NULL));
# endif /* G_OS_WIN32 */
}
diff --git a/libgnucash/tax/gnc-locale-tax.c b/libgnucash/tax/gnc-locale-tax.c
index 0bff95217b..d430e7c55f 100644
--- a/libgnucash/tax/gnc-locale-tax.c
+++ b/libgnucash/tax/gnc-locale-tax.c
@@ -36,7 +36,7 @@
#include <guile-mappings.h>
#include <gnc-guile-utils.h>
#include "gnc-locale-tax.h"
-
+#include <gnc-locale-utils.h>
void
@@ -50,7 +50,7 @@ gnc_locale_tax_init(void)
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
g_free(thislocale);
# else /* !G_OS_WIN32 */
- const char *thislocale = setlocale(LC_ALL, NULL);
+ const char *thislocale = gnc_locale_name();
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
# endif /* G_OS_WIN32 */
if (is_de_DE)
Summary of changes:
gnucash/gnome/dialog-print-check.c | 1 -
libgnucash/core-utils/gnc-locale-utils.c | 2 +-
libgnucash/tax/gnc-locale-tax.c | 4 ++--
3 files changed, 3 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list