* find/find.c (process_dir): Reduce memory consumption for large
directories. Don't save the whole directory content with
xsavedir, instead just loop over the results of readdir. This
means that oldfind will consume one file descriptor per directory
level.
* find/testsuite/sv-34079.sh: verify that the memory consumption
of oldfind is reasonable on large directories.
* gnulib: update to latest, mainly to include a bugfix (gnulib
commit 47cb657eca1abf2c26c32c8ce03def994a3ee37c) which limits the
memory consumed by fts.
* find/testsuite/sv-34079.sh: New test, verifying that memory
consumption in ftsfind does not grow indefinitely as the size of
directories increases.
* find/testsuite/Makefile.am (test_shell_progs): Added sv-34079.sh.
* find/parser.c (collect_arg_nonconst): Rename collect_arg to
collect_arg_nonconst and change the collected argument from const
char* to char*.
(collect_arg): Call collect_arg_nonconst to do the real work.
(parse_printf): Call collect_arg_nonconst instead of collect_arg.
Change `format' from const char* to char*.
(parse_fprintf): Likewise.
* find/print.h: Change 'format' from const char* to char*, since
actually we edit it in place.
* find/print.c (parse_octal_escape): Instead of updating a const
char* pointer to indicate how many characters from the input we
consumed, update a size_t value.
(insert_fprintf): Change function defintion to match updated
prototype. Eliminate fmt_inpos. Introduce a `readpos' offset
variable which takes the previous role of fmt_inpos.
* find/print.c (get_format_flags_length): Factor out of
insert_fprintf; computes the length of the format flags for a
format specifier (that is everything after the % but before the
format control character).
(get_format_specifer_length): Also factored out of insert_fprintf;
returns the number of format control characters (e.g. 2 for %A@)
or 0 for error.
(insert_fprintf): Keep fmt_editpos and fmt_inpos more closely in
step, instead of initialising fmt_inpos only when we need it (the
idea eventually will be to make fmt_inpos the loop control
variable). Call get_format_specifer_length and
get_format_flags_length when needed. Reduce the number of
different calls to make_segment. We now have one for each KIND_
value plus one for the error case.
* find/print.c (make_segment): Handle foo%% by simply generating a
format string of foo%% (that is, let vfprintf handle the escaped
%).
(insert_fprintf): Handle %% as KIND_FORMAT instead of KIND_PLAIN.
(do_fprintf): Handle %%.
* find/print.c (insert_fprintf): Rename some variables for greater
clarity:
format is now segstart, since it points to the start of the part
of the format string we're next going to pass to make_segment.
scan2 is now fmt_inpos (which is a const char*) and is the
scanning position beyond segstart which we're reading to locate
the end of this segment.
scan is now fmt_editpos and is the scanning position at which we
are modifying the format string (for example to change \n in the
format to the value of the '\n' character).
* find/testsuite/binary_locations.sh: New file, extracting common
code from the test scripts.
* find/testsuite/test_escape_c.sh: Source binary_locations.sh.
* find/testsuite/test_escapechars.sh: Source binary_locations.sh.
* 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.
* find/print.c (scan_for_digit_differences): Move to this file
from pred.c.
(do_time_format): Move to this file from pred.c.
(format_date): Likewise.
(weekdays): Likewise.
(months): Likewise.
(ctime_format): Likewise.
(file_sparseness): Likewise.
(checked_fprintf): Likewise.
(checked_print_quoted): Likewise.
(checked_fwrite): Likewise.
(checked_fflush): Likewise.
(HANDLE_TYPE): Likewise.
(do_fprintf): Likewise.
(pred_fprintf): Likewise.
* find/pred.c: Don't include human.h, filemode.h, verify.h or
xalloc.h, we don't need them. Don't define MAX. Don't declare
ctime_format or format_date. Each of the functions moved into
print.c were moved out of this file.
* find/print.h: Declare pred_fprintf.
* find/print.c (insert_fprintf): Reject %(, %{ and %[.
(make_segment): Remove code which previously supposedly rejected
these format specifiers, but in fact did nothing. Replace with
an assertion to document the fact that we do not expect to see
these format characters in make_segment.
* find/testsuite/find.gnu/printf-reserved.exp: New test case, for
%(, %{ and %[, which are all rejected.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
find.gnu/printf-reserved.exp.
* doc/find.texi (Reserved and Unkown Directives): Document this.
* find/find.1: Document this.
* NEWS: Mention this change.
* find/testsuite/find.gnu/printf.exp: Add test cases for left and
right string alignment (%-10p), string truncation (%10.6p),
explicit signs (%+d), left and right alignment (%10p, %-10p),
zero-filling on decimal fields.
* find/testsuite/find.gnu/printf.xo: Add expected outputs for the
new tests.
* find/print.c (insert_fprintf): Eliminate the 'func' argument,
since it is always pref_fprintf.
* find/print.h: Adjust the prototype accordingly.
* find/parser.c (parse_fprintf): Don't pass the func argument to
insert_fprintf.
(parse_printf): Likewise.
* find/testsuite/test_escapechars.golden: Expected output file.
* find/testsuite/Makefile.am (EXTRA_DIST_GOLDEN): New variable;
distribute test_escapechars.golden.
* find/testsuite/test_escapechars.sh: New test.
* find/testsuite/Makefile.am (test_shell_progs): New variable,
where we keep the list of shell script tests. Move existing
examples from TESTS and add test_escapechars.sh.
* find/testsuite/Makefile.am (TESTS): Refer to test_shell_progs.
* cfg.mk: allow trailing blanks and space-tab sequences in
find/testsuite/test_escapechars.golden.
* find/print.h: New file. Declare insert_fprintf and
make_segment.
* find/print.c: New file. Move definitions of insert_fprintf and
make_segment to here.
* find/parser.c: Include "parser.h". Move declarations of
insert_fprintf and make_segment into that file; move the
definitions into parser.c.
* find/Makefile.am (libfindtools_a_SOURCES): Add print.c.
(EXTRA_DIST): Add print.h.
* po/POTFILES.in: Add find/print.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.
* import-gnulib.config (modules): Add manywarnings.
* configure.ac: Invoke gl_MANYWARN_ALL_GCC and
gl_MANYWARN_COMPLEMENT.
* configure.ac: Turn on the compiler warnings only if
--enable-compiler-warnings was specified to configure.
Signed-off-by: James Youngman <jay@gnu.org>
* 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: 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.
* 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.
* locate/locate.c (dolocate): Remove declaration of e, which was
replaced by the variable db_name. Change the last two uses of 'e'
to use 'db_name'. This bugfix prevents possible coredumps when
issuing error messages about reads from the locate database (or
warnings about byte order for old databases). This bug had been
introduced in the previous change.
* 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.
* 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>
* cfg.mk: Move definition of which files we should not check to
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF, instead
of .x-sc_prohibit_empty_lines_at_EOF.
Move contents of .x-sc_bindtextdomain into
exclude_file_name_regexp--sc_bindtextdomain.
.x-sc_prohibit_empty_lines_at_EOF: Delete.
.x-sc_bindtextdomain: Delete.
* 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
* cfg.mk: Enable the sc_space_tab check. Exclude various xargs
test inputs and outputs from the check.
* locate/Makefile.am (dblocation.texi): Remove space-tab sequences.
* cfg.mk: Enable the sc_texinfo_acronym check. Exempt
doc/perm.text, which isn't ours anyway.
* doc/find.texi (Deleting Files): Say just POSIX rather than
@acronym{POSIX}, simply because this is the convention in GNU
documentation. The motivation is that it's hard to do so
consistently (because, for example, you can't use @acronym in a
node name).
* 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.
* build-aux/src-sniff.py: Mention that many of these checks would
be better as gnulib syntax checks (since there are more flexible
ways to disable these).
(RegexChecker.__init__): Don't pass a spurious second "self"
argument.
(RegexChecker.Check): Provide a more intelligible message when
complaining about use atof/scanf.
(RegexChecker.Check): Enable the check for HAVE_FCNTL_H.
(RegexChecker.Check): When checking for trailing whitespace, don't
complain about trailing newlines(!)
(RegexChecker.Check): Indicate what the out-of-date address is
when we find one.