2634 Commits

Author SHA1 Message Date
Bernhard Voelker
ea9288c6be doc: fix typo in Texinfo manual
* doc/find.texi (node Leaf Optimisation): s/filssytems/filesystems/
Bug introduced in v4.5.10-9-gb28cc8c4 in 2011.

Reported by <firasuke@gmail.com> in
https://savannah.gnu.org/bugs/?66418
2024-11-10 16:35:17 +01:00
Bernhard Voelker
baab958700 maint: remove unused include from fstype.c
With newer gnulib, the sc_prohibit_always_true_header_tests check
fails with:
  find/fstype.c:30:#if HAVE_MNTENT_H
  maint.mk: do not test the above HAVE_<header>_H symbol(s);
    with the corresponding gnulib module, they are always true
  make: *** [maint.mk:969: sc_prohibit_always_true_header_tests] Error 1

* find/fstype.c (#include <mntent.h>): Remove as it is not actually used.
2024-11-03 21:32:35 +01:00
Bernhard Voelker
744da6ddcc maint: prefer endian.h for byte order conversions
Now that <endian.h> is a part of POSIX 2024 it should become more
portable than <byteswap.h>.

* bootstrap.conf (gnulib_modules): Remove byteswap; add endian.
* locate/word_io.c: Include endian.h instead of byteswap.h.
(decode_value): Use htobe32 instead of bswap_32.
2024-11-03 21:32:30 +01:00
Bernhard Voelker
f4ec39eee0 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* tests/.gitignore (/init.sh): Add entry.
* Makefile.am (update-gnulib-to-latest): Remove handling tests/init.sh.
2024-11-03 21:32:17 +01:00
Bernhard Voelker
d0187016e1 maint: list Gnulib sys_types directly
* bootstrap.conf (gnulib_modules): Add sys_types.
Although it’s already brought in indirectly, findutils code
includes <sys/types.h> directly.
2024-11-03 21:32:08 +01:00
Bernhard Voelker
57fb016b73 maint: add NEWS entry for recent 'find -execdir/-okdir' change
* NEWS (Changes in find): Reflect the change in behavir in recent
commit v4.10.0-15-g1dcdf3de.
2024-11-03 21:14:37 +01:00
Bernhard Voelker
2ef0b4ce38 maint: fix indentation in NEWS
* NEWS: Use 2 char indentation.
2024-11-03 21:09:51 +01:00
Bernhard Voelker
128c5b18c9 maint: make tests/sample-test executable
To avoid that new tests copied from the template sample-test lack the
executable bit, add the executable bit to that file.

* tests/sample-test: Set executable permission bit.
2024-11-03 20:04:48 +01:00
Bernhard Voelker
727d261bb8 maint: make new tests/find/sv-bug-66365-exec.sh executable
'make syntax-check' fails with:
  tests_executable
  maint.mk: Please make test executable: tests/find/sv-bug-66365-exec.sh
  make: *** [cfg.mk:129: sc_tests_executable] Error 1

* tests/find/sv-bug-66365-exec.sh: Set executable permission bit.
2024-11-03 20:04:42 +01:00
James Youngman
1dcdf3de8e find: -exec is terminated by + only if the prior arg is exactly '{}'
A "+" only terminates -exec when it immediately follows an argument
which is exactly "{}" (and not, for example, "{}x").  This fixes
Savannah bug 66365.

* NEWS: explain this change.
* doc/find.texi: update one place which omitted the '{}' before '+'.
* find/parser.c (insert_exec_ok): consider + to be special ony if it
  follows an argument which is exactly '{}'.
* tests/find/sv-bug-66365-exec.sh: test for this bug.
* tests/local.mk: add the new test file.
2024-11-02 18:42:35 +00:00
James Youngman
457acfa06b Fix VPATH compilation failure for 'make check'
The libgnulib.a library isn't (necessarily) below $(top_srcdir), it's
below $(top_builddir).  This fixes a bug introduced in commit
85fc8966e5912390ad220d03b188dd319c85ed1e.
2024-10-31 15:29:07 +00:00
Bernhard Voelker
e38e2f8a36 tests: avoid -Wshadow warning
Seen on GCC 14.2.0:

tests/xargs/test-sigusr.c: In function 'run_xargs':
tests/xargs/test-sigusr.c:159:43: warning: declaration of 'optarg' \
  shadows a global declaration [-Wshadow]
  159 | run_xargs(const char *option, const char *optarg, int send_signal)
      |                               ~~~~~~~~~~~~^~~~~~
  ...
  /usr/include/bits/getopt_core.h:36:14: note: shadowed declaration is here
   36 | extern char *optarg;
      |              ^~~~~~

* tests/xargs/test-sigusr.c (run_xargs): Rename 'optarg' parameter
to 'opt_arg'.
2024-09-17 22:46:58 +02:00
Bernhard Voelker
523043b313 maint: avoid using FSF postal address
The postal address of the FSF has changed from Franklin Street to
Milk Street in Boston, yet according to RMS we shall better avoid
the postal address.

* build-aux/update-online-manual.sh (Copyright): Change from postal
address to the FSF URL.
2024-09-17 21:50:11 +02:00
Bernhard Voelker
f65a2a960f maint: adjust to Gnulib -Wsystem-headers change
* configure.ac: Don’t suppress -Wsystem-headers since Gnulib no
longer enables it.

Borrowed from
  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=94e8f2b012eb
2024-09-17 21:49:56 +02:00
Bernhard Voelker
4a719e65d2 maint: pacify GCC 14.2
Avoid the following warnings:
tree.c:1573:19: warning: no previous declaration for 'cost_table' [-Wmissing-variable-declarations]
 1573 | struct cost_assoc cost_table[] =
      |                   ^~~~~~~~~~
findutils-version.c:37:13: warning: no previous declaration for 'version_string' [-Wmissing-variable-declarations]
   37 | const char *version_string = VERSION;
      |             ^~~~~~~~~~~~~~

* find/tree.c (cost_table): Declare static.
* lib/findutils-version.c (version_string): Likewise.
* locate/frcode.c (version_string): Remove extern declaration.
* locate/locate.c: Likewise.
* xargs/xargs.c: Likewise.
2024-09-17 21:49:18 +02:00
Bernhard Voelker
889d001ab7 find: ignore more vanished entries with -ignore_readdir_race
Reproducer:
  # Spin up lots of short-living processes.
  $ while env true; do sleep .001; done &

  # Invoke 'find' on the /proc file system;
  # this pretty reliably gives the following error:
  $ find /proc -ignore_readdir_race -maxdepth 3 > /dev/null
  find: '/proc/845078': No such file or directory

* find/ftsfind.c (consider_visiting): Return when FTS returned ENOENT
with the option -ignore_readdir_race.
* NEWS (Bug Fixes): Mention the fix.

Fixes https://savannah.gnu.org/bugs/?45930
2024-09-17 21:49:00 +02:00
Dave
07bd7fa675 build: add bison as requirement
Building from git without bison available would result in
  cc1: fatal error: ./parse-datetime.c: No such file or directory
which is not a very helpful error message.
Let gnulib bootstrap check for bison much earlier.

* README-hacking (Prerequisites): Add Bison explicitly.
* bootstrap.conf (buildreq): Add bison.
* cfg.mk (bootstrap-tools): Add gnulib variable with tools including
bison.

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Copyright-paperwork-exempt: Yes
2024-09-17 21:44:33 +02:00
Collin Funk
85fc8966e5 tests: link binaries to gnulib
* tests/local.mk (AM_CPPFLAGS): Include gnulib headers.
(LDADD): Link to gnulib.

Copyright-paperwork-exempt: Yes
2024-06-24 14:35:55 +02:00
Bernhard Voelker
b94986a897 doc: avoid sc_prohibit_unhyphenated_eof failure
'make syntax-check' complains:
  maint.mk: use "end-of-file", not "end of file"
  make: *** [cfg.mk:273: sc_prohibit_unhyphenated_eof] Error 1

* doc/find.texi (xargs options): Change as suggested by the SC rule.
2024-06-24 14:33:09 +02:00
James Youngman
76ddbb913e doc: State that find -print0 and xargs -0 are in POSIX from Issue 8.
The forthcoming Issue 8 of the POSIX standard includes find -print0
and xargs -0.
* doc/find.texi: find -print0 is no longer GNU-specific.  Similarly
for xargs -0.
* xargs/xargs.1: Likewise.
* NEWS: mention these changes.
2024-06-03 12:40:42 +01:00
James Youngman
bb13ef8f93 find: mention when -print0 was introduced.
* find/find.1(COMPATIBILITY): mention that -print0 was introduced in
release 2.0 and is planned for inclusion in POSIX Issue 8.
2024-06-03 12:16:55 +01:00
James Youngman
1c8f85de97 maint: prohibit the use of tabs in Findutils C sources.
This check does not apply to gnulib code.
* cfg.mk (sc_spaces_not_tabs): add syntax check prohibiting
the use of tabs in Findutils code.
* build-aux/tabs-to-spaces.sh: Add small tool for converting
source file tabs to spaces.
2024-06-01 21:41:11 +01:00
James Youngman
e178314ae3 maint: convert tabs to spaces in C source files. 2024-06-01 21:41:05 +01:00
Bernhard Voelker
c8fd333368 maint: post-release administrivia
* NEWS: Add new dummy release header.
2024-06-01 19:19:31 +02:00
Bernhard Voelker
c67264238d version 4.10.0
* NEWS: Record release date.
v4.10.0
2024-06-01 17:04:27 +02:00
Bernhard Voelker
d3cbfbb6d4 maint: add more file related to test-sigusr to tests/.gitignore
* tests/.gitignore (/xargs/.dirstamp): Add entry.
(/xargs/test-sigusr.o): Likewise.
2024-06-01 17:04:24 +02:00
Bernhard Voelker
7daec5921e tests: re-introduce all_tests needed by syntax-check
The recent commit removed the variable 'all_tests' which is used by
sc_tests_list_consistency in cfg.mk.

* tests/local.mk (all_tests): Re-introduce and ...
(TESTS): ... use it here.
2024-06-01 17:04:21 +02:00
Bernhard Voelker
3d822be55a maint: improve ERE in sc_tests_list_consistency
The ERE used lacks the grouping of the extensions and therefore would
also match files where the first two patterns are not at the end of
the line:
  grep -E '\.sh|\.c$'

* cfg.mk (sc_tests_list_consistency): Add grouping (...) around the
sub-patterns.  While at it, also remove the redundant escaping, i.e.,
\$$ -> $$ to be consistent with the rest of this file.
2024-06-01 17:04:08 +02:00
James Youngman
b25f15aad7 tests: don't distribute the tests/xargs/test-sigusr binary.
There is no NEWS item for this change since this test was introduced
since the previous release.
2024-05-30 20:24:34 +01:00
Bernhard Voelker
0ffcd1ba81 NEWS: fix translation list.
s/Brazilian, Portuguese/Brazilian Portuguese/.
2024-05-27 23:04:05 +02:00
Bernhard Voelker
09f3233d6d NEWS: further improve wording for the imminent release. 2024-05-27 22:54:18 +02:00
James Youngman
7d4e08c8f7 NEWS: list the updated translations. 2024-05-27 21:33:43 +01:00
James Youngman
bad973ce40 NEWS: mention recent bug-fixes. 2024-05-27 21:12:33 +01:00
Bernhard Voelker
0f37f29bda maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 219 commits on gnulib
since the last update.

* gnulib: Update to latest.
* bootstrap-funclib.sh: Likewise.
2024-05-27 21:53:11 +02:00
James Youngman
dafd09f386 Standardize on "optimize" rather than "optimise".
While this is often described as a UK/US spelling difference, the
"-ise" spelling is described as a variant by the Oxford English
Dictionary.  Therefore we prefer the "-ize" spelling.

* doc/find.texi: standardize on optimize.
* find/find.1: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/tree.c: Likewise.
* NEWS: Likewise (except for historical entries).
2024-05-27 20:11:31 +01:00
James Youngman
81c1ec3dca find: by default, disable the cost-based optimiser.
The cost-based optimiser re-orders predicates based on their expected
cost.  This re-ordering (as currently implemented) results in
user-visible changes to the order of operations.  An optimiser should
not do that.  For example, "-empty -readable" and "-readable -empty"
don't actually have the same effect since "-empty" fails on an
unreadable directory.  This fixes savannah bug #58427 (unless the user
specifies -O2).

