NULL is best for C as discussed - for coreutils - at:
https://bugs.gnu.org/66221#53
* bootstrap.conf: Remove dependency on nullptr.
* s/nullptr/NULL/.
This effectively reverts 93ce19f0d5a1.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
* bootstrap.conf (gnulib_modules): Add nullptr.
In code, prefer nullptr to NULL where either will do.
* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.
(begword, endword): Add regex helper macros.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Now that Gnulib's 'error' module does proper static checking
for not returning, we need no longer use the 'die' macro.
This makes code easier to read for people that are used to 'error'.
* cfg.mk (sc_die_EXIT_FAILURE): Remove.
* src/die.h: Remove. All includes removed. All calls to 'die'
changed back to calls to 'error'.
* lib/Makefile.am (libfind_a_SOURCES): Remove 'die.h'.
* src/system.h: Include error.h. Stop including error.h elsewhere.
* find/ftsfind.c (process_all_startpoints): Avoid extra '\n' in error
diagnostics wrt/ -files0-from. Also avoid redundant "%s" formats.
* find/parser.c (parse_perm, parse_regex):
* lib/buildcmd.c (bc_push_arg):
Wrap calls to 'error' in block when under an if-condition and either
the if-condition or the 'error' invocation is spanning over more
than one line.
* find/tree.c (get_pred_cost): Make error message translatable - found
by sc_unmarked_diagnostics.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
The format of the copyright year number range in Texinfo files is
"YEAR1--YEAR2" now, i.e., with 2x '-'.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
The struct state field exit_status is only set to 0 (EXIT_SUCCESS) or
to 1 (EXIT_FAILURE) throughout the code.
Therefore, remove the more complicated wrapper function error_severity
which was only used in very few cases anyway.
While at it, replace the above magic numbers by EXIT_OKAY/EXIT_SUCCESS.
* find/defs.h (error_severity): Remove.
* find/util.c (error_severity): Remove, and update all callers by replacing
it by the direct assignment to state.exit_status.
(get_statinfo): Use the above better names.
(report_file_err): Likewise.
* find/exec.c (launch): Likewise.
* find/ftsfind.c (consider_visiting): Likewise.
(find): Likewise.
(process_all_startpoints): Likewise.
(main): Likewise.
* find/pred.c (pred_delete): Likewise.
(pred_empty): Likewise.
(match_lname): Likewise.
(pred_xtype): Likewise.
* find/print.c (do_fprintf): Likewise.
The type pid_t is defined as long on Solaris 11. Therefore, GCC
issued a -Wformat warning there when attempting to print as %d.
* find/exec.c: (launch): When writing the debug message, treat child_pid
as the wider long type.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
The format of the copyright year number range in Texinfo files is
"YEAR1--YEAR2" now, i.e., with 2x '-'.
* tests/sample-test: Likewise, here to avoid starting a year number range.
* All other files: Update copyright years via the above make run.
See section "Handling closed standard file descriptors" in the gnulib
manual.
* bootstrip.conf (gnulib_modules): Add fcntl-safer, openat-safer
and unistd-safer.
* find/exec.c: Include "fcntl--.h" to use the *-safer variant of open()
or openat().
* find/pred.c: Likewise.
* locate/locate.c: Likewise.
* xargs/xargs.c: Likewise, and include "unustd--.h" to use the *-safer
variant of pipe().
Previously, 'find -D exec' only gave helpful output right before the
invocation of complete_pending_execdirs, i.e., not for every child
execution of the -exec, -execdir, -ok and -okdir predicates.
Make the 'exec' debug output more useful and consistent.
* find/exec.c (launch): Output DebugExec diagnostics right before spawning
the child process, and after getting its exit status (unless we already
have regular error diagnotstic anyway, e.g. if the child has been
terminated by a signal).
* find/ftsfind.c (show_outstanding_execdirs): Remove.
(find): Remove invocation of the above function, and simplify.
* NEW: Mention the improvement.
Suggested by Philip Rowlands in https://sv.gnu.org/bugs/?59083
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Likewise, here to avoid starting a year number range.
* All other files: Update copyright years via the above make run.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
die() has the advantage of being apparent to the compiler
that it doesn't return, which will avoid warnings in some cases,
and possibly generate better code.
While at it, wrap some of the overly long error messages into a new line.
* cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to
catch any new uses of error (CONSTANT, ...);
* find/exec.c: Include "die.h" and use die rather than exit (EXIT_FAILURE).
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/oldfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/print.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/listfile.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
* lib/regexprops.c (copying): Update the text so that the
copyright years (and the line breaks) match the
result of "make update-copyright".
* doc/regexprops.texi: Tweak copyright years to match the
result of "make update-copyright".
* All other files: update copyright years if the file has
a copyright statement.
* .x-update-copyright: new file, a list of files to exclude
from automated copyright updates.
* find/util.c (check_nofollow): Avoid compiler warnings about
comparison between the float variable release and some double
constants by changing the constants to be floats, too.
* find/parser.c (estimate_file_age_success_rate): Avoid warnings
of comparison of float against other types by consistently using
float constants.
(insert_type): move the definition of type_cell and set it in the
switch cases handling S_IFLINK and other types of file which may
not be defined on the platform we're building for. We do this in
order to silence a compiler warning about use of an uninitialised
value. It's not really used uninitialised, it's just that the
compiler doesn't know that the way we're calling error() will
cause that function not to return.
(parse_time): Avoid a compiler warning about signed/unsigned
comparison by using a cast.
* find/ftsfind.c: Don't #define USE_SAFE_CHDIR, it's unused.
Likewise STRINGIFY.
(show_outstanding_execdirs): Avoid overflowing int variable seen
by making a bool and setting it to true, instead of incrementing
it.
(main): Correct the call to ctime; it takes time_t*, so don't pass
struct timeval* (instead, pass the address of the tv_sec member).
* find/exec.c (launch): Avoid warnign of unused parameter ctl. We
really don't use it, but this function takes the parameter as
it's a callback.
* find/pred.c (struct pred_assoc): make the pred_name member const.
* find/defs.h: Declare pred_quit as _GL_ATTRIBUTE_NORETURN.
* find/find.c (get_current_dirfd): remove unused function.
(process_dir): make parameters const: parent, pathname, name.
(process_path): make parameters const: parent, pathname, name.
(at_top): Modify the function pointer parameter accordingly.
* find/ftsfind.c (get_fts_info_name): Now returns const char*, not
char*.
(show_outstanding_execdirs): Fix type of loop variable to avoid
possible overflow.
(process_all_startpoints): Avoid compiler warning about overflow
of int loop variable.
* find/defs.h (struct predicate): Make p_name const.
(struct state): make rel_pathname const.
* find/exec.c (impl_pred_exec): Make prefix const.
(launch): Silence compiler warning about unused parameter argc.
* find/pred.c (blank_rtrim): Make str parameter const, since we do
not modify it.
* find/util.c (debug_option_assoc): name and docstring are now
const qualified.
(show_valid_debug_options): Avoid signed/unsigned comparison by
using a size_t array index.
(set_stat_placeholders): Avoid a compiler warning on systems
lacking birth time fields (and on which this function therefore
does nothing).
Before this change, a pointer to struct saved_cwd was used in place
of char*, leading to incorrect error diagnostics, e.g.:
$ chmod a-x . && find / -maxdepth 0 -exec true \;
find: Failed to change directory: ÿÿÿÿ: Permission denied
find: failed to restore initial working directory: ÿÿÿÿ: Permission denied
* find/exec.c (prep_child_for_exec): Fix error diagnostics.
* find/util.c (record_initial_cwd, cleanup_initial_cwd): Likewise.
* find/exec.c (prep_child_for_exec): When issuing an error message
about a failure to change directory, mention the directory.
* find/util.c (record_initial_cwd): Do the same when saving the
initial working directory.
(cleanup_initial_cwd): Also when restoring the initial working
directory.
* find/exec.c (initialise_wd_for_exec): rename to
initialize_wd_for_exec, since "initialize" is the preferred form
even in UK spelling (the OED says "initialise" is a variant).
Update callers (it's a static function). Update spelling in
comments.
* find/find.c (main): Fix missing "to" in error message and update
"initialise" to "initialize". Update comment too.
* find/ftsfind.c (main): Update spelling in error message.
* lib/listfile.c (print_name_with_quoting): spelling change in
comment.
* find/tree.c (init_pred_perf): Likewise.
* lib/extendbuf.c (extendbuf): Likewise.
* lib/splitstring.h: Likewise.
* find/print.c (format_date): Likewise.
* doc/find-maint.texi (Tools): Update spelling.
Prevent "Failed to save working dir[...]: Too many open files"
error by closing the file descriptor of the working directory.
* find/exec.c (impl_pred_exec): Free the working directory if find
executes the command in the local dir, i.e. if it has been saved
by record_exec_dir(). Re-indent code.
* find/testsuite/sv-34976-execdir-fd-leak.sh: Add test.
* find/testsuite/Makefile.am (test_shell_progs): Mention the test.
* NEWS: Mention the fix.
* find/exec.c (impl_pred_exec): Once pushing an argument for
-exec{,dir} ... +, Only set state.execdirs_outstanding if
there were previously no todo items on ths command line.
This avoids spurious calls to complete_pending_execdirs().
* locate/locate.c: Include <regex.h> instead of "regex.h".
Include "fnmatch.h" instead of <fnmatch.h> (because we use
fnmatch-gnu). Include "gettext.h".
* lib/regexprops.c: Include <regex.h> instead of "regex.h".
* find/tree.c: Include "gettext.h". Include "fnmatch.h" instead
of <fnmatch.h> (because we use fnmatch-gnu).
* find/parser.c: Include "gettext.h" and <regex.h>. Include
"fnmatch.h" instead of <fnmatch.h> (because we use fnmatch-gnu).
* find/pred.c: Likewise.
* find/exec.c: Include "gettext.h".
* find/find.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/print.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* find/util.c: Likewise.
* locate/bigram.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
* find/Makefile.am: Add a comment explaining why gnulib-tool
advised us to use each library.
* find/ftsfind.c (show_outstanding_execdirs): Now that
execp->state.cmd_argc is a size_t, we can't print it with %d. So
print it with PRIuMAX (and include <inttypes.h> to define that).
* find/tree.c (prec_name): change return type to const char*.
(type_name): Likewise.
* find/exec.c (impl_pred_exec): use a separate variable (buf) to
point the memory allocated/freed with malloc/free, so that the
existing variable target can then be const (and so we can assign
pathname to it without a compiler warning).
* find/find.c: Since gnulib defines O_NOFOLLOW, don't check to see
if the macro is defined. Check instead to see if it is 0.
(safely_chdir_nofollow): Point this out.
(safely_chdir): Check O_NOFOLLOW for zeroness.
* find/exec.c: Don't #define SIGCHLD.
* xargs/xargs.c: Likewise.
* find/exec.c: New file.
(initialise_wd_for_exec): Move out of pred.c
(record_exec_dir): Likewise.
(impl_pred_exec): Likewise.
(prep_child_for_exec): Likewise.
(launch): Likewise.
* find/pred.c: These functions are moved out of this file.
* find/defs.h: impl_pred_exec is no longer static in pred.c, do
add an external declaration for it. Move the declaration of
launch to here also.
* find/Makefile.am (libfindtools_a_SOURCES): Add exec.c.
* po/POTFILES.in: Add find/exec.c.
Signed-off-by: James Youngman <jay@gnu.org>