Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-26 Thread Markus Armbruster
"Daniel P. Berrange" writes: > On Wed, Aug 26, 2015 at 08:46:35AM +0200, Gerd Hoffmann wrote: >> Hi, >> >> > > It seems the only thing that we really care about being localized is >> > > the messages catalogue, so the GTK UI gets internationalization in >> > > its menus / dialogs / etc. As suc

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-26 Thread Daniel P. Berrange
On Wed, Aug 26, 2015 at 08:46:35AM +0200, Gerd Hoffmann wrote: > Hi, > > > > It seems the only thing that we really care about being localized is > > > the messages catalogue, so the GTK UI gets internationalization in > > > its menus / dialogs / etc. As such I think that we should do the > > >

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-26 Thread Markus Armbruster
"Daniel P. Berrange" writes: > On Wed, Aug 26, 2015 at 11:13:00AM +0200, Alberto Garcia wrote: >> On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote: >> >> >> (D) Run in a controlled mixed locale >> >>GTK runs completely in the locale determined by setlocale() (since it >> >> never

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-26 Thread Daniel P. Berrange
On Wed, Aug 26, 2015 at 11:13:00AM +0200, Alberto Garcia wrote: > On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote: > > >> (D) Run in a controlled mixed locale > >>GTK runs completely in the locale determined by setlocale() (since it > >> never has to display raw JSON) > >>We f

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-26 Thread Alberto Garcia
On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote: >> (D) Run in a controlled mixed locale >>GTK runs completely in the locale determined by setlocale() (since it >> never has to display raw JSON) >>We fix our JSON output code to use thread-specific locale >> manipulations to (t

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-25 Thread Gerd Hoffmann
Hi, > > It seems the only thing that we really care about being localized is > > the messages catalogue, so the GTK UI gets internationalization in > > its menus / dialogs / etc. As such I think that we should do the > > opposite of (C). ie run every LC_* in the C locale, except for > > LC_MESSA

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-25 Thread Markus Armbruster
Alberto Garcia writes: > On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote: > >> Switching back to C locale whenever some unwanted locale-dependency >> breaks the code is problematic, because it involves finding all the >> places that break, iteratively (euphemism for "we debug one bre

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-25 Thread Alberto Garcia
On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote: > Switching back to C locale whenever some unwanted locale-dependency > breaks the code is problematic, because it involves finding all the > places that break, iteratively (euphemism for "we debug one breakage > after the other, adding

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-25 Thread Markus Armbruster
Eric Blake writes: > On 08/24/2015 11:07 AM, Markus Armbruster wrote: > >>> You can prevent GTK+ from calling setlocale() by using >>> gtk_disable_setlocale() before gtk_init(), but note that setlocale() is >>> needed for gettext. >> >> We can >> >> (A) Internationalize our complete code base >

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Eric Blake
On 08/24/2015 11:56 AM, Daniel P. Berrange wrote: >> (C) Run in a mixed locale >> >> Whenever something breaks, we switch another LC_ to the C locale. >> >> Can partially break GTK's internationalization. >> >> I happily concede that (A) would be best. Until the manpower to pull it >> off

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Daniel P. Berrange
On Mon, Aug 24, 2015 at 07:07:38PM +0200, Markus Armbruster wrote: > Alberto Garcia writes: > > > On Mon 24 Aug 2015 12:05:02 PM CEST, Markus Armbruster wrote: > > > >>> This seems to happen because of GTK+ calling setlocale(). The easiest > >>> solution is probably to call setlocale(LC_NUMERIC,

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Eric Blake
On 08/24/2015 11:07 AM, Markus Armbruster wrote: >> You can prevent GTK+ from calling setlocale() by using >> gtk_disable_setlocale() before gtk_init(), but note that setlocale() is >> needed for gettext. > > We can > > (A) Internationalize our complete code base > > (B) Run in the C locale >

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Markus Armbruster
Alberto Garcia writes: > On Mon 24 Aug 2015 12:05:02 PM CEST, Markus Armbruster wrote: > >>> This seems to happen because of GTK+ calling setlocale(). The easiest >>> solution is probably to call setlocale(LC_NUMERIC, "C") before >>> snprintf() (or at start-up ui/gtk.c), but opinions are welcome.

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Markus Armbruster
Copying maintainer. Alberto Garcia writes: > We have this code in qjson.c to produce JSON from a QFloat: > > QFloat *val = qobject_to_qfloat(obj); > char buffer[1024]; > int len; > > len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val)); > w

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Alberto Garcia
On Mon 24 Aug 2015 12:05:02 PM CEST, Markus Armbruster wrote: >> This seems to happen because of GTK+ calling setlocale(). The easiest >> solution is probably to call setlocale(LC_NUMERIC, "C") before >> snprintf() (or at start-up ui/gtk.c), but opinions are welcome. > > A library calling setlocal

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-24 Thread Daniel P. Berrange
On Wed, Aug 19, 2015 at 01:57:55AM +0200, Alberto Garcia wrote: > We have this code in qjson.c to produce JSON from a QFloat: > > QFloat *val = qobject_to_qfloat(obj); > char buffer[1024]; > int len; > > len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_doubl

[Qemu-devel] QEMU produces invalid JSON due to locale-dependent code

2015-08-18 Thread Alberto Garcia
We have this code in qjson.c to produce JSON from a QFloat: QFloat *val = qobject_to_qfloat(obj); char buffer[1024]; int len; len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val)); while (len > 0 && buffer[len - 1] == '0') { len--