]> git.draconx.ca Git - cdecl99.git/commitdiff
libcdecl: Implement portable alternative to strtoumax.
authorNick Bowler <nbowler@draconx.ca>
Wed, 27 Dec 2023 01:52:01 +0000 (20:52 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 28 Dec 2023 07:18:36 +0000 (02:18 -0500)
It's not really OK for the scanner to use a strtoumax fallback with
limited range, as this means the library can't actually parse its own
output in general.  This causes test failures on systems which don't
have a suitable function in the C library.

Try hard to have a compact implementation, letting the scanner do as
much of the job as possible to reduce the amount of extra checks that
have to happen later.  For the ELF shared library case, the result seems
to be pretty good overall: with GCC, the size savings from the no-longer-
needed PLT entry are similar to the amount of extra code added.

As a bonus, this also avoids any unwanted locale dependency, since the
C standard permits strtoumax et al. to do weird things outside of the
"C" locale, although I'm not sure to what extent any real-world systems
take advantage of that freedom.


No differences found