]> git.draconx.ca Git - cdecl99.git/commit
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)
commit62fa1dac8cf3098d212c0e8f4b3cc2cadaddd4c5
treef93f1d3d6f80a5e0c3f867fa24b6cf9af07a1b0a
parentfed6418a32d3b0fd6036d169bd325c1172b391b5
libcdecl: Implement portable alternative to strtoumax.

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.
Makefile.am
src/intconv.h [new file with mode: 0644]
src/scan.l