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

Sebastian Harl sh at tokkee.org
Fri Sep 4 14:08:01 CEST 2009


On Fri, Sep 04, 2009 at 12:48:25PM +0200, Benny Baumann wrote:
> Am 04.09.2009 09:54, schrieb Tobias Oetiker:
> > in rrd_graph I am calling
> >
> >     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 ?

> The reason for those lines is - I guess - to get a defined language
> environment inside the library.

As Tobi mentioned, it sets the locale to whatever has been specified in
the users environment, so the settings inside the library are basically

> 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.

Uhm … I'm not sure I understood that correctly. If you override the
locale settings specified by the user, you will _get_ issues when
parsing numbers (in fact, anything that has been passed on the command
line). Or did you mean to parse that prior to changing the settings?

Also, when changing the locale settings, the graph output would no
longer be localized - i.e. month names would be in whatever language has
been specified inside the library.

Did I miss your point?

Anyway - I think removing those lines is probably a good idea but I'd
double-check the reasons why they have been introduced to avoid
reintroducing some issues they were supposed to fix. Has this been
documented, e.g. in some commit message?


Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090904/92c7e885/attachment-0001.pgp 

More information about the rrd-developers mailing list