221 Commits

Author SHA1 Message Date
James Youngman
8acf1d2ecf Bug #35753: check the success/failure of material I/O operations.
* 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).
2013-12-08 21:02:51 +00:00
Dmitry V. Levin
29f3173a56 find: fix potential buffer overflow in -execdir and -okdir
* lib/buildcmd.c (bc_push_arg): Take prefix length into account
to avoid state->argbuf overflow.
* NEWS: Mention this fix.
2013-09-21 22:55:43 +01:00
James Youngman
16e147b990 Don't use reserved identifiers in macro names; fix other code smells.
* 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).
2013-03-31 20:25:49 +01:00
Kamil Dudka
02a26d7ce5 Fix compile-time warnings.
* find/defs.h (struct predicate): Add a missing const modifier.
* find/find.c (wd_sanity_check): Suppress a warning in #else branch.
(process_dir): Remove an unused variables and statements.
* find/pred.c (pred_context): Use const modifier in the prototype.
* lib/buildcmd.{c,h} (bc_args_exceed_testing_limit): Remove a const
modifier causing unnecessary warnings.
* xargs/xargs.c (main): Add explicit type-casts.
2013-03-26 23:46:30 +00:00
James Youngman
a917eb988f Bugfix to "make clean": do not delete header files.
* 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.
2013-03-24 14:09:14 +00:00
Kamil Dudka
609853e791 Avoid using 'INCLUDES =' in automake templates.
* find/Makefile.am: Use AM_CPPFLAGS instead of deprecated INCLUDES.
* lib/Makefile.am: Likewise.
* locate/Makefile.am: Likewise.
* xargs/Makefile.am: Likewise.
2013-02-03 23:18:23 +00:00
James Youngman
81e33db099 Remove no-longer-used files savedir.[ch].
* lib/savedirinfo.c: delete unused file.
* lib/savedirinfo.h: delete unused file.
* lib/Makefile.am (libfind_a_SOURCES): Remove savedirinfo.c.
(EXTRA_DIST): Remove savedirinfo.h.
2011-08-21 11:25:37 +01:00
James Youngman
0da37ec720 Remove test-coverage output files for "make clean".
* 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.
2011-06-21 10:59:06 +01:00
James Youngman
dc2382e31a Fix some compiler warnings in xargs.
* 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.
2011-06-21 10:42:45 +01:00
James Youngman
633c791d97 Use a consistent include order in header files too.
* lib/printquoted.h: Use the preferred header-file inclusion order
here too.
2011-06-20 10:26:26 +01:00
James Youngman
8becd09bb9 Use a consistent order for header-file inclusion.
* find/exec.c: Include config.h, then system headers followed by
gnulib headers and last, find-specific headers.
* find/find.c: Likewise.
* find/finddata.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/dircallback.c: Likewise.
* lib/extendbuf.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.c: Likewise.
* lib/listfile.c: Likewise.
* lib/printquoted.c: Likewise.
* lib/qmark.c: Likewise.
* lib/regexprops.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/savedirinfo.c: Likewise.
* lib/splitstring.c: Likewise.
* lib/test_splitstring.c: Likewise.
* lib/waitpid.c: Likewise.
* locate/bigram.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
2011-06-20 10:26:24 +01:00
James Youngman
0caac6fe3d Take gnulib-tool's advice about which header files to include.
* 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.
2011-06-20 00:39:20 +01:00
James Youngman
d8260ba1e0 Fix compiler warnings in lib/regextype.c and find/parser.c.
* 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.
2011-06-18 20:04:09 +01:00
James Youngman
f932373da8 Eliminate some compiler warnings.
* 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.
2011-06-14 23:24:54 +01:00
James Youngman
fce1865424 Split strings into fields nondestructively.
* 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.
2011-06-13 23:54:48 +01:00
James Youngman
f92ac3bc3f Enable sc_makefile_at_at_check; fix problems it identifies.
* 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
2011-06-12 03:24:03 +01:00
James Youngman
28e02ca086 Enable more syntax checks, eliminate useless C preprocessor parentheses
* find/defs.h: Eliminate useless parentheses in #if.
* find/find.c (safely_chdir): Likewise.
* find/pred.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/fdleak.c: Likewise
* xargs/xargs.c: Likewise.
* find/parser.c: Likewise.
(ISDIGIT): Simplify, and avoid undefining isascii.
* cfg.mk (local-checks-to-skip): Remove sc_prohibit_cvs_keyword,
since the test produces no hits anyway.  Explain why we avoid
sc_two_space_separator_in_usage. Enable the sc_useless_cpp_parens
check.
2011-06-12 02:38:09 +01:00
James Youngman
0558bb1054 Use stat-size macros in pred.c also.
* 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.
2011-06-12 02:29:51 +01:00
James Youngman
a0c61bf45c Adopt the new gnulib module stat-size.
* 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.
2011-06-11 17:07:11 +01:00
James Youngman
e338e2c9db Don't include sys/param.h where we don't need it.
* xargs/xargs.c: Don't include sys/param.h, we don't use it.
2011-06-07 23:33:54 +01:00
James Youngman
c6370aa424 Don't include "stdio-safer.h" where it is not used.
* find/parser.c: Don't include stdio-safer.h, it's not used.
* lib/findutils-version.c: Likewise.
2011-06-05 22:19:58 +01:00
James Youngman
43fc13f467 Don't include <stddef.h> where it is not used.
* lib/dircallback.c: Don't include <stddef.h>, it's not used.
* lib/extendbuf.c: Likewise.
* lib/qmark.c: Likewise.
* lib/savedirinfo.c: Likewise.
2011-06-05 22:17:54 +01:00
James Youngman
a4d18ea477 Include dirent.h uncontintionally (since gnulib provides it).
* find/pred.c: Include <dirent.h> unconditionally; gnulib provides it.
* lib/savedirinfo.c: Likewise.
2011-06-05 01:10:37 +01:00
James Youngman
acdcf95b84 gnulib already defines O_CLOEXEC.
* lib/fdleak.c: gnulib's fcntl.h always defines O_CLOEXEC, so
don't define it here.
2011-06-05 01:10:36 +01:00
James Youngman
f457e8f05e Update the copyright year in C source files.
* find/defs.h: Update copyright year.
* find/find.c: Update copyright year.
* find/finddata.c: Update copyright year.
* find/ftsfind.c: Update copyright year.
* find/parser.c: Update copyright year.
* find/pred.c: Update copyright year.
* find/sharefile.c: Update copyright year.
* find/sharefile.h: Update copyright year.
* find/tree.c: Update copyright year.
* find/util.c: Update copyright year.
* lib/buildcmd.c: Update copyright year.
* lib/buildcmd.h: Update copyright year.
* lib/dircallback.c: Update copyright year.
* lib/dircallback.h: Update copyright year.
* lib/extendbuf.c: Update copyright year.
* lib/extendbuf.h: Update copyright year.
* lib/fdleak.c: Update copyright year.
* lib/fdleak.h: Update copyright year.
* lib/findutils-version.c: Update copyright year.
* lib/findutils-version.h: Update copyright year.
* lib/forcefindlib.c: Update copyright year.
* lib/listfile.c: Update copyright year.
* lib/listfile.h: Update copyright year.
* lib/nextelem.c: Update copyright year.
* lib/nextelem.h: Update copyright year.
* lib/printquoted.c: Update copyright year.
* lib/printquoted.h: Update copyright year.
* lib/qmark.c: Update copyright year.
* lib/regexprops.c: Update copyright year.
(copying): Update copyright year in the output file, too.
* lib/regextype.c: Update copyright year.
* lib/regextype.h: Update copyright year.
* lib/safe-atoi.c: Update copyright year.
* lib/safe-atoi.h: Update copyright year.
* lib/savedirinfo.c: Update copyright year.
* lib/savedirinfo.h: Update copyright year.
* lib/unused-result.h: Update copyright year.
* lib/waitpid.c: Update copyright year.
* locate/bigram.c: Update copyright year.
* locate/code.c: Update copyright year.
* locate/frcode.c: Update copyright year.
* locate/locate.c: Update copyright year.
* locate/locatedb.h: Update copyright year.
* locate/word_io.c: Update copyright year.
* xargs/xargs.c: Update copyright year.
2011-06-04 13:19:26 +01:00
James Youngman
073e6424ae Avoid code redundancy in lib/buildcmd.c.
* lib/buildcmd.c (bc_get_arg_max): Recheck val only if we might
have changed it (i.e. when ARG_MAX is defined).
2011-06-04 00:43:38 +01:00
James Youngman
8b0f894dcf Fix a compiler warning in lib/buildcmd.c
* lib/buildcmd.c: special_terminating_arg should be const.
2011-06-04 00:40:15 +01:00
James Youngman
d13223b942 Fix compiler warnings in lib/fdleak.c
* 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).
2011-06-04 00:38:47 +01:00
James Youngman
9ab5022447 Fix several small compiler warnings.
* 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.
2011-06-04 00:20:28 +01:00
James Youngman
c8b2946721 Fix some compiler warnings in findutils-version.c.
* lib/findutils-version.c: include findutils-version.h.  Make
version_string const.  Don't #define N_, since we don't use it.
2011-06-04 00:20:27 +01:00
James Youngman
a80e33b1c1 Don't display a separate gnulib version.
* 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
2011-06-04 00:20:27 +01:00
James Youngman
f3d4ac9bb4 Remove unnecessary header checks and include guards.
* 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.
2011-06-02 12:22:22 +01:00
James Youngman
d09450a94c Manage gnulib as a git submodule.
* .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.
2011-05-30 02:00:23 +01:00
James Youngman
de53ac2607 Savannah bug #31424: Revert Interix-specific change.
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.
2011-05-29 00:17:45 +01:00
James Youngman
553651bea5 Fix Savannah bug #18227 (-ls doesn't print device major/minor).
* 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.
2011-05-15 22:30:13 +01:00
James Youngman
cd2338d43b Change "can not" to "cannot".
* lib/buildcmd.c (bc_push_arg): "can not" -> "cannot" in message.
* find/tree.c: Likewise in a comment.
2011-04-02 21:15:20 +01:00
James Youngman
107af5aa0c Savannah bug #31424: Work around Interix bug in _SC_ARG_MAX, in which execve will fail with ENOMEM if we use a command line somewhere between ARG_MAX and _SC_ARG_MAX.
* 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.
2010-10-23 12:49:37 +01:00
Kamil Dudka
443487e989 Correctly initialise variables in run_in_dir.
* 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>
2010-05-07 09:29:17 +01:00
James Youngman
3102624c8a Remove support for compilers lacking prototypes.
* find/defs.h: Don't define or use the PARAMS macro.
* xargs/xargs.c: Likewise.
* locate/locatedb.h: Likewise.
* locate/frcode.c: Likewise.
* lib/buildcmd.c: Likewise.
* find/tree.c: Likewise.
* find/pred.c: Likewise.
* find/parser.c: Likewise.
* find/fstype.c: Likewise.
* find/find.c: Likewise.

