GNOME Bugzilla – Bug 317615
librsvg uses locale settings while parsing files (LC_NUMERIC)
Last modified: 2005-10-04 17:40:39 UTC
Distribution/Version: Freerock's GNOME (frg-current) Set LC_NUMERIC to pl_PL. Run Eye of Gnome, or Klotski (gnotski) or madjongg. SVG images is misdisplayd. This happenes because in polish we use coma ',' as a decimal point while SVG requires full stop '.' for this. Everything works fine if I set LC_NUMERIC=C
i find this hard to believe, unless there is a bug in glib. rsvg doesn't use printf or scanf with %g, %f, or %e arguments. rsvg doesn't use strtod, atof, etc. we use g_ascii_strtod, which is supposed to handle exactly this scanario. as far as i can tell, we've been *very* careful about these numeric locale issues.
Yet still, there is something wrong and changin LC_NUMERIC *really* helps. I am not 100% sure that this is the problem of the library. However, if I notice the same problem with three different applications: eog, mahjongg and gnotski, which all deal with SVG and all happen to fail if the LC_NUMERIC is pl_PL (',' decimal point), I am quite convinced is in the library. I also tried to view gnotski.svg and postmodern.svg with ImageMagic's display which isn't AFAIK linked against librsvg (at least not dynamically) and despite it has some problems with postmodern.svg it doesn't fail the way eog does. There are two PNG files made from gnotski.svg eog.
Created attachment 52887 [details] gnotski.svg saved as PNG with eog, LC_NUMERIC=C
Created attachment 52888 [details] gnotski.svg saved as PNG with eog, LC_NUMERIC=pl_PL.utf8
what version of glib do you have installed?
moving to NEEDINFO state
It's 2.8.2-i486-1frg (frg == Freerock's GNOME for Slackware; http://gsb.freerock.org)
reopening
*** Bug 317610 has been marked as a duplicate of this bug. ***
As per the bug I marked as a duplicate above, I can reproduce this on a recently updated Ubunutu Breezy install with librsvg 2.12.4 (2.12.4-0ubuntu1).
I have found the cause of the bug. The input is parsed absolutely correctly, but it turns out that Dom's second statement in comment #1 is wrong. In the file rsvg-shapes.c, function _rsvg_node_poly_draw there are lines like: g_string_append_printf (d, "M %f %f ", poly->pointlist[0], poly->pointlist[1] ); The data is being re-encoded, and when it is the locale settings are being used producing commas in the string. I'll look into getting a patch together after I've had some dinner.
Created attachment 53012 [details] [review] A patch to fix the problem This patch temporarily sets the locale back to the "C" locale while doing the g_string_append_printf operations. It is basically the same as the example in section 7.4 of the glibc manual. Quick and dirty, but it works. An alternative would be to make librsvg handle polygons natively rather than translating them to a path which is where the problem code lies.
ooh, good point... i'll fix this properly
fixed! thanks callum!
*** Bug 317942 has been marked as a duplicate of this bug. ***