* find/util.c(set_option_defaults): set default optimisation level to
1 instead of 2.
* find/tree.c(build_expression_tree): call do_arm_swaps (i.e. apply
cost-based optimisations) only at optimisation level 2 and above.
* find/find.1(-O): explain this change.
* doc/find.texi(Optimisation Options): explain this change.
* NEWS: mention this change.
2024-05-27 19:50:11 +01:00
James Youngman
b12fb8c216 Fix sv bug #51926: -xtype l fails on symlinks that have a loop
* find/pred.c (pred_xtype): if lstat fails with ELOOP, -xtype should
behave in the same way as -type.
(err_signals_broken_link): new function, true for ENOENT and ELOOP.
* doc/find.texi: document the fact that the "infinite loop" case is
handled like the "symbolic link target does not exist" case.
* find/find.1: Likewise.
2024-05-26 19:34:45 +01:00
James Youngman
88850fd0c6 maint: turn on Automake option subdir-objects.
Enabling subdir-objects fixes Savannah bug #65794.

* Makefile.am(AUTOMAKE_OPTIONS): enable subdir-objects.
2024-05-26 17:01:20 +01:00
James Youngman
64e9ddbd8c [check] make fail message of tests/misc/help-version.sh explicit.
This improved message is intended to help diagnose Savannah bug #65796.

