strutil: avoid glib/platform conversion calls for empty input
It appears that either glib or some underlying platform library code for
text to number conversion yields unexpected values for return codes,
errno, and "end pointer" when _none_ of the input could get converted.
This was reported for MacOS, did not reproduce on Linux. The reported
issue was addressed in commit
51bf39a1633c, this implementation is just
much more conservative and hopefully easier to verify since it's more
explicit.
Rephrase the rational text to number conversion to avoid the problematic
input cases. Address style nits while we are here in the hope to improve
readability: Move initial assignment and subsequent updates of variables
closer together for easier verification.
Accept optional leading whitespace. Accept numbers like "123." in
addition to the previously supported ".123" formats. But insist that one
of the integral or fractional parts must be present. Try harder to setup
non-zero errno values for other failed conversion attempts beyond failed
library calls (the strtol(3) manpage suggests so in the ERRORS section).
This implementation passes on Linux, but has not been tested with MacOS
which appears to have a pickier library implementation.