From 453df705675869123675ba399f08e92ca658aa2f Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 12 May 2003 14:03:26 +0000 Subject: merge changes from 4.1 --- Src/math.c | 4 ++-- Src/params.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'Src') diff --git a/Src/math.c b/Src/math.c index 6e3fce777..2bf65d117 100644 --- a/Src/math.c +++ b/Src/math.c @@ -398,12 +398,12 @@ zzlex(void) /* it's a float */ yyval.type = MN_FLOAT; #ifdef USE_LOCALE - prev_locale = setlocale(LC_NUMERIC, NULL); + prev_locale = dupstring(setlocale(LC_NUMERIC, NULL)); setlocale(LC_NUMERIC, "POSIX"); #endif yyval.u.d = strtod(ptr, &nptr); #ifdef USE_LOCALE - setlocale(LC_NUMERIC, prev_locale); + if (prev_locale) setlocale(LC_NUMERIC, prev_locale); #endif if (ptr == nptr || *nptr == '.') { zerr("bad floating point constant", NULL, 0); diff --git a/Src/params.c b/Src/params.c index f461c15e0..255260467 100644 --- a/Src/params.c +++ b/Src/params.c @@ -3213,6 +3213,10 @@ char * convfloat(double dval, int digits, int flags, FILE *fout) { char fmt[] = "%.*e"; + char *ret; +#ifdef USE_LOCALE + char *prev_locale; +#endif /* * The difficulty with the buffer size is that a %f conversion @@ -3247,14 +3251,22 @@ convfloat(double dval, int digits, int flags, FILE *fout) digits--; } } +#ifdef USE_LOCALE + prev_locale = dupstring(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "POSIX"); +#endif if (fout) { fprintf(fout, fmt, digits, dval); - return NULL; + ret = NULL; } else { VARARR(char, buf, 512 + digits); sprintf(buf, fmt, digits, dval); - return dupstring(buf); + ret = dupstring(buf); } +#ifdef USE_LOCALE + if (prev_locale) setlocale(LC_NUMERIC, prev_locale); +#endif + return ret; } /* Start a parameter scope */ -- cgit 1.4.1