[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: thousands separator
From: |
Aharon Robbins |
Subject: |
Re: thousands separator |
Date: |
Thu, 09 Jul 2009 21:53:10 +0300 |
Hi. Here is a patch to try.
It'll be in CVS shortly.
Eli, please apply (or get from the CVS) and see if it makes a difference
for you.
Gary, if you can't get to the gawk CVS to compile a fresh copy, maybe Eli
can get you one.
Thanks!
Arnold
---------------------------------------------------
Thu Jul 9 21:47:56 2009 Arnold D. Robbins <address@hidden>
* main.c (init_locale): New function to make a deep copy of the
struct lconv. Thanks to KIMURA Koichi <address@hidden>
for the info.
Index: main.c
===================================================================
RCS file: /d/mongo/cvsrep/gawk-stable/main.c,v
retrieving revision 1.22
diff -u -r1.22 main.c
--- main.c 23 Jun 2009 03:10:05 -0000 1.22
+++ main.c 9 Jul 2009 18:45:33 -0000
@@ -99,6 +99,7 @@
#if defined(HAVE_LOCALE_H)
struct lconv loc; /* current locale */
+static void init_locale(struct lconv *l);
#endif /* defined(HAVE_LOCALE_H) */
/* The name the program was invoked under, for error messages */
@@ -272,7 +273,7 @@
* the thousands separator for the %'d flag.
*/
setlocale(LC_NUMERIC, "");
- loc = *localeconv(); /* Make a local copy of locale numeric info,
early on */
+ init_locale(& loc);
setlocale(LC_NUMERIC, "C");
#endif
#if defined(LC_TIME)
@@ -1297,3 +1298,35 @@
fatal(_("could not find groups: %s"), strerror(errno));
#endif
}
+
+#if defined(HAVE_LOCALE_H)
+
+/* init_locale --- initialize locale info. */
+
+/*
+ * On some operating systems, the pointers in the struct returned
+ * by localeconv() can become dangling pointers after a call to
+ * setlocale(). So we do a deep copy.
+ *
+ * Thanks to KIMURA Koichi <address@hidden>.
+ */
+
+static void
+init_locale(struct lconv *l)
+{
+ struct lconv *t;
+
+ t = localeconv();
+ *l = *t;
+ l->thousands_sep = strdup(t->thousands_sep);
+ l->decimal_point = strdup(t->decimal_point);
+ l->grouping = strdup(t->grouping);
+ l->int_curr_symbol = strdup(t->int_curr_symbol);
+ l->currency_symbol = strdup(t->currency_symbol);
+ l->mon_decimal_point = strdup(t->mon_decimal_point);
+ l->mon_thousands_sep = strdup(t->mon_thousands_sep);
+ l->mon_grouping = strdup(t->mon_grouping);
+ l->positive_sign = strdup(t->positive_sign);
+ l->negative_sign = strdup(t->negative_sign);
+}
+#endif /* LOCALE_H */
- Re: thousands separator, (continued)
- Re: thousands separator, Aharon Robbins, 2009/07/07
- Re: thousands separator, Aharon Robbins, 2009/07/08
- Re: thousands separator, Aharon Robbins, 2009/07/08
- Re: thousands separator, KIMURA Koichi, 2009/07/09
- Re: thousands separator, Aharon Robbins, 2009/07/09
- Re: thousands separator,
Aharon Robbins <=