Closed zdohnal closed 10 months ago
This piece of code is to determine whether the string items[0]
is an integer number or not. First it is checked whether it is not empty and if so, the function strtol()
is applied. The * 0
we do as we want to ignore the actual number discovered. This makes the left hand side of the ||
always false so that we evaluate the right hand side. Here we check whether strtol()
errorred and whether it interpreted the whole string as a number. If there is no error and the whole string was interpreted as number, item[0]
is considered a number.
else if (strlen(items[0]) > 0 &&
((int)(strtol(items[0], &p, 10) * 0) ||
(errno == 0 && *p == '\0')))
This is exactly as it was designed. I do not remember to have done this, most probably this code stems froma contributor but it is correct.
Closing ...
A simpler solution to achieve the same thing is naturally welcome ...
Attempt at #38 .
The code line here looks like a typo - everything multiplied by zero is zero.