Signed-off-by: James Youngman <jay@gnu.org>
2010-04-21 10:47:42 +01:00
James Youngman
56682c9ff5 Make sure we don't open a file on a standard fd (that is, 0/1/2).
* lib/fdleak.c: Include fcntl--.h to turn calls to open into calls
to open_safer.
* find/find.c: Likewise.

Signed-off-by: James Youngman <jay@gnu.org>
2010-04-13 00:36:55 +01:00
James Youngman
61415ade1e Fix Savannah bug #29511: fails to build on kfreebsd-*
* 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>
2010-04-13 00:29:32 +01:00
James Youngman
3669c5011d Remove some unused or dead code.
* 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>
2010-04-13 00:27:40 +01:00
James Youngman
7dc70069a3 Exec predicates now store which directory they want to run in.
* 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>
2010-04-12 22:50:29 +01:00
James Youngman
daff367499 Remove trailing blank lines.
* .x-sc_prohibit_empty_lines_at_EOF: Add list of exceptions to the
no-blank-lines-at-EOF syntax check.
* doc/regexprops.texi: Remove empty lines at the end of the file.
* find/finddata.c: Likewise.
* find/fstype.c: Likewise.
* find/testsuite/excuses.txt: Likewise.
* find/testsuite/find.gnu/access.exp: Likewise.
* find/testsuite/find.gnu/exec-one-rtn-fail.exp: Likewise.
* find/testsuite/find.gnu/posix-perminvalid.exp: Likewise.
* find/testsuite/find.gnu/samefile-missing.exp: Likewise.
* find/testsuite/find.gnu/samefile-p-brokenlink.exp: Likewise.
* find/testsuite/find.gnu/sv-bug-17490.exp: Likewise.
* find/testsuite/find.gnu/sv-bug-18222.exp: Likewise.
* find/testsuite/find.posix/bracket-depth.exp: Likewise.
* find/testsuite/find.posix/empty-parens.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions1.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions2.exp: Likewise.
* find/testsuite/find.posix/files-not-expressions3.exp: Likewise.
* find/testsuite/find.posix/group-empty.exp: Likewise.
* find/testsuite/find.posix/user-empty.exp: Likewise.
* find/testsuite/find.posix/user-missing.exp: Likewise.
* lib/extendbuf.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/fdleak.h: Likewise.
* lib/findutils-version.h: Likewise.
* lib/gnulib-version.h: Likewise.
* lib/printquoted.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* locate/testsuite/config/unix.exp: Likewise.
* locate/testsuite/locate.gnu/exists1.exp: Likewise.
* locate/testsuite/locate.gnu/exists2.exp: Likewise.
* locate/testsuite/locate.gnu/exists3.exp: Likewise.
* locate/testsuite/locate.gnu/ignore_case1.exp: Likewise.
* locate/testsuite/locate.gnu/ignore_case2.exp: Likewise.
* locate/testsuite/locate.gnu/ignore_case3.exp: Likewise.
* locate/testsuite/locate.gnu/notexists1.exp: Likewise.
* locate/testsuite/locate.gnu/notexists2.exp: Likewise.
* locate/testsuite/locate.gnu/notexists3.exp: Likewise.
* locate/testsuite/locate.gnu/sv-bug-14535.exp: Likewise.
* m4/Makefile.am: Likewise.
* m4/nullsort.m4: Likewise.
* xargs/testsuite/xargs.posix/arg_max_32bit_linux_bug.exp: Likewise.
* xargs/testsuite/xargs.posix/arg_max_64bit_linux_bug.exp: Likewise.

