aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse-xml.c10
-rw-r--r--save-xml.c10
2 files changed, 11 insertions, 9 deletions
diff --git a/parse-xml.c b/parse-xml.c
index f62ce9891..15138f43e 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1045,15 +1045,11 @@ static int uddf_dive_match(struct dive **divep, const char *name, int len, char
static void gps_location(char *buffer, void *_dive)
{
- int i;
+ char *end;
struct dive *dive = _dive;
- double latitude, longitude;
- i = sscanf(buffer, "%lf %lf", &latitude, &longitude);
- if (i == 2) {
- dive->latitude = latitude;
- dive->longitude = longitude;
- }
+ dive->latitude = g_ascii_strtod(buffer, &end);
+ dive->longitude = g_ascii_strtod(end, &end);
free(buffer);
}
diff --git a/save-xml.c b/save-xml.c
index 824763c44..a70aacc3e 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -193,8 +193,14 @@ static void show_location(FILE *f, struct dive *dive)
*/
if (latitude || longitude) {
int len = snprintf(buffer, sizeof(buffer)-4,
- " <location gps='%.12g %.12g'>",
- latitude, longitude);
+ " <location gps=");
+ char *buf = buffer + len;
+
+ len = strlen(g_ascii_formatd(buf, 80, "'%.12g ", latitude));
+ buf += len;
+ len = strlen(g_ascii_formatd(buf, 80, "%.12g'>", longitude));
+ buf += len;
+ len = buf - buffer;
if (!dive->location) {
memcpy(&buffer[len-1], "/>\n", 4);
fputs(buffer, f);