On Tue, May 7, 2013 at 10:36 AM, Janne Liljeblad
<janne.liljeb...@gmail.com> wrote:
> f I change the values used in that test to "0.567800" and 0.5678, it
> still passes. Maybe you are affected by numeric locale. See test
> RadixRespondsToLocale() in the same file. If you are running in an
> environment that defines the radix as a comma, then indeed "0.5678"
> will get converted to 0.
>
> Dan, why giving does input for a c library give different output depending
> on locale? Should not output always be the same?

It should work the way the user expects it to work, which is to parse
numbers correctly based on their locale. This is the way the C lib
strtod() and atof() work. However, glibc does not load the current
locale by default, which can give unexpected results in many apps
including melt from 2 years ago. Therefore, mlt_factory_init loads the
system locale as of Sept 13, 2011. If you don't like that, then your
app can setlocale to whatever you want after initializing the factory.
See this e-mail for the motivation:

On Mon, Sep 12, 2011 at 10:27 AM, Dan Dennedy <d...@dennedy.org> wrote:
> On Mon, Sep 12, 2011 at 9:50 AM, j-b-m <j-...@users.sourceforge.net> wrote:
>> Hi!
>>
>> Once again a locale issue! As noticed by a Kdenlive user, MLT does not
>>
>> correctly detect locale, unless the ladspa plugins are installed
>> (swh-plugin),
>>
>> see:
>>
>> http://kdenlive.org/mantis/view.php?id=2310
>>
>> After some testing, I discovered in the setlocale documentation:
>>
>> "If setlocale() is not invoked, the POSIX locale is the default at entry to
>>
>> main(). [Option End]"
>
> I recall reading that as well but noticing that 'LC_NUMERIC=de_DE
> melt' worked as expected nonetheless. So, I was somewhat confused,
> felt the documented behavior sounds incorrect, and considered the
> possibility that either the documentation was incorrect depending upon
> some context.
>
>> So in fact, when starting MLT, it always defaults to the POSIX (C) locale,
>>
>> whatever your system locale is. It is probable that somewhere in the LADSPA
>>
>> plugins, a setlocale call is done that then initializes the process locale
>> to
>>
>> the system environment.
>
> What I failed to consider was that some optional dependency was
> responsible for making it work. It is very interesting to learn that
> all C/C++ programs must call setlocale() just to properly get numeric
> text input working. In programming coursework, just after the hello
> world examples, when they start showing some basic console or text
> file input, how often do you see a setlocale? Never, right? It seems
> that things like strtod() would follow on pretty quickly and start
> "cutting fingers." How can something so fundamental like this go
> unnoticed? Of all of the executables on your system, do you think
> nearly all of them call setlocale? What the hell is going on!?!
>
>> So I think that we should add the following lines:
>>
>> // this will set the process locale to the system's default
>>
>> setlocale(LC_NUMERIC, "");
>>
>> Somewhere in the mlt_factory_init or in the mlt_repository stuff to properly
>>
>> set the process locale at startup, that will fix the problem.
>
> OK
>
> --
> +-DRD-+

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to