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--;
        }


The problem here is that the output of snprintf() is locale-dependent,
so depending on the locale we might get a ',' as decimal separator.
That's not allowed by JSON and it actually breaks scripts/qmp/qmp.

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.

Berto

Reply via email to