> Le 26 janv. 2015 à 19:03, Eli Zaretskii <e...@gnu.org> a écrit : > >> From: Akim Demaille <a...@lrde.epita.fr> >> Date: Thu, 22 Jan 2015 16:20:16 +0100 >> Cc: Bison Bugs <bug-bison@gnu.org> >> >>> --- /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) >> >> That would be great! Put a #define setlocale mingw_setlocale >> in system.h, and I'm the happiest Bison maintainer in the world :) > > It's not _that_ easy. > > Does the below make you happy enough?
Actually I don't understand why you include mingw-setlocale instead of putting it in the lib/ library, and just link against it. I might be missing something. Yet I don't want to be a pain in the neck. Do you know of a build farm or something like that where I could run continuous builds for Bison on mingw? > --- src/main.c~0 2014-10-07 07:45:06 +0300 > +++ src/main.c 2015-01-25 12:54:03 +0200 > @@ -221,3 +221,5 @@ main (int argc, char *argv[]) > > return complaint_status ? EXIT_FAILURE : EXIT_SUCCESS; > } > + > +#include "mingw-setlocale.c" > > > --- src/system.h~0 2013-08-02 17:35:13 +0300 > +++ src/system.h 2015-01-25 13:05:18 +0200 > @@ -39,6 +39,18 @@ > # include <stdlib.h> > # include <string.h> > > +# ifdef __MINGW32__ > +/* This is needed to get O_TEXT for output.c */ > +# include <fcntl.h> > +/* This is needed for mbschr in parse-gram.y */ > +# include <mbstring.h> > +/* This is needed to get the prototype of 'setlocale' before we > + redirect it to 'mingw_setlocale'. */ > +# include <locale.h> > +# define setlocale(c,v) mingw_setlocale(c,v) > +char * mingw_setlocale (int, const char *); > +# endif > + > # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) > # define STREQ(L, R) (strcmp(L, R) == 0) > # define STRNEQ(L, R) (!STREQ(L, R)) > > > --- /dev/null 1970-01-01 02:00:00 +0200 > +++ src/mingw-setlocale.c 2015-01-25 13:19:41 +0200 > @@ -0,0 +1,38 @@ > +#ifdef __MINGW32__ > + > +#undef setlocale > + > +char * > +mingw_setlocale (int cat, const char *val) > +{ > + char *retval; > + > + if (cat == LC_ALL && val && val[0] == '\0') > + { > + /* The Windows 'setlocale' doesn't look at the environment > + variables, so do it here by hand. */ > + char const *cp = getenv ("LC_ALL"); > + > + if (cp) > + retval = setlocale (LC_ALL, cp); > + else > + { > + retval = setlocale (LC_ALL, val); > + if ((cp = getenv ("LANG")) != NULL) > + setlocale (LC_ALL, cp); > + 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); > + } > + } > + else > + return setlocale (cat, val); > +} > +#endif /* __MINGW32__ */