summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-23 12:09:29 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-23 12:55:37 -0800
commitaac44f9b0740726dd9d8cc9cce80b2e99626d0e1 (patch)
tree4f8548cd95b2a22e538a1fea439848a88c63e22b /parse-xml.c
parentb6c9301e584722b9b46dffd4d759e8c60df520ad (diff)
downloadsubsurface-aac44f9b0740726dd9d8cc9cce80b2e99626d0e1.tar.gz
Remove XML parsing special case temperature code
We had various hacky historical artifacts in our XML parsing, partly from our legacy of parsing integer and floating point data separately (we used to recognize certain import format differences based on whether the data was in a floating point or integer format). And partly from trying to do a good job of importing crap from other dive log software. Anyway, that actually meant that we refused to parse negative numbers, and we ignored temperatures of zero because some diving log would do that for missing values. Both of these actually bit us when parsing our native XML. Of course, only crazy ice divers would ever notice. Noticed by Henrik Brautaset Aronsen. Reported-acked-and-tested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 0aa4b7bf0..85b1c5306 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -234,26 +234,16 @@ enum number_type {
static enum number_type integer_or_float(char *buffer, union int_or_float *res)
{
char *end;
- long val;
double fp;
- /* Integer or floating point? */
- val = strtol(buffer, &end, 10);
- if (val < 0 || end == buffer)
- return NEITHER;
-
- /* Looks like it might be floating point? */
- if (*end == '.') {
- errno = 0;
- fp = g_ascii_strtod(buffer, &end);
- if (!errno) {
- res->fp = fp;
- return FLOAT;
- }
+ errno = 0;
+ fp = g_ascii_strtod(buffer, &end);
+ if (!errno && end != buffer) {
+ res->fp = fp;
+ return FLOAT;
}
- res->fp = val;
- return FLOAT;
+ return NEITHER;
}
static void pressure(char *buffer, void *_press)
@@ -353,10 +343,6 @@ static void temperature(char *buffer, void *_temperature)
switch (integer_or_float(buffer, &val)) {
case FLOAT:
- /* Ignore zero. It means "none" */
- if (!val.fp)
- break;
- /* Celsius */
switch (xml_parsing_units.temperature) {
case KELVIN:
temperature->mkelvin = val.fp * 1000;