[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building and testing Bison 3.0.2 with MinGW [3/5]
From: |
Eli Zaretskii |
Subject: |
Re: Building and testing Bison 3.0.2 with MinGW [3/5] |
Date: |
Tue, 20 Jan 2015 19:27:06 +0200 |
> From: Akim Demaille <address@hidden>
> Date: Sat, 17 Jan 2015 18:11:50 +0100
> Cc: Bison Bugs <address@hidden>
>
> >> Yes, I'm trying to avoid any #ifdef in the code,
> >> and to hide everything in the library. In this case,
> >> I'd prefer something in src/system.h than in src/main.c.
> >
> > I can work on a patch like that, if you'd like me to.
>
> That would be great, thanks!
Is the below acceptable?
(I couldn't simply put this on system.h, since this is non-trivial C
code, not a macro or a short function.)
--- /dev/null 1970-01-01 02:00:00 +0200
+++ src/mingw-setlocale.c 2015-01-20 18:48:47 +0200
@@ -0,0 +1,26 @@
+#ifdef __MINGW32__
+static void
+mingw_setlocale (void)
+{
+ /* The Windows 'setlocale' doesn't look at the environment
+ variables, so do it here by hand. */
+ char const *cp = getenv ("LC_ALL");
+
+ if (!cp)
+ cp = getenv ("LANG");
+ if (cp)
+ setlocale (LC_ALL, cp);
+ else
+ setlocale (LC_ALL, "");
+ if ((cp = getenv ("LC_COLLATE")) != NULL)
+ setlocale (LC_COLLATE, cp);
+ if ((cp = getenv ("LC_CTYPE")) != NULL)
+ setlocale (LC_CTYPE, cp);
+ if ((cp = getenv ("LC_NUMERIC")) != NULL)
+ setlocale (LC_NUMERIC, cp);
+ if ((cp = getenv ("LC_MONETARY")) != NULL)
+ setlocale (LC_MONETARY, cp);
+ if ((cp = getenv ("LC_TIME")) != NULL)
+ setlocale (LC_TIME, cp);
+}
+#endif /* __MINGW32__ */
--- src/main.c~0 2014-10-07 07:45:06 +0300
+++ src/main.c 2015-01-20 19:10:28 +0200
@@ -54,11 +54,17 @@
#include "tables.h"
#include "uniqstr.h"
+#include "mingw-setlocale.c"
+
int
main (int argc, char *argv[])
{
set_program_name (argv[0]);
+#ifdef __MINGW32__
+ mingw_setlocale ();
+#else /* !__MINGW32__ */
setlocale (LC_ALL, "");
+#endif
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) bindtextdomain ("bison-runtime", LOCALEDIR);
(void) textdomain (PACKAGE);
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/16
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Eli Zaretskii, 2015/01/16
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/17
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Eli Zaretskii, 2015/01/17
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/17
- Re: Building and testing Bison 3.0.2 with MinGW [3/5],
Eli Zaretskii <=
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/22
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Eli Zaretskii, 2015/01/26
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/27
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Eli Zaretskii, 2015/01/27
- Re: Building and testing Bison 3.0.2 with MinGW [3/5], Akim Demaille, 2015/01/29