Commit Graph
30608 Commits
Author SHA1 Message Date
Paul Eggert 336cd700c0 build: update gnulib submodule to latest 2025-08-01 17:02:22 -07:00
Bruno Haible 0142856e7b maint: date: refactor to be entirely bottom-up
* src/date.c (show_date_helper): Move function. Remove forward
declaration.
2025-08-01 13:31:28 +01:00
Bruno Haible 4d03487bbb date: fix calendar-related test failures on macOS and OpenBSD
* bootstrap.conf (gnulib_modules): Add xsetenv.
* src/date.c: Include xsetenv.h.
(set_LC_TIME): New function.
(show_date_helper): Call set_LC_TIME instead of setlocale.
* po/POTFILES.in: Add lib/xsetenv.c.
Fixes https://bugs.gnu.org/79118
2025-07-31 21:54:49 -07:00
Collin Funk 5bdd466c68 build: update gnulib submodule to latest 2025-07-31 21:43:55 -07:00
Collin Funk 6c2117ab80 build: fix previous commit
* src/local.mk (src/speedlist.h): Pass correct arguments $(COMPILE). Use
tabs consistently.
2025-07-31 17:57:59 -07:00
Collin Funk 72d483dab7 build: don't use '$<' in non-suffix rules
* src/local.mk (src/speedlist.h): Use the file name instead of '$<'
which is not supported by OpenBSD make.
2025-07-30 16:33:24 -07:00
Pádraig Brady a7c63296c1 du: improve diagnostics for --time-style
* src/system.h (x_timestyle_args): A new function refactored from ...
* src/ls.c (decode_switches): ... here.
* src/du.c: Use refactored x_timestyle_args() to output a custom error.
Addresses https://bugs.gnu.org/79113
2025-07-29 11:43:09 +01:00
Pádraig Brady 69f21c5d46 doc: use consistent references to standard files
* cfg.mk (sc_standard_outputs): A new syntax check to
enforce standard references.
* doc/coreutils.texi: s/stderr/standard error/ etc.
* src/date.c: Likewise.
* src/dd.c: Likewise.
* src/env.c: Likewise.
* src/sort.c: Likewise.
* src/split.c: Likewise.
* src/stty.c: Likewise.
* src/timeout.c: Likewise.
* src/who.c: Likewise.
2025-07-29 11:43:09 +01:00
Collin Funk afd899cb47 doc: update git version documented in HACKING
* HACKING: Mention that git version 1.6.4 or later is required since
'./bootstrap' will fail otherwise.
2025-07-27 11:53:42 -07:00
Paul Eggert 4a2402dcfa doc: mention 2025 speedup on large composites 2025-07-27 07:30:49 -07:00
Pádraig Brady 798a35a7b3 maint: avoid :> pattern in tests
This was seen to trigger the EXIT trap on cygwin

* cfg.mk (sc_prohibit_colon_redirection): Disallow all
cases of :> in tests/
* tests/cksum/md5sum-bsd.sh: Adjust to avoid more
stringent syntax check.
2025-07-26 20:06:42 +01:00
Collin Funk 93304acc10 tests: avoid a false failure on Cygwin
* tests/cksum/md5sum-bsd.sh: Use 'echo' instead of ':' to redirect to
the file. Otherwise 'Exit $fail' is not called on Cygwin.
2025-07-26 11:29:02 -07:00
Collin Funk ba8e55ea95 maint: avoid syntax-check failure from previous commit
* src/test.c (binary_operator): Place string argument on a separate line
to avoid sc_error_quotes syntax-check failure.
2025-07-26 00:17:16 -07:00
Paul Eggert 3c40470c5d test: simplify for clarity
This should help avoid further audit confusion,
such as was just fixed by removing a FIXME.
* src/test.c (enum binop): New type.
(get_mtime): Return a struct timespec instead of returning
a bool and storing a struct timespec.  All callers changed.
(binop): Return an int recording either success (an enum binop)
or failure (-1).  All callers changed.
(binary_operator): Accept an enum binop, so that we need
not recompute the op type.  All callers changed.  Simplify.
2025-07-25 12:27:39 -07:00
Harry Fellowes ecde78e1df test: removed dead code for unrecognised binary operators
the fallback error in binary_operator() was unreachable, since invalid
binary operators are rejected in three_arguments() via binop() which
returns false and prevents entry into binary_operator().

this dead code was unreachable and safe to remove

ref: line 636 where "binary operator expected" is generated.

