1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 03:12:48 +02:00
Commit Graph

30668 Commits

Author SHA1 Message Date
Paul Eggert
88cca5d5fc factor: remove wide_int
* src/factor.c (wide_int): Remove, since it gets in the
way of using mp_limb_t for words.  All uses removed.
(submod2, HIGHBIT_TO_MASK, divexact_21):
Rewrite without using wide_int.
This shouldn't change the machine code these days,
as compilers are pretty smart about isolating the
top bit of an unsigned int.
2025-07-09 17:12:39 -07:00
Paul Eggert
397d9b02a3 factor: add platform sanity check
* src/factor.c: Check against theoretical platform.
2025-07-09 17:12:39 -07:00
Paul Eggert
8ff11d626b factor: squfof cleanup
* src/factor.c (USE_SQUFOF, STAT_SQUFOF):
Assume these are always false, and simplify the code accordingly.
We can bring it back later if needed be.
2025-07-09 17:12:39 -07:00
Paul Eggert
d7fd90d22d factor: don’t used uninitialized uu[0]
In practice there’s no bug but we might as well avoid the
undefined behavior.
* src/factor.c (hi_is_set): New static function.
(factor_insert_large, prime2_p, print_factors_single): Use it.
2025-07-09 17:12:39 -07:00
Pádraig Brady
fd59e4a955 build: avoid make distcheck error
* src/local.mk: Similarly to commit v8.22-156-g09937e9d0
track speedlist.h with nodist_src_stty_SOURCES and DISTCLEANFILES
to ensure the make distcheck manifest comparison passes.
Addresses https://bug.gnu.org/78960
2025-07-05 22:14:08 +01:00
Collin Funk
2230933f84 doc: fix a dead link
* doc/coreutils.texi (Block Size): Use an updated link to SI prefixes.
2025-07-05 09:57:29 -07:00
Pádraig Brady
1485eabfdd build: fix non parallel VPATH builds
* src/local.mk: Use the coarser BUILT_SOURCES mechanism
to generate speedlist.h, rather than a specific dependency
(which did seem to work for parallel builds).
Fixes https://bugs.gnu.org/78960
2025-07-05 12:49:02 +01:00
Collin Funk
e34a79a034 maint: prefer endian.h macros to WORDS_BIGENDIAN, part 2
* src/blake2/blake2-impl.h: Include endian.h. Use BYTE_ORDER and
LITTLE_ENDIAN instead of WORDS_BIGENDIAN.
2025-07-04 20:52:37 -07:00
Collin Funk
991934d9c9 maint: prefer endian.h macros to WORDS_BIGENDIAN
* src/od.c: Include endian.h.
(WORDS_BIGENDIAN): Remove definition.
(main): Use BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN instead of
WORDS_BIGENDIAN. Fix formatting.
2025-07-04 10:59:39 -07:00
Collin Funk
4db08f928e maint: add files generated by 'make ps' to .gitignore
* doc/.gitignore (/coreutils.ps, /coreutils.t2d/): Add entries.
2025-07-02 19:01:27 -07:00
Collin Funk
9cb89ff084 doc: remove outdated TODO/FIXME items
* TODO: Remove note about missing documentation for 'pinky' and '['.
* doc/coreutils.texi: Likewise.
2025-07-02 18:51:02 -07:00
Pádraig Brady
8771957703 tests: cat: add test for O_APPEND bug fix
* tests/cat/cat-self.sh: Add a test case
for commit v9.6-19-g7386c291b
2025-07-01 23:32:31 +01:00
Pádraig Brady
ab21f2e95e doc: remove extraneous double quotes within @samp{}
* doc/coreutils.texi (df invocation): @samp{} items
are suitably quoted already.
2025-07-01 12:02:08 +01:00
Collin Funk
1535ac272e doc: use ``...'' instead of "..."
* doc/coreutils.texi (split invocation): Use ``...'' for quoting text.
(cksum common options): Likewise.
(Control): Likewise.
2025-06-30 19:50:58 -07:00
Pádraig Brady
0512608a44 tests: avoid false failure due to varied ERANGE errors
* tests/od/od.pl: Use the system error string for ERANGE,
rather than hardcoding a particular one.
Fixes https://bugs.gnu.org/78934
2025-07-01 00:03:30 +01:00
Paul Eggert
48281e56a3 od: port to Apple clang 14
* src/od.c (print_function_type): New type.  Use it for convenience.
(width_bytes): Omit duplicate entries, such as ‘double’ vs ‘long
double’ on macOS.  Problem reported by Bruno Haible
<https://bugs.gnu.org/78933>.
(decode_one_format): Cast null pointer to print_function_type
to pacify Apple clang-1400.0.29.202.
2025-06-30 15:41:47 -07:00
Pádraig Brady
017fc50bb6 build: fix VPATH builds with --enable-single-binary
* src/local.mk: Adjust the dependency so that speedlist.h
is built irrespective of the object file name.
Note we could use BUILT_SOURCES for this,
but it's better to have this more accurate dependency.
2025-06-30 16:03:44 +01:00
Pádraig Brady
87dcd447b1 od: reinstate half float validation check
Reinstate check removed in commit 56aa549a0 so that we
disallow -f2 when configured with utils_cv_ieee_16_bit_supported=no.
Otherwise the output routines will consume floats,
i.e. 4 bytes at a time.  Without this extra check
the tests/od/od-endian.sh will fail with this configuration.

