Re: Bug in MagickAnnoteImage() if locale is set to de_DE.UTF-8

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Mon, 12 Jun 2017, Marvin Gülker wrote:

> Hi,
>
> apologies for the late reply. I forgot about the topic...
>
> On Sun, May 28, 2017 at 06:00:44PM -0500, Bob Friesenhahn wrote:
>> There is a known problem in that parsing floating point numbers (e.g.
>> numbers like "200.0") may fail if the locale uses different delimiter for
>> the decimal point (e.g. "200,0").  The reason for this is that all text
>> formats which include floating point numbers use traditional C/POSIX locale.
>> Changing the numeric locale to something else causes the operating system's
>> floating point parsing and generation to operate incorrectly.
>
> I see this, but I did not input my numbers as text at all. They're
> floating-point literals directly in the C source code (just see the
> example I submitted) so unless GraphicsMagick is converting them to a
> string by itself, this should have no effect.

GraphicsMagick is converting internally to strings since the renderer 
is based on parsing strings.

>> Try adding
>>
>>   (void) setlocale(LC_NUMERIC,"C");
>>
>> after any preceding locale requests.
>
> I can confirm this works. If I change LC_NUMERIC as advised by you, the
> problem does not occur. This however looks to me more like a workaround
> than like a solution. If this is the only possible way to avoid the
> problem, I think GraphicsMagick should do that call on itself before it
> does a text conversion, and afterwards reset it to what it was
> before. Ideally however it would not depend on the locale at all.

Unfortunately, changing the locale is not thread safe.  Additional 
problems would result.  It would be possible to test if the locale is 
set correctly and only switch it if it is not.

The proper solution is to implement built-in floating point 
parsing/formatting support which is not dependent on the locale.

There was originally an objective to re-implement the renderer to use 
a binary-object format rather than text so that C/C++ code could use 
the renderer without parsing at all.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.