Signed-off-by: James Youngman <jay@gnu.org>
2010-04-11 15:57:16 +01:00
James Youngman
742766f729 Adopt (explicitly) the use of the gnulib module dirent-safer.
* 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>
2010-04-11 11:36:02 +01:00
James Youngman
a3fbb31c1d Adopt the use of the gnulib module d-type.
* 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>
2010-04-11 11:36:02 +01:00
James Youngman
c8f6b3d7fa Delete unused file lib/strspn.c
Signed-off-by: James Youngman <jay@gnu.org>
2010-04-07 21:50:34 +01:00
James Youngman
f9187a197d Eliminate some obsolete code.
* locate/locate.c (search_one_database): Remove obsolete code
(alternative size for procdata.pathsize).
* lib/buildcmd.c (get_line_max): Remove obsolete function.

Signed-off-by: James Youngman <jay@gnu.org>
2010-04-07 21:36:49 +01:00
James Youngman
d020204b5a Remove obsolete code from savedirinfo.c.
* lib/savedirinfo.c (new_savedirinfo): Rename new_savedirinfo to
savedirinfo.
(old_savedirinfo): Remove obsolete function body.

Signed-off-by: James Youngman <jay@gnu.org>
2010-04-07 21:36:00 +01:00
James Youngman
5b9e20405d Support extendbuf buffers larger than SIZE_MAX/2.
* 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>
2010-04-07 21:35:02 +01:00