* src/od.c (decode_one_format): Reinstate the explicit check
for this configuration edge case.
2025-06-30 14:34:55 +01:00
Pádraig Brady
9075b2b8d2 maint: avoid sc_prohibit-quotearg failure
* src/od.c (parse_old_offset): s/quotearg_colon/quotef/.
2025-06-30 13:10:59 +01:00
Paul Eggert
5c5f069a4c od: add test cases for recent fix
* tests/od/od.pl: New tests for the offset issues
2025-06-29 22:32:05 -07:00
Paul Eggert
9002c04ccc od: more minor fixes for offsets
* src/od.c (parse_old_offset): Reject invalid offsets like "++0".
Treat overflowing offsets as errors, not as file names.
2025-06-29 22:26:14 -07:00
Paul Eggert
617220e970 od: refactor parse_old_offset
* src/od.c (parse_old_offset): Refactor for brevity and clarity.
2025-06-29 22:26:14 -07:00
Paul Eggert
3eb731e8ab maint: fix version in NEWS
* NEWS: Update version number as per Jim Meyering
<https://bugs.gnu.org/78880#46>.
2025-06-29 17:14:48 -07:00
Paul Eggert
dcdb2550c4 od: pacify gcc -Wduplicated-cond
Problem reported by Pádraig Brady <https://bugs.gnu.org/78880#43>.
This patch doesn’t fix any bugs; it merely pacifies GCC.
* src/od.c (ispec_to_format): New function, replacing
the old ISPEC_TO_FORMAT macro.  All uses changed.
This part of the change is just refactoring.
(decode_one_format): Pacify à la ispec_to_format.
2025-06-29 17:14:48 -07:00
Paul Eggert
25454fa34d od: be more consistent re sizeof
* src/od.c (width_bytes, decode_one_format): Don’t assume a signed
type has the same size as the corresponding unsigned type.
This has no effect on practical platforms; it’s just for
consistency there.
2025-06-28 21:00:41 -07:00
Paul Eggert
d5ea5e8aed od: fix integer overflow with large pseudos
* src/od.c (format_address_label): Diagnose overflow.
2025-06-28 21:00:41 -07:00
Paul Eggert
667be269ed od: speed up -S
* src/od.c (read_char): Use getc, not fgetc.
2025-06-28 21:00:41 -07:00
Paul Eggert
984dcc37f2 od: check sign bit more often
* src/od.c (read_char, dump_strings, main):
Instead of testing for an exact negative number,
just look at the sign bit.  This is a very minor tweak.
2025-06-28 21:00:41 -07:00
Paul Eggert
9aab4fb287 od: simplify away one loop copy
* src/od.c (dump): Coalesce two loops into one.
2025-06-28 21:00:41 -07:00
Paul Eggert
34b5043c6e od: simpler static initialization
* src/od.c (address_base, address_pad_len, format_address):
Initialize statically rather than dynamically.
(limit_bytes_to_format): Remove.  All uses replaced by
checking sign of end_offset.
(max_bytes_to_format): Remove static var.  Now local to ‘main’.
(end_offset): -1 now means no limit.  All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
0e104647a7 od: minor lcm tuning
* src/od.c (dump, main): Redo lcm calcuations to avoid a multiply.
2025-06-28 21:00:41 -07:00
Paul Eggert
56aa549a06 od: omit some duplicate code
On x86-64 (for example) print_long, print_long_long, and
print_intmax all behave identically, so give GCC enough info so
that it generates code for just one of these functions.
* src/od.c (enum size_spec): Arrange for enum values to
be the same if they represent types that behave the same.
(width_bytes, ISPEC_TO_FORMAT, decode_one_format):
Match the enum size_spec changes.
2025-06-28 21:00:41 -07:00
Paul Eggert
3ad59e19bc 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.
2025-06-28 21:00:41 -07:00
Paul Eggert
274226dbff od: support uintmax_t too
This has practical effect only on hypothetical platforms where
uintmax_t is wider than unsigned long long int.
* src/od.c (enum size_spec): New constant INTMAX.
(MAX_INTEGRAL_TYPE_WIDTH): Now equals UINTMAX_WIDTH.
(FMT_BYTES_ALLOCATED): Allow for the extra "l" in "%lld".
Also, fix off-by-two error in size calculation.
(width_bytes, integral_type_size): Add entries for uintmax_t.
(print_intmax): New function.
(decode_one_function): Use it.
(ISPEC_TO_FORMAT): New arg Max_fmt. All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
d8aaafc094 od: initialize type-size tables statically
* src/od.c (NO_SIZE): Make it explicitly 0, as the
initializers now rely on this.
(MAX_INTEGRAL_TYPE_SIZE): Remove.  All uses replaced by
ARRAY_CARDINALITY (integral_type_size) - 1.
Move static assertion down to where this can be used.
(integral_type_size, fp_type_size): Make them const,
and initialize them statically.
(main): Omit no-longer-needed initialization code.
2025-06-28 21:00:41 -07:00
Paul Eggert
4d527dda58 od: prefer intmax_t to uintmax_t
* src/od.c (MAX_ADDRESS_LENGTH, pseudo_offset, n_bytes_to_skip)
(max_bytes_to_format, end_offset, skip, format_address_none)
(format_address_std, format_address_paren, format_address_label)
(write_block, parse_old_offset, dump, dump_strings, main):
Prefer intmax_t to uintmax_t.  This makes no practical difference,
and lets -fsanitize=undefined check for signed integer overflow.
(skip, dump): Remove no-longer-needed casts.
(xstr2nonneg): New static function.  All callers of xstrtoumax
now call this function instead.
(main): Use ckd_add to detect signed integer overflow, since
the unsigned trick no longer works reliably.
Let xstrtol_fatal report the overflow, instead of doing
it by hand ourselves.
2025-06-28 21:00:41 -07:00
Paul Eggert
66464e61f5 od: fix '+N.' bug
* src/od.c (parse_old_offset): First arg is now char *,
not char const *.  If a decimal number, temporarily
modify the string so that xstrtoumax does not complain
about the '.'.
* tests/od/od.pl: Test for the bug.
2025-06-28 21:00:41 -07:00
Paul Eggert
88f30ee0a5 od: fix some unlikely integer overflows
* src/od.c (print_n_spaces, pad_at, pad_at_overflow):
New static functions.
(struct tspec, PRINT_FIELDS, print_named_ascii, print_ascii)
(decode_one_format, write_block, main):
Use idx_t, not int, for counts that depend on the number
of bytes in an object.
(decode_one_format): Use print_n_spaces to output spaces.
(PRINT_FIELDS, print_named_ascii, print_ascii):
Use pad_at to avoid integer overflow.
(write_block): Do not use %*s to pad, as the total pad might
exceed INT_MAX.  Instead, pad by hand with putchar (' ').
(main): Use pad_at_overflow to report integer overflow due to
oversize -w.  Use better way to tell whether -w is used,
without needing IF_LINT.
* tests/od/big-w.sh: New test.
* tests/local.mk (all_tests): Add it.
2025-06-28 21:00:41 -07:00
Paul Eggert
35d9bf6915 od: prefer idx_t to size_t
This helps find overflow bugs when compiling with -fsanitize=undefined.
* src/od.c (struct tspec, bytes_per_block, PRINT_FIELDS)
(PRINT_TYPE, print_named_ascii, print_ascii, decode_one_format)
(skip, write_block, read_block, dump, main):
Use idx_t, not size_t.
2025-06-28 21:00:41 -07:00
Paul Eggert
dbe4e2f428 od: don’t assume no holes in wide unsigned
Also, fix minor related typos.
* src/od.c (MAX_INTEGRAL_TYPE_SIZE, MAX_ADDRESS_LENGTH):
Now a constant, not a macro.
(MAX_INTEGRAL_TYPE_WIDTH): New constant.  Use it instead of
CHAR_BIT, so as not to assume that uintmax_t and unsigned long
long int are hole-free.  This doesn’t matter on practical porting
targets, though there is still a mainframe or two that have holes.
(FMT_BYTES_ALLOCATED): Fix typo by changing "jd" to "jo".
Fix off-by-one typo in static assertion.
2025-06-28 21:00:41 -07:00
Paul Eggert
671d79a0b7 maint: assume long long int
It’s long been safe to assume C99+ support for long long int.
* .gitignore: Remove m4/longlong.m4.
* bootstrap.conf (buildreq): Boost git prereq from 1.4.4 to 1.5.5,
syncing with Gnulib.
(bootstrap_post_import_hook): Remove m4/longlong.m4.
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES):
No need to require AC_TYPE_UNSIGNED_LONG_LONG_INT.
* src/factor.c (DItype, UDItype):
* src/od.c (main):
Assume HAVE_LONG_LONG_INT.
* src/od.c: (unsigned_long_long_int):
Remove.  All uses replaced with unsigned long long int.
2025-06-28 21:00:41 -07:00
Paul Eggert
69b07cc58d od: fix another off-by-one issue with --strings
* src/od.c (main): Fix off-by-one error in string_min limit.
2025-06-28 21:00:41 -07:00
Paul Eggert
0d1c25d1cb od: fix theoretical size_t malloc overflow
* src/od.c (dump, dump_strings): Use idx_t allocators
rather than size_t allocators, to avoid unchecked integer
overflow on theoretical platforms where SIZE_MAX < IDX_MAX.
2025-06-28 21:00:40 -07:00
Collin Funk
2a08ab2bd5 doc: list signals added by POSIX.1-2024
* doc/coreutils.texi (Signal specifications): Mention that POSIX.1-2024
added SIGWINCH.
2025-06-27 22:15:28 -07:00
Collin Funk
cc01e72491 doc: mention that POSIX.1-2024 added dd iflag=fullblock
* doc/coreutils.texi (dd invocation): Document that POSIX.1-2024 added
iflag=fullblock.
2025-06-27 20:10:09 -07:00
Pádraig Brady
7c2729cb58 doc: cksum: --check: improve supported formats description
* doc/coreutils.texi (cksum common options): Reorder and tweak the info
to make it clearer that --check does not support the legacy crc output
from the cksum command.
Reported at https://bugs.debian.org/1108363
2025-06-27 19:50:51 +01:00
Collin Funk
5a5b4a7810 maint: prefer UINTMAX_MAX to TYPE_MAXIMUM (uintmax_t)
* src/df.c (get_dev): Use UINTMAX_MAX.
* src/shred.c (dopass): Likewise.
2025-06-25 09:08:35 +01:00
Pádraig Brady
2b7f3621f8 od: output standard diagnostics for invalid -w arguments
* src/od.c (main): Don't pass LONGINT_OK to xstrtol_fatal(),
as otherwise it will abort().
* tests/od/od.pl: Add test cases.
* NEWS: Mention the bug fix.

