From a012ce05158165b4ea4e92e557a1b9be5491eb0e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 5 Dec 2012 11:57:40 -0800 Subject: 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 --- save-xml.c | 7 ++++--- 1 file 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(" salinity, " salinity='", "'"); fputs(" />\n", f); } -- cgit v1.2.3-70-g09d2