* lib/listfile.c (list_file): Check the result of fprintf to
determine if there was an I/O error on output. Return false (bool
instead of void) if so.
(print_name_without_quoting): Likewise.
(print_name_with_quoting): Likewise.
(print_name): Propagate the result of print_name_without_quoting
or print_name_with_quoting (and make all three functions return bool).
* find/pred.c (is_ok): Check the result of fprintf to
determine if there was an I/O error on output. Exit fatally if
there was a problem (since we cannot expect the user to say "yes"
or "no" to a prompt they will not have seen).
* xargs/xargs.c (print_args): Check the result of fprintf and
fflush to determine if there was an I/O error on output. Exit
fatally for the same reason as above if there is a problem.
* NEWS: Mention this bugfix (now that it is fully fixed).
* build-aux/src-sniff.py (checkers): Check for #define directives
which use a macro name which is reserved.
(MakefileRegexChecker): New class which performs regex checks on
makefiles; this ensures that we don't check Makefile.in if we're
going to check Makefile.am anyway.
* lib/unused-result.h: Don't use a reserved identifier in the
macro name defined as the #include guard.
* locate/locatedb.h: Likewise.
* Makefile.am (findutils-check-smells): Don't check gnulib code.
* import-gnulib.sh (hack_gnulib_tool_output): Move the 'do' of a
for loop onto the line following the 'for' (instead of the same
line).
* lib/Makefile.am (coverage-clean): Remove output files left
behind by gcc -fprofile-arcs -ftest-coverage by using $(RM) with a
glob pattern rather than a $(libfindtools_a_SOURCES.c=.gcno)
Makefile substitution, because the latter caused us to delete
header files entirely (their names do not end in .c). This had
meant that it was impossible to compile findutils after "make
clean". Bug report by David Gilbert.
* find/Makefile.am (coverage-clean): Likewise.
* xargs/Makefile.am (coverage-clean): Likewise.
* locate/Makefile.am (coverage-clean): Likewise.
* Makefile.am (coverage-clean): Likewise, but also do this in the
subdirectories whose Makefile.am files are generated by
gnulib-tool.
* find/Makefile.am (CLEANFILES): Clean the .gcda and .gcdo files
which are produced by running programs that were compile with gcc
-fprofile-arcs -ftest-coverage.
* lib/Makefile.am (CLEANFILES): Likewise.
* locate/Makefile.am (CLEANFILES): Likewise.
* xargs/Makefile.am (CLEANFILES): Likewise.
* xargs/xargs.c: Remove definition of the unused macro VOID.
Include error.h instead of declaring error (incorrectly).
Change the type of lineno from int to size_t.
(get_char_oct_or_hex_escape): Don't point endp unnecessarily at p,
because they have different constness. There's no need for this,
just initialise it to NULL.
(main): Make input_file const. Make the default arglist
non-const, to avoid a constness warning.
(main): Pass the option name as the argument to error's %s format,
as opposed to the whole struct (this was a bug, but since the name
member was the first in the struct, there were probably no
symptoms).
(main): read_args returns an int, but the only negative value it
can return is -1. Once we know that didn't happen, assign the
value to a size_t variable to avoid signed/unsigned warnings
elsewhere.
(xargs_do_exec): Manually inhibit some unused-parameters warnings.
(print_args): Use size_t as the type of a loop variable.
(wait_for_proc): Since procs_executing is an unsigned long, use a
%lu format specifier to print it.
(increment_proc_max): Inhibit an unused-parameter warning (the
signal number).
(decrement_proc_max): Likewise.
* lib/buildcmd.h (struct buildcmd_control): Make member
replace_pat const. Change the type of lines_per_exec to unsigned
long.
* 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.
* lib/regextype.c (tagRegexTypeMap): make the name field const.
* find/parser.c (parse_version): instead of counting features, use
a boolean variable, nofeatures. This avoids compiler warnings
about overflow.
* find/find.c: Remove definition of SAFE_CHDIR, which we don't
use.
* find/defs.h: Remove redundant declaration of launch.
* find/parser.c (parse_false): Cast unused arguments to void.
(parse_print0): Likewise.
(pred_context): Likewise.
(parse_newerXY): Add some parens for slightly greater clarity.
(make_segment): Avoid switch-missing-default-case warning by
turning it into an if statement.
(check_path_safety): Remove unused argument.
(insert_exec_ok): Don't pass the unwanted arugment to
check_path_safety.
(get_relative_timestamp): silence compiler warning by adding a
case for the remaining enumberation value rather than using
default.
* find/pred.c (months): the strings can be const char*, rather
than just char*.
(ctime_format): change TIME_BUF_LEN to an integer constant to
avoid signed/unsigned comparison.
(blank_rtrim): Change to new-style function definition(!) and
remove unnecessary parentheses around a return value.
* lib/buildcmd.c: Omit redundant declaration of environ.
* find/tree.c (get_expr): Make static.
(cost_assoc): make the name field const.
(prec_assoc): make the prec_name field const.
(op_assoc): make the type_name field const.
(type_name): turn into an ANSI function definition(!).
(prec_name): Likewise! Also remove spurious parentheses around
return value.
(prec_name): Remove spurious parentheses around return value.
* lib/buildcmd.h (buildcmd_state): change types of several fields
to size_t: cmd_argc, cmd_argv_alloc, largest_successful_arg_count,
smallest_failed_arg_count.
(buildcmd_control): change types of several fields
to size_t: max_arg_count, initial_argc, lines_per_exec,
args_per_exec.
* lib/splitstring.c: New file; defines splitstring(), which will
non-destructively locate character-separated fields in a string.
* lib/splitstring.h: New file; declares splitstring.
* lib/test_splitstring.c: New file; unit test for splitstring.c.
* lib/nextelem.c: Delete (obsoleted by splitstring.c).
* lib/nextelem.h: Delete (obsoleted by splitstring.h).
* lib/Makefile.am (libfind_a_SOURCES): Add splitstring.c,
splitstring.c. Remove nextelem.c, nextelem.h.
(check_PROGRAMS): Add test_splitstring.
(TESTS): Add test_splitstring.
(test_splitstring_SOURCES): Sources for the
test_splitstring unit test.
* locate/locate.c: Include splitstring.h rather than nextelem.h.
(dolocate): Use splitstring rather than next_element. In places
where we need a nul-terminated string, use strndup() to create it.
Convert some space-tab sequences to regular spacing.
* find/parser.c: Include splitstring.h rather than nextelem.h.
(check_path_safety): Use splitstring rather than next_element.
* import-gnulib.config (modules): Depend on the module strndup.
* cfg.mk: Exempt lib/test_splitstring.c from calling
bindtextdomain or set_program_name.
* lib/Makefile.am: Use $(FINDLIBOBJS) instead of @FINDLIBOBJS@.
* find/Makefile.am (LDADD): Use $(FINDLIBS) instead of @FINDLIBS@.
* locate/Makefile.am (updatedb): Use $(VERSION) and
$(PACKAGE_NAME) instead of @VERSION@ and @PACKAGE_NAME@.
* cfg.mk: remove sc_makefile_at_at_check from local-checks-to-skip
* find/pred.c: Include stat-size. Eliminate definitions of
DEV_BSIZE, ST_BLKSIZE, ST_NBLOCKS, ST_NBLOCKSIZE macros which are
now in stat-size.h (yes, this is the second set of these macros
we've removed).
(file_sparseness): Use ST_NBLOCKS and ST_NBLOCKSIZE.
* cfg.mk (local-checks-to-skip): Don't skip
sc_prohibit_stat_st_blocks, because now we no loner access the
st_blocks field of struct stat, directly.
* lib/listfile.c: Include "stat-size.h". Delete the DEV_BSIZE,
ST_BLKSIZE, ST_NBLOCKS, ST_NBLOCKSIZE macros which are now in
stat-size.h.
* gnulib: Update to latest.
* import-gnulib.config (modules): Add stat-size.
* lib/fdleak.c (visit_open_fds): Rename loop variable from i to j
to avoid shadowing.
(get_proc_max_fd): Fix definition (it's a void function, not a
traditional pre-ANSI function definition).
* lib/dircallback.c: Include dircallback.h.
* lib/dircallback.h: Correct declaration of run_in_dir.
* lib/listfile.c (file_blocksize): Use the otherwise-unused parameter.
* find/defs.h: Remove redundant declaration of variable options.
* lib/findutils-version.c (display_findutils_version): Don't
display gnulib_version because it's no longer defined (because
there is no gnulib version separate from the findutils version,
now that gnulib is a submodule).
* import-gnulib.config: remove gnulib_version and destdir, they
are not needed any more.
* lib/Makefile.am (EXTRA_DIST): Don't distribute gnulib-version.h
or gnulib-version.c.
(BUILT_SOURCES): delete, there are no longer any built sources.
* lib/gnulib-version.h: Remove.
* locate/code.c: Don't include gnulib-version.h
* xargs/xargs.c: Don't include gnulib-version.h
* configure.ac (AC_CHECK_HEADERS): Remove checks for header files
that gnulib either assumes are always present, or provides
itself. These include errno.h fcntl.h inttypes.h limits.h
locale.h stddef.h stdint.h stdlib.h string.h sys/types.h
unistd.h.
* lib/buildcmd.c: Remove include guard for limits.h.
* find/fstype.c: Remove include guard for sys/types.h.
* lib/savedirinfo.c: Likewise.
* find/find.c: Remove include guard for locale.h.
* find/ftsfind.c: Likewise.
* .gitmodules: New file; manage gnulib as a submodule. For future
compatibility with the "bootstrap" script, keep the gnulib
submodule in the gnulib directory (instead of the gnulib-git
directory as before). This means we need to find a new directory
for the output of gnulib-tool; we will use "gl" for that.
* import-gnulib.sh (do_checkout): Replace with do_submodule.
(do_submodule): initialise and configure the gnulib module.
(main): call do_submodule instead of do_checkout. Don't call
move_cvsdir, it's obsolete.
(move_cvsdir): delete
* Makefile.am (SUBDIRS): Rename gnulib to gl.
(ACLOCAL_AMFLAGS): Likewise.
(findutils-check-smells): Rename gnulib-git to gnulib.
* .gitignore: Rename gnulib to gl.
Gnulib will use suacomp for solving this problem, so findutils
will not need a workaround here.
* lib/arg-max.h: Delete this file.
* lib/Makefile.am (libfind_a_SOURCES): Remove arg-max.h.
* lib/buildcmd.c: Don't include arg-max.h.
* xargs/xargs.c: Likewise.
* lib/listfile.c (list_file): check HAVE_STRUCT_STAT_ST_RDEV
instead of HAVE_ST_RDEV, fixing this bug. HAVE_ST_RDEV was
defined by the obsolete Autoconf macro AC_STRUCT_ST_RDEV, but
findutils hasn't actually called AC_STRUCT_ST_RDEV since Apr 5
2000.
* NEWS: Mention this bugfix.
* lib/arg-max.h: New file: undefine _SC_ARG_MAX if we cannot rely
on the value that sysconf produces.
* lib/Makefile.am (libfind_a_SOURCES): Add arg-max.h.
* lib/buildcmd.c: #include arg-max.h.
* xargs/xargs.c: Likewise.
* lib/dircallback.c (run_in_dir): Make sure that if the callback
doesn't get run, the return value is nonzero. Make sure that if
the directory save/restore fails, we don't overwrite errno with a
random value (and hence report some unrelated and nonexistent
error, instead of the real problem). Restore the previous current
directory.
Signed-off-by: James Youngman <jay@gnu.org>
* lib/fdleak.c (get_max_fd): Don't use RLIM_SAVED_MAX or
RLIM_SAVED_CUR. Not only are they non-portable, they aren't
useful.
* NEWS: Mention this bugfix.
Signed-off-by: James Youngman <jay@gnu.org>
* find/util.c (hook_fstatat): This has been disabled and unused
for a long time, delete it.
* find/find.c (process_dir): Remove some unused debug code.
* find/tree.c (predlist_insert): Remove some dead code.
* lib/fdleak.c (complain_about_leaky_fds): Remove some unused
debug code.
Signed-off-by: James Youngman <jay@gnu.org>
* lib/dircallback.c (run_in_dirfd): New name for old run_in_dir
function.
(run_in_dir): Like the old funciton of the same name, but now
takes an argument const struct saved_cwd *.
* lib/dircallback.h: Update declarations of run_in_dirfd and
run_in_dir.
* find/util.c: Include dircallback.h, xalloc.h, save-cwd.h.
(do_complete_pending_execdirs): Remove dir_fd parameter, since the
per-predicate data structures now indicate what directory they
need to be run in. Instead of calling bc_do_exec directly, use a
callback 'exec_cb' that uses run_in_dir (which now takes a
saved_cwd* parameter instead of a file descriptor).
(do_exec): Called by do_complete_pending_execdirs, and simply uses
run_in_dir to call exec_cb, restoring the working directory
afterward.
(record_initial_cwd): New function, initialises the global
variable initial_wd.
(cleanup_initial_cwd): New function, cleans up the global variable
initial_wd.
(cleanup): Call cleanup_initial_cwd.
(get_start_dirfd): Remove.
(is_exec_in_local_dir): New funciton; true for predicates -execdir
and -okdir.
* find/pred.c: Include cloexec.h and save-cwd.h.
(record_exec_dir): New function, sets the value of
execp->wd_for_exec if needed.
(new_impl_pred_exec): Remove the obsolete dir_fd parameter. Call
record_exec_dir.
(pred_exec): Don't pass the dir_fd parameter.
(pred_execdir): Likewise.
(pred_ok): Likewise.
(pred_okdir): Likewise.
(can_access): Call run_in_dirfd rather than run_in_dir (the
function was renamed).
(prep_child_for_exec): Remove dir_fd parameter; don't fchdir to
that. Call restore_cwd instead (passing a saved_cwd* parameter
which replaced dir_fd).
(launch): Remove references to execp->use_current_dir.
(launch): Change references to execp->dir_fd to execp->wd_for_exec.
* find/parser.c: Correct indentiation of declaration of
insert_exec_ok and remove the obsolete dir_fd parameter.
(parse_exec): Don't pass the dir_fd parameter to insert_exec_ok.
(parse_execdir): Likewise.
(parse_ok): Likewise.
(parse_okdir): Likewise.
(insert_exec_ok): Remove obsolete dir_fd paramter. Initialise
execp->wd_for_exec, either to NULL (for -*dir) or to the
initial_wd.
* find/ftsfind.c: Remove get_current_dirfd. Remove
complete_execdirs_cb.
(consider_visiting): Call complete_pending_execdirs directly.
(main): Call record_initial_cwd to record the initial working
directory, early on. Don't initialise starting_dir or
starting_desc, they have been removed.
* find/finddata.c: Include save-cwd.h. Remove starting_dir and
starting_desc. Add new global variable initial_wd. It is a struct
saved_wd* and represents find's initial working directory.
* find/find.c: Include save-cwd.h.
(main): Call record_initial_cwd in order to initialise the
global variable initial_wd Don't set starting_desc and
starting_dir, since those variables have been removed.
(safely_chdir): Don't pass an fd to complete_pending_execdirs.
(chdir_back): Remove the safety check (since we are using fchdir
and in any case no longer have all the data that the existing
wd_sanity_check function wants).
(do_process_top_dir): Don't pass an fd to
complete_pending_execdirs.
(process_dir): Likewise.
* find/defs.h (struct exec_val): Remove use_current_dir and
dir_fd. Replace with wd_for_exec, which is a struct saved_wd*.
(get_start_dirfd): Remove prototype.
(get_current_dirfd): Remove prototype.
(complete_pending_execdirs): No longer takes dir_fd parameter.
(record_initial_cwd): Add prototype.
(is_exec_in_local_dir): Add prototype.
(options): Declare.
(initial_wd): Add declaration. It is a struct saved_wd* and
represents find's initial working directory.
(starting_dir): Remove devlaration of global variable.
(starting_desc): Remove devlaration of global variable.
* import-gnulib.config (modules): Import module save-cwd.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Add dirent-safer; we were
previously transitively importing this module, but we are now
importing it directly.
* lib/savedirinfo.c: Include opendir-safer.h.
(xsavedir): Call opendir_safer instead of opendir.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Import the d-type module.
* configure.ac: Remove old struct dirent.d_type detection logic
(since we now use the gnulib macro from the d-type module for
this).
* find/parser.c (parse_version): Use HAVE_STRUCT_DIRENT_D_TYPE
(since the d-ino module still defines it) but remove references to
the macro USE_STRUCT_DIRENT_D_TYPE, since it's not defined and not
needed.
* lib/savedirinfo.c: Use HAVE_STRUCT_DIRENT_D_TYPE but ignore
USE_STRUCT_DIRENT_D_TYPE.
(xsavedir): Unconditionally initialise
internal[result->size].type_info so that we don't have untested
code (HAVE_STRUCT_DIRENT_D_TYPE is defined on my system).
Signed-off-by: James Youngman <jay@gnu.org>
* lib/extendbuf.c (xextendbuf): New function; extends the buffer,
but calls xalloc_die on failure. On the the other hand, extendbuf
returns NULL on failure.
(decide_size): If wanted>SIZE_MAX/2, return wanted. This means
that for very large buffers, performance on repeated extension
degrades from linear to quadratic (instead of just failing at that
point, as before).
* lib/savedirinfo.c (xsavedir): Use xextendbuf rather than
extendbuf, now that there is a difference in semantics.
* find/fstype.c (get_mounted_filesystems): If extendbuf returns
NULL, fail (by returning NULL ourselves).
(get_mounted_devices): Likewise.
Signed-off-by: James Youngman <jay@gnu.org>