summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/save-xml.c b/save-xml.c
index b61f79440..54a0a8606 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -71,16 +71,19 @@ static void quote(struct membuffer *b, const char *text, int is_attribute)
static void show_utf8(struct membuffer *b, const char *text, const char *pre, const char *post, int is_attribute)
{
int len;
+
+ if (!text)
+ return;
+ while (isspace(*text))
+ text++;
+ len = strlen(text);
+ if (!len)
+ return;
+ while (len && isspace(text[len - 1]))
+ len--;
+ /* FIXME! Quoting! */
put_string(b, pre);
- if (text){
- while (isspace(*text))
- text++;
- len = strlen(text);
- while (len && isspace(text[len - 1]))
- len--;
- /* FIXME! Quoting! */
- quote(b, text, is_attribute);
- }
+ quote(b, text, is_attribute);
put_string(b, post);
}
@@ -185,7 +188,13 @@ static void show_location(struct membuffer *b, struct dive *dive)
*/
if (latitude.udeg || longitude.udeg) {
int len = sprintf(buffer, " <location ");
+
len += format_location(buffer + len, latitude, longitude);
+ if (!dive->location) {
+ memcpy(buffer + len, "/>\n", 4);
+ put_string(b, buffer);
+ return;
+ }
buffer[len++] = '>';
buffer[len] = 0;
prefix = buffer;