After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 647908 - gtkrc does not handle "shade()" in a locale safe manor
gtkrc does not handle "shade()" in a locale safe manor
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.20.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-04-15 21:06 UTC by Elliot Glaysher
Modified: 2011-04-27 21:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (545 bytes, text/plain)
2011-04-15 21:07 UTC, Elliot Glaysher
  Details
gtkrc.c: Use g_ascii_dtostr for formatting floats (1013 bytes, patch)
2011-04-15 22:00 UTC, Colin Walters
committed Details | Review
Locally tested and modified version of Colin's patch above. (1.00 KB, patch)
2011-04-19 17:26 UTC, Elliot Glaysher
reviewed Details | Review
Plus space in printf (1.00 KB, patch)
2011-04-21 17:17 UTC, Elliot Glaysher
committed Details | Review

Description Elliot Glaysher 2011-04-15 21:06:01 UTC
When parsing gtkrc files, 'shade(0.5, "#color")' is not parsed in a locale neutral way. In locales where a ',' is used to separate floating point numbers instead of '.', parsing just fails on shade() directives. Attached is a minimal repro case, which produces the following output depending on the locale: 

---
$ gcc gtk_gdk_parsing.c `pkg-config --cflags --libs gtk+-2.0`
$ LC_NUMERIC=C ./a.out 
Parsed color: #101010101010
$ LC_NUMERIC=ru_RU.utf8 ./a.out 
Gtk-Message: (for origin information, set GTK_DEBUG): failed to retrieve property `GtkWidget::link-color' of type `GdkColor' from rc file value "((GString*) 0x54c620)" of type `GString'

(a.out:17856): Gdk-CRITICAL **: gdk_color_to_string: assertion `color != NULL' failed
Parsed color: (null)
---

This is a big problem for chromium as we read GdkColors for themeing purposes.
Comment 1 Elliot Glaysher 2011-04-15 21:07:23 UTC
Created attachment 186050 [details]
Test case
Comment 2 Colin Walters 2011-04-15 22:00:58 UTC
Created attachment 186052 [details] [review]
gtkrc.c: Use g_ascii_dtostr for formatting floats
Comment 3 Elliot Glaysher 2011-04-15 23:12:31 UTC
Review of attachment 186052 [details] [review]:

Patching this in locally, I get a:

(a.out:674): GLib-CRITICAL **: g_ascii_formatd: assertion `format[0] == '%'' failed

when running the test case I supplied earlier. Removing the first space from the g_ascii_formatd format string and rebuilding made everything work, but then I assume that an extra "g_string_append(gstring, " ");" needs to be added for the space.

Thanks for doing this, BTW.
Comment 4 Elliot Glaysher 2011-04-15 23:12:32 UTC
Review of attachment 186052 [details] [review]:

Patching this in locally, I get a:

(a.out:674): GLib-CRITICAL **: g_ascii_formatd: assertion `format[0] == '%'' failed

when running the test case I supplied earlier. Removing the first space from the g_ascii_formatd format string and rebuilding made everything work, but then I assume that an extra "g_string_append(gstring, " ");" needs to be added for the space.

Thanks for doing this, BTW.
Comment 5 Dmitry Shachnev 2011-04-16 05:15:29 UTC
Can I apply this patch to Gtk+ 2.24 (just copying it to debian/patches and debuild'ing)?
I'm a reporter of the upstream bug.
Comment 6 Elliot Glaysher 2011-04-19 17:26:26 UTC
Created attachment 186304 [details] [review]
Locally tested and modified version of Colin's patch above.

I tested and worked out the problem with the format string. I believe this fixes it.
Comment 7 Colin Walters 2011-04-21 13:34:08 UTC
Review of attachment 186304 [details] [review]:

Hm, isn't your modified version here missing the space?  (Thanks for fixing up my untested patch btw)
Comment 8 Elliot Glaysher 2011-04-21 17:17:48 UTC
Created attachment 186443 [details] [review]
Plus space in printf

Good catch. Added the space to the printf format string.
Comment 9 Colin Walters 2011-04-27 21:11:20 UTC
Attachment 186052 [details] pushed as c4b2d3a - gtkrc.c: Use g_ascii_dtostr for formatting floats