mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b6c9301e58
commit
aac44f9b07
1 changed files with 6 additions and 20 deletions
26
parse-xml.c
26
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue