Skip to content

Commit

Permalink
Correct float/double check in SW_SIT_read()
Browse files Browse the repository at this point in the history
The boolean `doDoubleConv` encompasses the index values of `doFloatConv` plus, the value of `doDoubleConv` is checked first, meaning that the value of float variables are set to zero
  • Loading branch information
N1ckP3rsl3y committed Jul 25, 2024
1 parent 250756f commit b832a02
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/SW_Site.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,15 +1344,16 @@ void SW_SIT_read(
if (!strLine) {
/* Check to see if the line number contains a double or integer
* value */
doDoubleConv = (Bool) ((lineno >= 0 && lineno <= 2) ||
(lineno >= 5 && lineno <= 31));

doFloatConv = (Bool) (lineno >= 14 && lineno <= 21);

if (doDoubleConv) {
doubleRes = strtod(inbuf, &endPtr);
} else if (doFloatConv) {
doDoubleConv =
(Bool) (!doFloatConv && ((lineno >= 0 && lineno <= 2) ||
(lineno >= 5 && lineno <= 31)));

if (doFloatConv) {
floatRes = strtof(inbuf, &endPtr);
} else if (doDoubleConv) {
doubleRes = strtod(inbuf, &endPtr);
} else {
intRes = (int) strtol(inbuf, &endPtr, 10);
}
Expand Down

0 comments on commit b832a02

Please sign in to comment.