Addresses https://bugs.gnu.org/78879
2025-06-24 16:37:01 +01:00
Pádraig Brady
44809c3379 od: fix various off-by-one issues with --strings with -N
* src/od.c (dump_strings): There are three related issues here
due to not accounting for the terminating NUL char appropriately.

1. Ensure BUF always has enough space for the terminating NUL.
This avoids CWE-122: Heap-based Buffer Overflow,
where we wrote a single NUL byte directly after the allocated buffer.
I.e., there should be no buffer overflow with:
  printf '%100s' | od -N100 -S1

2. Ensure we support -S == -N (END_OFFSET - STRING_MIN == ADDRESS):
I.e., there should be output with:
  printf '%100s' | od -N10 -S10

3. Ensure we always output a valid address by ensuring
the ADDRESS and I variables are kept in sync.
I.e., this should output address 0000000 not 1777777777777777777777:
  printf '%100s' | od -N10 -S1

As well as fixing these we simplify by using a single loop
to read the data, rather than two.

* doc/coreutils.texi (od invocation): Clarify that -N
implicitly NUL terminates strings.
* tests/od/od-N.sh: Add test cases.
* NEWS: Mention the bug fixes.

Fixes https://bugs.gnu.org/78880
2025-06-24 16:21:00 +01:00
Bruno Haible
63c040b879 build: fix compilation error on OpenBSD and Solaris
* src/speedgen: Use 'printf', not 'sed', to emit code with newlines.
2025-06-23 22:56:36 +01:00