From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20869 invoked from network); 12 Mar 2003 03:32:20 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 12 Mar 2003 03:32:20 -0000 Received: (qmail 11782 invoked by alias); 12 Mar 2003 03:32:13 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18341 Received: (qmail 11767 invoked from network); 12 Mar 2003 03:32:12 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 12 Mar 2003 03:32:12 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [216.27.190.146] by sunsite.dk (MessageWall 1.0.8) with SMTP; 12 Mar 2003 3:32:12 -0000 Received: from ceramic.fifi.org (mail@ceramic.fifi.org [216.27.190.147]) by tantale.fifi.org (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id TAA19349; Tue, 11 Mar 2003 19:32:09 -0800 Received: from phil by ceramic.fifi.org with local (Exim 3.35 #1 (Debian)) id 18swyN-0005Vn-00; Tue, 11 Mar 2003 19:32:07 -0800 To: Oliver Kiddle Cc: Zsh workers Subject: Re: LC_NUMERIC=fr_FR and floating point arithmetics References: <20030224184502.A9922@pcchazelas.free.fr> <1556.1047286700@finches.logica.co.uk> <20030310192526.GA15858@fysh.org> <16574.1047378921@finches.logica.co.uk> Mail-Copies-To: nobody From: Philippe Troin Date: 11 Mar 2003 19:32:07 -0800 In-Reply-To: <16574.1047378921@finches.logica.co.uk> Message-ID: <87bs0hdzuw.fsf@ceramic.fifi.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Philippe Troin Oliver Kiddle 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.