diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-05 11:57:40 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-05 12:31:31 -0800 |
commit | a012ce05158165b4ea4e92e557a1b9be5491eb0e (patch) | |
tree | e9253ba28c833ff572d6c9dfe7bd15a89441afcc /save-xml.c | |
parent | d00be63c86bae3579e9cdd5e523e09146b72dc22 (diff) | |
download | subsurface-a012ce05158165b4ea4e92e557a1b9be5491eb0e.tar.gz |
Fix saving of salinity
Several things were wrong.
- we saved it as floating point (that was stupid, given the locale issue
with that and given the fact that the precision was really artificial)
- we always saved it when set (we should only save it if the value is
different from our default of 1030g/l == salt water)
- most embarrassing - the unit we assigned was wrong. That's g/l, not
kg/l...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/save-xml.c b/save-xml.c index 5dc47795f..1d38cc1b8 100644 --- a/save-xml.c +++ b/save-xml.c @@ -60,7 +60,7 @@ static void show_pressure(FILE *f, pressure_t pressure, const char *pre, const c static void show_salinity(FILE *f, int salinity, const char *pre, const char *post) { if (salinity) - fprintf(f, "%s%.1f kg/l%s", pre, salinity / 10.0, post); + fprintf(f, "%s%d g/l%s", pre, salinity / 10, post); } /* * We're outputting utf8 in xml. @@ -170,9 +170,10 @@ static void save_airpressure(FILE *f, struct dive *dive) static void save_salinity(FILE *f, struct dive *dive) { - if (!dive->salinity) + /* only save if we have a value that isn't the default of sea water */ + if (!dive->salinity || dive->salinity == 10300) return; - fputs(" <water ", f); + fputs(" <water", f); show_salinity(f, dive->salinity, " salinity='", "'"); fputs(" />\n", f); } |