|
From: Ethan A M. <merritt@u.washington.edu> - 2008-02-13 05:11:15
|
On Tuesday 12 February 2008 16:05, Hans-Bernhard Bröker wrote:
> Hello, guys,
>
> I received mail from a German user of gnuplot on Win32 who observes
> strange behaviour, apparently from 'set decimalsign locale' being set to
> German:
>
> Version:
> G N U P L O T
> Version 4.2 patchlevel 2
> last modified 31 Aug 2007
> System: MS-Windows 32 bit
>
> [Condensed] script to reproduce:
>
> set datafile separator ';'
> set decimalsign locale 'german'
> p1 = -22.5
> p2 = 52.5
> p3 = 30
> p(x)=p1*(x-2001)**2+p2*(x-2001)+p3
> print p(2005)
> print p(2005.5)
>
> Output from the two print commands is:
>
> -120.0
> -189,375
>
> Note that it's -120.0, with a '.', instead of the requested and expected
> ',', while the output of -189,375 worked as expected. Does this ring a
> bell with anyone?
No. But after a bit of poking around I found this routine in show.c
num_to_str(double r)
{
static int i = 0;
static char s[4][25];
int j = i++;
if (i > 3)
i = 0;
sprintf(s[j], "%.15g", r);
if (strchr(s[j], '.') == NULL &&
#ifdef HAVE_LOCALE_H
strchr(s[j], ',') == NULL &&
#endif
strchr(s[j], 'e') == NULL &&
strchr(s[j], 'E') == NULL)
strcat(s[j], ".0");
return s[j];
}
As you can see, it gratuitiously adds ".0" to the end of integers without
regard to the current locale. I suppose this is fixable if necessary.
But now I have another question. In current CVS the "print" command is not
one of the special cases for which the current locale is checked.
All output from "print" is processed in the C locale. Should it be?
The documentation is silent on this precise issue, but implies that the
locale is used only for numberic output to the graph itself, not to the terminal.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|