Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Locale problem

Date2012-02-29 10:27
FromFrancois PINOT
SubjectRe: [Cs-dev] Locale problem
AttachmentsNone  None  
OK. Looking at getstring.c, init_gestring seems actually under construction with two definitions depending on the GNU_GETTEXT definition when building csound. Then I can temporaily insert the statement in both definitions to be sure it's executed in any case.

Francois


Date: Wed, 29 Feb 2012 10:47:59 +0100
From: Tito Latini <tito.01beta@gmail.com>
Subject: Re: [Cs-dev] Locale problem
To: Developer discussions <csound-devel@lists.sourceforge.net>
Message-ID: <20120229094759.GA1705@hosteria.homenet.telecomitalia.it>
Content-Type: text/plain; charset=us-ascii

Well, perhaps `init_getstring' (Top/getstring.c) is a better place
(`csoundInitialize' calls `init_getstring').

tito

On Wed, Feb 29, 2012 at 10:03:33AM +0100, Francois PINOT wrote:
> Hello,
>
> I had a problem in blue using the new parser: as soon as there was a
> literal floating point value in the orchestra, i got an error about numeric
> values. It's a locale problem because in French, the decimal separator is a
> comma instead of a dot.
>
> I first thought that the problem was specific to blue and I transmitted the
> problem to Steven. But then Joachim Heintz signaled that he add the same
> problem with csoundQt and Tito Latini suggested that a solution might be to
> export LC_NUMERIC=C to force C syntax for floating point literals.
>
> I investigated in the csound sources and I found that the error comes from
> the strtod function used by csound in different files of the csound5/Engine
> dir: csound_orc_compile.c, express.c, linevent.c, otran.c, sread.c, and in
> csound5/Opcodes/ftgen.c
>
> We find this statement in csound5/Engine/otran.c (line306):
>
> setlocale(LC_NUMERIC, "C"); /* Ensure C syntax */
>
> So, if otran is not used by the new parser, this could explain that we have
> not this problem with the old parser.
>
> I suggest to solve the problem by inserting the setlocale(LC_NUMERIC, "C");
> statement in the csoundCreate function of the csound5/Top/csound.c source
> file, so that we are sure to have C syntax for literal floating point
> values in all cases (i.e. csound being launched from console, from a system
> call or through the API). I tried the solution here and it seems to work.
>
> If other developpers don't have any objection, I'll commit the patch to git
> when I'm back home this evening.
>
> Regards
>
> Francois