Signed-off-by: Harry Fellowes <harryfellowes1@gmail.com>
Copyright-paperwork-exempt: Yes
2025-07-25 12:27:39 -07:00
Collin Funk 56eaa4ffc3 tests: date: add tests for the Ethiopian calendar
* tests/date/date-ethiopia.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Collin Funk a9cd174811 tests: date: add tests for the Solar Hijri calendar
* tests/date/date-iran.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Pádraig Brady 5a106af2d6 install: with -d, use more accurate diagnostics
* gnulib: Update to latest to get the fix to
propagate the appropriate error message.
* tests/install/basic-1.sh: Add a test case.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/79072
2025-07-22 21:15:17 +01:00
Collin Funk 5ab05e5a36 tests: date: add tests for the Thai solar calendar
* tests/date/date-thailand.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-21 21:25:58 -07:00
Collin Funk 027855dcad doc: NEWS: mention that 'date' now supports non-Gregorian calendars
Suggested by Bruno Haible in:
<https://lists.gnu.org/r/bug-gnulib/2025-07/msg00091.html>.

* NEWS: Mention the improvement.
2025-07-21 15:04:53 -07:00
Collin Funk 1b98590037 build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2025-07-21 14:43:59 -07:00
Bruno Haible 4a3eb45d72 date: update documentation regarding non-Gregorian calendars
* doc/coreutils.texi (Calendars): New section.
2025-07-21 21:18:25 +01:00
Bruno Haible c3cea90de3 date: force a Gregorian calendar for options --iso-8601 and --rfc-3339
* src/date.c (show_date_helper): Add a use_c_locale parameter.
(batch_convert): Add a format_in_c_locale parameter.
(main): Set format_in_c_locale to true if any of the options --rfc-3339,
--iso-8601, -R is seen.
2025-07-21 21:16:03 +01:00
Pádraig Brady 083f89528e tests: sort: add a test for equivalent floats
* tests/sort/sort-float.sh: Ensure equivalent floats
are treated as such.
2025-07-12 19:58:06 +01:00
Paul Eggert 3a9ec02138 tests: fix fraction comparison in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985#13>.
* tests/sort/sort-float.sh: At top level, use C locale at first.
(dbl_minima_order): Assume C locale.
Use string comparison for the fractional parts.

2025-07-10  Paul Eggert  <eggert@cs.ucla.edu>

tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test, to avoid problems with integers
too large for the shell.
2025-07-11 14:45:04 -07:00
Paul Eggert 8f9fc8f08c tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test to compare fractions,
to avoid problems with integers too large for the shell.
2025-07-10 10:18:06 -07:00
Paul Eggert 1dda42fa58 factor: remove SINGLE_WORKS
* src/factor.c (SINGLE_WORKS): Remove, and remove its use,
as the buggy code that it is referring to has been removed.
2025-07-09 22:27:29 -07:00
Paul Eggert 5b2ddab2d3 factor: use 64-bit internal counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int_fast64_t for internal counters rather than int, as int
could overflow on some somewhat-practical examples.  Problem
discovered on a hypothetical platform where W_TYPE_SIZE is neither
32 nor 64, when factoring 0x7ffffffffffffeab7fffffffffff7369 ==
170141183460469225450570946617781744489, causing k to overflow in
mp_factor_using_pollard_rho.  Presumably a similar problem exists
in the previous stable coreutils 9.7, too, on 32-bit platforms
with somewhat-larger test cases, though I haven’t take the
somewhat-extensive CPU time to discover it.
2025-07-09 22:01:42 -07:00
Paul Eggert 4171ca3353 factor: fix mp_factor_using_pollard_rho aliasing
* src/factor.c (mp_factor_using_pollard_rho):
Fix recently-introduced aliasing bug by computing q
before g gets updated in place.  Problem discovered
on a hypothetical platform where W_TYPE_SIZE
is neither 32 nor 64.
2025-07-09 22:01:42 -07:00
Paul Eggert 5fde9ad14b maint: fix apostrophe in old NEWS 2025-07-09 17:12:40 -07:00
Paul Eggert bbca1c106c factor: speed up converting strings to uuint
* src/factor.c: Do not include c-ctype.h.
(strtouuint): Don’t bother generating a number on
error; just return a strtol_error value other than LONGINT_OK.
Speed up overflow checking.
2025-07-09 17:12:40 -07:00
Paul Eggert 035b837146 factor: simplify primes table
* src/factor.c (primes_ptab): New table of primes, replacing
primes_diff and primes_diff8.  All uses changed.  This is simpler
and should improve performance slightly.  Although this limits the
table’s primes to 2**15 instead of to 668221, the limit can easily
grow to 2**32 by changing the type of ‘prime’, without hurting
performance significantly compared to the primes_diff and
primes_diff8 approach.
* src/make-prime-list.c (output_primes):
For each prime p, output p instead of two differences.
2025-07-09 17:12:40 -07:00
Paul Eggert b754d14117 factor: prefer false for boolean 0
* src/factor.c: Prefer false to 0 for booleans.
2025-07-09 17:12:40 -07:00
Paul Eggert d658d121c3 maint: port speedgen to FreeBSD 15
* src/speedgen: Avoid ‘trap 'command' ERR’, as ERR
does not conform to POSIX and does not work in
FreeBSD 15 sh.
2025-07-09 17:12:40 -07:00
Paul Eggert ef456bef37 factor: speed up Pollard-rho loop counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int, not unsigned long int, for counters that won’t go above
2**31 on practical platforms.  This yields a significant speedup
on GCC 15 x86-64, and using signed values allows for automatic
checks for overflow when using gcc -fsanitize=undefined.
2025-07-09 17:12:40 -07:00
Paul Eggert 033a50af8b factor: avoid an mpz init+clear
* src/factor.c (mp_factor_insert_ui): Rename fom
mp_factor_insert_ui, and change arg type from unsigned long int to
mp_limb_t.  All uses changed.  This avoids creating and freeing a
small mpz_t.
(mp_factor_using_division): Add a static assert requiring that
that mp_limb_t be wide enough, which it should be (and is in
standard GMP).
2025-07-09 17:12:40 -07:00
Paul Eggert 2ba4216441 factor: Pollard-rho a is now mp_limb_t
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2): Use mp_limb_t, not unsigned long int,
for a parameter.  This avoids some casts, and avoids a theoretical
bug where converting to mp_limb_t loses info.
2025-07-09 17:12:40 -07:00
Paul Eggert d4cff38776 factor: redo ge2 in terms of lt2
lt2 a bit more natural, given the current implementation.
* src/factor.c (lt2): New function.
(ge2): Rewrite in terms of lt2.
(gt2): Remove.  All callers changed to use lt2.
2025-07-09 17:12:40 -07:00
Paul Eggert d70e07668c factor: speed up umul_ppmm when !USE_LONGLONG_H
* src/factor.c (umul_ppmm): When !USE_LONGLONG_H so we need to
define this, speed things up if there is an unsigned type uuroom_t
wide enough to hold two words.  Do not make a similar change for
udiv_qrnnd, as it is not performance critical and anyway on GCC 15
x86-64 that would mean a subroutine call.
2025-07-09 17:12:40 -07:00
Paul Eggert e16d3f38f3 factor: streamline gcd2_odd
* src/factor.c (gcd2_odd): Omit a gt2 and adjusts other
tests accordingly.  Omit duplicate code that makes A odd.
2025-07-09 17:12:40 -07:00
Paul Eggert 37fbbc5373 factor: faster gcd_odd since 2nd is odd
* src/factor.c (gcd_odd, gcd2_odd): Speed up, given that the
second argument is always odd.
(gcd_odd): Avoid recomputing a temporary.
(gcd2_odd): Test for zero only if a multiple of B.
This saves an ‘assume’.
2025-07-09 17:12:40 -07:00
Paul Eggert 2ce3fc0c1b doc: update ‘factor’ benchmarks 2025-07-09 17:12:40 -07:00
Paul Eggert 3ee25abfd3 factor: prefer exact division
* src/factor.c (mp_factor_using_division, mp_factor_using_pollard_rho):
Use exact division when it suffices, as it’s typically faster.
2025-07-09 17:12:40 -07:00
Paul Eggert 73bb62f7df factor: tune submod2
* src/factor.c (submod2): Use ckd_sub to subtract by hand rather
than using sub_ddmmss plus a compare.  This speeds things up a
bit, on x86-64 with GCC 15 anyway.
2025-07-09 17:12:40 -07:00
Paul Eggert b0c58a8b29 factor: DELIM and DIVBLOCK no longer macros
* src/factor.c (DELIM): Now a constant, not a macro.
(divblock): Now a static inline function, not a macro DIVBLOCK.
All uses changed.
2025-07-09 17:12:40 -07:00
Paul Eggert d4bc32a5ff factor: simplify by assuming !PROVE_PRIMALITY
* src/factor.c (PROVE_PRIMALITY, mp_millerrabin): Remove.
All uses removed, and surrounding code simplified.
2025-07-09 17:12:40 -07:00
Paul Eggert a29d128162 factor: simplify by assuming USE_BAILLIE_PSW
* src/factor.c (make_uuint2, powm, powm2, millerrabin)
(millerrabin2, USE_BAILLIE_PSW): Remove; no longer used.
(prime_p, prime2_p): Simplify by assuming USE_BAILLIE_PSW.
2025-07-09 17:12:40 -07:00
Paul Eggert 5bab674646 factor: prime comments
* src/factor.c: Add comments re prime functions.
2025-07-09 17:12:40 -07:00
Paul Eggert fb20a7d3e4 factor: no ferror+fclose
* src/make-prime-list.c (main): Avoid parallel calls
to ferror and fclose.
2025-07-09 17:12:40 -07:00
Paul Eggert 86bddb0d53 factor: define SQUARE_OF_FIRST_OMITTED_PRIME
* src/make-prime-list.c (output_primes): Output
SQUARE_OF_FIRST_OMITTED_PRIME, not FIRST_OMITTED_PRIME.  All uses
changed.  This way, the uses don’t need to worry about casts to
avoid overflow.
2025-07-09 17:12:40 -07:00