Received: from eggs.gnu.org ([2001:4830:134:3::10]:44878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTp1L-0006tL-9N for qemu-devel@nongnu.org; Mon, 24 Aug 2015 06:30:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTp1H-0008C9-3X for qemu-devel@nongnu.org; Mon, 24 Aug 2015 06:30:31 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:9079 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTp1G-0007Qo-RZ for qemu-devel@nongnu.org; Mon, 24 Aug 2015 06:30:27 -0400 From: Alberto Garcia In-Reply-To: <87r3mtq9wx.fsf@blackfin.pond.sub.org> References: <20150818235754.GA31625@igalia.com> <87r3mtq9wx.fsf@blackfin.pond.sub.org> Date: Mon, 24 Aug 2015 12:29:21 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Gerd Hoffmann 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 setlocale() is a big no-no in my book. > > Overriding LC_NUMERIC as you propose should fix this particular bug. >However, exposing unprepared code to locale is not a good idea for >other categories as well. LC_COLLATE and LC_CTYPE are even sneakier >sources of bugs in my experience. I'd really, really prefer to stay in >the "C" locale *completely*. You can prevent GTK+ from calling setlocale() by using gtk_disable_setlocale() before gtk_init(), but note that setlocale() is needed for gettext. Berto