Csound Csound-dev Csound-tekno Search About

[Cs-dev] Locale problem

Date2012-02-29 09:03
FromFrancois PINOT
Subject[Cs-dev] Locale problem
AttachmentsNone  None  
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



Date2012-02-29 09:47
FromTito Latini
SubjectRe: [Cs-dev] Locale problem
AttachmentsNone