[rrd-developers] getting rid of some of the LOCALE magic

Tobias Oetiker tobi at oetiker.ch
Sun Oct 4 13:58:13 CEST 2009


Hi Benny,

Sep 4 Benny Baumann wrote:

> Hi,
>
> The reason for those lines is - I guess - to get a defined language
> environment inside the library. I'd more or less correct those to first
> query the current env and then set the one the library expects. That way
> you avoid some issues with number format conversions especially when
> parsing numbers in floating point arguments.

this is being done for LC_NUMERIC numerous times to avoid getting
bitten by commas instead of . in numbers ... but apart from that
the library should not mess with the locale on its own since it is
written to be able to cope with whatever locale is set ... the
reason these statements were in there was to have the locale set,
when I put them in it was not clear to me that this should be only
done by the main program (as it is now being done by rrd_tool.c).

someone calling the library may also do it before the library is
called and would most likely not be thrilled if the library altered
the settings on the fly to whatever some environemt variable sais
...

cheers
tobi


> Regards,
> BenBE.
>
> Am 04.09.2009 09:54, schrieb Tobias Oetiker:
> > People,
> >
> > in rrd_graph I am calling
> >
> > #ifdef HAVE_SETLOCALE
> >     setlocale(LC_TIME, "");
> > #ifdef HAVE_MBSTOWCS
> >     setlocale(LC_CTYPE, "");
> > #endif
> > #endif
> >
> > this causes the locale settings to be reset to whatever the
> > coresponding environment variable sais ... this is nice when people
> > set the LC_* variable in the surrounding code ... but it cause
> > unexpected behaviour, if people use setlocale when calling rrdtool
> > as a library ...
> >
> > I think about dropping the calls for 1.4 ... what do you think ?
> >
> > cheers
> > tobi
> >
> >
> >
> >
>
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-developers mailing list