]> Pileus Git - grits/commitdiff
Add reset locale when formatting certain strings
authorAndy Spencer <andy753421@gmail.com>
Sat, 2 Jul 2011 03:19:35 +0000 (03:19 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 2 Jul 2011 03:19:35 +0000 (03:19 +0000)
LC_NUMERIC is used to determine the conversion for "%f" this can result
in errors when formatting strings with expected floating point formats.

src/data/grits-wms.c

index 32c0c0cfa3cec96f9e336d1c60fdb9335af843d5..fe6338c03b0e936b31eec0dbf0485b7835aec3c0 100644 (file)
 #include <config.h>
 #include <stdio.h>
 #include <glib.h>
+#include <locale.h>
 
 #include "grits-wms.h"
 #include "grits-http.h"
 
+static gchar *g_strdup_printf_safe(char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       setlocale(LC_ALL, "POSIX.UTF-8");
+       char *str = g_strdup_vprintf(fmt, ap);
+       setlocale(LC_ALL, "");
+       va_end(ap);
+       return str;
+}
+
 static gchar *_make_uri(GritsWms *wms, GritsTile *tile)
 {
-       return g_strdup_printf(
+       return g_strdup_printf_safe(
                "%s?"
                "SERVICE=WMS&"
                "VERSION=1.1.0&"