[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk 3.1.3 and 3.1.4 problem with -v and non-C locales
From: |
Aharon Robbins |
Subject: |
gawk 3.1.3 and 3.1.4 problem with -v and non-C locales |
Date: |
Wed, 8 Sep 2004 10:01:07 +0300 |
Hello world.
Gawk 3.1.3 and 3.1.4 have a problem in non-C locales when -v
is used, as demonstrated by this simple example:
$ (export LC_ALL=pl_PL ; bash)
bash-2.05b$ gawk-3.1.4 'BEGIN { print 1.67 }'
1,67
bash-2.05b$ gawk-3.1.4 -v b=4 'BEGIN { print 1.67 }'
1
This was reported in comp.lang.awk. The fix is attached.
Arnold
-------- Attachments? We don't need no steenkeeng attachments! -------
Wed Sep 8 09:54:53 2004 Arnold D. Robbins <address@hidden>
* main.c (main): Force LC_NUMERIC locale to "C" before parsing
the program, since a variable assignment with -v can leave the
locale set incorrectly.
--- ../gawk-3.1.4/main.c 2004-07-28 16:42:19.000000000 +0300
@@ -532,6 +538,15 @@
init_args(optind, argc, (char *) myname, argv);
(void) tokexpand();
+#if defined(LC_NUMERIC)
+ /*
+ * FRAGILE! CAREFUL!
+ * Pre-initing the variables with arg_assign() can change the
+ * locale. Force it to C before parsing the program.
+ */
+ setlocale(LC_NUMERIC, "C");
+#endif
+
/* Read in the program */
if (yyparse() != 0 || errcount != 0)
exit(1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gawk 3.1.3 and 3.1.4 problem with -v and non-C locales,
Aharon Robbins <=