]> git.ipfire.org Git - thirdparty/coreutils.git/commit
od: replace lookup tables with simple arithmetic
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 27 Jun 2025 23:08:06 +0000 (16:08 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 29 Jun 2025 04:00:41 +0000 (21:00 -0700)
commit3ad59e19bc289b41c7998f91eda424672b2c8497
tree043dd600400bd5551842801a7db8f1a919592b51
parent274226dbff6866b130bc69b84a7b7c8c00c3264d
od: replace lookup tables with simple arithmetic

* src/od.c (FMT_BYTES_ALLOCATED): Use a simpler formula.
Although slightly too generous, the storage wasted is very small
and it pacifies gcc -Wformat-overflow=2.
(bytes_to_oct_digits, bytes_to_signed_dec_digits)
(bytes_to_unsigned_dec_digits, bytes_to_hex_digoits): Remove.
All uses replaced by algorithmic calculations, which are good
enough: they are valid for integers up to 2620 bits (!) and might
be slightly conservative for wider integers.  Remove related
static_asserts, which are no longer needed.
src/od.c