NULL is best for C as discussed - for coreutils - at:
https://bugs.gnu.org/66221#53
* bootstrap.conf: Remove dependency on nullptr.
* s/nullptr/NULL/.
This effectively reverts 93ce19f0d5a1.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
* bootstrap.conf (gnulib_modules): Add nullptr.
In code, prefer nullptr to NULL where either will do.
* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.
(begword, endword): Add regex helper macros.
Commit '1b53838ddf' has changed the order of the nodes, yet not
quite well. Let's use alphabetical sort order.
* lib/regextype.c (regex_map): Move 'awk' and 'egrep' entries up.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Like in the recent commit, also change the following variables to follow
the renaming done in gnulib:
- LIB_SETLOCALE_NULL -> SETLOCALE_NULL_LIB,
- LIB_MBRTOWC -> MBRTOWC_LIB,
- LIB_EACCESS -> EUIDACCESS_LIBGEN.
* find/Makefile.am (LDADD): Change as described above.
* lib/Makefile.am: Likewise.
* locate/Makefile.am: Likewise.
* xargs/Makefile.am: Likewise.
The following syntax-check rule fails:
$ make syntax-check
...
maint.mk: Use #include <hdr.h>, not #include "hdr.h" for the above
make: *** [maint.mk:619: sc_prefer_angle_bracket_headers] Error 1
The rule suggests using '#include <header.h>' instead of
'#include "header.h"' for headers that override system headers.
See gnulib documentation, section "Style of #include statements".
* find/parser.c (#include "fnmatch.h": Change from "..." to <...> style.
* find/pred.c (#include "fnmatch.h"): Likewise.
* find/tree.c (#include "fnmatch.h"): Likewise.
* lib/system.h (#include "error.h"): Likewise.
* locate/locate.c (#include "fnmatch.h"): Likewise.
* tests/xargs/test-sigusr.c (#include "error.h"): Likewise.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Now that Gnulib's 'error' module does proper static checking
for not returning, we need no longer use the 'die' macro.
This makes code easier to read for people that are used to 'error'.
* cfg.mk (sc_die_EXIT_FAILURE): Remove.
* src/die.h: Remove. All includes removed. All calls to 'die'
changed back to calls to 'error'.
* lib/Makefile.am (libfind_a_SOURCES): Remove 'die.h'.
* src/system.h: Include error.h. Stop including error.h elsewhere.
* find/ftsfind.c (process_all_startpoints): Avoid extra '\n' in error
diagnostics wrt/ -files0-from. Also avoid redundant "%s" formats.
* find/parser.c (parse_perm, parse_regex):
* lib/buildcmd.c (bc_push_arg):
Wrap calls to 'error' in block when under an if-condition and either
the if-condition or the 'error' invocation is spanning over more
than one line.
* find/tree.c (get_pred_cost): Make error message translatable - found
by sc_unmarked_diagnostics.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
https://sparse.docs.kernel.org/
Running the tool against unviled the following warnings:
find/parser.c:328:7: warning: Using plain integer as NULL pointer
find/parser.c:328:10: warning: Using plain integer as NULL pointer
find/parser.c:328:13: warning: Using plain integer as NULL pointer
find/parser.c:466:49: warning: Using plain integer as NULL pointer
find/parser.c:656:45: warning: Using plain integer as NULL pointer
find/print.c:1024:30: warning: Using plain integer as NULL pointer
lib/regexprops.c:531:7: warning: symbol 'options' shadows an earlier one
lib/regextype.c:48:24: warning: symbol 'regex_map' was not declared. Should it be static?
locate/locate.c:131:25: warning: symbol 'check_existence' was not declared. Should it be static?
locate/locate.c:207:12: warning: symbol 'metacharacters' was not declared. Should it be static?
xargs/xargs.c:902:24: warning: symbol 'state' shadows an earlier one
xargs/xargs.c:542:23: warning: Using plain integer as NULL pointer
The fixes for these findings are all trivial, so let's apply them.
* find/parser.c (parse_table): Initialize pointer-type members of
the last element with NULL instead of 0.
(get_noop): Compare to NULL as end condition of for-loop.
(find_parser): Likewise.
* find/print.c (do_fprintf): Initialize linkname with NULL instead of 0.
* lib/regexprops.c (describe_all): Rename local variable options
to regopts to avoid name shadowing.
* lib/regextype.c (regex_map): Declare static.
* locate/locate.c (check_existence): Likewise.
(metacharacters): Likewise.
* xargs/xargs.c (main): Set eof_str to NULL instead of 0.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
The format of the copyright year number range in Texinfo files is
"YEAR1--YEAR2" now, i.e., with 2x '-'.
* tests/sample-test: Adjust to use the single most recent year.
* All other files: Update copyright years via the above make run.
Linking on AIX7.2 fails:
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
Bruno Haible noticed that $(LIB_MBRTOWC) and $(LIB_SETLOCALE_NULL)
expand to -lpthread on that platform, so let's add them to LDADD.
Maybe we should better depend on a 'gnulib.mk' file generated by
'gnulib-import' in the long run, but let's fix this issue with the
simpler solution for now.
* find/Makefile.am (LDADD): Add $(LIB_SETLOCALE_NULL) and $(LIB_MBRTOWC).
* locate/Makefile.am (LDADD): Likewise.
* xargs/Makefile.am (LDADD): Likewise.
* lib/Makefile.am (regexprops_LDADD): Add definition.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
The format of the copyright year number range in Texinfo files is
"YEAR1--YEAR2" now, i.e., with 2x '-'.
* tests/sample-test: Likewise, here to avoid starting a year number range.
* All other files: Update copyright years via the above make run.
Avoid using fopen_safer and opendir_safer directly in favor of
letting gnulib transparently doing the work via "dirent--.h" and
"stdio--.h".
* find/oldfind.c (dirent-safer.h): Replace include ...
(dirent--.h): ... by this.
(process_dir): Change opendir_safer to the regular opendir call.
* find/sharefile.c (stdio-safer.h): Replace include ...
(stdio--.h): ... by this.
(sharefile_fopen): Change fopen_safer to regular fopen call.
* lib/fdleak.c (dirent-safer.h): Replace include ...
(dirent--.h): ... by this.
(get_proc_max_fd): Change opendir_safer to regular opendir call.
Use HTTPS for GNU, FSF, OpenGroup and Google URLs.
* build-aux/update-online-manual.sh: Switch to HTTPS.
* doc/find.texi (node Further Reading on Security): Likewise.
* lib/buildcmd.c: Likewise in a comment.
* NEWS: Likewise, and shorten a debbugs URL.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* tests/sample-test: Likewise, here to avoid starting a year number range.
* All other files: Update copyright years via the above make run.
Utilize GNU_FINDUTILS_FD_LEAK_CHECK environment variable
to enable/disable fd leak check for xargs the same way as
for find.
* find/defs.h: Remove prototype for fd_leak_check_is_enabled().
* find/util.c: Remove implementation of fd_leak_check_is_enabled().
* lib/fdleak.c: Add implementation of fd_leak_check_is_enabled().
* lib/fdleak.h: Add prototype for fd_leak_check_is_enabled().
* xargs/testsuite/config/unix.exp: Enable GNU_FINDUTILS_FD_LEAK_CHECK
for all tests.
* xargs/xargs.c: Execute complain_about_leaky_fds when
fd_leak_check_is_enabled returns true.
* NEWS (Improvements): Document support of GNU_FINDUTILS_FD_LEAK_CHECK
by xargs.
Copyright-paperwork-exempt: Yes
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
* lib/bugreports.c (explain_how_to_report_bugs): Avoid continued strings
by using multi-part strings, one per line.
* cfg.mk (sc_prohibit_continued_string_alpha_in_column_1): Add SC rule.
* lib/fdleak.c (get_max_fd): Move definition of the fd_limit variable
into the HAVE_GETRLIMIT block giving it a better scope: platforms
lacking getrlimit probably also lack struct rlimit, too.
Copyright-paperwork-exempt: Yes
When qmark_chars() replaces a multibyte character with a single
character, this reduces the length of the string. When this happens,
terminate the now-shorter string at the new length.
This is simple workaround for bug http://savannah.gnu.org/bugs/?54236.
Some make implementations, e.g. on NetBSD 7.1, lack it; therefore
avoid it in order to prevent error messages during 'make clean'.
* Makefile.am (coverage-clean): Replace $(RM) by 'rm -f'.
* find/Makefile.am: Likewise.
* lib/Makefile.am: Likewise.
* locate/Makefile.am: Likewise.
* xargs/Makefile.am: Likewise.
Run 'make update-copyright'.
* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
* lib/regextype.c (get_regex_type_synonym): don't return regex
dialect Y as a synonym of dialect X, if we're not in fact going to
include X. Accept a CONTEXT parameter in order to identify this
situation. This ensures that the bug fixed in commit
e2c673cbcdc325a3a2e9dd02169bb4a42c61bc48 stays fixed for any
permutation of regex_map.
* lib/regextype.h: update prototype of get_regex_type_synonym.
* lib/regexprops.c (describe_all): Pass the new context parameter.
* doc/regexprops.texi: regenerate this file.
* 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.
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.
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'.
* 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.
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.
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.
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.
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".
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
* 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.
'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.
* 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.