diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2023-03-04 11:42:16 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2023-03-04 14:49:46 -0800 |
commit | 3434cdcec18c918de992bc28b0e9f52b6f168d9b (patch) | |
tree | 20256590c892e6abf9afd3ce221e883087b9048c /HACKING | |
parent | 1ebee5b1a375fd16041de6a57a5aa19b03a70a97 (diff) | |
download | coreutils-3434cdcec18c918de992bc28b0e9f52b6f168d9b.tar.gz |
split: handle large numbers better
Prefer signed types to uintmax_t, as this allows for better
runtime checking with gcc -fsanitize=undefined.
Also, when an integer overflows just use the maximal value
when the code will do the right thing anyway.
* src/split.c (set_suffix_length, bytes_split, lines_split)
(line_bytes_split, lines_chunk_split, bytes_chunk_extract)
(lines_rr, parse_chunk, main):
Prefer a signed type (typically intmax_t) to uintmax_t.
(strtoint_die): New function.
(OVERFLOW_OK): New macro. Use it elsewhere, where we now allow
LONGINT_OVERFLOW because the code then does the right thing on all
practical platforms (they have int wide enough so that it cannot
be practically exhausted). We can do this now that we can safely
assume intmax_t has at least 64 bits.
(parse_n_units): New function.
(parse_chunk, main): Use it.
(main): Do not worry about integer overflow when the code
will do the right thing anyway with the extreme value.
Just use the extreme value.
* tests/split/fail.sh: Adjust to match new behavior.
Diffstat (limited to 'HACKING')
0 files changed, 0 insertions, 0 deletions