[libgdata] Bug 588995 – float radix character depends on LC_NUMERIC, but Google wants "."



commit 9ab94286da929f3bfa0c04a052963b608a45f956
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Jul 19 12:41:02 2009 +0100

    Bug 588995 â?? float radix character depends on LC_NUMERIC, but Google wants "."
    
    Changes based on a patch by Richard Schwarting <aquarichy gmail com> to
    use locale-independent functions to print doubles. Closes: bgo#588995

 gdata/services/picasaweb/gdata-picasaweb-file.c  |    4 +++-
 gdata/services/picasaweb/gdata-picasaweb-query.c |   10 +++++++---
 gdata/services/youtube/gdata-youtube-query.c     |   13 +++++++++----
 gdata/tests/youtube.c                            |    2 +-
 4 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/gdata/services/picasaweb/gdata-picasaweb-file.c b/gdata/services/picasaweb/gdata-picasaweb-file.c
index e683b72..d8ec071 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-file.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-file.c
@@ -687,6 +687,7 @@ static void
 get_xml (GDataParsable *parsable, GString *xml_string)
 {
 	GDataPicasaWebFilePrivate *priv = GDATA_PICASAWEB_FILE (parsable)->priv;
+	gchar ascii_double_str[G_ASCII_DTOSTR_BUF_SIZE];
 
 	/* Chain up to the parent class */
 	GDATA_PARSABLE_CLASS (gdata_picasaweb_file_parent_class)->get_xml (parsable, xml_string);
@@ -695,7 +696,8 @@ get_xml (GDataParsable *parsable, GString *xml_string)
 	if (priv->version != NULL)
 		g_string_append_printf (xml_string, "<gphoto:version>%s</gphoto:version>", priv->version);
 
-	g_string_append_printf (xml_string, "<gphoto:position>%f</gphoto:position>", priv->position);
+	g_string_append_printf (xml_string, "<gphoto:position>%s</gphoto:position>",
+				g_ascii_dtostr (ascii_double_str, sizeof (ascii_double_str), priv->position));
 
 	if (priv->album_id != NULL)
 		g_string_append_printf (xml_string, "<gphoto:albumid>%s</gphoto:albumid>", priv->album_id);
diff --git a/gdata/services/picasaweb/gdata-picasaweb-query.c b/gdata/services/picasaweb/gdata-picasaweb-query.c
index 7001fad..d56dedf 100644
--- a/gdata/services/picasaweb/gdata-picasaweb-query.c
+++ b/gdata/services/picasaweb/gdata-picasaweb-query.c
@@ -275,10 +275,14 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
 	}
 
 	if (priv->bounding_box.north != priv->bounding_box.south && priv->bounding_box.east != priv->bounding_box.west) {
+		gchar west[G_ASCII_DTOSTR_BUF_SIZE], south[G_ASCII_DTOSTR_BUF_SIZE], east[G_ASCII_DTOSTR_BUF_SIZE], north[G_ASCII_DTOSTR_BUF_SIZE];
+
 		APPEND_SEP
-		g_string_append_printf (query_uri, "bbox=%f,%f,%f,%f",
-					priv->bounding_box.west, priv->bounding_box.south,
-					priv->bounding_box.east, priv->bounding_box.north);
+		g_string_append_printf (query_uri, "bbox=%s,%s,%s,%s",
+					g_ascii_dtostr (west, sizeof (west), priv->bounding_box.west),
+					g_ascii_dtostr (south, sizeof (south), priv->bounding_box.south),
+					g_ascii_dtostr (east, sizeof (east), priv->bounding_box.east),
+					g_ascii_dtostr (north, sizeof (north), priv->bounding_box.north));
 	}
 
 	if (priv->location != NULL) {
diff --git a/gdata/services/youtube/gdata-youtube-query.c b/gdata/services/youtube/gdata-youtube-query.c
index 8617529..50cbe36 100644
--- a/gdata/services/youtube/gdata-youtube-query.c
+++ b/gdata/services/youtube/gdata-youtube-query.c
@@ -468,11 +468,16 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
 
 	if (priv->latitude >= -90.0 && priv->latitude <= 90.0 &&
 	    priv->longitude >= -180.0 && priv->longitude <= 180.0) {
-		g_string_append_printf (query_uri, (priv->has_location == TRUE) ? "&location=%f,%f!" : "&location=%f,%f",
-					priv->latitude, priv->longitude);
+		gchar latitude[G_ASCII_DTOSTR_BUF_SIZE], longitude[G_ASCII_DTOSTR_BUF_SIZE];
 
-		if (priv->location_radius >= 0.0)
-			g_string_append_printf (query_uri, "&location-radius=%fm", priv->location_radius);
+		g_string_append_printf (query_uri, (priv->has_location == TRUE) ? "&location=%s,%s!" : "&location=%s,%s",
+					g_ascii_dtostr (latitude, sizeof (latitude), priv->latitude),
+					g_ascii_dtostr (longitude, sizeof (longitude), priv->longitude));
+
+		if (priv->location_radius >= 0.0) {
+			gchar radius[G_ASCII_DTOSTR_BUF_SIZE];
+			g_string_append_printf (query_uri, "&location-radius=%sm", g_ascii_dtostr (radius, sizeof (radius), priv->location_radius));
+		}
 	} else if (priv->has_location == TRUE) {
 		g_string_append (query_uri, "&location=!");
 	}
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index 38a4672..703acf2 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -518,7 +518,7 @@ test_query_uri (GDataService *service)
 	g_assert (has_location == TRUE);
 
 	query_uri = gdata_query_get_query_uri (GDATA_QUERY (query), "http://example.com";);
-	g_assert_cmpstr (query_uri, ==, "http://example.com?q=q&time=all_time&safeSearch=none&format=1&location=45.013640,-97.123560!&location-radius=112.500000m";);
+	g_assert_cmpstr (query_uri, ==, "http://example.com?q=q&time=all_time&safeSearch=none&format=1&location=45.013640000000002,-97.123559999999998!&location-radius=112.5m";);
 	g_free (query_uri);
 
 	gdata_youtube_query_set_location (query, G_MAXDOUBLE, 0.6672, 52.8, TRUE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]