[PATCH] Different system locale settings cause the export to crash

Linus Torvalds torvalds at linux-foundation.org
Sat Apr 5 13:01:34 PDT 2014


On Sat, Apr 5, 2014 at 1:00 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> Which would make the patch something like this (untested, but it compiles).

.. and by that I meant *this*.

            Linus
-------------- next part --------------
 membuffer.c     | 12 ++++++++++++
 membuffer.h     |  1 +
 save-git.c      | 17 ++---------------
 worldmap-save.c |  4 ++--
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/membuffer.c b/membuffer.c
index 9d3167293458..82816ece6166 100644
--- a/membuffer.c
+++ b/membuffer.c
@@ -164,3 +164,15 @@ void put_salinity(struct membuffer *b, int salinity, const char *pre, const char
 	if (salinity)
 		put_format(b, "%s%d%s", pre, salinity / 10, post);
 }
+
+void put_degrees(struct membuffer *b, degrees_t value, const char *pre, const char *post)
+{
+	int udeg = value.udeg;
+	const char *sign = "";
+
+	if (udeg < 0) {
+		udeg = -udeg;
+		sign = "-";
+	}
+	put_format(b,"%s%s%u.%06u%s", pre, sign, FRACTION(udeg, 1000000), post);
+}
diff --git a/membuffer.h b/membuffer.h
index 4386b1e114fb..ee0305eeefaa 100644
--- a/membuffer.h
+++ b/membuffer.h
@@ -56,6 +56,7 @@ extern void put_depth(struct membuffer *, depth_t, const char *, const char *);
 extern void put_duration(struct membuffer *, duration_t, const char *, const char *);
 extern void put_pressure(struct membuffer *, pressure_t, const char *, const char *);
 extern void put_salinity(struct membuffer *, int, const char *, const char *);
+extern void put_degrees(struct membuffer *b, degrees_t value, const char *, const char *);
 
 #ifdef __cplusplus
 }
diff --git a/save-git.c b/save-git.c
index 9b0d2dbbae27..634db66067bd 100644
--- a/save-git.c
+++ b/save-git.c
@@ -38,24 +38,11 @@ static void cond_put_format(int cond, struct membuffer *b, const char *fmt, ...)
 
 #define SAVE(str, x) cond_put_format(dive->x, b, str " %d\n", dive->x)
 
-static void put_degrees(struct membuffer *b, degrees_t value, const char sep)
-{
-	int udeg = value.udeg;
-	const char *sign = "";
-
-	if (udeg < 0) {
-		udeg = -udeg;
-		sign = "-";
-	}
-	put_format(b,"%s%u.%06u%c", sign, FRACTION(udeg, 1000000), sep);
-}
-
 static void show_gps(struct membuffer *b, degrees_t latitude, degrees_t longitude)
 {
 	if (latitude.udeg || longitude.udeg) {
-		put_string(b, "gps ");
-		put_degrees(b, latitude, ' ');
-		put_degrees(b, longitude, '\n');
+		put_degrees(b, latitude, "gps ", " ");
+		put_degrees(b, longitude, "", "\n");
 	}
 }
 
diff --git a/worldmap-save.c b/worldmap-save.c
index 0c40bc30f06e..36ee9431182e 100644
--- a/worldmap-save.c
+++ b/worldmap-save.c
@@ -94,8 +94,8 @@ void writeMarkers(struct membuffer *b)
 		if (dive->latitude.udeg == 0 && dive->longitude.udeg == 0)
 			continue;
 
-		put_format(b, "temp = new google.maps.Marker({position: new google.maps.LatLng(%f,%f)});\n",
-			   dive->latitude.udeg / 1000000.0, dive->longitude.udeg / 1000000.0);
+		put_degrees(b, dive->latitude, "temp = new google.maps.Marker({position: new google.maps.LatLng(", "");
+		put_degrees(b, dive->longitude, ",", ")});\n");
 		put_string(b, "markers.push(temp);\ntempinfowindow = new google.maps.InfoWindow({content: '<div id=\"content\">'+'<div id=\"siteNotice\">'+'</div>'+'<div id=\"bodyContent\">");
 		put_HTML_date(b, dive);
 		put_duration(b, dive->duration, "<p>duration=", " min</p>");


More information about the subsurface mailing list