diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2014-05-28 14:43:57 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-29 07:26:44 -0700 |
commit | ecb5e15dabf26ab3d5eb6548acd67ea6441a2a78 (patch) | |
tree | 3645db73b7a0676f00d24944dcebb4dc3259976a /save-html.c | |
parent | ca781afdbb0bfbbddbfd723d156642dfa86d3748 (diff) | |
download | subsurface-ecb5e15dabf26ab3d5eb6548acd67ea6441a2a78.tar.gz |
Fix json exporter output
The note is prefixed by a colon
Fix the output of Null values of dive master, dive suit, location and buddy.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-html.c')
-rw-r--r-- | save-html.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/save-html.c b/save-html.c index e2222b3f6..8f16fdfe8 100644 --- a/save-html.c +++ b/save-html.c @@ -59,7 +59,7 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive, const char *pre, con { if (dive->notes) { char *notes = quote(dive->notes); - put_format(b, "%s: %s %s", pre, notes, post); + put_format(b, "%s%s%s", pre, notes, post); free(notes); } } @@ -101,6 +101,10 @@ void put_HTML_tags(struct membuffer *b, struct dive *dive, const char *pre, cons { put_string(b, pre); struct tag_entry *tag = dive->tag_list; + + if (!tag) + put_string(b, "--"); + while(tag){ put_format(b, "%s ", tag->tag->name); tag = tag->next; @@ -108,6 +112,13 @@ void put_HTML_tags(struct membuffer *b, struct dive *dive, const char *pre, cons put_string(b, post); } +void write_attribute(struct membuffer *b, const char *att_name, const char *value) +{ + if(!value) + value="--"; + put_format(b, "\"%s\":\"%s\",", att_name, value); +} + void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no) { put_string(b, "{"); @@ -115,16 +126,16 @@ void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no) put_format(b, "\"subsurface_number\":%d,", dive->number); put_HTML_date(b, dive, "\"date\":\"", "\","); put_HTML_time(b, dive, "\"time\":\"", "\","); - put_format(b, "\"location\":\"%s\",", dive->location); + write_attribute(b, "location", dive->location); put_format(b, "\"rating\":%d,", dive->rating); put_format(b, "\"visibility\":%d,", dive->visibility); put_string(b, "\"temperature\":{"); put_HTML_airtemp(b, dive, "\"air\":\"", "\","); put_HTML_watertemp(b, dive, "\"water\":\"", "\","); put_string(b, " },"); - put_format(b, "\"buddy\":\"%s\",", dive->buddy); - put_format(b, "\"divemaster\":\"%s\",", dive->divemaster); - put_format(b, "\"suit\":\"%s\",", dive->suit); + write_attribute(b, "buddy", dive->buddy); + write_attribute(b, "divemaster", dive->divemaster); + write_attribute(b, "suit", dive->suit); put_HTML_tags(b, dive, "\"tags\":\"", "\","); put_HTML_notes(b, dive ,"\"notes\":\"" ,"\","); put_string(b, "},\n"); |