|
From: Ethan M. <merritt@u.washington.edu> - 2005-06-10 17:38:11
|
>=20
> >Comment By: Petr Mikulik (mikulik)
> Date: 2005-06-10 09:24
>=20
> I hope gnuplot's reading will not depend on environmental
> variables as it would immediately became non-portable.
I think you have this backwards. The LOCALE mechanism is our
best and probably only path toward true portability.
=20
> I would rather prefer
> set decimalsign input ","
We can discuss the choice of gnuplot commands at leisure,
but the fact is that the only way to take action on such a
request is via the LOCALE mechanism, and for better or for
worse that affects both input (scanf, atof, strtod, ...) and
output (printf, ...) in parallel.
This is the code I have been testing:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
/* process 'set decimalsign' command */
static void
set_decimalsign()
{
c_token++;
if (END_OF_COMMAND) {
if (decimalsign !=3D NULL)
free(decimalsign);
decimalsign=3DNULL;
#ifdef HAVE_LOCALE_H
} else if (equals(c_token,"locale")) {
c_token++;
setlocale(LC_NUMERIC,"");
fprintf(stderr,"decimal_sign in locale is %s\n", (localeconv()->dec=
imal_point));
decimalsign =3D gp_strdup(localeconv()->decimal_point);
#endif
} else if (!(decimalsign =3D try_to_get_string()))
int_error(c_token, "expecting string");
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
So to read an input file with numeric formatting in the convention
of your local environment, you would say
set decimal locale
plot "foo" ...
So far as I know, it is not possible to hard-code the LOCALE choice
entirely internal to gnuplot, because gnuplot has no control over
what locales are installed or supported on the machine it runs on.
We are guaranteed that the "C" locale is available, which uses=20
'.' as a decimal sign, but I have been unable to find any guaranteed
locale that would use ',' instead.
=46rom the command line on linux you can say
setenv LC_NUMERIC ,
and `locale -c -k` claims that the decimal sign is now "," but upon
testing I find that it does not in fact have any effect on formatting
and anyhow the equivalent request from inside a program via setlocale()
is not accepted at all.
(I'll be out of town for several days, so I won't see any replies for
a while)
=2D-=20
Ethan A Merritt merritt@u.washington.edu
Biomolecular Structure Center
Mailstop 357742
University of Washington, Seattle, WA 98195
|