* tests/misc/help-version.sh: when the --version ouptut of some
findutils program doesn't match the value of the VERSION environment
variable during "make check", issue a more detailed error message.
2024-05-26 16:58:15 +01:00
Bernhard Voelker
32132e9749 tests: avoid various syntax-check failures wrt/ test-sigusr
The syntax-check complains:
  $ make syntax-check -k
  ...
  maint.mk: the above files do not call bindtextdomain
  make: *** [maint.mk:869: sc_bindtextdomain] Error 1
  ...
  maint.mk: the above files do not include <config.h>
  make: *** [maint.mk:509: sc_require_config_h] Error 1
  ...
  maint.mk: use EXIT_* values rather than magic number
  make: *** [maint.mk:411: sc_prohibit_magic_number_exit] Error 1
  ...
  maint.mk: found unmarked diagnostic(s)
  make: *** [maint.mk:916: sc_unmarked_diagnostics] Error 1
  ...
  make: *** [cfg.mk:111: sc_tests_list_consistency] Error 1
  ...
  maint.mk: Please make test executable: tests/xargs/test-sigusr.c
  make: *** [cfg.mk:124: sc_tests_executable] Error 1

* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add test-sigusr.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Define with the
pattern of the test-sigusr source file.
(sc_tests_list_consistency): Strip off ".c" suffix.
(sc_tests_executable): Exempt C source from this rule.
* tests/local.mk (TEST_EXTENSIONS): Add .c sources, needed also for
sc_tests_list_consistency to work.
* tests/xargs/test-sigusr.c (#include <config.h>): Add to avoid
sc_require_config_h failure.
(verify_signal_ignored): Call exit with EXIT_FAILURE instead of 1 to
avoid sc_prohibit_magic_number_exit failure.
(verify_signal_is_fatal): Likewise.
(verify_signal_is_nonfatal_with_p): Likewise.
* tests/.gitignore (/xargs/test-sigusr): While at it, add an entry
for the built test program here.
2024-05-20 13:57:53 +02:00
Bernhard Voelker
a76e5e1f02 xargs: avoid sc_useless_cpp_parens failure
$ make syntax-check
...
xargs/xargs.c:674:#if !(defined(SIGUSR1) && defined(SIGUSR2))
maint.mk: found useless parentheses in cpp directive
make: *** [maint.mk:924: sc_useless_cpp_parens] Error 1

* xargs/xargs.c (main): Simplify -P #if conditional to avoid the
above syntax-check failure.
2024-05-20 13:54:46 +02:00
Bernhard Voelker
b9c9310eec maint: avoid gnulib sc_prefer_angle_bracket_headers failure
The following syntax-check rule fails:

  $ make syntax-check
  ...
  maint.mk: Use #include <hdr.h>, not #include "hdr.h" for the above
  make: *** [maint.mk:619: sc_prefer_angle_bracket_headers] Error 1

The rule suggests using '#include <header.h>' instead of
'#include "header.h"' for headers that override system headers.
See gnulib documentation, section "Style of #include statements".

* find/parser.c (#include "fnmatch.h": Change from "..." to <...> style.
* find/pred.c (#include "fnmatch.h"): Likewise.
* find/tree.c (#include "fnmatch.h"): Likewise.
* lib/system.h (#include "error.h"): Likewise.
* locate/locate.c (#include "fnmatch.h"): Likewise.
* tests/xargs/test-sigusr.c (#include "error.h"): Likewise.
2024-05-20 13:54:38 +02:00
Bernhard Voelker
8d48e1ee65 build: avoid spurious failures due to lack of EGREP definition
Similar to Jim Meyering's commit in coreutils:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=d73ca62c4fa3

* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.
2024-05-20 13:54:29 +02:00
James Youngman
9874c773f2 [find] avoid undefined behaviour in consider_arm_swap.
This fixes Savannah bug #63605.

* find/tree.c: avoid invalid struct member access in consider_arm_swap
2024-05-19 22:23:19 +01:00
James Youngman
9f5295f704 [xargs] restart stdin reads interruipted by SIGUSR1/SIGUSR2.
While we do use the gnulib safe_read function, we read input from
stdin using stdio, not direct Unix syscalls, so safe_read is not
involved.

* xargs/xargs.c: If a stdin read fails with EINTR, do it again.  Use
SA_RESTART when setting up signal handlers.  This fixes Savannah
bug #64442.
2024-05-19 13:11:02 +01:00
James Youngman
9fed05088f [doc] Mention the changes to xargs -P
* doc/find.texi: explain how xargs -P affects the handling of the
SIGUSR1 and SIGUSR2 signals.
* xargs/xargs.1: Likewise.
2024-05-19 11:27:46 +01:00
James Youngman
b560e3f911 [xargs] POSIX requires SIGUSR1/2 to be fatal if not blocked.
If the user uses -P we're not using only POSIX options, so in that
case it is OK to handle SIGUSR1/2.  Otherwise (without -P) don't
handle these signals, meaning that they could cause xargs to
terminate.

* xargs/xargs.c: set signal handlers for SIGUSR1 and SIGUSR2 only if
the -P option was used.  Warn if SIGUSR1 or SIGUSR2 is not defined.
* tests/xargs/test-sigusr: a new test for this.
* tests/local.mk: build and run the new test.
* NEWS: mention these changes.
2024-05-19 11:13:31 +01:00
James Youngman
ad636eae01 xargs: Wait for all children even if one exited with 255.
* xargs/xargs.c: fix Savannah bug #64451 (xargs -P exits before all
children have exited if one exits with status 255).
* xargs/xargs.1 (BUGS): mention this bug and the corrected behaviour.
* doc/find.texi: Likewise.
* NEWS: mention this bugfix.
2024-05-18 10:59:52 +01:00
James Youngman
8368fd0b2a [doc] add missing "-" to "-regextype". 2024-05-18 08:10:15 +01:00
James Youngman
b6fc295bfb [doc] -regextype is also a positional option. 2024-05-17 09:54:40 +01:00