252 Commits

Author SHA1 Message Date
James Youngman
e2c673cbcd regexprops: fix dangling reference to the `ed' regular expression dialect.
* lib/regextype.c (regex_map): Permute the entries to list POSIX
dialects before other ones, so that we don't end up with a
dangling reference to `ed' regular expressions when
context=findutils.  Remove trailing white space from the output.
* doc/regexprops.texi: Regenerate this file, so that we no longer
have a dangling reference to the `ed' dialect.
* doc/find.texi (Regular Expressions): Point out the difference
between Emacs regular expressions and findutils regular
expressions: in findutils "." will match newline.
* find/find.1: Likewise.
* locate/locate.1: Likewise.  Also document the --regextype option.
2017-11-14 13:43:32 +00:00
Bernhard Voelker
aa742e34b8 all: use die() rather than error(EXIT_FAILURE)
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.
2017-11-13 18:40:29 +01:00
Bernhard Voelker
ff4701b4ef maint: avoid unused-but-set-variable, unused-parameter warnings from GCC 7
GCC-7.2.1 complained about this occur during 'make check'.

* lib/regexprops.c (menu): Remove set-but-unused-variable 'options'.
* lib/test_splitstring.c (main): Avoid unused-parameter warnings
for 'argc' and 'argv'.
2017-11-13 18:40:29 +01:00
Bernhard Voelker
cd61e9f7ac maint: add die.h; avoid missing-fallthrough warnings after error w/ GCC 7
* lib/die.h (die): New file/function from grep/coreutils.
Note: this file will probably be migrated to gnulib.
* lib/Makefile.am (libfind_a_SOURCES): Reference it.
* xargs/xargs.c: Include die.h.
(xargs_do_exec): Use die in place of error-nonzero, thus allowing
the compiler to know that we do not fall through into the 0 (child)
case.
2017-11-13 18:40:29 +01:00
Bernhard Voelker
05da1fa358 maint: avoid implicit-fallthrough warnings from GCC 7
Avoid the new warnings GCC 7 gives with the
"-Werror=implicit-fallthrough=" compiler option.
Since version 7, GCC requires fallthrough switch/cases to be
marked by the appropriate attribute.

* lib/system.h: Add new header file defining the FALLTHROUGH macro.
* lib/Makefile.am (libfind_a_SOURCES): Reference it.
* find/print.c (do_fprintf): Use the new macro.
* xargs/xargs.c (read_line): Likewise.
(xargs_do_exec): For error(3), GCC 7 doesn't know that the function
does not return, and would complain about falling through into the
following case.  Temporarily add an abort call - this will be fixed
with another commit.
2017-11-13 18:38:08 +01:00
Bernhard Voelker
3876904855 maint: avoid unused-macros warning from GCC 7
GCC-7.2.1 on openSUSE-Tumbleweed complains:
  listfile.c:56:0: error: macro "HAVE_MAJOR" is not used \
  [-Werror=unused-macros]
  #define HAVE_MAJOR

* listfile.c (major,minor): Avoid the temporary #define HAVE_MAJOR
by using #else's.
2017-11-08 00:32:39 +01:00
Bernhard Voelker
2cb10332af all: prefer https:// URLs where possible
Change from http:// to https:// URLs for the following:
www.gnu.org, gnu.org, savannah.gnu.org, git.sv.gnu.org, lists.gnu.org,
translationproject.org, cve.mitre.org, cwe.mitre.org, xkcd.com,
standards.ieee.org, and gcc.gnu.org.

* COPYING: Do the above replacement.
* ChangeLog-2013: Likewise.
* NEWS: Likewise.
* README: Likewise.
* README-hacking: Likewise.
* build-aux/Makefile.am: Likewise.
* build-aux/check-testfiles.sh: Likewise.
* build-aux/gen-changelog.sh: Likewise.
* build-aux/man-lint.sh: Likewise.
* build-aux/src-sniff.py: Likewise.
* cfg.mk: Likewise.
* configure.ac: Likewise.
* doc/Makefile.am: Likewise.
* doc/find-maint.texi: Likewise.
* doc/find.texi: Likewise.
* find/defs.h: Likewise.
* find/exec.c: Likewise.
* find/find.1: Likewise.
* find/finddata.c: Likewise.
* 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/print.h: Likewise.
* find/sharefile.c: Likewise.
* find/sharefile.h: Likewise.
* find/testsuite/Makefile.am: Likewise.
* find/testsuite/binary_locations.sh: Likewise.
* find/testsuite/checklists.py: Likewise.
* find/testsuite/config/unix.exp: Likewise.
* find/testsuite/find.gnu/name-period.exp: Likewise.
* find/testsuite/find.posix/depth1.exp: Likewise.
* find/testsuite/sv-34079.sh: Likewise.
* find/testsuite/sv-34976-execdir-fd-leak.sh: Likewise.
* find/testsuite/sv-48030-exec-plus-bug.sh: Likewise.
* find/testsuite/sv-48180-refuse-noop.sh: Likewise.
* find/testsuite/sv-52220.sh: Likewise.
* find/testsuite/sv-bug-32043.sh: Likewise.
* find/testsuite/test_escape_c.sh: Likewise.
* find/testsuite/test_escapechars.sh: Likewise.
* find/testsuite/test_inode.sh: Likewise.
* find/testsuite/test_type-list.sh: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* gnulib-local/lib/gcc-function-attributes.h: Likewise.
* lib/bugreports.c: Likewise.
* lib/bugreports.h: Likewise.
* lib/buildcmd.c: Likewise.
* lib/buildcmd.h: Likewise.
* lib/check-regexprops.sh: Likewise.
* lib/dircallback.c: Likewise.
* lib/dircallback.h: Likewise.
* lib/extendbuf.c: Likewise.
* lib/extendbuf.h: Likewise.
* lib/fdleak.c: Likewise.
* lib/fdleak.h: Likewise.
* lib/findutils-version.c: Likewise.
* lib/findutils-version.h: Likewise.
* lib/listfile.c: Likewise.
* lib/listfile.h: Likewise.
* lib/printquoted.c: Likewise.
* lib/printquoted.h: Likewise.
* lib/qmark.c: Likewise.
* lib/regexprops.c: Likewise.
* lib/regextype.c: Likewise.
* lib/regextype.h: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/safe-atoi.h: Likewise.
* lib/splitstring.c: Likewise.
* lib/splitstring.h: Likewise.
* lib/test_splitstring.c: Likewise.
* lib/unused-result.h: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.1: Likewise.
* locate/locate.c: Likewise.
* locate/locatedb.5: Likewise.
* locate/locatedb.h: Likewise.
* locate/testsuite/Makefile.am: Likewise.
* locate/testsuite/config/unix.exp: Likewise.
* locate/updatedb.1: Likewise.
* locate/updatedb.sh: Likewise.
* locate/word_io.c: Likewise.
* po/fetch-po-files: Likewise.
* xargs/testsuite/Makefile.am: Likewise.
* xargs/testsuite/config/unix.exp: Likewise.
* xargs/xargs.1: Likewise.
* xargs/xargs.c: Likewise.
2017-10-23 00:57:57 +02:00
Bernhard Voelker
0548a502cd maint: add copyright header to more files
* Makefile.am: Add copyright header.
* README: Likewise.
* TODO: Likewise.
* doc/perm.texi: Likewise; use 1994-2017 as Kevin brought it into
findutils from coreutils.
* find/Makefile.am: Add copyright header.
* lib/Makefile.am: Likewise.
* locate/Makefile.am: Likewise.
* xargs/Makefile.am: Likewise.
2017-10-23 00:57:57 +02:00
Bernhard Voelker
4625495c48 maint: align copyright header line
* lib/extendbuf.c: s/Copyright/Copyright (C)/
* lib/printquoted.h: Likewise.
* lib/regextype.c: Likewise.
* lib/regextype.h: Likewise.
2017-10-23 00:57:35 +02:00
Bernhard Voelker
77651af6a8 maint: update copyright year number ranges
Better late than never: run 'make update-copyright'.

* cfg.mk (update-copyright-env): Change UPDATE_COPYRIGHT_USE_INTERVALS
from 1 to 2 to get a minimal containing range of years; also set
UPDATE_COPYRIGHT_MAX_LINE_LENGTH to 79 characters.
* .x-update-copyright: Add an entry for bootstrap which comes from
gnulib.
* lib/qmark.c: While at it, fix a typo: s/courutils/coreutils/.
* lib/regexprops.c (copying): Update the text so that the
copyright years match the result of "make update-copyright".
* po/fi.po: Change copyright header so that "make update-copyright"
can pick it up: s/©/(C)/
* po/it.po: Likewise.
* po/vi.po: Likewise.
* All other files: Update copyright years via the above make run.
2017-10-23 00:45:18 +02:00
Bernhard Voelker
4bbc9e7a4a maint: avoid warnings from GCC 6.2.1
buildcmd.c: In function 'bc_push_arg':
buildcmd.c:362:11: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
           if (ctl->replace_pat
           ^~
buildcmd.c:366:13: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
             bc_do_exec (ctl, state);
             ^~~~~~~~~~
pred.c: In function 'print_optlist':
pred.c:1328:46: error: format '%ld' expects argument of type 'long int', but argument 3 has type 'long unsigned int' [-Werror=format=]
           fprintf (fp, "[real success rate %ld/%ld", p->perf.successes, p->perf.visits);
                                              ^
pred.c:1328:50: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'long unsigned int' [-Werror=format=]
           fprintf (fp, "[real success rate %ld/%ld", p->perf.successes, p->perf.visits);
                                                  ^
print.c: In function 'scan_for_digit_differences':
print.c:449:46: error: logical 'or' of equal expressions [-Werror=logical-op]
           if (!isdigit ((unsigned char)q[i]) || !isdigit ((unsigned char)q[i]))
                                              ^~
In file included from ../gl/lib/gettext.h:25:0,
                 from locate.c:86:
locate.c: In function 'dolocate':
locate.c:1873:28: error: format '%d' expects argument of type 'int', but argument 5 has type 'unsigned int' [-Werror=format=]
                          _("warning: database %s is more than %d %s old (actual age is %.1f %s)"),
                            ^
locate.c:1873:26: note: in expansion of macro '_'
                          _("warning: database %s is more than %d %s old (actual age is %.1f %s)"),
                          ^
locate.c:1927:18: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'long unsigned int' [-Werror=format=]
       printf ("%ld\n", found);
                  ^
cc1: all warnings being treated as errors

* find/pred.c (print_optlist): Use %lu for unsigned long int.
* find/print.c (scan_for_digit_differences): Check p[i] too rather than
q[i] two times.
* lib/buildcmd.c (bc_push_arg): Fix indentation.
* locate/locate.c (dolocate): Use %u format for unsigned int.
Use %lu format for unsigned long int.
2017-02-06 22:25:01 +01:00
Bernhard Voelker
7a6e548690 find: handle more readdir(3) errors
Similar to the FTS readdir fix in v4.6.0-72-g155c9d1, handle the last
two unhandled readdir(3) errors.

* find/pred.c (pred_empty): Do the above.
* lib/fdleak.c (get_proc_max_fd): Likewise.  While at it, fix the
condition to only skip "." and ".."; previously, also other files
beginning with ".." would have been skipped - that was theoretically,
as we only expect the FD files in "/proc/self/fd".
2016-11-02 23:32:04 +01:00
Bernhard Voelker
8cdc9767e3 Fix bug #48030: find: -exec + does not pass all arguments in certain cases
When the -exec arguments buffer (usually 128k) is full and the given
command has been executed with all that arguments, find(1) missed to
execute the command yet another time if only 1 another file would have
to be processed.
Both find(1), i.e., nowadays FTS-version, and oldfind are affected.
This bug was present since the implementation of '-exec +' in 2005,
see commit FINDUTILS_4_2_11-1-25-gf0a6ac6.

* lib/buildcmd.c (bc_push_arg): Move the assignment to set 'state->todo'
to 1 down after the immediate execution which resets that flag.
* find/testsuite/sv-48030-exec-plus-bug.sh: Add a test.
* find/testsuite/Makefile.am (test_shell_progs): Reference the test.
* NEWS (Bug Fixes): Mention the fix.

Reported by Joe Philip Ninan <indiajoe@gmail.com> in
https://savannah.gnu.org/bugs/?48030
2016-05-31 10:39:10 +02:00
Bernhard Voelker
06c72d9009 maint: adjust .gitignore files
* lib/.gitignore: Use pattern for prominent suffixes like *.o, *.log
and *.a; an entry for the new intermediate file bugreports.o was missing
here.  Sort file.
* locate/.gitignore (bigram,code,bigram.o,code.o): Remove, as these
programs have been removed with commit v4.6.0-44-g89ec021.
* find/.gitignore: Use pattern for *.o, and sort the file.
* xargs/.gitignore: Likewise.
2016-02-16 23:27:44 +01:00
Bernhard Voelker
b05118da9c maint: avoid syntax-check failures
'make syntax-check' failed with:

  locate/word_io.h:
  maint.mk: the above files include assert.h but don't use it
  maint.mk:479: recipe for target 'sc_prohibit_assert_without_use' failed
  ...
  lib/bugreports.h:
  maint.mk: empty line(s) or no newline at EOF
  maint.mk:929: recipe for target 'sc_prohibit_empty_lines_at_EOF' failed

* locate/word_io.h (#include <assert.h>): Remove superfluous inclusion
of <assert.h>.
* lib/bugreports.h: Remove stray empty line at EOF.
2016-02-16 23:27:21 +01:00
James Youngman
f535461241 Better and more consistent guidance on how to report bugs.
* configure.ac (PACKAGE_BUGREPORT_URL): Define this macro to point
to the findutils bug-reporting web page.
* lib/bugreports.c: New file, defining the function
explain_how_to_report_bugs which explains how to report bugs.  Use
the new PACKAGE_BUGREPORT_URL macro.
* lib/bugreports.h: New file, providing a declaration of
explain_how_to_report_bugs.
* lib/Makefile.am (libfind_a_SOURCES): Add bugreports.c and
bugreports.h.
* find/parser.c (parse_help): Call explain_how_to_report_bugs
instead of printing an explanation here.
* xargs/xargs.c (usage): Likewise.
* locate/locate.c (usage): Likewise.
* locate/code.c (usage): Likewise.
* locate/frcode.c (usage): Likewise.
* locate/updatedb.sh (usage): Produce a similar message
by including it in the usage text itself.
2016-01-25 23:56:17 +00:00
Bernhard Voelker
43b6de455e maint: update .gitignore files, remove obsolete .cvsignore files
* .gitignore (tool-versions.txt): Add entry.
(ABOUT-NLS): Change to ...
(/ABOUT-NLS): ... this to avoid ./bootstrap adding it again.
* build-aux/.gitignore (/ar-lib, /snippet/, /test-driver): Add entries.
While at it, use the git-specific '/' prefix on other entries, and sort
the file.
* doc/.gitignore (/dblocation.texi): Add entry.  Prefix other entries
with '/' and sort the file.
* find/.gitignore (/exec.o, /print.o): Likewise.
* find/testsuite/.gitignore (/configured-testfiles.txt, /*.log, /*.trs):
Likewise.
* lib/.gitignore (check-regexprops, /check-regexprops.log,
/check-regexprops.trs, /regexprops.texi.new, /splitstring.o,
/test_splitstring, /test_splitstring.log, /test_splitstring.o
/test_splitstring.trs, /test-suite.log): Likewise.
* po/.gitignore (/Makevars): Add entry.  While at it, prefix all
other entries with '/', too, to avoid bootstrap adding entries for
e.g. "/Makefile.in.in" again.
* .cvsignore: Remove file.
* build-aux/.cvsignore: Likewise.
* doc/.cvsignore: Likewise.
* find/.cvsignore: Likewise.
* find/testsuite/.cvsignore: Likewise.
* lib/.cvsignore: Likewise.
* locate/.cvsignore: Likewise.
* locate/testsuite/.cvsignore: Likewise.
* m4/.cvsignore: Likewise.
* po/.cvsignore: Likewise.
* xargs/.cvsignore: Likewise.
* xargs/testsuite/.cvsignore: Likewise.
2016-01-04 08:22:04 +01:00
James Youngman
265753b4af maint: update copyright years.
* 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.
2016-01-03 23:27:34 +00:00
James Youngman
c83e75f548 regexprops: Fix compiler warnings and update copyright years.
* lib/regexprops.c (newpara): Function parameter list should be
declared as void in the function definition, instead of leaving it
blank (C++ style).  This fixes a GCC warning controlled by
-Wstrict-prototypes.
(beginenum): Likewise.
(endenum): Likewise.
(endtable): Likewise.
(copying): Update copyright years.
* doc/regexprops.texi: Update copyright years to match the output
of regexprops.c.
2016-01-03 23:20:54 +00:00
James Youngman
7ce6b13157 lib: Update the width of the st_nlink field and fix some compiler warnings.
* lib/listfile.h (list_file): Make the relname parameter const.
* lib/listfile.c (list_file): Make the relname parameter const.
Remove the unused local variable inode_field_width.  Update
nlink_width with the greatest width of the st_nlink field, and
print the field using the maximum width (as we do for other
fields).
2016-01-03 17:29:36 +00:00
James Youngman
317c00f610 maint: Don't define the gettext-related macro N_ where it is not needed.
* lib/buildcmd.c: Don't define the macro N_(), since we don't use
it.
* lib/fdleak.c: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/regextype.c: Likewise.
* lib/listfile.c: Likewise.
* locate/bigram.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/word_io.c: Likewise.
* find/fstype.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/exec.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* find/print.c: Likewise.
* find/ftsfind.c: Likewise.
2016-01-03 17:29:35 +00:00
James Youngman
f298f37169 lib: FINDLIB_REPLACE_FUNCS has become obsolete, so delete findlib.
* configure.ac: gnulib supplies waitpid and C89 supplies strspn.
Hence there is no need for any call to FINDLIB_REPLACE_FUNCS.
That being the case we don't need to test it with forcefindlib.
* m4/findlib.m4: remove since FINDLIB_REPLACE_FUNCS is unused.
* m4/Makefile.am (EXTRA_DIST): findlib.m4 has been deleted, so
don't distribute it.
* lib/waitpid.c: remove, since gnulib provides this.
* lib/forcefindlib.c: remove, since there is no longer any need to
test FINDLIB_REPLACE_FUNCS.
* lib/Makefile.am (libfind_a_SOURCES): Specify this variable all
in one go, instead of in several parts.  Move some header files
into here instead of just having them in EXTRA_DIST.  Because
FINDLIBOBJS is empty now, there is no need to copy that to
libfind_a_LIBADD.
2016-01-03 16:52:02 +00:00
Bernhard Voelker
f593432309 maint: avoid sc_prohibit_always_true_header_tests failure.
* configure.ac: Check for getrlimit function directly rather than the
"sys/resource.h" header file.
* lib/fdleak.c: Include "sys/resource.h" when HAVE_GETRLIMIT is set.
(get_max_fd): s/HAVE_GETRUSAGE/HAVE_GETRLIMIT/.
2015-12-28 10:15:31 +00:00
Bernhard Voelker
852e4225af maint: avoid syntax-check failures
* Makefile.am (gen-ChangeLog): Replace 8 spaces by a tab to avoid
sc_makefile_TAB_only_indentation failure.
* po/POTFILES.in: Remove some entries to let sc_po_check pass.
While at it, sort the entries.
* find/print.c (do_fprintf): Remove stray semicolon to let
sc_prohibit_double_semicolon pass.
* find/util.c (digest_mode): Likewise.
* bootstrap.conf: Change comment to let sc_prohibit_doubled_word pass.
* build-aux/git-log-fix: Remove empty lines at EOF to let
sc_prohibit_empty_lines_at_EOF pass.
* find/testsuite/Makefile.am: Likewise.
* find/testsuite/sv-34079.sh: Likewise.
* find/testsuite/test_inode.sh: Likewise.
* locate/testsuite/locate.gnu/slocate.exp: Likewise.
* lib/buildcmd.c: Remove unused include of openat header to let
sc_prohibit_openat_without_use pass.
* lib/listfile.c: Likewise.
* find/util.c: Remove unused include of 'verify.h' to let
sc_prohibit_verify_without_use pass.
* xargs/xargs.c: Likewise.
* find/parser.c (insert_regex): Mark error diagnostic for translation;
found by 'make sc_unmarked_diagnostics'.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_strncpy): Exempt the
2 remaining sources using the possibly dangerous strncpy function
from the syntax-check.
2015-12-28 10:15:31 +00:00
Andreas Metzler
783704be4e Use the official FDL license wording in license text.
* README-hacking (footer): use the official FDL license wording as
listed in FDL's "ADDENDUM: How to use this License for your
documents". Update copyright year.
* NEWS (footer): Likewise.
* doc/find-maint.texi: Likewise.
* doc/find.texi: Likewise.
* doc/regexprops.texi: Likewise.
* lib/regexprops.c (copying): Amend the code to emit the updated
wording.  Update the copyright year.
2015-12-27 15:43:53 +00:00
James Youngman
9f640e8034 Document the functions declared in regextype.h.
* lib/regextype.h: Document the semantics of the functions
declared in this header.
2015-12-23 18:34:59 +00:00
James Youngman
771ace2582 Add copyright headers to some files which lack them.
* find/testsuite/excuses.txt: remove spurious character (a typo).
* find/testsuite/test_escape_c.sh: Add copyright header.
* find/testsuite/binary_locations.sh: Likewise.
* find/testsuite/checklists.py: Likewise.
* find/testsuite/Makefile.am: Likewise.
* find/testsuite/sv-bug-32043.sh: Likewise.
* find/testsuite/test_escapechars.sh: Likewise.
* find/testsuite/test_inode.sh: Likewise.
* xargs/testsuite/Makefile.am: Likewise.
* locate/testsuite/Makefile.am: Likewise.
* build-aux/Makefile.am: Likewise.
* doc/Makefile.am: Likewise.
* find/print.h: Likewise.
* lib/check-regexprops.sh: Likewise.
2015-11-01 14:37:12 +00:00
James Youngman
731826cc8d find: adaptive column alignment (resolves Savannah bug #45780)
* lib/listfile.c (list_file): For aligned fields, use the number
of characters output to deduce whether our current idea of the
maximum width of each field is too small.  When this happens,
increase the field width.  Keep track of the field width in a
static variable for each field.  Do this for the inode number,
number of blocks, owner, group, major and minor device numbers,
and the file size.  Use mbswidth in some places to count
characters.
* find/print.c (do_fprintf): Mention the potential portability
problems in casting ino_t to uintmax_t.
* bootstrap.conf (gnulib_modules): Add mbswidth.
* po/Makevars (XGETTEXT_OPTIONS): updated by running bootstrap.
*NEWS: Mention this bugfix.
2015-10-31 23:26:31 +00:00
James Youngman
eb61454479 Stop ignoring the now-nonexistent gnulib-version.c.
* lib/.gitignore: remove gnulib-version.c since we no longer
create it.
2015-05-10 21:15:54 +01:00
James Youngman
d5234fe96a Standardize on "initialize".
* 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.
2014-07-19 11:17:52 +01:00
James Youngman
67a87f51c6 Fix bug #42793: "Failed to write output" with -ls.
* lib/listfile.c (print_name_with_quoting): Avoid using the
variable fprintf_result before it is initialised.  I hope this
fixes Savannah bug #42793.
2014-07-19 00:46:35 +01:00
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