Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: LC_NUMERIC=fr_FR and floating point arithmetics
- X-seq: zsh-workers 18341
- From: Philippe Troin <phil@xxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: Re: LC_NUMERIC=fr_FR and floating point arithmetics
- Date: 11 Mar 2003 19:32:07 -0800
- Cc: Zsh workers <zsh-workers@xxxxxxxxxx>
- In-reply-to: <16574.1047378921@xxxxxxxxxxxxxxxxxxxx>
- Mail-copies-to: nobody
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20030224184502.A9922@xxxxxxxxxxxxxxxxxx> <1556.1047286700@xxxxxxxxxxxxxxxxxxxx> <20030310192526.GA15858@xxxxxxxx> <16574.1047378921@xxxxxxxxxxxxxxxxxxxx>
- Sender: Philippe Troin <phil@xxxxxxxx>
Oliver Kiddle <okiddle@xxxxxxxxxxx> writes:
> Index: Src/params.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/params.c,v
> retrieving revision 1.69
> diff -u -r1.69 params.c
> --- Src/params.c 31 Oct 2002 18:32:40 -0000 1.69
> +++ Src/params.c 11 Mar 2003 10:00:10 -0000
> @@ -3417,6 +3417,7 @@
> convfloat(double dval, int digits, int flags, FILE *fout)
> {
> char fmt[] = "%.*e";
> + char *prev_locale, *ret;
>
> /*
> * The difficulty with the buffer size is that a %f conversion
> @@ -3451,16 +3452,24 @@
> 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);
> if (!strchr(buf, 'e') && !strchr(buf, '.'))
> strcat(buf, ".");
> - return dupstring(buf);
> + ret = dupstring(buf);
> }
> +#ifdef USE_LOCALE
> + if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
> +#endif
> + return ret;
> }
>
> /* Start a parameter scope */
Aren't you leaking a copy of the current locale (via dupstring())
every time?
Phil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author