Compare commits

...

628 Commits

Author SHA1 Message Date
Bernhard Voelker
6b49775f9d maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 58 commits on gnulib
since the last update.

* gnulib: Update to latest.
2026-01-25 19:40:23 +01:00
Bernhard Voelker
6cf0fe34d7 maint: simplify updating 'bootstrap' and adjust target 'gnulib-sync'
Copy the 'bootstrap' script from the 'build-aux' directory in gnulib
instead of from the 'top' directory.  The former one already contains
the 'bootstrap-funclib.sh' code which can then be removed as well here.
Finally, remove the obsolete 'autogen.sh' and 'autopull.sh' scripts.

* autogen.sh: Remove.
* autopull.sh: Remove.
* bootstrap-funclib.sh: Remove.
* bootstrap: Update from 'gnulib/build-aux/bootstrap'.
* Makefile.am (gnulib-sync): Change the source dirsctory of 'bootstrap'
from 'top' to 'build-aux', and remove the copying of above obsolete
files.
2026-01-25 19:18:23 +01:00
Bernhard Voelker
c56b96a54f maint: prefer NULL to nullptr
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.
2026-01-20 23:03:54 +01:00
Bernhard Voelker
99b3365ec3 tests: avoid unportable 'sed -i'
The sed(1) implementations at least on Solaris and the BSD familiy OSes do
not support the -i flag, and latest POSIX 2024 still does not specify it.

* tests/find/user-group-max.sh: Avoid 'sed -i' by redirecting to
another file ERR2.
2026-01-06 10:34:37 +01:00
Bernhard Voelker
ebea22e88b tests: make new -mount test more robust
This test failed on non-Linux systems:
- On Solaris 11, the output of the native df(1) tool has a different order,
  and hence the detection of a usable mount point for the test fails.
  Verify that df(1) is from GNU coreutils, or fall back to 'gdf',
  else skip the test.
- On a FreeBSD system where /home was a symlink to /usr/home, the code
  for finding a usable mount point failed, because the symlink itself
  is on the '/' file system.
  Ensure that the found mount point is identical to the original test
  directory like /home etc.

* tests/find/mount-vs-xdev.sh: Try harder to use a GNU df(1) tool.
Check whether the found mount point is identical to the original
directory name, thus avoiding symlinks.
2026-01-06 10:33:59 +01:00
Bernhard Voelker
3c2af8a185 doc: avoid man-lint errors due to deprecated .HP macro
The .HP macro introduced only recently triggers a 'make check' errors:

   env GROFF=groff ../build-aux/man-lint.sh . find.1
   check_manpages_format_without_error_messages  (         find.1): OK
   check_manpages_with_groff_checkstyle_2        (         find.1): FAILED
   an.tmac:./find.1:23: style: use of deprecated macro: .HP
   make[3]: *** [Makefile:3112: findutils-check-manpages] Error 1

and

   env GROFF=groff ../build-aux/man-lint.sh . locate.1 updatedb.1 locatedb.5
   check_manpages_format_without_error_messages  (       locate.1): OK
   check_manpages_format_without_error_messages  (     updatedb.1): OK
   check_manpages_format_without_error_messages  (     locatedb.5): OK
   check_manpages_with_groff_checkstyle_2        (       locate.1): FAILED
   an.tmac:./locate.1:18: style: use of deprecated macro: .HP
   make[3]: *** [Makefile:3287: findutils-check-manpages] Error 1
   make[3]: Target 'check-local' not remade because of errors.

The HP hanging paragraph would work nicely, but is marked as deprecated
in groff-1.23; the deprecations warning will disappear in groff-1.24.
Until then, use .TP instead to avoid the check errors.

* find/find.1: Change '.HP' to the '.TP' tagged paragraph macro.
Add a FIXME for 2027 to switch to .HP when groff-1.24 is more commonly
available.
* locate/locate.1: Likewise.
2026-01-05 16:52:58 +01:00
G. Branden Robinson
09a4602970 xargs.1: revise option formatting
* xargs/xargs.1:

- Migrate from comma-separated to "stacked tag" formatting for command
  options.  This is easier to read and understand when option syntax is
  complex, and eliminates the problem of the comma being misinterpreted.
  Setting the comma in bold, not roman, might have increased this risk.

  Stacking tags--without direct recourse to formatter requests--however
  requires the use of a groff man(7) extension macro, `TQ` (from groff
  1.20, 2009).  Because this page needs to be portable to non-groff
  formatters, define a page-local version after testing for its
  nonexistence using other GNU troff extensions (the `do` request and
  the `d` conditional expression operator).  (Actually, the method here
  is to test for `TQ`'s existence and then ignore the macro definition
  if the test succeeds; the token `..` terminates whichever eventuates.)

- Use the `TQ` macro to stack paragraph tags presenting synonymous
  options to xargs(1).

- Use the page-local `~~` string to put unbreakable spaces (where
  supported) between short options and their arguments.  (On the other
  hand, if a paragraph tag breaks across lines, the document likely
  requires revision.)

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
b698bc19a1 xargs.1: fix markup nit
* xargs/xargs.1: Consistently use empty request before paragraphing macros
to aid document maintainers.  This was already done, inconsistently.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
a86cd78912 xargs.1: fix markup nit
groff_man(7):
   History
     M. Douglas McIlroy ⟨m.douglas.mcilroy@dartmouth.edu⟩ designed,
     implemented, and documented the AT&T man macros for Unix Version 7
     (1979) and employed them to edit Volume 1 of its Programmer’s
     Manual, a compilation of all man pages supplied by the system.  The
     package supported the macros listed in this page not described as
     extensions, except P and the deprecated AT and UC.  It documented
     no registers and defined only R and S strings.

     UC appeared in 3BSD (1980).  Unix System III (1980) introduced P
     and exposed the registers IN and LL, which had been internal to
     Seventh Edition Unix man.  PWB/Unix 2.0 (1980) added the Tm string.
     4BSD (1980) added lq and rq strings.  SunOS 2.0 (1985) recognized
     C, D, P, and X registers.  4.3BSD (1986) added AT and P.  Ninth
     Edition Unix (1986) introduced EX and EE.  SunOS 4.0 (1988) added
     SB.  Unix System V (1988) incorporated BSD’s lq and rq strings.

     Except for EX/EE, James Clark implemented the foregoing features in
     early versions of groff.  Later, groff 1.20 (2009) resurrected
     EX/EE and originated SY/YS, TQ, MT/ME, and UR/UE.  Plan 9 from User
     Space’s troff introduced MR in 2020.

* xargs/xargs.1: Favor `P` macro, which the page predominantly uses, over
`PP` (`LP` is not observed).  `P` has been universally portable since 1986.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
8d74646de9 xargs.1: fix markup nit
* xargs/xargs.1:
Drop unnecessary quotes around single-word macro arguments.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
214285e6f2 xargs.1: fix unescaped hyphens
* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
341ba019f4 xargs.1: clarify --max-args value "1" better
* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
289eaa25dc xargs.1: hyphenate attributive phrase
* xargs/xargs.1 (OPTIONS): Use hyphen in "POSIX-compliant".

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
ab387c1cdc xargs.1: fix font markup nit
* xargs/xargs.1:
Favor man(7) font macros over *roff font selection escape sequences.
Macros are (a) visually less cluttered, (b) interfere less with spell
checking, and (c), in groff man(7), automatically apply italic
corrections, which otherwise requires explicit use of GNU troff
extension escape sequences (`\/` and `\,`).

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
2b9f253b15 xargs.1: use ellipses in synopsis
...rather than pluralization.

* xargs/xargs.1 (SYNOPSIS): Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
c5dfe4c378 xargs.1: set file names in italics
...not roman.

groff_man_style(7):
   Font style macros
...
     .I [text]
            Set text in an italic or oblique face.  Given no argument, I
            plants a one‐line input trap; text on the next line, which
            can be further formatted with a macro, is set in an italic
            or oblique face.

            Use italics for file and path names, for environment
            variables, for C data types, for enumeration or preprocessor
            constants in C, for variant (user‐replaceable) portions of
            syntax synopses, for the first occurrence (only) of a
            technical concept being introduced, for names of journals
            and of literary works longer than an article, and anywhere a
            parameter requiring replacement by the user is encountered.
            An exception involves variant text in a context already
            typeset in italics, such as file or path names with
            replaceable components; in such cases, follow the convention
            of mathematical typography: set the file or path name in
            italics as usual but use roman for the variant part (see IR
            and RI below), and italics again in running roman text when
            referring to the variant material.

* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
6d695cc480 xargs.1: use quotation marks
* xargs/xargs.1: Also set the braces in `-I{}` in bold, not roman,
since they are literal.

The `lq` and `rq` strings are widely portable.

groff_man_style(7):
   Strings
     \*(lq
     \*(rq   interpolate special character escape sequences for left and
             right double‐quotation marks, \(lq and \(rq, respectively.
...
     A contemporary man page needs none of the above.  \*S is
     superfluous; type size changes are invisible on terminals, and
     macros that change it restore its original value afterward.  Better
     alternatives exist for the rest; simply use the \[rg], \[lq],
     \[rq], and \[tm] special character escape sequences directly.
     Unless you are aiming for a pathological level of portability——
     perhaps composing a man page for consumption on simulators of 1980s
     Unix systems (or Solaris 10 troff, though even it supports
     “\(rg”)——avoid using the above strings.
...
Notes
     Some tips on composing and troubleshooting your man pages follow.
...
     • When and how should I use quotation marks?

       As noted above in subsection “Font style macros”, apply quotation
       marks to “brief specimens of literal text, such as article
       titles, inline examples, mentions of individual characters or
       short strings, and (sub)section headings in man pages”.  Multi‐
       word literals, such as Unix commands with arguments, when set
       inline (as opposed to displayed between EX and EE), should be
       quoted to ensure that the boundaries of the literal are clear
       even when the material is stripped of font styling by, for
       example, copy‐and‐paste operations.  groff, Heirloom Doctools
       troff, neatroff, and mandoc support all of the special characters
       \[oq], \[cq], \[lq], \[rq], \[aq], and \[dq] described in
       subsection “Portability” above.  DWB, Plan 9, and Solaris 10
       troffs do not.  Interpolating the strings \*(lq and \*(rq
       portably yields directional double quotation marks, if available,
       in all these formatters (though neatroff does not supply a man
       macro package), but they cannot reliably be used in macro
       arguments.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
34142ca063 xargs.1: set "findutils" in italics
...not roman.

* xargs/xargs.1 (STANDARDS CONFORMANCE): Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
4055cf7bbc xargs.1: fix truncated examples on old troff
Seventh Edition Unix man(7)[1] and its descendants handle at most six
arguments to macros.  Excess arguments are ignored and not formatted.

[1] https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/lib/tmac/tmac.an

* xargs/xargs.1 (EXAMPLES): Add quotes.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
5c31ac2aeb xargs.1: add styling to text
...for consistency with existing practice in findutils man pages.

* xargs/xargs.1: Set "find" (the command) and "-print0" in bold, not roman.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
4e562ab11f xargs.1: access ' character portably
* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
cd4977172c xargs.1: overcome limited portability of \~
Warnings from `groff -C -ww -man` in the forthcoming groff 1.24:
troff:xargs/xargs.1:295: warning: an escaped '~' is not portable to AT&T troff
troff:xargs/xargs.1:296: warning: an escaped '~' is not portable to AT&T troff
troff:xargs/xargs.1:296: warning: an escaped '~' is not portable to AT&T troff
troff:xargs/xargs.1:298: warning: an escaped '~' is not portable to AT&T troff

groff_man_style(1):
   Portability
...
     \~        Adjustable non‐breaking space.  Use this escape sequence
               to prevent a break inside a short phrase or between a
               numerical quantity and its corresponding unit(s).

                      Before starting the motor,
                      set the output speed to\~1.
                      There are 1,024\~bytes in 1\~KiB.
                      CSTR\~#8 documents the B\~language.

               \~ is a GNU extension also supported by Heirloom Doctools
               troff 050915 (September 2005), mandoc 1.9.14
               (2009‐11‐16), neatroff (commit 1c6ab0f6e, 2016‐09‐13),
               and Plan 9 from User Space troff (commit 93f8143600,
               2022‐08‐12), but not by DWB or Solaris 10 troffs.

* xargs/xargs.1:
Define a string to indirect use of `\~` escape sequence.  On formatters
that don't support groff extensions, use the AT&T troff `\ `
(backslash-space) escape sequence, which isn't quite as good because it
is a space that is not only unbreakable, but unadjustable--which,
however, doesn't matter when formatting man pages with adjustment
disabled, as some implementations do (and which groff makes
configurable).

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
5a000f9a50 locate.1: access ^ character portably
The `\(ha` special character escape sequence is not universally
portable.  Indirect it through a string definition.  (GNU Bash also uses
this technique.[1])

* locate/locate.1: Do the above.

[1] a8a1c2fac0/doc/bash.1 (L26)

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
a64197a3d8 locatedb.5: fix unescaped hyphens
These instances represent hyphen-minus characters, so should be spelled
in man(7) source as `\-`.

* locate/locatedb.5: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
236a3c8647 xargs.1: use portable typographer's quotes
* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
755d9fbf38 find.1: set file name literals in italics
...not roman, and protect them from hyphenation.

GNU troff, Heirloom Doctools troff, and mandoc all support use of the
`\%` hyphenation control escape sequence at the _beginning_ of a word
suppress its hyphenation.  Other troffs do not.  Indirect this
application of the escape sequence through a string, interpolating
nothing on formatters that don't advertise GNU compatibility via the
`.g` register.  (This means that literals can hyphenate undesirably on
DWB, Solaris, and Plan 9 troffs.)

GNU troff, Heirloom Doctools troff, and mandoc all also support the GNU
`\:` extension to mark break points that should not produce hyphens.
Apply the same technique to avoid undesired formatting of a ':'
character on DWB, Solaris, and Plan 9 troffs.

* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
30f820abf7 find.1: access “ and ” portably
The `\(lq` and `\(rq` and special character escape sequences are not
universally portable.

Traditionally, AT&T troff did not bother to identify these special
characters at all; it was apparently felt that adjacently setting
directional single quotes sufficed.  You can discern this fact in
materials typeset by AT&T troff by observing what one might call
generous kerning of these glyphs when used as "double" quotes.

However, someone at the Berkeley CSRG had a brainwave, and for 4BSD in
1980, added strings named `lq` and `rq` to the man(7) package so that
man pages could access double quotes by whatever means the underlying
implementation had for realizing them.  This excellent idea made it into
Unix System V (1988/9), so that every surviving troff implementation
known to me, including DWB and Solaris 10, supports them--save one.  The
exception is Plan 9.  Fortunately, the Plan 9 from User Space
("plan9port") project accepted a patch from me on 10 October to add
support there as well.[1]

Like the \*" string, \*(lq and \*(rq should not be used in quoted macro
arguments if one desires portability to AT&T troff-descended formatters
(other than Heirloom Doctools troff); if the implementation defines
these strings such that their interpolations contain `"`, undesired
output is the likely result.

[1] https://github.com/9fans/plan9port/pull/735

* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
897264c8e8 find.1: use new ~ string for pastable tilde
* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
c4f03874ac find.1: access ~ character portably
* find/find.1:
The `\(ti` special character escape sequence is not universally
portable.  Indirect it through a string definition.  (GNU Bash also uses
this technique.[1])

[1] a8a1c2fac0/doc/bash.1 (L26)

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
bbce846161 find.1: improve cosmetics of *roff logic
* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
2923a0d78f doc: access en dash character portably
The `\(en` special character escape sequence is not universally
portable.  Indirect it through a string definition.

* find/find.1:
* locate/locate.1:
* locate/locatedb.5:
* locate/updatedb.1:
* xargs/xargs.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
7cb135d5fb find.1: use em dash for linguistic pausa
An em dash is the more orthographically correct dash for a couple of
contexts where the page had been using an en dash (which denotes a
range), and its special character escape sequence is universally
portable to boot.

* find/find.1: \Replace "(en" by "\(em".

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
f0e2bbe45b find.1: set quotation marks as such in roman
* find/find.1: ...not bold.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
e0d0dab353 find.1: access ` character portably
When using ` as the Unix shell's command output substitution operator,
use the portable *roff `\(ga` special character escape sequence to
ensure that we really format a grave accent rather than a typographer's
single quotation mark (‘).

* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
a81c9c431d find.1: access ' character portably
The `\(aq` special character escape sequence is not universally
portable.  Indirect it through a string definition.  (GNU Bash also uses
this technique.[1])

[1] a8a1c2fac0/doc/bash.1 (L26)

* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
ba94c5423e find.1: access " character somewhat portably
The `\(dq` special character escape sequence is not universally
portable.  Indirect it through a string definition.  (GNU Bash also uses
this technique.[1])

Unfortunately, `"` is one of the worst-behaved and least-accessible
characters in AT&T troff; a pleasant Dr. Jekyll when used on text lines,
its Mr. Hyde persona erupts when used in macro calls, and is wholly
unpredictable to non-experts when appearing in request arguments.[2]
_Some_ AT&T troffs offer `\(dq` on _some_ output devices.  AT&T troff
also has no mechanism for a document to define its own special character
escape sequences.  GNU troff offers `\(dq` on all output devices.

[1] a8a1c2fac0/doc/bash.1 (L26)

[2] "For the (neutral) double quote, you have recourse to an obscure
    syntactical feature of AT&T troff.  Because a double quote can begin
    a macro argument, the formatter keeps track of whether the current
    argument was started thus, and doesn’t require a space after the
    double quote that ends it.  In the argument list to a macro, a
    double quote that isn’t preceded by a space doesn’t start a macro
    argument.  If not preceded by a double quote that began an argument,
    this double quote becomes part of the argument.  Furthermore, within
    a quoted argument, a pair of adjacent double quotes becomes a
    literal double quote."

    https://www.gnu.org/software/groff/manual/groff.html.node/Calling-Macros.html

* find/find.1: Do the above.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
700e8cae79 find.1: improve table formatting
* find/find.1:
- Use paragraphing macros to put vertical space above and below the
  tables (where not already present) so that they looks more like
  typographical "displays".[1]
- Simplify "XY" table definition (see groff's tbl(1) man page).  This
  simpler definition has the same result (and is more adaptable in the
  event the text of the table is revised).
- Put horizontal rule below column headings in table that uses them.
- Use thin space escape sequences `\|` between the dots of an ellipsis;
  the effect is visible only on typesetting devices.[2]  I left the
  dummy character escape sequence `\&` trailing it intact, but observe
  for the edification of nit-pickers that it has no effect in this
  context.[3]

[1] man(7) implementations are historically inconsistent with respect to
    whether a `TS` macro call should put any vertical space on the
    output, and compositional practices on the part of man page authors
    have thus been, to quote Ingo Schwarze, "wildly inconsistent".

    https://savannah.gnu.org/bugs/?62841

[2] groff_man_style(7):

       Examples of ellipsis usage are shown above, in subsection
       “Synopsis macros”.  The idiomatic roff ellipsis is three dots
       (periods) with thin space escape sequences \| internally
       separating them.

[3] tbl(1):

     Ordinarily, a table entry is typeset rigidly.  It is not filled,
     broken, hyphenated, adjusted, or populated with supplemental inter‐
     sentence space.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
1520e3d307 find.1: quote multi-word SH, SS call arguments
The man(7) macro package from AT&T troff and most of its descendants,
including those in DWB, Plan 9, and Solaris troffs, support at most six
arguments to any macro call.

* find/find.1: Quote all multi-word arguments to these macros, not just those
in excess of six arguments, as a reminder of defensive practice to document
maintainers.

Before and after on Plan 9 from User Space troff:

  $ diff -b -U0 find-plan9port-[12].txt
  --- find-plan9port-1.txt        2025-11-18 20:20:08.388887375 -0600
  +++ find-plan9port-2.txt        2025-11-18 20:20:14.712881949 -0600
  @@ -2068 +2068 @@
  -       Safer `find -print0 | xargs -0`
  +       Safer `find -print0 | xargs -0` approach
  @@ -2129 +2129,2 @@
  -       Traversing the filesystem just once en
  +       Traversing the filesystem just once en for 2 different actions

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
10235e591a locate.1: improve table formatting
* locate/locate.1 (HISTORY):
- Use paragraphing macro to put vertical space above the table so that
  it looks more like a typographical "display".[1]
- Set table cells that overset the line on AT&T nroff (where the line
  length is 65n) using text blocks.
- Issue `na` request in these text blocks to prevent the cell contents
  from adjusting in the event the formatter/package/user has configured
  man pages to employ adjustment by default.  (Practices vary; it's a
  long story.[2])
- Remove spaces around the configured tbl(1) tab character of `|`.  This
  certainly does make the table uglier in source form.  Unfortunately,
  AT&T tbl(1) takes those spaces deadly seriously and they impact the
  computed cell (and therefore column) widths.  GNU tbl has for decades
  supported a "nospaces" region option to address precisely this
  problem; unfortunately it is not portable to DWB 3.3, Plan 9, or
  Solaris 10 troffs, and I suspect not to _any_ surviving System V
  troff.

Fixes warning from tbl(1) in groff 1.23.0:

locate/locate.1:289: warning: table wider than line length minus indentation

[1] man(7) implementations are historically inconsistent with respect to
    whether a `TS` macro call should put any vertical space on the
    output, and compositional practices on the part of man page authors
    have thus been, to quote Ingo Schwarze, "wildly inconsistent".

    https://savannah.gnu.org/bugs/?62841

[2] "Some people do hate adjustment of nroff output, though, which is
    why I added a feature to groff man(7) to support disabling it.

    The history of this practice is inconsistent.  Seventh Edition Unix
    (1979) disabled adjustment of man pages when rendering in nroff
    mode,[3] and BSD retained that disablement until death.  SunOS
    commented it as early as SunOS 2.0 (1985), thus restoring adjustment
    in nroff mode, and retained that all the way through Solaris 10
    (2005).  When James Clark wrote groff starting in about 1989, his
    man(7) implementation closely emulated SunOS.  With the Solaris 11
    release in 2010, Oracle discarded its AT&T-descended troff in favor
    of the then-current groff release.  [That's not quite true--see
    below.]  They're still on groff 1.22.2 (2013) today, and so they've
    been adjusting their man pages in nroff mode for at least 40 years,
    as has groff for about 35[].  I don't know what other System V
    Unices did."

    https://lists.gnu.org/archive/html/groff/2025-05/msg00001.html

    (I made an incorrect claim in the foregoing; Solaris 11 still has
    its AT&T troff around, but its man page rendering is now performed
    by [an old version of] groff.)

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
c2b67c7c92 doc: improve formatting of command synopses (2/2)
* find/find.1:
* locate/locate.1: Use unbreakable spaces between options and their
  arguments, potentially improving legibility.

The existing synopses are short enough that they don't break in such a
way as to promote confusion even on old-fashioned AT&T troffs that use a
line length of 65n in nroff mode (vs. groff man(7)'s historical 78n and
present-day 80n).  Thus this change merely makes the synopses robust to
future changes.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
d9cef9e7da doc: improve formatting of command synopses (1/2)
* find/find.1:
* locate/locate.1: Use `HP` hanging paragraph macro to indent
  non-initial lines of synopsis.  Temporarily disable adjustment.

An alternative approach would be to use groff man(7)'s `SY` and `YS`
extension macros; each man page would then need to define local versions
for portability to DWB 3.3, Plan 9, and Solaris 10 troffs.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
3d398b07cd doc: improve typography of synopses
* find/find.1:
* locate/locate.1: Place thin space escape sequences between ellipsis
  dots for more pleasant output when typesetting.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
7e8712f0ca doc: use man(7) macros to style command synopses
* find/find.1:
* locate/locate.1:
* locate/updatedb.1:
* xargs/xargs.1: Favor man(7) font alternation macros over *roff font
  escape sequences.  When typesetting with groff(1), the macros
  automatically apply italic corrections.

* locate/locate.1: Protect long option name literals from hyphenation.
  GNU troff, Heirloom Doctools troff, and mandoc all support use of the
  `\%` hyphenation control escape sequence at the _beginning_ of a word
  suppress its hyphenation.  Other troffs do not.  Indirect this
  application of the escape sequence through a string, interpolating
  nothing on formatters that don't advertise GNU compatibility via the
  `.g` register.  (This means that literals can hyphenate undesirably on
  DWB, Solaris, and Plan 9 troffs.)

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
fe5b98b247 find.1: use AT&T troff-compatible syntax
Before and after, using DWB 3.3 troff (Plan 9 and Solaris 10 troffs are
similar):

  $ diff -U0 find.1.dwb-[12].txt|head -n 19
  --- find.1.dwb-1.txt    2025-10-13 10:09:17.024054824 -0500
  +++ find.1.dwb-2.txt    2025-10-13 10:09:24.764012282 -0500
  @@ -2039 +2039 @@
  -            [bu]
  +            o   Find files named core in or below the directory /tmp and
  @@ -2054 +2053,0 @@
  -                Find files named core in or below the directory /tmp and
  @@ -2064,2 +2063 @@
  -            [bu]
  -                Find files named core in or below the directory /tmp and
  +            o   Find files named core in or below the directory /tmp and
  @@ -2080,2 +2078 @@
  -            [bu]
  -                Given that another program proggy pre-filters and cre-
  +            o   Given that another program proggy pre-filters and cre-
  @@ -2097,2 +2094 @@
  -            [bu]
  -                Run file on every file in or below the current direc-
  +            o   Run file on every file in or below the current direc-

Further changes in the diff appear because the document now paginates
differently with these troffs.  That's because a one-en-wide mark 'o'
(the ASCII representation of a bullet) fits within the 4n space allotted
by the document's `IP` calls, whereas "[bu]" does not.

Fixes warnings from "nroff -C -ww -man" in the forthcoming groff 1.24:
troff:./find/find.1:2260: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2277: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2305: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2326: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2349: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2372: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2392: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2402: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2415: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2431: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2442: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2459: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2471: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2498: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2542: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2597: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2618: warning: an escaped '[' is not portable to AT&T troff
troff:./find/find.1:2630: warning: an escaped '[' is not portable to AT&T troff

* find/find.1: Replace '\[bu]' by '\(bu'.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:58 +01:00
G. Branden Robinson
ad7e34650a doc: delete blank lines from man page sources
* find/find.1:
* xargs/xargs.1: Replace blank lines with empty requests or paragraphing
  macro calls as seems to be intended.
* find/find.1: Delete blank lines preceding paragraphing or sectioning
  macros that serve only to put excess vertical space in the output.
* locate/locatedb.5: Replace blank lines with a dummy character
  producing a blank output line as _might_ be intended.

groff_man_style(7):
     ?  The empty request (.), which does nothing, vertically spaces the
        input file for readability by the document maintainer.  Do not
        put blank (empty) lines in a man page source document.  Some
        man(1) programs ?squeeze? multiple blank output lines into one.

Fixes style warnings from `groff -rCHECKSTYLE=3 -man`:
an.tmac:/.../share/man/man1/find.1:87: style: blank line in input
...
an.tmac:/.../share/man/man1/xargs.1:231: style: blank line in input
...
an.tmac:/.../share/man/man5/locatedb.5:118: style: blank line in input
...

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-05 16:52:37 +01:00
G. Branden Robinson
d1edc59b19 find.1: fix typo in *roff syntax
Style warning from `groff -rCHECKSTYLE=3 -man`:
an.tmac:/.../share/man/man1/find.1:9: style: 1 leading space(s) on input line

* find/find.1 (SYNOPSIS): Make an intended empty request work that way.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-02 22:48:58 +01:00
G. Branden Robinson
627072f022 doc: populate man pages' headers and footers more
Style warnings from `groff -rCHECKSTYLE=3 -man`.
an.tmac:/.../share/man/man1/locate.1:1: style: .TH missing third argument; \
  consider document modification date in ISO 8601 format (YYYY-MM-DD)
an.tmac:/.../share/man/man1/locate.1:1: style: .TH missing fourth argument; \
  consider package/project name and version (e.g., "groff 1.23.0")
...and similar.

groff_man_style(7):
     .TH identifier section [footer‐middle [footer‐inside [header‐
     middle]]]
...
            By convention, footer‐middle is the date of the most recent
            modification to the man page source document, and footer‐
            inside is the name and version or release of the project
            providing it.

* find/find.1:
* locate/locate.1:
* locate/locatedb.5:
* locate/updatedb.1:
* xargs/xargs.1: Add appropriate third and fourth arguments to `TH` macro calls.

To determine the revision date to include in the page, I used the Git
"AuthorDate" of the last commit consituting anything but a "bump" to the
copyright notice.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-02 22:48:58 +01:00
G. Branden Robinson
2749632838 find.1: drop unportable tbl(1) 'x' modifier
Plan 9 and Solaris tbl, like Seventh Edition Unix tbl, do not support
the 'x' column modifier.  This extension appeared in DWB tbl by version
3.3 and early in GNU troff development (both circa 1990).  I suspect,
but do not know, that other System V Unix tbl programs don't support it
either.

These old tbl programs are brutal when they encounter an unsupported
column modifier--they abort the preprocessor altogether ("tbl quits")
without attempting recovery.[1]  Because tbl works as a filter, like
eqn, pic, soelim, or more familiar Unix tools (cat, sed, nl), this means
that tbl truncated the entire remainder of the input at that point.  GNU
tbl is more robust, and discards input only until the next `.TE` token.

Due to this rudeness it's impossible to portably use 'x' without
rewriting the page text, and I know of no good way to parameterize a
table format.  (tbl(1) doesn't have variables or anything like a macro
preprocessor.  *roff strings are no use because tbl is a _pre_processor
for troff.)

To portably use 'x' requires a man page to test the underlying
implementation and potentially rewrite the page prior to installing it.

See a recent patch of mine to ncurses (merged in its 20251115 release)
for an approach potentially adaptable to findutils.

https://lists.gnu.org/archive/html/bug-ncurses/2025-11/msg00035.html

[1] I've proposed a merge request to Plan 9 from User Space to make its
    tbl less intolerant.  Even if accepted, that won't help anyone who
    uses other "legacy" troffs.

    https://github.com/9fans/plan9port/pull/739

* find/find.1 (Functional Changes): Drop 'x' table modifier.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-11/msg00094.html

Copyright-paperwork-exempt: Yes
2026-01-02 22:48:58 +01:00
Bernhard Voelker
04738593b4 find: add more -mount tests (check-root)
Add some more tests exercising bind mounts on the same device which
should not be affected by -mount or -xdev, and tests with a loopback
file system and a bind mount from there.

* tests/find/mount-vs-xdev-bind.sh: Add test.
* tests/find/mount-vs-xdev-other-fs.sh: Likewise.
* tests/local.mk (all_root_tests): Reference them.
2026-01-02 22:36:44 +01:00
Bernhard Voelker
0d8de87299 find: add -mount tests
* tests/find/mount-vs-xdev.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
2026-01-02 22:36:42 +01:00
Bernhard Voelker
6da3a73f73 NEWS: enhance description about the -mount change
* NEWS (Changes in find): Clarify better what is the difference between
the -mount and -xdev options including an example.  Also move the
topic to the top of the section due to its importance.
2026-01-02 22:35:49 +01:00
Lukáš Zaoral
cd8568758a find: make -mount POSIX 2024 compliant
* find/defs.h (struct options): Add mount member and rename
stay_on_filesystem to xdev.
* find/ftsfind.c (find): Set FTS_MOUNT flag when -mount is enabled.
* find/parser.c (parse_table): Use a separate parser for -mount.
(parse_mount): Declare and define function.
(parse_xdev): Use xdev option flag.
* find/util.c (set_option_defaults): Initialize new struct members.
* doc/find.texi (node Filesystems): Add new section describing the new
behaviour of -mount and specify the current behaviour of -xdev.
* find/find.1: Document the new -mount behaviour and specify current
behaviour of -xdev.
* NEWS (Changes in find): Mention the -mount behaviour change.
2026-01-02 11:48:31 +01:00
Bernhard Voelker
733bb9a054 maint: update copyright year number ranges
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.
2026-01-02 11:46:15 +01:00
Bernhard Voelker
e69e78fb1d maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 135 commits on gnulib
since the last update.
This is mainly for the following change making sc_copyright_check pass
again, but there are also other useful fixes and improvements:
  > maint: run 'make update-copyright'

* gnulib: Update to latest.
* autogen.sh: Likewise.
* autopull.sh: Likewise.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
2026-01-02 11:45:58 +01:00
James Youngman
580be65e25 [find] Format findutils changes as reverse-time-ordered tables.
* find/find.1 (COMPATIBILITY): Add release-year information to the
feature addition table.  Format the functional changes as a table,
too.
2025-11-18 09:49:21 +00:00
James Youngman
99cfb6cf42 [maint] Stricter manpage checks.
From a suggestion by G. Branden Robinson to use `groff -t -z -ww
-rCHECKSTYLE=2 -man`, by pointing to and example in
https://lists.gnu.org/archive/html/bug-findutils/2025-11/msg00004.html.

* configure.ac: discover the location of the groff binary.
* build-aux/man-lint.sh: also run groff with -rCHECKSTYLE=2.   Use
  groff at the path discovered during configuration.
* find/Makefile.am: Lint-check manpages during "make check",
  not "make dist". Set the environment variable GROFF to the
  location of the groff binary.
* locate/Makefile.am: Likewise.
* xargs/Makefile.am: Likewise.
2025-11-17 10:08:13 +00:00
James Youngman
c9a2aaa354 [find] Fix a lint problem in the find manual page.
Without this fix, we get this error from `groff -C -t -z -ww
-rCHECKSTYLE=2 -man find/find.1`:

troff: find/find.1:2255: warning: macro '."' not defined
troff: find/find.1:2255: warning: number register '[' not defined

* find/find.1: revert a change which caused a lint warning from
  troff.
2025-11-17 10:08:13 +00:00
James Youngman
8821923b49 [find] Use ASCII apostrophe in find.1 (instead of U+2019).
* find/find.1: Use ASCII apostrophe U+0027 instead of U+2019.
2025-11-17 10:08:13 +00:00
Bernhard Voelker
7156420fab maint: switch from gnulib ctype to ctype-h module
Prompted by the following bootstrap notice:
  Notice from module ctype:
    This module is deprecated. Use the module 'ctype-h' instead.

* bootstrap.conf (gnulib_modules): ctype -> ctype-h
2025-11-15 19:44:18 +01:00
Bernhard Voelker
bccc4f8a28 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 450 commits on gnulib
since the last update.

This pulls in the new FTS_MOUNT flag needed for the upcoming changes
to -mount vs. -xdev mandated by POSIX Issue 8 (IEEE Std 1003.1-2024),
thanks to Lukáš Zaoral <lzaoral@redhat.com>:
> fts: Introduce the FTS_MOUNT flag.

* gnulib: Update to latest.
* bootstrap-funclib.sh: Likewise.
2025-11-15 19:44:13 +01:00
Bernhard Voelker
c78d103e81 parser.c: simplify parse_table
Avoid macro preprocessing when filling the parse_table for better
readability.

* find/parser.c (PASTE, PARSE_OPTION, PARSE_POSOPT, PARSE_TEST,
PARSE_TEST_NP, PARSE_ACTION, PARSE_PUNCTUATION): Remove macros.
(parse_table): Replace macro-based filling with regular structure entries.
Group entries by types: regular options, positional options, punctuation,
tests and actions; loosely sort within each group.
Remove duplicate "atime" entry introduced in commit 7102a229fa.
While at it, change -help and -version from ARG_TEST to ARG_OPTION.
2025-11-15 19:43:35 +01:00
Bernhard Voelker
aa292af4c1 maint: help translators to disambiguate -0 as --null, not option "o"
As reported in <https://savannah.gnu.org/bugs/?67432>, it is easy to
confuse -0 with -O.  Give a hint to translators.

* xargs/xargs.c (main): Add TRANSLATORS hints.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
9e505ec52f maint: add entry to .gitignore file
* po/.gitignore (/insert-header.sed): Add.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
93ce19f0d5 maint: prefer C23-style nullptr
* 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.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
499e792fc0 maint: do not produce DVI-format manual anymore
The GNU standards don't require DVI-format documentation anymore:
https://lists.gnu.org/archive/html/bug-standards/2025-07/msg00011.html

* build-aux/update-online-manual.sh: Remove DVI format.
* doc/.gitignore: Remove ignore entries for DVI files.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
deb3f7066d maint: use consistent references to standard files in messages
Use standard input instead of stdin, standard output instead of stdout,
and standard error instead of stderr in messages and documentation.
Inspired by coreutils commit:
https://cgit.git.sv.gnu.org/cgit/coreutils.git/commit/?id=c9a30d6781

* cfg.mk (sc_standard_outputs): Add syntax-check rule.
* doc/find.texi: Do the above.
* find/find.1: Likewise.
* locate/locate.1: Likewise.
* locate/locate.c: Likewise.
* xargs/xargs.1: Likewise.
* xargs/xargs.c: Likewise.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
c41a617953 doc: clarify that POSIX Issue 8 is "IEEE Std 1003.1-2024"
* doc/find.texi: Do the above in various places.
* find/find.1:  Likewise.
* xargs/xargs.1: Likewise.
2025-11-15 19:39:43 +01:00
Bernhard Voelker
56a376a26d doc: state that POSIX from Issue 8 specifies 'find -iname'
* doc/find.texi (-iname): Document POSIX compliance.
* find/find.1 (COMPATIBILITY): Mark POSIX compliance of -iname.
2025-11-15 19:39:43 +01:00
Collin Funk
c18bba5c59 maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* NEWS: Fix typos.
* README-hacking: Likewise.
* doc/find-maint.texi: Likewise.
* doc/find.texi: Likewise.
* bootstrap.conf: Fix typos in comments.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/print.c: Likewise.
* find/testsuite/find.gnu/exec-one-rtn-fail.exp: Likewise.
* find/testsuite/find.posix/bracket-depth.exp: Likewise.
* find/testsuite/find.posix/exec-nogaps.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/util.c: Likewise.
* init.cfg: Likewise.
* lib/regextype.h: Likewise.
* lib/splitstring.h: Likewise.
* locate/locate.c: Likewise.
* locate/updatedb.sh: Likewise.
* tests/find/exec-plus-last-file.sh: Likewise.
* tests/find/files0-from.sh: Likewise.
* tests/xargs/test-sigusr.c: Likewise.
* tests/xargs/verbose-quote.sh: Likewise.
* xargs/xargs.c: Likewise.
2025-11-15 19:39:02 +01:00
James Youngman
0cac25f6e7 doc: minor shell coding improvements in examples.
- Use -type f so that the timestamp of `subdir` is not relevant.
- Use LC_ALL=C with sort, tail, cut (as file names are not text).
- Use "$(...)" instead of just $(...).

Also mention that Issue 8 of the POSIX standard has been published
now.
2025-10-15 05:55:05 +01:00
James Youngman
cabfc3b184 find: point out that -newer is false when timestamps are equal. 2025-10-15 05:55:05 +01:00
Bernhard Voelker
74d25ac58d find: document -newerXY in --help output
* find/util.c (usage): Add above find(1) option, and briefly explain
that XY stands for the combination [aBcm][aBcmt].
2025-10-13 22:15:09 +02:00
Bernhard Voelker
1c39dc6055 find: fix minor typo in --help output
* find/util.c (usage): Terminate sentence about -D with a dot.
(show_valid_debug_options): While at it, add indentation for -D values.
2025-10-13 22:12:01 +02:00
danny mcClanahan
fbbda507c6 doc: fix typo in symbolics links node
* doc/find.texi (node Symbolic Links): s/directoires/directories/
* find/testsuite/find.gnu/execdir-hier.exp: Likewise here in a comment.

Copyright-paperwork-exempt: Yes
2025-08-24 14:19:50 +02:00
Bernhard Voelker
facc27e180 doc: regenerate regexprops.texi
* doc/regexprops.texi: Regenerate due to recent changes in gnulib regex.h
to align with current Emacs behavior (gnulib commit efd5c380ff), and also
due to the change of the node sort order in regextype.c in the previous
commit.

Reported by Collin Funk in
  https://lists.gnu.org/r/bug-gnulib/2025-07/msg00037.html
2025-07-09 20:53:21 +02:00
Bernhard Voelker
c9c2c51175 regexprops: sort regex_map alphabetically
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.
2025-07-09 20:49:51 +02:00
Bernhard Voelker
c7f5ff1ed8 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 645 commits on gnulib
since the last update.

* gnulib: Update to latest.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
2025-07-09 08:55:51 +02:00
Bernhard Voelker
acd4564eda doc: reference -newer for -anewer,-cnewer in find.1
* find/find.1 (-anewer): Reference the similarity to -newer.
(-cnewer): Likewise.

Discussed at:
  https://sv.gnu.org/bugs/?67220
2025-07-01 19:38:20 +02:00
raf
1ef8d7c2cf doc: supplement list of actions that suppress default -print
* find/find.1 (EXPRESSION): Add missing -print0 and -fprint0 to
the list of actions that suppress the default -print action.
Sort items.
* doc/find.texi (find Expressions): Likewise.
* NEWS: Mention the fix.
2025-04-18 13:01:22 +02:00
Bernhard Voelker
bad1de52aa NEWS: mention the previous doc fixes
* NEWS (Documentation Changes): Describe the fix done by the two
previous commits.
2025-04-18 13:01:08 +02:00
Bernhard Voelker
97b8920482 doc: fix the "Finding the Shallowest Instance" example in find.1
* find/find.1 (EXAMPLES): Fix the Pruning SCM example by changing the
attribution of the list from "Sample output" to "Sample directories".
The wrong attribution was made in commit v4.7.0-76-g9302afb9.
Then, add the output for clarity.

Fixes https://sv.gnu.org/bugs/?62259
2025-04-18 13:00:07 +02:00
raf
45530ee875 doc: fix the "Finding the Shallowest Instance" example in Texinfo manual
* doc/find.texi (Finding the Shallowest Instance): Add surrounding \(
and \) around the 3x -exec actions to correctly group them with higher
priority than the implicit '-a' for the following '-print'.  Otherwise,
only the SCM roots matching the last test, "CVS", would be printed.
Improve indentation of the multi-line command.
Add sample output for clarity.
While at it, fix a minor typo.

This bug was present since adding that example in 2008.
The very same issue was already fixed for the man page in commit
v4.6.0-55-g47d8fd38.

Fixes https://sv.gnu.org/bugs/?62259
2025-04-18 12:56:23 +02:00
Bernhard Voelker
ee500667d4 tests: add case for passing -files0-from multiple times
Passing -files0-from several times silently overrides the previously given
file names, and only takes the last one.  This behavior is quite common
and has precedence e.g. in 'du --files0-from ...'.
Add a test to document the current behavior.

* tests/find/files0-from.sh: Add a test passing -files0-from 3 times.

Discussed at:
  https://sv.gnu.org/bugs/?66965
2025-04-06 16:49:12 +02:00
Bernhard Voelker
8e1331d8a7 NEWS: document the previous fixes in find.1
* NEWS (Documentation Changes): Mention the change of the previous commit.
2025-03-25 22:40:37 +01:00
Bjarni Ingi Gislason
2be6812e01 find.1: some remarks and editing fixes in the man page
Reported at:
  https://lists.gnu.org/r/bug-findutils/2025-03/msg00002.html

Output from "mandoc -T lint  find.1": (shortened list)

      1 input text line longer than 80 bytes: Some of the conversi...
      1 missing date, using "": TH
      1 unterminated quoted argument

-.-.

Output from "test-nroff -mandoc -t -ww -z find.1": (shortened list)

      1 	Use macro '.B' for one argument or split argument.
      1 	Use macro '.I' for one argument or split argument.
      1 .BR is for at least 2 arguments, got 1
      1 .IR is for at least 2 arguments, got 1

-.-.

Change a HYPHEN-MINUS (code 0x2D) to a minus(-dash) (\-),
if it
is in front of a name for an option,
is a symbol for standard input,
is a single character used to indicate an option,
or is in the NAME section (man-pages(7)).
N.B. - (0x2D), processed as a UTF-8 file, is changed to a hyphen
(0x2010, groff \[u2010] or \[hy]) in the output.

73:until an expression argument comes (which also starts with a `-').
74:Now, if a path argument would start with a `-', then
875:An exception to this is when using only a slash as \fIpattern\fR (`-name /'),
878:A warning is issued if you try to pass a pattern containing a - but not
879:consisting solely of one - slash, unless the environment variable
1095:The + and - prefixes signify greater than and less than, as usual;
1832:find / -name needle -print -quit
2252:.SS Safer `find -print0 | xargs -0` approach
2324:.SS Traversing the filesystem just once - for 2 different actions
2473:Pruning - omitting files and subdirectories
2590:.B $ find / -name needle -print -quit
2607:.B $ find . .. / /tmp /tmp/TRACE compile compile/64/tests/find -maxdepth 0 -printf '[%h][%f]\en'
2654:.B find -print0
2656:.B xargs -0
2743:find: possible unquoted pattern after predicate `-name'?

-.-.

Add a "\&" (or a comma (Oxford comma)) after "e.g." and "i.e.",
or use English words
(man-pages(7)).
Abbreviation points should be marked as such and protected against being
interpreted as an end of sentence, if they are not, and that independent
of the current place on the line.

546:and e.g. from a pipe.
565:The processing of the starting points is otherwise as usual, e.g.

-.-.

Wrong distance (not two spaces) between sentences in the input file.

  Separate the sentences and subordinate clauses; each begins on a new
line.  See man-pages(7) ("Conventions for source file layout") and
"info groff" ("Input Conventions").

  The best procedure is to always start a new sentence on a new line,
at least, if you are typing on a computer.

Remember coding: Only one command ("sentence") on each (logical) line.

E-mail: Easier to quote exactly the relevant lines.

Generally: Easier to edit the sentence.

Patches: Less unaffected text.

Search for two adjacent words is easier, when they belong to the same line,
and the same phrase.

  The amount of space between sentences in the output can then be
controlled with the ".ss" request.

Mark a final abbreviation point as such by suffixing it with "\&".

Some sentences (etc.) do not begin on a new line.

Split (sometimes) lines after a punctuation mark; before a conjunction.

  Lines with only one (or two) space(s) between sentences could be split,
so latter sentences begin on a new line.

Use

sed -e '/^\./n' \
-e 's/\([[:alpha:]]\)\.  */\1.\n/g' $1

to split lines after a sentence period.
Check result with the difference between the formatted outputs.
See also the attachment "general.bugs"

[List of affected lines removed.]

-.-.

Split lines longer than 80 characters into two or more lines.
Appropriate break points are the end of a sentence and a subordinate
clause; after punctuation marks.
Add "\:" to split the string for the output, "\<newline>" in the source.

Line 1546, length 86

Some of the conversion specification characters might not be available on all systems,

Line 2487, length 82

.B $ find . \-name .snapshot \-prune \-o \e( \e! \-name \(aq*~\(aq \-print0 \e) \e

Line 2607, length 96

.B $ find . .. / /tmp /tmp/TRACE compile compile/64/tests/find -maxdepth 0 -printf '[%h][%f]\en'

Line 2645, length 87

.I A Research UNIX Reader: Annotated Excerpts from the Programmer’s Manual, 1971-1986

-.-.

Use \(en (en-dash) for a dash at the beginning (end) of a line,
or between space characters,
not a minus (\-) or a hyphen (-), except in the NAME section.

find.1:2324:.SS Traversing the filesystem just once - for 2 different actions
find.1:2473:Pruning - omitting files and subdirectories

-.-.

Remove reverse slash (\) in front of a period (.) that is to be printed
as such, and can not come a control character in the first column of a line.
Use "\&" to protect the period to avoid that.
This is a sign, that the man page was transformed from another source
file with a program, whose name is NOT mentioned in a comment.

2715:\.B \-perm +MODE
2717:\.B \-perm

-.-.

Split a punctuation mark from a single argument for a two-font macro

1048:.IR ./fubar3,

-.-.

Put a parenthetical sentence, phrase on a separate line,
if not part of a code.
See man-pages(7), item "semantic newline".

[List of affected lines removed.]

-.-.

One space only after an end of sentence.

find.1:339:no error message will be issued. This is the reason why such operation
find.1:546:and e.g. from a pipe.
find.1:960:find . \-path \(dq./sr*sc\(dq
find.1:1797:find . \-path ./src/emacs \-prune \-o \-print
find.1:1896:.B find . \-name afile \-o \-name bfile \-print
find.1:2309:.B $ find . \-type f \-exec file \(aq{}\(aq \e;
find.1:2384:.B $ find . \-perm 664
find.1:2399:.B $ find . \-perm \-664
find.1:2413:.B $ find . \-perm /222
find.1:2423:.B $ find . \-perm /220
find.1:2424:.B $ find . \-perm /u+w,g+w
find.1:2425:.B $ find . \-perm /u=w,g=w
find.1:2440:.B $ find . \-perm \-220
find.1:2441:.B $ find . \-perm \-g+w,u+w
find.1:2452:.B $ find . \-perm \-444 \-perm /222 \e! \-perm /111
find.1:2453:.B $ find . \-perm \-a+r \-perm /a+w \e! \-perm /a+x
find.1:2467:.RB ( "! \-perm /111"
find.1:2469:.B ! \-perm /a+x
find.1:2487:.B $ find . \-name .snapshot \-prune \-o \e( \e! \-name \(aq*~\(aq \-print0 \e) \e
find.1:2607:.B $ find . .. / /tmp /tmp/TRACE compile compile/64/tests/find -maxdepth 0 -printf '[%h][%f]\en'
find.1:2727:.B find . \-name afile \-o \-name bfile \-print
find.1:2731:.BR "find . \-name afile \-o \e( \-name bfile \-a \-print \e)" .
find.1:2741:.B $ find . \-name *.c \-print
find.1:2754:.B find . \-name frcode.c locate.c word_io.c \-print
find.1:2766:.B $ find . \-name \(aq*.c\(aq \-print
find.1:2767:.B $ find . \-name \e*.c \-print

-.-.

Put a subordinate sentence (after a comma) on a new line.

[List of affected lines removed.]

-.-.

Remove quotes when there is a printable
but no space character between them
and the quotes are not for emphasis (markup),
for example as an argument to a macro.

find.1:638:.IP "\-noleaf"
find.1:1154:.IP "\-writable"
find.1:1196:.IP "\-delete\fR"
find.1:1802:.IP "\-quit"
find.1:2233:.SH "EXAMPLES"
find.1:2638:.SH "HISTORY"
find.1:2659:.SH "COMPATIBILITY"
find.1:2724:.SH "NON-BUGS"
find.1:2770:.SH "BUGS"

-.-.

Section headings (.SH and .SS) do not need quoting their arguments.

1968:.SH "STANDARDS CONFORMANCE"
2120:.SH "ENVIRONMENT VARIABLES"
2233:.SH "EXAMPLES"
2638:.SH "HISTORY"
2659:.SH "COMPATIBILITY"
2724:.SH "NON-BUGS"
2770:.SH "BUGS"
2788:.SH "REPORTING BUGS"
2811:.SH "SEE ALSO"

-.-.

Space after an end of sentence.

temp.table:25:\-exec ... +	4.2.12	POSIX

-.-.

Output from "test-groff  -mandoc -t -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -z ":

an.tmac:<stdin>:2: style: .TH missing third argument; consider document modification date in ISO 8601 format (YYYY-MM-DD)
an.tmac:<stdin>:2: style: .TH missing fourth argument; consider package/project name and version (e.g., "groff 1.23.0")
an.tmac:<stdin>:690: misuse, warning: .BR is for at least 2 arguments, got 1
	Use macro '.B' for one argument or split argument.
an.tmac:<stdin>:1048: misuse, warning: .IR is for at least 2 arguments, got 1
	Use macro '.I' for one argument or split argument.

-.-.

Additionally:

  Change "1\ KB" to "1\ KiB"

  Change indent "4m" to "4n".  "4m" is too wide in troff-mode.

  Inhibit hyphenation of "strftime" once (based on an A4 page size).

  Create a "space" between some tags and the its following text by adding
" \&" to the tag.

  Decrease indent after a bullet in lists.

Generally:

Split (sometimes) lines after a punctuation mark; before a conjunction.

* find/find.1: Change as described above.
2025-03-25 21:57:29 +01:00
Bernhard Voelker
f3a3833320 maint: remove declared-only find_pred_name
Only user was inside a an #ifdef DEBUG / #endif block.
Introduced with -context in commit v4.5.5-42-g1a05af6a.

* find/parser.c (parse_context): Remove #ifdef/#endif block.
* find/defs.h (find_pred_name): Remove declaration.
2025-03-25 20:12:40 +01:00
Bernhard Voelker
dc3365628e find: issue a warning for wrongly accepted operators like '-!'
In the current implementation, GNU find accepts the operators '!', ',',
'(' and ')' with a leading dash, e.g. '-!'.
Let's issue a warning to see if anyone relies on that odd behavior.
With a later release, let's fix the parser, and not accept these anymore.

* find/parser.c (find_parser): Issue a warning in the case one of the
above operators has been passed with a leading '-'.
* tests/find/operators-wrong-with-dash.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
* NEWS (Changes in find): Mention the change in behavior.

Discussed at:
https://lists.gnu.org/r/bug-findutils/2025-03/msg00005.html
2025-03-23 23:47:15 +01:00
Collin Funk
faa1301368 tests: adjust shell syntax that breaks AIX /bin/sh
* find/testsuite/find.gnu/execdir-multiple.exp: Move the 'do' of a for
loop to the same line so AIX doesn't fail.
2025-01-26 18:18:57 +01:00
Bernhard Voelker
e5d6eb919b find: avoid crash when diagnosing a file system loop
When gnulib's FTS returns FTS_DC indicating a directory cycle, then the
struct member 'fts_cycle' is not guaranteed to contain valid data.
Avoid dereferencing it when diagnosing the file system loop.

* find/ftsfind.c (issue_loop_warning): Change the error message to avoid
mentioning the other entry involved in the loop anymore.
(partial_quotearg_n): Remove now-unused function.
* NEWS (Bug Fixes): Mention the fix.

Reported by Dietmar Hahn in
<https://lists.gnu.org/r/bug-findutils/2025-01/msg00013.html>
2025-01-26 18:17:10 +01:00
Bernhard Voelker
d44172075a pred.c: consolidate numerical comparisons
Several predicate tests perform a numerical comparison based on the
comparison_type (COMP_GT, COMP_LT, COMP_EQ).
Factor that out into a utility function.

* find/pred.c (compare_num): Add static function.
(pred_gid, pred_inum, pred_links, pred_size, pred_uid): Use it.
2025-01-06 21:43:57 +01:00
Bernhard Voelker
0c20228608 xargs: clarify command as optional in --help output
* xargs/xargs.c (usage): Fix synopsis by wrapping COMMAND in '[...]',
because it is in fact optional.  Also add a sentence that the default
COMMAND is 'echo'.
2025-01-05 22:32:46 +01:00
Bernhard Voelker
85c67e9c3c doc: mention default command of xargs in 'Invoking xargs'
* doc/find.texi (node Invoking xargs): Add sentence about default
command 'echo'.

Reported by <toomas@rosin.ee> in
https://savannah.gnu.org/bugs/?66591
2025-01-05 22:00:00 +01:00
Bernhard Voelker
a465fc58bc maint: silence GCC-14 on utility source getlimits.c
Seen on GCC 14:
  getlimits.c:73:3: warning: stack-based buffer overflow [CWE-121] \
     [-Wanalyzer-out-of-bounds]
     73 |   sprintf (limit + 1, "%" "ju", (uintmax_t) TYPE##_MAX);     \
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... while limit is defined more than large enough.

* find/getlimits.c: Add pragma for GCC version >= 14.
2025-01-05 21:23:25 +01:00
Bernhard Voelker
b52c6688ff maint: adjust to gnulib module renaming
Since previous gnulib update, './bootstrap' shows deprecation warnings
like the following for several modules:
  Notice from module errno:
    This module is deprecated. Use the module 'errno-h' instead.
Use the newer names instead:
- errno -> errno-h
- inttypes -> inttypes-h
- locale -> locale-h
- math -> math-h
- realloc-gnu -> realloc-posix
- stdarg -> stdarg-h
- stdbool -> bool
- stddef -> stddef-h
- stdint -> stdint-h
- stdio -> stdio-h
- stdlib -> stdlib-h
- string -> string-h
- sys_stat -> sys_stat-h
- sys_time -> sys_time-h
- sys_types -> sys_types-h
- sys_wait -> sys_wait-h
- wchar -> wchar-h

* bootstrap.conf (gnulib_modules): Do the above replacements.
2025-01-05 00:58:10 +01:00
Bernhard Voelker
7752c3da26 xargs: simplify error handling for gnulib's safe_read function
The gnulib/NEWS file states:
  SAFE_READ_ERROR and SAFE_WRITE_ERROR are now
  obsolescent; callers can just check for < 0.

* xargs/xargs.c (xargs_do_exec): Adjust error handling of safe_read
accordingly.
2025-01-04 20:04:15 +01:00
Bernhard Voelker
00e698e1b2 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 1127 commits on gnulib
since the last update.

* gnulib: Update to latest.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
* cfg.mk (exclude_file_name_regexp--sc_fsf_postal): Add to exempt the
script build-aux/src-sniff.py from this syntax-check.
2025-01-04 19:59:41 +01:00
Bernhard Voelker
f1f6471ae8 maint: update copyright year number ranges
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.
2025-01-04 11:43:53 +01:00
Christoph Anton Mitterer
a78812c62e doc: state that -execdir prepends the base names with "./"
The '{}' replacement done by the -execdir action prepends each entry,
i.e., the base names, with "./" unless for the root directory "/".

* doc/find.texi (-execdir): Document that behavior.
* find/find.1: Likewise.

Discussed at: https://sv.gnu.org/bugs/?66568

Copyright-paperwork-exempt: Yes
2024-12-24 14:07:30 +01:00
Bernhard Voelker
1da19bdba7 doc: maint: break lines at sentences in a paragraph to change
As the texinfo renderer is caring about proper layout, we can let sentences
start at the beginning of the line, thus making further changes easier
to review.

* doc/find.texi (-execdir): Break lines at the end of sentences.
2024-12-24 13:35:10 +01:00
Bernhard Voelker
00e82f2c15 maint: fix typo in comment
* find/exec.c (impl_pred_exec): Add '-' to 'execdir' example in comment.
2024-12-24 10:30:08 +01:00
Bernhard Voelker
324b5dddc2 maint: pull in gnulib module basename-lgpl
* bootstrap.conf (gnulib_modules): Add 'basename-lgpl', because we're
using the gnulib 'base_name' function.
2024-12-23 21:00:51 +01:00
Bernhard Voelker
aff4e48c11 find: ignore more vanished subdirectories with -ignore_readdir_race
Similar to commit 889d001ab750 which handles vanished files better,
also fix the race for subdirectories (FTS_DNR).

Reproducer:
In average, the following produced 6-10 failures out of 1000 runs:
  $ mkdir testdir
  $ while :; do mkdir testdir/foo; rmdir testdir/foo; done &
  $ for f in $(seq 1000); do \
      find testdir -ignore_readdir_race -ls ; done >/dev/null
  find: 'testdir/foo': No such file or directory
  find: 'testdir/foo': No such file or directory

* find/ftsfind.c (consider_visiting): Return when FTS returned ENOENT
for FTS_DNR, i.e., unreadable directory, with -ignore_readdir_race.
* tests/find/readdir_race.sh: Add test.
* tests/local.mk (sh_tests): Reference it.
* NEWS (Bug Fixes): Amend and improve description of the previous fix.

See also https://savannah.gnu.org/bugs/?45930
2024-12-23 12:59:24 +01:00
Bernhard Voelker
eac8aecaad maint: update further Makefile variables used by Gnulib
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.
2024-12-02 19:54:19 +01:00
Collin Funk
e65a91d2fb maint: update Makefile variables used by Gnulib
* locate/Makefile.am (LDADD): Remove $(LIB_CLOSE) as it is no longer
required per Gnulib NEWS 2009-03-20.
* xargs/Makefile.am (LADD): Likewise.
* find/Makefile.am (LDADD): Likewise. Change $(LIB_EACCESS) to
$(EUIDACCESS_LIBGEN) per Gnulib NEWS 2023-01-07.
2024-12-02 19:54:19 +01:00
Collin Funk
5db475b306 maint: don't use gettimeofday
POSIX marked gettimeofday obsolete in POSIX.1-2017 and removed it in
POSIX.1-2024. Prefer Gnulib functions which use nanosecond resolution if
supported by the operating system.

* bootstrap.conf (gnulib_extra_files): Remove gettimeofday. Add gettime.
* find/util.c (now): Remove function.
(set_option_defaults): Use current_timespec.
* find/Makefile.am (LDADD): Rename $(LIB_CLOCK_GETTIME) to
$(CLOCK_TIME_LIB) per Gnulib NEWS 2023-01-07.
2024-12-02 19:54:19 +01:00
Bernhard Voelker
ea9288c6be doc: fix typo in Texinfo manual
* doc/find.texi (node Leaf Optimisation): s/filssytems/filesystems/
Bug introduced in v4.5.10-9-gb28cc8c4 in 2011.

Reported by <firasuke@gmail.com> in
https://savannah.gnu.org/bugs/?66418
2024-11-10 16:35:17 +01:00
Bernhard Voelker
baab958700 maint: remove unused include from fstype.c
With newer gnulib, the sc_prohibit_always_true_header_tests check
fails with:
  find/fstype.c:30:#if HAVE_MNTENT_H
  maint.mk: do not test the above HAVE_<header>_H symbol(s);
    with the corresponding gnulib module, they are always true
  make: *** [maint.mk:969: sc_prohibit_always_true_header_tests] Error 1

* find/fstype.c (#include <mntent.h>): Remove as it is not actually used.
2024-11-03 21:32:35 +01:00
Bernhard Voelker
744da6ddcc maint: prefer endian.h for byte order conversions
Now that <endian.h> is a part of POSIX 2024 it should become more
portable than <byteswap.h>.

* bootstrap.conf (gnulib_modules): Remove byteswap; add endian.
* locate/word_io.c: Include endian.h instead of byteswap.h.
(decode_value): Use htobe32 instead of bswap_32.
2024-11-03 21:32:30 +01:00
Bernhard Voelker
f4ec39eee0 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* tests/.gitignore (/init.sh): Add entry.
* Makefile.am (update-gnulib-to-latest): Remove handling tests/init.sh.
2024-11-03 21:32:17 +01:00
Bernhard Voelker
d0187016e1 maint: list Gnulib sys_types directly
* bootstrap.conf (gnulib_modules): Add sys_types.
Although it’s already brought in indirectly, findutils code
includes <sys/types.h> directly.
2024-11-03 21:32:08 +01:00
Bernhard Voelker
57fb016b73 maint: add NEWS entry for recent 'find -execdir/-okdir' change
* NEWS (Changes in find): Reflect the change in behavir in recent
commit v4.10.0-15-g1dcdf3de.
2024-11-03 21:14:37 +01:00
Bernhard Voelker
2ef0b4ce38 maint: fix indentation in NEWS
* NEWS: Use 2 char indentation.
2024-11-03 21:09:51 +01:00
Bernhard Voelker
128c5b18c9 maint: make tests/sample-test executable
To avoid that new tests copied from the template sample-test lack the
executable bit, add the executable bit to that file.

* tests/sample-test: Set executable permission bit.
2024-11-03 20:04:48 +01:00
Bernhard Voelker
727d261bb8 maint: make new tests/find/sv-bug-66365-exec.sh executable
'make syntax-check' fails with:
  tests_executable
  maint.mk: Please make test executable: tests/find/sv-bug-66365-exec.sh
  make: *** [cfg.mk:129: sc_tests_executable] Error 1

* tests/find/sv-bug-66365-exec.sh: Set executable permission bit.
2024-11-03 20:04:42 +01:00
James Youngman
1dcdf3de8e find: -exec is terminated by + only if the prior arg is exactly '{}'
A "+" only terminates -exec when it immediately follows an argument
which is exactly "{}" (and not, for example, "{}x").  This fixes
Savannah bug 66365.

* NEWS: explain this change.
* doc/find.texi: update one place which omitted the '{}' before '+'.
* find/parser.c (insert_exec_ok): consider + to be special ony if it
  follows an argument which is exactly '{}'.
* tests/find/sv-bug-66365-exec.sh: test for this bug.
* tests/local.mk: add the new test file.
2024-11-02 18:42:35 +00:00
James Youngman
457acfa06b Fix VPATH compilation failure for 'make check'
The libgnulib.a library isn't (necessarily) below $(top_srcdir), it's
below $(top_builddir).  This fixes a bug introduced in commit
85fc8966e5912390ad220d03b188dd319c85ed1e.
2024-10-31 15:29:07 +00:00
Bernhard Voelker
e38e2f8a36 tests: avoid -Wshadow warning
Seen on GCC 14.2.0:

tests/xargs/test-sigusr.c: In function 'run_xargs':
tests/xargs/test-sigusr.c:159:43: warning: declaration of 'optarg' \
  shadows a global declaration [-Wshadow]
  159 | run_xargs(const char *option, const char *optarg, int send_signal)
      |                               ~~~~~~~~~~~~^~~~~~
  ...
  /usr/include/bits/getopt_core.h:36:14: note: shadowed declaration is here
   36 | extern char *optarg;
      |              ^~~~~~

* tests/xargs/test-sigusr.c (run_xargs): Rename 'optarg' parameter
to 'opt_arg'.
2024-09-17 22:46:58 +02:00
Bernhard Voelker
523043b313 maint: avoid using FSF postal address
The postal address of the FSF has changed from Franklin Street to
Milk Street in Boston, yet according to RMS we shall better avoid
the postal address.

* build-aux/update-online-manual.sh (Copyright): Change from postal
address to the FSF URL.
2024-09-17 21:50:11 +02:00
Bernhard Voelker
f65a2a960f maint: adjust to Gnulib -Wsystem-headers change
* configure.ac: Don’t suppress -Wsystem-headers since Gnulib no
longer enables it.

Borrowed from
  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=94e8f2b012eb
2024-09-17 21:49:56 +02:00
Bernhard Voelker
4a719e65d2 maint: pacify GCC 14.2
Avoid the following warnings:
tree.c:1573:19: warning: no previous declaration for 'cost_table' [-Wmissing-variable-declarations]
 1573 | struct cost_assoc cost_table[] =
      |                   ^~~~~~~~~~
findutils-version.c:37:13: warning: no previous declaration for 'version_string' [-Wmissing-variable-declarations]
   37 | const char *version_string = VERSION;
      |             ^~~~~~~~~~~~~~

* find/tree.c (cost_table): Declare static.
* lib/findutils-version.c (version_string): Likewise.
* locate/frcode.c (version_string): Remove extern declaration.
* locate/locate.c: Likewise.
* xargs/xargs.c: Likewise.
2024-09-17 21:49:18 +02:00
Bernhard Voelker
889d001ab7 find: ignore more vanished entries with -ignore_readdir_race
Reproducer:
  # Spin up lots of short-living processes.
  $ while env true; do sleep .001; done &

  # Invoke 'find' on the /proc file system;
  # this pretty reliably gives the following error:
  $ find /proc -ignore_readdir_race -maxdepth 3 > /dev/null
  find: '/proc/845078': No such file or directory

* find/ftsfind.c (consider_visiting): Return when FTS returned ENOENT
with the option -ignore_readdir_race.
* NEWS (Bug Fixes): Mention the fix.

Fixes https://savannah.gnu.org/bugs/?45930
2024-09-17 21:49:00 +02:00
Dave
07bd7fa675 build: add bison as requirement
Building from git without bison available would result in
  cc1: fatal error: ./parse-datetime.c: No such file or directory
which is not a very helpful error message.
Let gnulib bootstrap check for bison much earlier.

* README-hacking (Prerequisites): Add Bison explicitly.
* bootstrap.conf (buildreq): Add bison.
* cfg.mk (bootstrap-tools): Add gnulib variable with tools including
bison.

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Copyright-paperwork-exempt: Yes
2024-09-17 21:44:33 +02:00
Collin Funk
85fc8966e5 tests: link binaries to gnulib
* tests/local.mk (AM_CPPFLAGS): Include gnulib headers.
(LDADD): Link to gnulib.

Copyright-paperwork-exempt: Yes
2024-06-24 14:35:55 +02:00
Bernhard Voelker
b94986a897 doc: avoid sc_prohibit_unhyphenated_eof failure
'make syntax-check' complains:
  maint.mk: use "end-of-file", not "end of file"
  make: *** [cfg.mk:273: sc_prohibit_unhyphenated_eof] Error 1

* doc/find.texi (xargs options): Change as suggested by the SC rule.
2024-06-24 14:33:09 +02:00
James Youngman
76ddbb913e doc: State that find -print0 and xargs -0 are in POSIX from Issue 8.
The forthcoming Issue 8 of the POSIX standard includes find -print0
and xargs -0.
* doc/find.texi: find -print0 is no longer GNU-specific.  Similarly
for xargs -0.
* xargs/xargs.1: Likewise.
* NEWS: mention these changes.
2024-06-03 12:40:42 +01:00
James Youngman
bb13ef8f93 find: mention when -print0 was introduced.
* find/find.1(COMPATIBILITY): mention that -print0 was introduced in
release 2.0 and is planned for inclusion in POSIX Issue 8.
2024-06-03 12:16:55 +01:00
James Youngman
1c8f85de97 maint: prohibit the use of tabs in Findutils C sources.
This check does not apply to gnulib code.
* cfg.mk (sc_spaces_not_tabs): add syntax check prohibiting
the use of tabs in Findutils code.
* build-aux/tabs-to-spaces.sh: Add small tool for converting
source file tabs to spaces.
2024-06-01 21:41:11 +01:00
James Youngman
e178314ae3 maint: convert tabs to spaces in C source files. 2024-06-01 21:41:05 +01:00
Bernhard Voelker
c8fd333368 maint: post-release administrivia
* NEWS: Add new dummy release header.
2024-06-01 19:19:31 +02:00
Bernhard Voelker
c67264238d version 4.10.0
* NEWS: Record release date.
2024-06-01 17:04:27 +02:00
Bernhard Voelker
d3cbfbb6d4 maint: add more file related to test-sigusr to tests/.gitignore
* tests/.gitignore (/xargs/.dirstamp): Add entry.
(/xargs/test-sigusr.o): Likewise.
2024-06-01 17:04:24 +02:00
Bernhard Voelker
7daec5921e tests: re-introduce all_tests needed by syntax-check
The recent commit removed the variable 'all_tests' which is used by
sc_tests_list_consistency in cfg.mk.

* tests/local.mk (all_tests): Re-introduce and ...
(TESTS): ... use it here.
2024-06-01 17:04:21 +02:00
Bernhard Voelker
3d822be55a maint: improve ERE in sc_tests_list_consistency
The ERE used lacks the grouping of the extensions and therefore would
also match files where the first two patterns are not at the end of
the line:
  grep -E '\.sh|\.c$'

* cfg.mk (sc_tests_list_consistency): Add grouping (...) around the
sub-patterns.  While at it, also remove the redundant escaping, i.e.,
\$$ -> $$ to be consistent with the rest of this file.
2024-06-01 17:04:08 +02:00
James Youngman
b25f15aad7 tests: don't distribute the tests/xargs/test-sigusr binary.
There is no NEWS item for this change since this test was introduced
since the previous release.
2024-05-30 20:24:34 +01:00
Bernhard Voelker
0ffcd1ba81 NEWS: fix translation list.
s/Brazilian, Portuguese/Brazilian Portuguese/.
2024-05-27 23:04:05 +02:00
Bernhard Voelker
09f3233d6d NEWS: further improve wording for the imminent release. 2024-05-27 22:54:18 +02:00
James Youngman
7d4e08c8f7 NEWS: list the updated translations. 2024-05-27 21:33:43 +01:00
James Youngman
bad973ce40 NEWS: mention recent bug-fixes. 2024-05-27 21:12:33 +01:00
Bernhard Voelker
0f37f29bda maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 219 commits on gnulib
since the last update.

* gnulib: Update to latest.
* bootstrap-funclib.sh: Likewise.
2024-05-27 21:53:11 +02:00
James Youngman
dafd09f386 Standardize on "optimize" rather than "optimise".
While this is often described as a UK/US spelling difference, the
"-ise" spelling is described as a variant by the Oxford English
Dictionary.  Therefore we prefer the "-ize" spelling.

* doc/find.texi: standardize on optimize.
* find/find.1: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/tree.c: Likewise.
* NEWS: Likewise (except for historical entries).
2024-05-27 20:11:31 +01:00
James Youngman
81c1ec3dca find: by default, disable the cost-based optimiser.
The cost-based optimiser re-orders predicates based on their expected
cost.  This re-ordering (as currently implemented) results in
user-visible changes to the order of operations.  An optimiser should
not do that.  For example, "-empty -readable" and "-readable -empty"
don't actually have the same effect since "-empty" fails on an
unreadable directory.  This fixes savannah bug #58427 (unless the user
specifies -O2).

* find/util.c(set_option_defaults): set default optimisation level to
1 instead of 2.
* find/tree.c(build_expression_tree): call do_arm_swaps (i.e. apply
cost-based optimisations) only at optimisation level 2 and above.
* find/find.1(-O): explain this change.
* doc/find.texi(Optimisation Options): explain this change.
* NEWS: mention this change.
2024-05-27 19:50:11 +01:00
James Youngman
b12fb8c216 Fix sv bug #51926: -xtype l fails on symlinks that have a loop
* find/pred.c (pred_xtype): if lstat fails with ELOOP, -xtype should
behave in the same way as -type.
(err_signals_broken_link): new function, true for ENOENT and ELOOP.
* doc/find.texi: document the fact that the "infinite loop" case is
handled like the "symbolic link target does not exist" case.
* find/find.1: Likewise.
2024-05-26 19:34:45 +01:00
James Youngman
88850fd0c6 maint: turn on Automake option subdir-objects.
Enabling subdir-objects fixes Savannah bug #65794.

* Makefile.am(AUTOMAKE_OPTIONS): enable subdir-objects.
2024-05-26 17:01:20 +01:00
James Youngman
64e9ddbd8c [check] make fail message of tests/misc/help-version.sh explicit.
This improved message is intended to help diagnose Savannah bug #65796.

* tests/misc/help-version.sh: when the --version ouptut of some
findutils program doesn't match the value of the VERSION environment
variable during "make check", issue a more detailed error message.
2024-05-26 16:58:15 +01:00
Bernhard Voelker
32132e9749 tests: avoid various syntax-check failures wrt/ test-sigusr
The syntax-check complains:
  $ make syntax-check -k
  ...
  maint.mk: the above files do not call bindtextdomain
  make: *** [maint.mk:869: sc_bindtextdomain] Error 1
  ...
  maint.mk: the above files do not include <config.h>
  make: *** [maint.mk:509: sc_require_config_h] Error 1
  ...
  maint.mk: use EXIT_* values rather than magic number
  make: *** [maint.mk:411: sc_prohibit_magic_number_exit] Error 1
  ...
  maint.mk: found unmarked diagnostic(s)
  make: *** [maint.mk:916: sc_unmarked_diagnostics] Error 1
  ...
  make: *** [cfg.mk:111: sc_tests_list_consistency] Error 1
  ...
  maint.mk: Please make test executable: tests/xargs/test-sigusr.c
  make: *** [cfg.mk:124: sc_tests_executable] Error 1

* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add test-sigusr.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Define with the
pattern of the test-sigusr source file.
(sc_tests_list_consistency): Strip off ".c" suffix.
(sc_tests_executable): Exempt C source from this rule.
* tests/local.mk (TEST_EXTENSIONS): Add .c sources, needed also for
sc_tests_list_consistency to work.
* tests/xargs/test-sigusr.c (#include <config.h>): Add to avoid
sc_require_config_h failure.
(verify_signal_ignored): Call exit with EXIT_FAILURE instead of 1 to
avoid sc_prohibit_magic_number_exit failure.
(verify_signal_is_fatal): Likewise.
(verify_signal_is_nonfatal_with_p): Likewise.
* tests/.gitignore (/xargs/test-sigusr): While at it, add an entry
for the built test program here.
2024-05-20 13:57:53 +02:00
Bernhard Voelker
a76e5e1f02 xargs: avoid sc_useless_cpp_parens failure
$ make syntax-check
...
xargs/xargs.c:674:#if !(defined(SIGUSR1) && defined(SIGUSR2))
maint.mk: found useless parentheses in cpp directive
make: *** [maint.mk:924: sc_useless_cpp_parens] Error 1

* xargs/xargs.c (main): Simplify -P #if conditional to avoid the
above syntax-check failure.
2024-05-20 13:54:46 +02:00
Bernhard Voelker
b9c9310eec maint: avoid gnulib sc_prefer_angle_bracket_headers failure
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.
2024-05-20 13:54:38 +02:00
Bernhard Voelker
8d48e1ee65 build: avoid spurious failures due to lack of EGREP definition
Similar to Jim Meyering's commit in coreutils:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=d73ca62c4fa3

* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.
2024-05-20 13:54:29 +02:00
James Youngman
9874c773f2 [find] avoid undefined behaviour in consider_arm_swap.
This fixes Savannah bug #63605.

* find/tree.c: avoid invalid struct member access in consider_arm_swap
2024-05-19 22:23:19 +01:00
James Youngman
9f5295f704 [xargs] restart stdin reads interruipted by SIGUSR1/SIGUSR2.
While we do use the gnulib safe_read function, we read input from
stdin using stdio, not direct Unix syscalls, so safe_read is not
involved.

* xargs/xargs.c: If a stdin read fails with EINTR, do it again.  Use
SA_RESTART when setting up signal handlers.  This fixes Savannah
bug #64442.
2024-05-19 13:11:02 +01:00
James Youngman
9fed05088f [doc] Mention the changes to xargs -P
* doc/find.texi: explain how xargs -P affects the handling of the
SIGUSR1 and SIGUSR2 signals.
* xargs/xargs.1: Likewise.
2024-05-19 11:27:46 +01:00
James Youngman
b560e3f911 [xargs] POSIX requires SIGUSR1/2 to be fatal if not blocked.
If the user uses -P we're not using only POSIX options, so in that
case it is OK to handle SIGUSR1/2.  Otherwise (without -P) don't
handle these signals, meaning that they could cause xargs to
terminate.

* xargs/xargs.c: set signal handlers for SIGUSR1 and SIGUSR2 only if
the -P option was used.  Warn if SIGUSR1 or SIGUSR2 is not defined.
* tests/xargs/test-sigusr: a new test for this.
* tests/local.mk: build and run the new test.
* NEWS: mention these changes.
2024-05-19 11:13:31 +01:00
James Youngman
ad636eae01 xargs: Wait for all children even if one exited with 255.
* xargs/xargs.c: fix Savannah bug #64451 (xargs -P exits before all
children have exited if one exits with status 255).
* xargs/xargs.1 (BUGS): mention this bug and the corrected behaviour.
* doc/find.texi: Likewise.
* NEWS: mention this bugfix.
2024-05-18 10:59:52 +01:00
James Youngman
8368fd0b2a [doc] add missing "-" to "-regextype". 2024-05-18 08:10:15 +01:00
James Youngman
b6fc295bfb [doc] -regextype is also a positional option. 2024-05-17 09:54:40 +01:00
James Youngman
9cbbb20bd5 [doc] Explain how locate's and find's default matching differ.
Example: The output of "locate foo" would include /home/james/foo/bar
while the output of "find /home -name foo" would not.
2024-05-17 09:45:46 +01:00
James Youngman
0582f8057e [doc] Explain that find defaults to GNU Emacs regexes.
This fixes Savannah bug #65297.
2024-05-17 09:29:17 +01:00
James Youngman
e549900aa6 [doc] Use @var{name}, not NAME or @var{NAME} in "Hard Links".
The @var{name} renders as NAME in Info, to this inconsistency is hard
to spot there.  The inconsistency is easier to spot in the typeset
output (e.g. PDF, Postscript).

Our solution is to use @var{name} even inside @samp, since that
works (and is intended to, according to the documentation).

This fixes Savannah bug #65305.
2024-05-17 08:42:07 +01:00
James Youngman
76215fb45f Simplify use of predicate->args.exec_vec slightly.
We introduce a function which tells us whether that union member is
valid.
2024-05-13 22:14:12 +01:00
James Youngman
ab0137eff3 Rename is_fts_enabled() to is_fts_cwdfd_enabled().
This simplifies the caller.  FTS is always enabled.  Remove some
now-unused variables.
2024-05-13 21:38:42 +01:00
James Youngman
c785979507 Remove unused predicate field literal_control_chars. 2024-05-13 21:27:12 +01:00
James Youngman
f63b1419bd Fix typo in comment. 2024-05-13 15:49:17 +01:00
James Youngman
de9d23dd1a Correct download URLs.
Also some minor corrections:

- Remove --with-afs, this configure option no longer exists.
- -exec ... {} + is implemented now.
2024-05-13 15:10:28 +01:00
Bernhard Voelker
be2ea9b3b4 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 518 commits on gnulib
since the last update, including the update of the copyright year numbers.

* gnulib: Update to latest.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
* tests/init.sh: Likewise.
2024-04-20 13:18:39 +02:00
Bernhard Voelker
3df6a55800 maint: doc: warn about consistency of node menu entries
* doc/Makefile.am (AM_MAKEINFOFLAGS): Add configuration variable
CHECK_NORMAL_MENU_STRUCTURE=1 to warn about inconsistent menu structure
again: makeinfo >=6.8 would not do this anymore.
2024-04-15 18:58:11 +02:00
Bernhard Voelker
360b9b1ea8 doc: use upper-case 'B' as birthtime for -newerXY consistently
* doc/find.texi (deffn Test -newerXY reference): Change lower-case
'b' to upper-case 'B' as only the latter is recognized in the code.
* NEWS (Documentation Changes): Document the fix.

Documentation bug introduced with commit f361af57cdb3 in 2007.
Fixes https://savannah.gnu.org/bugs/?65378
2024-02-28 08:23:40 +01:00
Bernhard Voelker
ea1abfa968 maint: update copyright year number ranges
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.
2024-01-02 09:13:29 +01:00
Bernhard Voelker
da8b3e965c doc/find.texi: avoid 'update-copyright' changing code sample output
* doc/find.texi (@node O_NOFOLLOW): Add a grep filter to 'find --version'
to only get the wanted "Features" line, thus avoiding to have a regular
Copyright line in the texi file.  Previously, that place always had to
be reverted after 'make update-copyright'.
2024-01-02 09:06:52 +01:00
Bernhard Voelker
809f8dc3eb maint: update gnulib to latest
Run 'make update-gnulib-to-latest'; there have been 219 commits on gnulib
since the last update, including the update of the copyright year numbers.

* gnulib: Update to latest.
* autogen.sh: Auto-update.
* autopull.sh: Likewise.
* bootstrap: Likewise.
* bootstrap-funclib.sh: Likewise.
* tests/init.sh: Likewise.
2024-01-02 08:50:58 +01:00
Bernhard Voelker
dbd0f01503 maint: adjust make target 'gnulib-sync' wrt/ autogen and autopull
Since gnulib update in findutils commit f293f5da80f9, there are more
files the make target 'gnulib-sync' alias 'update-gnulib-to-latest'
needs to copy.

* Makefile.am (gnulib-sync): Use 'fdl.texi' from gnulib now as it is
identical to 'fdl-1.3.texi'.
Copy autogen.sh, autopull.sh, bootstrap-funclib.sh and bootstrap from
the 'gnulib/top' directory.
2024-01-02 00:08:48 +01:00
Bernhard Voelker
3008e19df8 find: allow -user,-group to accept larger integers beyond INT_MAX
The number parsing of integer arguments of the -user and -group option
was limited to INT_MAX, although the data types uid_t and gid_t are
larger on many systems, including x86_64 GNU/Linux.

* find/parser.c (UID_T_MAX, GID_T_MAX): Define.
(parse_group): Use xstrtoumax directly instead of safe_atoi, and check
the returned number vs. GID_T_MAX.  Simplify error handling.
While at it, fix the est_success_rate guessing.
(parse_user): Use xstrtoumax directly instead of safe_atoi, and check
the returned number vs. UID_T_MAX.
* find/getlimits.c: Add helper utility to determine platform-local
limits for uid_t and gid_t, based on 'getlimits' of GNU coreutils,
written by Padraig Brady.
* find/Makefile.am (noinst_PROGRAMS): Make 'getlimits' as such.
* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add getlimits.c.
* find/.gitignore (/getlimits): Add entry.
* tests/find/user-group-max.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (Bug Fixes): Mention the fix.

Reported by Jocelyn Le Sage in
https://savannah.gnu.org/bugs/?64900
2023-12-30 21:01:15 +01:00
Bernhard Voelker
c79e5f7973 find.1: fix syntax error
Build failed with:
  $ build-aux/man-lint.sh find find.1
  lint check on manpage find.1: FAILED:
  troff:find/find.1:2048: warning: macro 'find' not defined \
  (possibly missing space after 'fi')

* find/find.1: Fix highlighting.
Bug introduced in recent commit 9a6b5821e680.
2023-11-11 17:32:10 +01:00
Bernhard Voelker
485693836a updatedb.1: fix typo
* locate/updatedb.1: s/LOCATGE02/LOCATE02/

Bug introduced in commit v4.6.0-44-g89ec0211.
Fixes https://savannah.gnu.org/bugs/?64876
2023-11-10 07:52:55 +01:00
Bernhard Voelker
9a6b5821e6 find.1: highlight the find(1) tool in more places.
When the word 'find' stands for the tool, hightlight it.

* find/find.1: Do the above in more cases.
2023-10-14 20:37:46 +02:00
Bernhard Voelker
65f456e055 xargs.1: narrow down deprecation on the -i option
The long option --replace it not deprecated, only the short form.

* xargs/xargs.1: Clarify the above better by explicitly mentioning
the short -i form.
2023-10-14 18:29:20 +02:00
Bernhard Voelker
e6e2d10a8b doc: fix description of xargs options -i, --replace
The description of the --replace/-i options of xargs in the Reference
chapter said that the replace-str would only be allowed to be omitted
for -i while this holds also true for the long option --replace.

A similar description of the same options in Interspersing File Names
was missing the '[]' to mark the REPLACE-STR as optional for -i.

* doc/find.texi (xargs options): Document that omitting the REPLACE-STR
is allowed for --replace, too.  Further align the description with
that in ...
(Interspersing File Names): ... here.  Mark the replace-str as optional
for -i by surrounding with '[]'.
2023-10-02 08:51:56 +02:00
Bernhard Voelker
3acecd2153 doc: use option --replace instead of deprecated -i in xargs example
* doc/find.texi (subsection Coping with odd filenames too):
Change the deprecated -i option to --replace.
* NEWS (Documentation Changes): Document the change.
2023-10-02 08:49:10 +02:00
Bernhard Voelker
ad4e2bdde0 doc: use option -L instead of deprecated -l in xargs examples
* doc/find.texi: Change the deprecated -l option to -L 1 in various
xargs(1) examples.
* NEWS (Documentation Changes): Document the change.

Reported by Sebastian Carlos in
Fixes https://savannah.gnu.org/bugs/?64480
2023-10-01 15:11:11 +02:00
Bernhard Voelker
d76d0f5668 maint: go back to using 'error'
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.
2023-09-30 14:57:05 +02:00
Bernhard Voelker
2841c3a82a find: diagnose NaN arguments better
The predicates -used, -amin, -cmin, -mmin, -atime, -ctime, and -mtime
dumped core via an assertion when passing a not-a-number argument.

* find/parser.c (isnan): Add define.
(get_relative_timestamp): Diagnose when the return value of xstrtod
is not-a-number.  Mention the missing parsers in the description of
the function.
* tests/find/arg-nan.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (Improvements): Mention the improvement.

Reported by Jaehan Yoon in
https://savannah.gnu.org/bugs/?64717
2023-09-30 13:42:24 +02:00
Bernhard Voelker
b5b10712c8 doc: reference COPYING from README
* README: Reference COPYING as per the GNU coding standards,
and enforced by a new syntax-check from gnulib.
2023-09-25 20:20:58 +02:00
Bernhard Voelker
227faa86af maint: update gnulib to latest
There have been 522 commits on gnulib since the last update.

* bootstrap: Auto-update.
* bootstrap-funclib.sh: Likewise.
* gnulib: Update to latest.
2023-09-25 20:19:12 +02:00
Bernhard Voelker
59c70af150 maint: run groff(1) when lint-ing man pages
Newer troff(1) complains about the TE macro:
  find/find.1:908: warning: tbl preprocessor failed, or it or soelim \
    was not run; table(s) likely not rendered (TE macro called with  \
    TW register undefined)

* build-aux/man-lint.sh: Change from troff(1) to groff(1).
2023-09-25 20:18:29 +02:00
Bernhard Voelker
c2002a3646 xargs.1: further editing improvements
* xargs/xargs.1: Start new sentences on a new line.
Use '\~' as unbreakable space in "2048 bytes".
2023-09-24 16:11:06 +02:00
Bjarni Ingi Gislason
a77c161b65 xargs.1: some remarks and editing fixes in the man page
Not in the patch.

Output from "mandoc -T lint xargs.1":

mandoc: xargs.1:1:2: WARNING: missing date, using "": TH

#######

Change '-' (\-) to '\(en' (en-dash) for a numeric range.
GNU gnulib has recently (2023-06-18) updated its
"build_aux/update-copyright" to recognize "\(en" in man pages.

xargs.1:393:if any invocation of the command exited with status 1-125
xargs.1:518:Copyright \(co 1990-2023 Free Software Foundation, Inc.

#####

Change (or include a "FIXME" paragraph about) misused SI (metric)
numeric prefixes (or names) to the binary ones, like Ki (kibi), Mi
(mebi), Gi (gibi), or Ti (tebi), if indicated.
If the metric prefixes are correct, add the definitions or an
explanation to avoid misunderstanding.

254:more than 128KiB, 128Kib is used as the default value; otherwise, the
255:default value is the maximum.  1KiB is 1024 bytes.

#####

Reduce space between words.

51:prevents such problems.   When using this option you will need to
94:command.   Multibyte characters are not supported.
466:internally.   This means that there is an upper limit on the length
492:a line which is longer than it can handle.   This is not an ideal

#####

Change -- in x--y to \(em (em-dash), or, if an
option, to \-\-

268:.BR --no-run-if-empty )

#####

Change - to \- if it shall be printed as a minus sign.

xargs.1:393:if any invocation of the command exited with status 1-125
xargs.1:518:Copyright \(co 1990-2023 Free Software Foundation, Inc.

#####

Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of a
name for an option.

234:.BR -t .
248:.BI -s " max-chars\fR, \fI" \-\-max\-chars "=\fImax-chars\fR"

#####

Wrong distance between sentences.

  Separate the sentences and subordinate clauses; each begins on a new
line.  See man-pages(7) ("Conventions for source file layout") and
"info groff" ("Input Conventions").

  The best procedure is to always start a new sentence on a new line,
at least, if you are typing on a computer.

Remember coding: Only one command ("sentence") on each (logical) line.

E-mail: Easier to quote exactly the relevant lines.

Generally: Easier to edit the sentence.

Patches: Less unaffected text.

  The amount of space between sentences in the output can then be
controlled with the ".ss" request.

51:prevents such problems.   When using this option you will need to
94:command.   Multibyte characters are not supported.
316:are mutually exclusive. If some of them are specified at the same
466:internally.   This means that there is an upper limit on the length
492:a line which is longer than it can handle.   This is not an ideal

#####

Do not use more than two space characters between sentences or (better)
only a new line character.

51:prevents such problems.   When using this option you will need to
94:command.   Multibyte characters are not supported.
466:internally.   This means that there is an upper limit on the length
492:a line which is longer than it can handle.   This is not an ideal

#####

  Not in the patch.

Output from "test-nroff -man -b -ww -z":

[ "test-groff" is a developmental version of "groff" ]

Input file is ./xargs.1

Output from test-groff -b -mandoc -dAD=l -rF0 -rHY=0 -t -w w -z :
an.tmac:/tmp/chk_manuals.temp.ZC2PK6:1: style: .TH missing third argument;\
  suggest document modification date in ISO 8601 format (YYYY-MM-DD)
an.tmac:/tmp/chk_manuals.temp.ZC2PK6:1: style: .TH missing fourth argument;\
  suggest package/project name and version (e.g., "groff 1.23.0")

####

* xargs/xargs.1: Change as described above.
2023-09-23 16:12:45 +02:00
Bernhard Voelker
81bcf2b9b3 maint: prefer canonical Savannah URL for the gnulib submodule
This avoids the following warning from 'git fetch':
  warning: redirecting to https://git.savannah.gnu.org/git/gnulib.git/

* .gitmodules (url): s/sv/savannah/
2023-05-23 22:57:01 +02:00
Bernhard Voelker
6aedc4e631 doc: fix extra escaping of a minus '-' character in xargs.1
* xargs/xargs.1 (--show-limits): Remove redundant backslash character,
introduced when adding the description of that option in commit
956992ff71b3 in 2005.
2023-05-23 22:17:15 +02:00
Bernhard Voelker
bbd06d8e06 doc: document double dash "--" option delimiter for xargs
* doc/find.texi (node xargs options): Add description of the "--"
option delimiter.
* xargs/xargs.1 (OPTIONS): Likewise.
* NEWS (Documentation Changes): Document the change.

Suggested by Dan Jacobson <jidanni@jidanni.org> in
<https://lists.gnu.org/r/bug-findutils/2023-04/msg00009.html>
2023-05-23 22:17:07 +02:00
Bernhard Voelker
a5b2e20d8f tests: fix FP in xargs test when /bin/sh is dash
Dash as /bin/sh apparently does not know $'\n' syntax.

* tests/xargs/verbose-quote.sh: Define NL variable for newline character;
change from $'\n' syntax to the above variable when generating input
for xargs.

Fixes https://sv.gnu.org/bugs/?63934
2023-05-23 01:57:47 +02:00
Bernhard Voelker
277de38d4b doc: add 'bugs, reporting' to primary index
* doc/find.texi: Do the above.

Suggested by Dan Jacobson in:
<https://lists.gnu.org/r/bug-findutils/2023-04/msg00013.html>
2023-05-23 01:14:46 +02:00
Bernhard Voelker
0bc43b0b40 maint: require support for post-2038 timestamps
* bootstrap.conf (gnulib_modules): Replace year2038 with
year2038-recommended.
* NEWS (Changes to the build process): Mention the change.
2023-05-23 00:13:10 +02:00
Bernhard Voelker
cf4133e9b0 maint: update gnulib to latest
There have been 626 commits on gnulib since the last update.

* bootstrap: Auto-update.
* bootstrap-funclib.sh: Likewise.
* gnulib: Update to latest.
* tests/init.sh: Likewise.
2023-05-23 00:12:54 +02:00
Bernhard Voelker
db175578e3 doc: change find enty point to "Finding Files"
The previous entry point for 'info find' was "Invoking find" which
is not that enlightening for the user.   Change to the better choice.

* doc/find.texi (@direntry): Change target for 'find' to the
chapter "Finding Files".

Discussed at:
<https://lists.gnu.org/r/bug-findutils/2023-04/msg00006.html>
2023-05-22 23:15:34 +02:00
Bernhard Voelker
251158b59e build: update gnulib prerequisite tools
* bootstrap.conf (buildreq): Add autopoint, m4, makeinfo, texi2pdf,
wget and xz.
2023-05-22 23:15:27 +02:00
Bernhard Voelker
2be229d3af xargs: pacify GCC 13
* xargs/xargs.c: Ignore -Wanalyzer-fd-leak.
2023-05-22 23:15:16 +02:00
James Youngman
fc47dadea9 doc: describe history of find, xargs and locate. 2023-03-18 20:23:43 +00:00
Bernhard Voelker
7836aa1def doc: use "end-of-file" with hyphenation consistently
* cfg.mk (sc_prohibit_unhyphenated_eof): Add syntax-check rule.
* doc/find.texi: Change "end of file" to "end-of-file" in several places.
* xargs/xargs.1: Likewise.
* xargs/xargs.c (eof_str): Change comment to adhere to the new rule.
2023-02-13 20:46:48 +01:00
Bernhard Voelker
da65ab1e69 doc: improve description about when xargs stops processing
* doc/find.texi (Multiple Files): Clarify better that xargs will stop when
reading the EOF marker string specified with the --eof option, or when a
launched command exists with status 255.  Switch the two termination
conditions to reflect the behavior.

Fixes RT #1912852.
2023-02-13 20:46:42 +01:00
Bernhard Voelker
4a72809272 find: fix error diagnostics of options with mandatory, numeric arguments
The error diagnostic for wrong invocations with option that require
numeric arguments (-inum, -links, -gid, -uid) was wrong and not helpful:
  $ find -gid
  find: invalid argument `-gid' to `-gid'

* find/parser.c (parse_gid): Remove changing back of the ARG_PTR in
the error case; thus simplify.
(parse_inum,parse_links,parse_uid): Likewise.
(get_num): While at it, mention -gid and -uid in the comment as well.
(insert_num): Also improve the error diagnostic in the case the user
has provided a non-numeric argument.  Previously, it was just "invalid
argument".
* tests/find/opt-numeric-arg.sh: Add test.
* tests/local.mk: Reference it.
* NEWS (Bug Fixes): Mention the fix.

Reported by Andreas Schwab <schwab@linux-m68k.org> in
<https://lists.gnu.org/r/bug-findutils/2023-01/msg00001.html>
2023-01-05 19:43:25 +01:00
ribbon
6490a80765 doc: minor formatting fixes in xargs.1
* xargs/xargs.1 (--max-args): Reset the bold formatting earlier
in two places.

Fixes https://sv.gnu.org/bugs/?62325

Copyright-paperwork-exempt: Yes
2023-01-02 00:05:44 +01:00
Bernhard Voelker
73d020f472 maint: update copyright year number ranges
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.
2023-01-01 23:51:15 +01:00
Bernhard Voelker
f293f5da80 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:

  > maint: run 'make update-copyright'

This also pulls in the splitting of bootstrap into autopull.sh,
autogen.sh and bootstrap.

* autogen.sh: Add file.
* autopull.sh: Likewise.
* bootstrap-funclib.sh: Likewise.
* bootstrap: Auto-update.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
2023-01-01 23:51:03 +01:00
Bernhard Voelker
5c43cfb05c maint: avoid unportable 'grep -q'
The upcoming gnulib update comes with the new syntax-check named
'sc_unportable_grep_q':

  maint.mk: unportable 'grep -q', use >/dev/null instead
  make: *** [maint.mk:1377: sc_unportable_grep_q] Error 1

Fix offending places.

* cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Replace unportable '-q' by redirecting grep output to /dev/null.
* doc/find.texi (node Adding Tests): Likewise.
* init.cfg (find_emits_warnings_): Likewise.
2023-01-01 23:15:36 +01:00
Bernhard Voelker
4391e438a4 doc: generate manuals with makeinfo --no-split
* doc/Makefile.am (AM_MAKEINFOFLAGS): Add for --no-split option.
(find_mono.html): Remove --no-split from makeinfo invocation.
* NEWS (Documentation Changes): Document the change.
* doc/.gitignore (/find.info-1,/find.info-2): Remove entries.

Suggested by Antonio Diaz Diaz <antonio@gnu.org> in
https://lists.gnu.org/r/bug-findutils/2022-11/msg00001.html
2022-11-16 01:12:40 +01:00
Antonio Diaz Diaz
f9f1ffc850 doc: fix typo in maintainer manual
* doc/find-maint.texi (chapter Security): s/p[art/part/

Copyright-paperwork-exempt: Yes
2022-11-16 00:30:47 +01:00
Antonio Diaz Diaz
8ff8307fd6 doc: remove redundant @deffnx for option -files0-from from manual
* doc/find.texi (section Starting points): Remove @deffnx; the @deffn
above it is sufficient.

Copyright-paperwork-exempt: Yes
2022-11-16 00:27:06 +01:00
John A. Leuenhagen
3657b73ecb doc: fix grammar issue in find man page
* find/find.1 (GLOBAL OPTIONS): Add "be" between "should" and
"specified".

Copyright-paperwork-exempt: Yes
2022-10-11 08:07:55 +02:00
Shuiqing Zhou
3c2d824ef5 tests: add tests for the 'find -newer' family
* tests/find/newer.sh: Add to improve test coverage.
* tests/local.mk (all_tests): Reference the test.

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Copyright-paperwork-exempt: Yes
2022-08-09 23:45:57 +02:00
Bernhard Voelker
e5c697eccf maint: remove obsolete AC_HEADER_STDC macro
Avoid the following warning:
  configure.ac:208: warning: The macro `AC_HEADER_STDC' is obsolete.

* configure.ac (AC_HEADER_STDC): Remove, and ...
(AC_CHECK_INCLUDES_DEFAULT): ... add this instead.
2022-04-25 08:37:17 +02:00
Helmut Grohne
a48d2ba8d7 build: bump gettext version to 0.19.8
findutils failed to build from source on musl-libc, because it failed
to detect gettext availability.  Newer gettext fixes this:

  Version 0.19.8 - June 2016
  [...]
  - The AM_GNU_GETTEXT Autoconf macro can now detect musl-libc's
    gettext as a compatible implementation.

* configure.ac (AM_GNU_GETTEXT_VERSION): Update from 0.19.3 to 0.19.8.
(AM_GNU_GETTEXT_REQUIRE_VERSION): Add to make autopoint pull the latest
available version instead of the exact specified version.
* NEWS: Mention the change.

Reported via Andreas Metzler <ametzler@bebt.de> at:
  https://sv.gnu.org/patch/?10203

Fixes: https://bugs.debian.org/1009874

Copyright-paperwork-exempt: Yes
2022-04-25 08:37:10 +02:00
Bernhard Voelker
d3097b3325 doc: fix formatting typo in Texinfo manual
* doc/find.texi (LC_COLLATE): Change man-style `\-name' to @samp{-name}.
2022-04-24 13:37:26 +02:00
Bernhard Voelker
36ec95c4d6 maint: fix code smell
Detected by `make findutils-check-smells` (ironically for itself):
  error: ./Makefile.am:88: Spaces at start of makefile line

* Makefile.am (findutils-check-smells): Fix tab indentation of the
recipe, and re-indent for better reading.
2022-04-24 13:37:00 +02:00
Bernhard Voelker
6d2fa2c9a0 find: omit warning diagnostic for -name '/'
Although usually a pattern containing a directory separator does not match
anything, a pattern solely consisting of one '/' still does (and has to)
for the root directory "/".

* find/parser.c (check_name_arg): Omit the warning in the case the
given pattern equals "/".
find/find.1 (-name): Clarify better that the pattern "/" is valid to
match the "/" directory.
* init.cfg (find_emits_warnings_): Add utility function.
* tests/find/name-slash.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* MEWS (Bug Fixes): Mention the fix.

Fixes https://savannah.gnu.org/bugs/?62227
2022-04-24 13:35:49 +02:00
Bernhard Voelker
82e81acc5c maint: simplify check_name_arg in parser.c
* find/parser.c (check_name_arg): Change to void; remove return statement.
(parse_iname): Adjust caller.
(parse_name): Likewise.
2022-03-30 21:55:35 +02:00
Bernhard Voelker
fa7e628e19 find: port to Ubuntu 20.04 cross-compiling for OpenWRT 21.02
In the above build environment, HAVE_ENDPWENT seems to be defined to 0
instead of being #undef'ed.  Hence the build fails:

  parser.c: In function 'parse_user':
  parser.c:75:20: error: expected expression before ')' token
     75 | # define endpwent ()
        |                    ^
  parser.c:2463:7: note: in expansion of macro 'endpwent'
   2463 |       endpwent ();
        |       ^~~~~~~~

* find/parser.c (HAVE_ENDGRENT,HAVE_ENDPWENT): Change from #ifndef to
"#if !", and define the replacement code to "(void) 0".

Fixes https://github.com/openwrt/packages/issues/17912
2022-03-30 21:55:30 +02:00
Bernhard Voelker
43679658e2 find: fix indentation of --help output
* find/util.c (usage): Remove excess leading blank in the -mount line
of the "Normal options" block.
2022-02-04 16:49:44 +01:00
Bernhard Voelker
cabad6fc17 maint: post-release administrativa
* NEWS: Add new dummy release header.
2022-02-02 01:39:45 +01:00
Bernhard Voelker
f56ec21a34 NEWS: update before release
* NEWS: Prepare for the 4.9.0 release: minor re-ordering, and update
entries with bug numbers.
2022-02-02 00:05:33 +01:00
Bernhard Voelker
1ce4f28720 maint: update gnulib to latest
Run 'make update-gnulib-to-latest' in order to use the latest version
for the imminent release.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2022-02-01 19:18:03 +01:00
Andreas Metzler
58747d778e doc: improve description of 'find -delete'
* doc/find.texi (Action -delete): Improve and re-structure:
Mention that -delete is able to remove directories (if they are empty),
that failure to delete a file changes the exit code to nonzero, and
clarify better the relation between -delete, -depth and -prune.
* find/find.1 (-delete): Align with the above mentioned section in the
Texinfo manual.

Fixes https://savannah.gnu.org/bugs/?61774
Originally reported by Chris Davies in
  https://bugs.debian.org/1003339

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
2022-01-31 00:48:47 +01:00
Bernhard Voelker
841aa66f1e maint: avoid warnings from sparse tool
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.
2022-01-06 03:28:38 +01:00
Bernhard Voelker
2e6c701850 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly due to:

  > license: fix GPLv3 texts to use a comma instead of semicolon.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2022-01-06 01:55:29 +01:00
Bernhard Voelker
17e3183c1a maint: fix GPLv3 texts to use a comma instead of semicolon
See: https://www.gnu.org/licenses/gpl-3.0.html#howto
Run:
  $ git grep -l 'Foundation; either version 3' \
      | xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/'

* bootstrap.conf: Adjust GPLv3 header via the above command.
* build-aux/gen-changelog.sh: Likewise.
* lib/die.h: Likewise.
2022-01-05 21:54:16 +01:00
Bernhard Voelker
db5ec614a7 maint: update copyright year number ranges
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.
2022-01-02 18:42:35 +01:00
Bernhard Voelker
780b31ad23 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:

  > maint: run 'make update-copyright'

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
2022-01-02 18:39:11 +01:00
Bernhard Voelker
2efc2d2e33 doc: fix 'xargs --open-tty' example
doc/find.texi (xargs options): Change 'grep -lz' to 'grep -lZ' as
input for 'xargs -0o' as only the latter will write a NUL after
each file name.  Add -n1 to the xargs call.

Reported by Robin A. Meade in
https://savannah.gnu.org/bugs/?61341
2021-12-31 02:34:31 +01:00
Bernhard Voelker
71556793c1 tests: avoid FP from 'find -files0-from DIR' on certain platforms
On most modern systems like GNU/Linux, read(2)-ing from a directory file
descriptor will fail with EISDIR, but it succeeds e.g. on GNU/Hurd and
AIX-7.1/AIX-7.2.

tests/find/files0-from.sh: Skip the test case excercising a directory
argument for the -files0-from option when the system allows reading
from a directory.
2021-12-31 02:13:56 +01:00
Bernhard Voelker
a8e60e7437 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2021-12-29 20:45:24 +01:00
Bernhard Voelker
9290525c77 find: fix visiting of files with inode number Zero
On GNU/Hurd, the value 0 is a valid inode number, and is e.g. used
for /dev/console and /dev/tty.  The find(1) program aborted on this
platform when the user specified the -inum test and when the search
visited such a file.

  $ find /dev/null /dev/tty -inum 40799 -printf '%i:%p\n'
  40799:/dev/null
  find: util.c:330: get_info: Assertion `p->st_ino' failed.
  Aborted

Likewise, 'find -printf %i' aborted when hitting such a file.

* find/defs.h (get_info): Remove declaration.
* find/pred.c (pred_inum): Remove the redundant assert for ST_INO
as parse_inum sets need_inum=true which ensures that the inode number
is known.
* find/util.c (get_info): Declare static, and simplify: remove the
assertions for the inode number and file type.
While at it, add condition !state.have_stat in the need_stat case
for consistency.
* tests/find/inode-zero.sh: Add test.
* tests/local.mk (all_tests): Reference it.

Problem introduced by the inum optimisation in commit 2bf001636e6.

Reported by Andrea Monaco <andrea.monaco@autistici.org> in
https://lists.gnu.org/r/bug-findutils/2021-12/msg00008.html
2021-12-29 20:36:19 +01:00
Bernhard Voelker
68979e578c find: avoid '-D stat' side effect on SELinux handling with -L or -H
With the '-D stat' debugging option turned on, 'find -L' determined the
SELinux context information as if the -L (or -H) option was not given:

  $ strace -ve getxattr,lgetxattr find -L . -maxdepth 0 -printf '%Z:%p\n'
  getxattr(".", "security.selinux", 0x55b29a2b2d40, 255) = -1 ENODATA (No data available)
  ...

  $ strace -ve getxattr,lgetxattr find -D stat -L . -maxdepth 0 -printf '%Z:%p\n'
  lgetxattr(".", "security.selinux", 0x5649c91d8d40, 255) = -1 ENODATA (No data available)
  ...

* find/parser.c (set_follow_state): Move the DebugStat handling after
the switch statement, thus eliminating the if/else.

Bug present since adding the SELinux implementation in v4.5.5-42-g1a05af6a.
2021-12-25 16:55:49 +01:00
Bernhard Voelker
b1b58be2b2 doc: add description for birth time in 'find -printf' format
find(1) supports both searching for and printing of the birth time
of a file since 2007, but the documenation lacked the description
for the latter.

* doc/find.texi (node Time Directives): Add item for %B.
(node Time Formats): Mention that the described formats also apply to
the %B directive.
* find/find.1 (-printf format): Add description of %B.
* NEWS (Documentation Changes): Mention the change.

Fixes https://savannah.gnu.org/bugs/?61327
2021-11-28 00:30:57 +01:00
Bernhard Voelker
4ddb092de6 find: allow -files0-from input file to be empty
Do no longer output an error diagnostic when the input file of
the -files0-from option is empty.

* find/ftsfind.c (process_all_startpoints): Remove error diagnostic.
* doc/find.texi (node Starting points): Adjust documentation.
* find/find.1: Likewise.
* tests/find/files0-from.sh: Adjust test.

Suggested by Stephane Chazelas in
https://savannah.gnu.org/bugs/?60383#comment11
2021-11-27 23:21:06 +01:00
Bernhard Voelker
f16272db43 tests: fix error diagnostic
* find/testsuite/config/unix.exp (safe_path): Change $PATH to PATH
as the message refers to the name of the environment variable, i.e.,
not its value.
2021-11-27 23:04:30 +01:00
Bernhard Voelker
94e91f60fb tests: skip -execdir test if PATH contains unsafe directory
* find/testsuite/find.gnu/sv-bug-27563-execdir.exp: Guard test by
'safe_path' condition to avoid false-positive failures in case the
PATH variable contains the current directory '.' ... which lets the
`find -execdir` action fail with an error diagnostic.

Reported by Paxsali <akis.kapo@googlemail.com> in
https://savannah.gnu.org/bugs/?60383
2021-11-27 23:04:16 +01:00
Bernhard Voelker
0dd5eaa329 maint: update gnulib to latest
Run 'make update-gnulib-to-latest' - thus pulling in 357 commits,
including the following which was also discussed in:
  https://savannah.gnu.org/bugs/?60383
  > test-framework-sh: remove unsafe entries from PATH

* gnulib: Update to latest.
* cfg.mk (local-checks-to-skip): Add and therefore disable sc_indent
as auto indent is too invasive for now.
* m4/mkinstalldirs.m4: Fix repeated word: s/can can/can/.  Reported by
a new rule in sc_prohibit_doubled_word.
* m4/noreturn.m4: Likewise.
* tests/init.sh: Likewise.
2021-11-27 23:03:16 +01:00
Bernhard Voelker
372cd34894 doc: improve maintainer description of the online manual
* doc/find-maint.texi (User Documentation): Add details how to
update the online manual from Git via the CVS web repository.
2021-10-20 12:09:11 +02:00
Bernhard Voelker
425e82e7b0 maint: copy online docs from 'doc/manual' to apply the GNU stylesheet
The script to copy the documentation for the web to the CVS checkout
directory took the files from 'doc'.  But as those files do not
reference the GNU stylesheet, the resulting online documentation
didn't look as fancy as usual.
Instead, copy the files from 'doc/manual' which gets created by the make
target 'web-manual'.

* build-aux/update-online-manual.sh: Call the 'web-manual' make target
instead of building the documentation files in 'doc/' explicitly.
Adjust the commands to copy the just-generated files accordingly.
Remove the PostScript format as that does not get generated by the
'web-manual' target; it is probably no longer used nowadays anyway.

* NEWS (Documentation Changes): Mention the change.

Reported by Charles Burkitt <cecburkitt@gmail.com> in
https://lists.gnu.org/r/bug-findutils/2021-10/msg00008.html
2021-10-20 12:09:01 +02:00
Renaud Pacalet
40edc25232 doc: fix typo in "Full Name Patterns"
* doc/find.texi (subsection Full Name Patterns): Change 2nd '-wholename'
to '-iwholename' to complete the enumeration of related options.
Fixes https://savannah.gnu.org/bugs/?61303

Copyright-paperwork-exempt: Yes
2021-10-10 23:47:04 +02:00
Bernhard Voelker
5768a03ddf oldfind: remove
The FTS-based find is the default for a long time; oldfind has not been
installed since 4.5.18 (2015), and was only just used in tests.

* NEWS: Document the change.
* doc/find-maint.texi (Factor Out Repeated Code): Remove mentioning of
oldfind.
* find/.gitignore (/oldfind): Remove entry.
* find/Makefile.am (check_PROGRAMS): Remove.
(oldfind_SOURCES): Remove.
* find/defs.h (struct dir_id): Remove, it was only used in oldfind.c.
(symlink_handling): Likewise.
Adjust comments wrt oldfind otherwise.
* find/oldfind.c: Remove.
* find/testsuite/config/unix.exp: Remove the code to search for and
to run tests with oldfind.
* find/testsuite/find.posix/dotdotfiles.exp: Adjust comment.
* po/POTFILES.in (find/oldfind.c): Remove entry.
* tests/find/debug-missing-arg.sh: Remove run with oldfind.
* tests/find/exec-plus-last-file.sh: Likewise.
* tests/find/execdir-fd-leak.sh: Likewise.
* tests/find/many-dir-entries-vs-OOM.sh: Likewise.
* tests/find/name-lbracket-literal.sh: Likewise.
* tests/find/printf_escape_c.sh: Likewise.
* tests/find/printf_escapechars.sh: Likewise.
* tests/find/printf_inode.sh: Likewise.
* tests/find/refuse-noop.sh: Likewise.
* tests/find/type_list.sh: Likewise.
* tests/local.mk (built_programs): Remove oldfind from list.
2021-09-20 00:14:58 +02:00
Bernhard Voelker
2c56e00ec9 find: improve readability of --help output
* find/util.c (usage): Start sentences with upper case.
Add extra newlines to put each section (operators, options, tests, and
actions) on its own line.
Move the typical generic options --help and --version to the end.
* NEWS (Documentation Changes): Mention the change.
2021-09-19 23:18:15 +02:00
Bernhard Voelker
45d8dd64d5 maint: generate ChangeLog with --no-cluster
* build-aux/gen-changelog.sh: Call gitlog-to-changelog with the
--no-cluster option.  The resulting ChangeLog reads better, because
each commit get its own date/author line.
2021-09-18 21:46:59 +02:00
Bernhard Voelker
c286752823 find: remove redundant function error_severity and avoid magic numbers
The struct state field exit_status is only set to 0 (EXIT_SUCCESS) or
to 1 (EXIT_FAILURE) throughout the code.
Therefore, remove the more complicated wrapper function error_severity
which was only used in very few cases anyway.
While at it, replace the above magic numbers by EXIT_OKAY/EXIT_SUCCESS.

* find/defs.h (error_severity): Remove.
* find/util.c (error_severity): Remove, and update all callers by replacing
it by the direct assignment to state.exit_status.
(get_statinfo): Use the above better names.
(report_file_err): Likewise.
* find/exec.c (launch): Likewise.
* find/ftsfind.c (consider_visiting): Likewise.
(find): Likewise.
(process_all_startpoints): Likewise.
(main): Likewise.
* find/pred.c (pred_delete): Likewise.
(pred_empty): Likewise.
(match_lname): Likewise.
(pred_xtype): Likewise.
* find/print.c (do_fprintf): Likewise.
2021-09-18 21:46:04 +02:00
Bernhard Voelker
e4a1915029 maint: fix typos in comments
* find/tree.c (get_expr): Add missing closing paren.
* find/util.c (insert_primary): s/insure/ensure/
(fatal_nontarget_file_error): s/isssue/issue/
* xargs/xargs.c (XargsStatusValues): s/exites/exited/
2021-09-18 21:45:44 +02:00
Bernhard Voelker
a5659a42fa tree.c: avoid segfault with closing parenthesis ')' after -files0-from
Prompted by the following warning of GCC-11.1.1:

  tree.c: In function 'get_expr':
  tree.c:140:31: warning: dereference of NULL 'prev_pred' [CWE-476] \
  [-Wanalyzer-null-dereference]
    140 |       if ((UNI_OP == prev_pred->p_type
        |                      ~~~~~~~~~^~~~~~~~

Former versions of find are not vulnerable to this, because a closing
parenthesis ')' without anything before was treated as a pathname
rather than an option.
But this is possible now with the recent introduction of the -files0-from
option (see commit 11576f4e6a) - yet still an invalid invocation.
Reproducer for a crash:
  $ find -files0-from FILE ')' -print
  Segmentation fault (core dumped)

In the similar case when the user didn't specify any action, and find(1)
adds the default action via '( user-expr ) -print', the error diagnostic
was very confusing, too:
  $ find -files0-from FILE ')'
  find: invalid expression; empty parentheses are not allowed.

* find/tree.c (get_expr): Handle the cases when there's no predicate
before CLOSE_PAREN, and output a useful error diagnostic.
* tests/find/files0-from.sh: Add a test case for it.
2021-08-18 08:36:37 +02:00
James Youngman
70aede7af9 Fix Savannah bug 60823: unescaped `@' in find.texi code example. 2021-06-25 19:30:04 +01:00
Bernhard Voelker
11576f4e6a find: add -files0-from option
* bootstrap.conf (gnulib_modules): Add argv-iter and same-inode.
* find/defs.h (struct options): Add files0_from and ok_prompt_stdin
members.
* find/ftsfind.c (argv-iter.h, same-inode.h, xalloc.h): Add #include
for gnulib headers.
(process_all_startpoints): Change loop over starting point arguments
to a loop using the argv_iter gnulib module.
* find/parser.c (parse_table): Add option.
(parse_files0_from): Declare and define function.
(insert_exec_ok): Set options flag ok_prompt_stdin to true for
the -ok and -okdir action.
* find/util.c (usage): Add new option.
(set_option_defaults): Initialize new struct members.
* doc/find.texi (node Starting points): Add new section describing
the regular processing of starting points, and that with the new
option.  Also mention in the description of -ok and -okdir that they
conflict with the new option.
* find/find.1: Document the new option here as well.
* tests/find/files0-from.sh: Add test.
* tests/local.mk (all_tests): Reference it.
* NEWS (New features in find): Mention the new option.
2021-05-08 14:13:36 +02:00
Bernhard Voelker
9ec8970ce7 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2021-05-08 14:13:26 +02:00
Bernhard Voelker
80c618ca81 maint: fix typo in comment
* xargs/testsuite/xargs.posix/rc-125.exp: s/compinent/component/
2021-05-04 22:17:13 +02:00
Bernhard Voelker
ffe13fdfd4 README: add GNU Project notice
* README: Add section to attract more people towards the GNU project.
Inspired by a suggestion from Jose E. Marchesi <jemarch@gnu.org> on
the gnu-prog-discuss mailing list.
2021-05-04 22:17:06 +02:00
Bernhard Voelker
6a56f165c5 maint: fix typo in comments in parser.c
* find/parser.c: s/fnd/find/; s/consiming/consuming/
2021-04-23 02:28:36 +02:00
Andrew Gaul
caa038677b updatedb: exclude s3fs filesystems by default
s3fs is a popular way to access S3-compatible object storage.
Its users have reported many bugs being surprised that updatedb crawls
these remote storage systems which causes poor performance:
https://github.com/s3fs-fuse/s3fs-fuse/issues?q=is%3Aissue+updatedb

* locate/updatedb.sh (PRUNEFS): Add 'fuse.s3fs'.

Copyright-paperwork-exempt: Yes
2021-02-23 14:36:43 +01:00
Bernhard Voelker
bb0c81f66b doc: show environment variables in a consistent style
In manual pages, set environment variables in bold;
in the texinfo manual, use the @env{} macro consistently.
Additionally, talk about PATH instead of $PATH in all manuals.

* doc/find.texi: Do the above.
* find/find.1: Likewise.
* NEWS (Documentation Changes): Mention the fix.

Reported by Helge Kreutzmann in
https://savannah.gnu.org/bugs/?59963
2021-01-31 19:18:11 +01:00
Helge Kreutzmann
7ed26e1731 find.1: fix some formatting issues
* find/find.1 (Safer `...` approach): When referring to stat(2), change
the formatting so that only the function name 'stat' is set in bold,
not the '(2)'.
(Pruning ...): Change formatting of the tilde backup suffix in the example
to use simple quoting without additional markup.

Fixes https://savannah.gnu.org/bugs/?59963

Copyright-paperwork-exempt: Yes
2021-01-31 19:18:01 +01:00
Bernhard Voelker
b6783f8470 xargs.1: clarify 'echo' as the default command
The default command changed from '/bin/echo' to 'echo' in version 4.5.11,
but the commit 804ff7b90e only adjusted the Texinfo manual.

* xargs/xargs.1 (.SH DESCRIPTION): Change the default command here
in the man page as well.
2021-01-31 12:17:55 +01:00
Bernhard Voelker
692800525b maint: post-release administrativa
* NEWS: Add new dummy release header.
2021-01-09 20:14:50 +01:00
Bernhard Voelker
b38464865a build: fix linking on AIX7.2
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.
2021-01-09 17:06:23 +01:00
Bernhard Voelker
192c5b2f0c NEWS: update before release
* NEWS: Prepare for the 4.8.0 release: minor re-ordering, and update
entries with bug numbers.
2021-01-09 17:06:15 +01:00
Bernhard Voelker
325422e668 maint: fix GCC format attribute of checked_fprintf
* gnulib-local/lib/gcc-function-attributes.h: Rename
_GL_ATTRIBUTE_FORMAT_PRINTF to _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
following gnulib's change:
https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=387d654c
* find/print.c (checked_fprintf): Use it.
2021-01-09 13:48:20 +01:00
Bernhard Voelker
8e1ffd8186 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'.  Let's use this latest version
for the imminent 4.8.0 release.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2021-01-09 13:41:46 +01:00
Andreas Metzler
ee402bdd3a xargs: warn on conflicting options -L, -I, -n
* xargs/xargs.c (warn_mutually_exclusive): Add function to output the
new warning diagnostic.
(main): Call the above new function in order to show a warning message
if conflicting options (-L -l -I -i -n) are specified.
* xargs/xargs.1: Explicitly document the fact that -L -l -I -i -n
options are mutually exclusive and how xargs behaves when more than one
of these options are specified.
* doc/find.texi (node Conflicting xargs options): Likewise, add this
section with examples.
* xargs/testsuite/config/unix.exp (xargs_start): Replace the full path
of the xargs executable in the stderr output file by its basename.
* xargs/testsuite/xargs.gnu/P3-n1-IARG.xe: Add file containing the
expected output with the new warning diagnostic.
* xargs/testsuite/xargs.posix/L2-n2.xe: Likewise.
* xargs/testsuite/xargs.posix/rc-123.xe: Likewise.
* xargs/testsuite/xargs.sysv/l1n4.xe: Likewise.
* xargs/testsuite/xargs/testsuite/xargs.gnu/P3-n1-IARG.exp: Ensure the
error diagnostic is in C locale to avoid false positives in other locales.
* xargs/testsuite/xargs.posix/L2-n2.exp: Likewise.
* xargs/testsuite/xargs.posix/rc-123.exp: Likewise.
* xargs/testsuite/xargs.sysv/l1n4.exp: Likewise.
* tests/xargs/conflicting_opts.sh: Add test coverage for combinations
of the mutually exclusive options -I -L and -n.
* xargs/testsuite/Makefile.am (EXTRA_DIST_EXP): Reference the new tests.
(EXTRA_DIST_XO): Reference the new *.xo files.
(EXTRA_DIST_XE): Reference the new *.xe files.
* NEWS (Improvements): Mention the change.

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>

Discussed at https://savannah.gnu.org/bugs/?52137
Duplicate of https://savannah.gnu.org/bugs/?58156
2021-01-07 18:28:00 +01:00
Bernhard Voelker
62b59ea8b7 maint: avoid warning for printing pid_t on Solaris 11
The type pid_t is defined as long on Solaris 11.  Therefore, GCC
issued a -Wformat warning there when attempting to print as %d.

* find/exec.c: (launch): When writing the debug message, treat child_pid
as the wider long type.
2021-01-07 01:20:29 +01:00
Bernhard Voelker
21e23d1e60 tests: avoid FP on Solaris 11
'ls -i' outputs leading blanks before the inode number on Solaris 11.
The 'exp' reference file should not contain them.

* tests/find/printf_inode.sh (make_canonical): Strip off leading
blanks.
2021-01-07 01:20:22 +01:00
Bernhard Voelker
1b38632207 doc: avoid overfull \hbox issues in find.texi
"Overfull \hbox" results lines exceeding the page width, and therefore
may not even be readable.  At least they are ugly.

* doc/find.texi (node O_NOFOLLOW): Break long example lines into
the next lines.  While at it, update the version in that example to
4.8.0 (in good faith we'll have it in 2021), because we shouldn't
have a "*-git" version there.
2021-01-07 01:20:13 +01:00
Bernhard Voelker
75dd3bbfe2 pred.c: remove unused code
* find/pred.c (struct pred_assoc): Remove.
(pred_table): Remove.
2021-01-05 18:31:46 +01:00
Bernhard Voelker
41fc1218cb xargs: mention in --help that -I splits input at newlines
* xargs/xargs.c (usage): Amend the -I description to mention that
the input is split at newlines.
* NEWS: Mention the change.

Fixes https://savannah.gnu.org/bugs/?58149
2021-01-05 16:40:22 +01:00
Bernhard Voelker
792dda71c3 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly for these two commits:

  > free-posix: Work around GCC mis-optimization bug.
  > getgroups test: Avoid warning with glibc >= 2.32 and gcc >= 10.

* gnulib: Update to latest.
2021-01-04 01:24:15 +01:00
Bernhard Voelker
1c061fb003 tests/find/used.sh: make more robust
This test was prone to false-positive errors due to sub-second rounding
issues.  Failures have been seen on openSUSE's build system.

* tests/find/used.sh: Use larger time intervals for the future access
times of the test files (compared to the '-used N' search), and adjust
the expected output accordingly.
2021-01-04 01:21:27 +01:00
Bernhard Voelker
1ca94cd43b maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:

  > maint: run 'make update-copyright'

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
2021-01-02 01:46:55 +01:00
Bernhard Voelker
c5da48bcff maint: update copyright year number ranges
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.
2021-01-02 01:46:51 +01:00
Bernhard Voelker
ddc53014ad maint: exempt 'doc/fdl.texi' from 'make update-copyright'
This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for that file.
2021-01-02 01:46:47 +01:00
Bernhard Voelker
d7ababc405 NEWS: mention the recent documentation changes
* NEWS (Documentation Changes): Document the changes of the previous
couple of man page and Texinfo manual changes.
2020-12-30 19:35:29 +01:00
Bernhard Voelker
e3a0d170fc find.1: remove vague mentioning of "Finding Files" from BUGS section
The user probably doesn't know that the reference to "Finding Files"
means to consult the Texinfo manual.  It seems to be sufficient to
note that -exec is more insecure than -execdir, so remove the reference,

* find/find.1 (.SH BUGS): Remove reference as described above.
While at it, remove the empty .P and the end of the section.
2020-12-30 19:19:40 +01:00
Andreas Metzler
7b1df8c514 find.1: fix various other issues
Namely:
- When referencing C system or library functions, refer to their
  man pages.
- Avoid oddly boldfaced ',' after a filename value.
- Remove superfluous ',' in the description of %h.
- Avoid extra space before comme after a boldfaced value.

* find/find.1: Do the above.

Reported by Helge Kreutzmann in
https://savannah.gnu.org/bugs/?59745
2020-12-30 19:19:38 +01:00
Bernhard Voelker
8dd1c99cc0 find.1: avoid confusing brackets a sentence
Two side notes in brackets in one sentence are disturbing the
reading flow.

* find/find.1 ("-exec command {} +"): Avoid having two bracketed side
notes in one sentence; borrow the better description from the Texinfo
manual.

Reported by Helge Kreutzmann in
https://savannah.gnu.org/bugs/?59745
2020-12-30 19:19:35 +01:00
Bernhard Voelker
9b7edc6884 doc: minor grammar change about a change in the past
In the description of -name patterns matching "hidden" files, i.e.,
those beginning with a dot, avoid talking in the future.
The change was back in version 4.2.2.
Maybe we should drop this hint about historic behavior at all.

* doc/find.texi (Base Name Patterns): Remove the word "will".
* find/find.1 (.SH STANDARDS CONFORMANCE): Likewise.
(.SH HISTORY): Likewise.
2020-12-30 19:19:32 +01:00
Bernhard Voelker
9302afb984 find.1: improve formatting of EXAMPLES section
The EXAMPLES sesction was hard to read because it was not clear to
which sentence a sample command belonged.  Use '.SS' and '.IP' markup,
and also indent the sample commands nicer.
Furthermore, change the formatting of file names as italice consistently.
Avoid empty lines, by either explicitly marking as empty via '.', or
by adding the invisible zero-width character '\&'.

* find/find.1 (.SH EXAMPLES): Do the above.
2020-12-30 19:19:22 +01:00
Bernhard Voelker
0e82bbc40c find.1: fix and improve some more markups
Mark whitespace in commands as non-breakable in more cases to avoid
unwanted hyphenation in the middle of commands.  For this to work,
some cases need to have some consecutive lines joined into one '.B'
or '.BR', the latter may require quoting the first argument within "...".

* find/find.1: Do the above.
(.IP -path): Improve indentation using '.in +4m', and set filename
as italic.
(.BR "ls -l"): Escape the minus of the option.
(.BR "\-size\ \-1\|048\|576c"): Add space before dot '.', the 2nd arg.
(.B \-exec ... \e+): No need to escape '+': remove '\e'.
(.B \-execdir ... \e+): Likewise.
(POSIXLY_CORRECT): Set the strings '+zzz' and '/zzz' in the -perm
description as italic.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
ee76276833 find.1: set filenames in italics
man-pages(7) says:
  Filenames [...] are always in italics, except in the SYNOPSIS
  section, [...]

Set filenames in italics, respectively change from boldface to italics.
While at it, mark whitespaces in commands as non-breakable via '\ '
to avoid unwanted hyphenation in the middle of commands.

* find/find.1 (-regex): Do the above.
(-exec,-execdir,-fprint): Likewise.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
37079c08f2 doc: avoid starting sentences with an option
A sentence starting with an option looks odd:
  "... starting-points.  -maxdepth 0 means only apply ..."

* doc/find.texi (-maxdepth): Add "Using " to avoid having an option
at the start of the sentence.
(-mindepth): Likewise.
* find/find.1: Likewise.
While at it, mark the whitespace as non-breakable via '\ '.

Reported by Helge Kreutzmann in
https://savannah.gnu.org/bugs/?59745
2020-12-30 19:11:18 +01:00
Bernhard Voelker
5582094307 locate.1: improve formatting in BUGS section
* locate/locate.1 (.SH "BUGS"): Set 'locate' in bold, and the -z option
in italic.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
ab3bb081ba doc: harmonize the end of the man pages
The "BUGS" section also documented how to report bugs.  This is better
done in a separate "REPORTING BUGS" section.  Add this section where
missing.  In it, redirect the user to the "How to get help" section
("#get-help") of the GNU findutils online page; also mention where
to report translation issues.

Bring the sections "SEE ALSO" and "COPYRIGHT" into the correct order,
which is: "REPORTING BUGS", "COPYRIGHT" and finally "SEE ALSO".
See 'man-pages(7)'.

The "SEE ALSO" section now refers to both the corresponding node in
the online HTML version of the Texinfo manual and lists the 'info' command.
Sort the entries referring to other man pages: first by their manual
section numbers, then alphabetically.

While at it, add an empty line (directive '.') before all '.SH' section
headers.

* find/find.1: Do the above.
* locate/locate.1: Likewise.
* locate/locatedb.5: Likewise.
* locate/updatedb.1: Likewise.
* xargs/xargs.1: Likewise.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
90e60a2003 updatedb.1: avoid Texinfo macro in man page
* locate/updatedb.1 (DESCRIPTION): Replace @samp{} macro by .B setting,
introduced in commit v4.6.0-44-g89ec0211.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
2ac3be4c99 xargs.1: remove deprecated .PD macro
Use of the .PD macro is discouraged, see:
https://man7.org/linux/man-pages/man7/groff_man_style.7.html

* xargs/xargs.1 (.SH OPTIONS): Remove all uses of the .PD macro.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
83ca662d42 xargs.1: improve indentation of list of exit statuses
* xargs/xargs.1 (EXIT STATUS): Use .RS + .IP + .RE to get a nicer
indentation of the list of exit values.
2020-12-30 19:11:18 +01:00
Bernhard Voelker
dc1a69f6dc maint: use gnulib *_safer functions consistently
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.
2020-12-02 02:14:00 +01:00
Bernhard Voelker
160e2f8258 maint: use more *-safer gnulib modules
See section "Handling closed standard file descriptors" in the gnulib
manual.

* bootstrip.conf (gnulib_modules): Add fcntl-safer, openat-safer
and unistd-safer.
* find/exec.c: Include "fcntl--.h" to use the *-safer variant of open()
or openat().
* find/pred.c: Likewise.
* locate/locate.c: Likewise.
* xargs/xargs.c: Likewise, and include "unustd--.h" to use the *-safer
variant of pipe().
2020-12-02 01:12:16 +01:00
Bernhard Voelker
f65445d23c doc: relate -anewer, -cnewer, and -newer to their -newerXY equivalents
* doc/find.texi (Comparing Timestamps): Clarify that the above options
are equivalent to the options -neweram, -newercm and -newermm.

Suggested by Reuben Thomas.
2020-11-22 16:08:18 +01:00
Bernhard Voelker
cc5d59382f maint: fix bug URL in ChangeLog entry
* build-aux/git-log-fix (v4.7.0-15-g6e55ad98): Tweak ChangeLog entry
for this commit during 'make dist' to reference the bug system on
Savannah instead of that on debbugs.gnu.org.

Reported by Axel Beckert in
    https://sv.gnu.org/bugs/?57291
2020-10-30 11:53:05 +01:00
Andreas Metzler
003c590ae8 updatedb.1: fix formatting
* locate/updatedb.1 (--prunepaths): Use apostrophe instead of acute accent.
2020-10-25 09:53:11 +01:00
Andreas Metzler
a9ac804528 find.1: fix typo "onthe"
* find/find.1 (-quit): Change to "on the".
2020-10-25 09:49:03 +01:00
Bernhard Voelker
fda5f28453 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly for these two commits:
  > selinux-at, selinux-h: port to SELinux 3.1
  > parse-datetime: Make the build rule work with parallel 'make'.

* gnulib: Update to latest.
2020-10-21 09:11:32 +02:00
Bernhard Voelker
51f2b26edd build: disable -Wformat-nonliteral
GCC-10.2.1 complains about format strings it was not able to check:

  print.c:529:11: warning: format not a string literal, format string not \
                           checked [-Wformat-nonliteral]
    529 |           strftime (altbuf, buf_size, timefmt, &altered_time);
        |           ^~~~~~~~

* configure.ac (compiler-warnings): Add -Wformat-nonliteral.
2020-10-19 23:58:14 +02:00
Bernhard Voelker
68c1a06f34 find: avoid deprecation warnings with libselinux 3.1
Libselinux 3.1 deprecates typedef 'security_context_t', leading to
several warnings like:

  defs.h:330:5: warning: ‘security_context_t’ is deprecated [-Wdeprecated-declarations]
    330 |     security_context_t scontext; /* security context */
        |     ^~~~~~~~~~~~~~~~~~

Replace all matches of 'security_context_t' by 'char *'.

* find/defs.h (struct predicate.args.scontext): Change to 'char *'.
(x_getfilecon): Adjust type of 3rd parameter.
* find/parser.c (fallback_getfilecon): Adjust type of 3rd parameter.
(optionh_getfilecon): Likewise.
(optionl_getfilecon): Likewise.
(optionp_getfilecon): Likewise.
* find/pred.c (pred_context): Adjust type of 'scontext' variable.
* find/print.c (do_fprintf): Likewise.
2020-10-19 23:57:22 +02:00
Bernhard Voelker
b818a7086b find: add error handling for strdup in the '-print %h' case
* find/print.c (do_fprintf): Change strdup call to xstrdup to ensure
proper error handling.  Reported by Infer.

Fixes https://sv.gnu.org/bugs/?59133
2020-10-19 19:02:07 +02:00
Kamil Dudka
efa4554930 doc: avoid misunderstanding of '-printf %Ak' description
* find/find.1 (-printf): Make it clear that the list of conversion
specification characters of '%Ak' is incomplete; refer to the
strftime() documentation.  While at it, document the F conversion
character which yields 'yyyy-mm-dd'.
* doc/find.texi (Time Formats): Likewise.
* NEWS: Mention the improvement.

Suggested in https://bugzilla.redhat.com/1882695
2020-10-07 00:31:16 +02:00
Bernhard Voelker
2035073c76 find: improve '-D exec' debug output
Previously, 'find -D exec' only gave helpful output right before the
invocation of complete_pending_execdirs, i.e., not for every child
execution of the -exec, -execdir, -ok and -okdir predicates.
Make the 'exec' debug output more useful and consistent.

* find/exec.c (launch): Output DebugExec diagnostics right before spawning
the child process, and after getting its exit status (unless we already
have regular error diagnotstic anyway, e.g. if the child has been
terminated by a signal).
* find/ftsfind.c (show_outstanding_execdirs): Remove.
(find): Remove invocation of the above function, and simplify.
* NEW: Mention the improvement.

Suggested by Philip Rowlands in https://sv.gnu.org/bugs/?59083
2020-09-17 00:39:13 +02:00
Bernhard Voelker
9f950b67bc find.1: use consistent quoting in example
* find/find.1 (EXAMPLES): Use (aq...(aq consistently around the -exec
arguments containing the placeholder '{}/...'.

Suggested in https://sv.gnu.org/bugs/?59012
2020-09-17 00:37:50 +02:00
Bernhard Voelker
319a65893c maint: fix typo in comment
* find/util.c: s/insure/ensure/
2020-09-16 23:52:37 +02:00
Bernhard Voelker
2c15992f51 doc: add examples for -maxdepth, -mindepth
* doc/find.texi (-maxdepth): Add examples.
(-mindepth): Reference them.

Suggested by 積丹尼 Dan Jacobson <jidanni@jidanni.org> in
https://lists.gnu.org/r/bug-findutils/2020-07/msg00006.html
2020-08-14 00:09:22 +02:00
Bernhard Voelker
0da0554e49 doc: clarify that 'find -perm +MODE' is unrelated to umask
* doc/find.texi (Test -perm pmode): Do the above.
* NEWS: Mention the change.

Reported by Mohamed Akram in
    https://sv.gnu.org/bugs/?58654
2020-08-14 00:09:17 +02:00
Bernhard Voelker
b9ddd2bca1 doc: enhance description of tests accepting numeric arguments in find.1
* find/find.1 (TESTS): Improve the description of tests accepting a
numeric argument that they match "less than, more than or exactly" the
given 'n', thus helping the user to remind to use '-n', '+n' or a bare
'n' (as decribed at the top).
* doc/find.texi (section find Expressions): Move section from chapter
"Introduction" to "Finding Files".  The description about the general
syntax of a find expression fits more naturally there, including the
already existing part about numeric arguments.
* NEWS: Mention the change.
Suggested in https://sv.gnu.org/bugs/?57025 .
2020-08-14 00:09:13 +02:00
Bernhard Voelker
2faa781ec9 find.1: clarify double dash '--' option
* find/find.1: Document that the '--' option is not much useful for
find, because if a path name following that would start with a `-',
then find would treat it as an expression argument.
* NEWS: Mention it.

Reported by Andreas Metzler <ametzler@bebt.de> in
https://sv.gnu.org/bugs/?58205
2020-08-14 00:09:09 +02:00
Bernhard Voelker
f2878945ac doc: display version of the GNU findutils on the title page
The first page of the Texinfo documentation should display the package
version the documentation corresponds to.  Also change the title
from "Finding Files" to "GNU Findutils ..." to better reflect the
package name.  These changes align the documentation better with
that of other GNU packages like e.g. grep.

* doc/find.texi: Do the above.  Furthermore, display the VERSION also
in the first sentence after the @direntry list.
While at it, enclose the FDL licence text in a @quotation block.
* doc/find-maint.texi: Likewise.
2020-08-14 00:09:03 +02:00
Bernhard Voelker
c0827572fd maint: explicitly copy fdl-1.3 from gnulib
* Makefile.am (update-gnulib-to-latest): Prompted by a probably
accidental difference between gnulib's fdl.texi and fdl-1.3.texi
(to be fixed in GNU standards first), change the command to
explicitly copy version 1.3 of the FDL.
* doc/fdl.texi: Update from 'gnulib/doc/fdl-1.3.texi'.

See https://lists.gnu.org/r/bug-standards/2020-08/msg00000.html
and https://lists.gnu.org/r/bug-gnulib/2020-07/msg00185.html
2020-08-14 00:08:42 +02:00
Bernhard Voelker
ce6d2b7a1b doc: change "allows to <verb>" to "allows <verb>ing"
* doc/find.texi: Use gerund after "allows".
As a side effect, this also avoids passive voice in some cases;
active voice is usually clearer.
2020-08-13 00:06:14 +02:00
Bernhard Voelker
9be67ec6f4 maint: fix typo in comment
* find/ftsfind.c (inside_dir): s/currentl/currently/
2020-08-13 00:06:06 +02:00
Bernhard Voelker
dff4077ecd doc: modernize example list of filesystem types for -fstype
* doc/find.texi (-fstype): Mention more common types.
2020-08-13 00:04:18 +02:00
Bernhard Voelker
777035bb3c doc: remove fts from configuration chapter
The corresponding configure option was removed with commit 42a28b0dfb.

* doc/find.texi (node fts): Remove section.
2020-07-20 23:47:20 +02:00
Bjarni Ingi Gislason
de3c6279f2 doc: fix warnings from "mandoc -Tlint" in man pages
mandoc: ./find/find.1:313:2: WARNING: skipping paragraph macro: PP empty
mandoc: ./find/find.1:607:1: WARNING: skipping paragraph macro: sp after PP
mandoc: ./find/find.1:606:2: WARNING: skipping paragraph macro: PP empty
mandoc: ./find/find.1:1678:2: WARNING: skipping paragraph macro: PP after SS
mandoc: ./find/find.1:2063:2: STYLE: fill mode already enabled, skipping: fi
mandoc: ./find/find.1:2302:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./find/find.1:2400:2: WARNING: skipping paragraph macro: PP empty
mandoc: ./find/find.1:2455:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./locate/locate.1:282:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./locate/locatedb.5:153:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./locate/updatedb.1:128:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./xargs/xargs.1:316:2: STYLE: fill mode already enabled, skipping: fi
mandoc: ./xargs/xargs.1:327:2: STYLE: fill mode already enabled, skipping: fi

* find/find.1: Remove superfluous paragraph macros.
Remove superfluous requests ".fi".
* locate/locate.1: Likewise.
* locate/locatedb.5: Likewise.
* locate/updatedb.1: Likewise.
* xargs/xargs.1: Likewise.
2020-06-22 21:28:02 +02:00
Bjarni Ingi Gislason
8bff322b56 doc: fix warnings from "test-groff" in man pages
Output is from: test-groff -b -mandoc -T utf8 -rF0 -t -w w -z

  [ "test-groff" is a developmental version of "groff" ]
  Input file is ././find/find.1
  <./find/find.1>:365 (macro BR): only 1 argument, but more are expected
  <./find/find.1>:380 (macro BR): only 1 argument, but more are expected
  <./find/find.1>:1494 (macro BR): only 1 argument, but more are expected
  <./find/find.1>:1496 (macro BR): only 1 argument, but more are expected
  <./find/find.1>:1513 (macro BR): only 1 argument, but more are expected
  [...]
  Input file is ././locate/locate.1
  troff: <./locate/locate.1>:167: warning: trailing space

* find/find.1: Use a one-font (single letter) macro for a single argument.
* locate/locate.1: Remove a trailing space in a "string".
2020-06-22 21:23:36 +02:00
Bernhard Voelker
7c72d72838 doc: improve section 'Hard links' and fix 'find -L -samefile' description
* doc/find.texi (Hard links): Clarify that 'find -L -samefile FILE'
returns both hard links and symbolic links to FILE, and why.
Further attempt to improve the wording of the whole section by
avoiding wording like "you can ...", and instead describing more
how find works and behaves for the -samefile, -inum and -links
options.  Especially mention that -inum potentially returns files
with the given inode number but yet are no hard links per definition:
this happens if they are on a different file system, i.e., if they
have a different device number.

Fixes https://sv.gnu.org/bugs/?58458
2020-06-21 19:40:11 +02:00
Bernhard Voelker
f066937370 maint: copy FDL from gnulib instead of using it as module
Since the previous gnulib update, bootstrap outputs this warning:

  Notice from module fdl:
    Don't use this module! Instead, copy the referenced license file \
    into your version control repository.

See gnulib commit:
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=88fc5afbccc9

* bootstrap.conf (gnulib_modules): Remove 'fdl'.
* doc/fdl.texi: Add file as a copy of 'gnulib/doc/fdl.texi'.
* doc/.gitignore (/fdl.texi): Remove to no longer ignore that file.
* Makefile.am (update-gnulib-to-latest): Add command to sync the file.
While at it, add the command to show the git status for
'tests/init.sh' as well.
2020-05-25 18:05:55 +02:00
Bernhard Voelker
b72ba2e332 maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly for some performance
improvement for FTS with -L:

  > Tune fts for FTS_LOGICAL+FTS_NOSTAT

* gnulib: Update to latest.
2020-05-25 18:05:05 +02:00
Bernhard Voelker
2915d367aa maint: fix typo in comment
* find/tree.c (do_arm_swaps): s/evauating/evaluating/.
2020-05-23 17:05:13 +02:00
Bernhard Voelker
c1dd7c8a94 maint: bootstrap gnulib with --symlink
* bootstrap.conf (gnulib_tool_option_extras): Add --symlink option.
2020-04-22 19:38:19 +02:00
Bernhard Voelker
7642d172e1 find: fix -used predicate
* find/pred.c (pred_used): Reverse the check for the delta between
the atime and ctime of the file to accomodate to how pred_timewindow
is working.
Also return false if atime < ctime.
Bug introduced in FINDUTILS_4_3_3-1 in commit a4718831e17.
* tests/find/used.sh: Add test.
* tests/local.mk (all_tests): Reference the test.
* NEWS (Bug Fixes): Mention the fix.

Reported by Martin Schulte in
<https://lists.gnu.org/r/bug-findutils/2019-11/msg00010.html>
2020-04-22 19:35:13 +02:00
Bernhard Voelker
abec46d204 maint: update gnulib to latest, to avoid FTS crash on XFS
Run 'make update-gnulib-to-latest', mainly to pull in a fix for FTS
to avoid a crash when traversing a heavily changed XFS file system:

> fts: remove NOSTAT_LEAF_OPTIMIZATION

* NEWS (Bug fixes): Mention the fix.
* gnulib: Update to latest.
* bootstrap: Sync from gnulib/build-aux/bootstrap.

Discussed at:
<https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html>
2020-04-19 09:17:29 +02:00
Kim Thor
44e995915f xargs.1: fix grammar issue
* xargs/xargs.1 (BUGS): Remove extra "the".
Fixes https://sv.gnu.org/bugs/?58193

Copyright-paperwork-exempt: Yes
2020-04-17 08:52:24 +02:00
Bernhard Voelker
e6149e4014 build: remove 'withfts.m4' from distribution
* m4/Makefile.am (EXTRA_DIST): Remove 'withfts.m4'; that file was removed
with commit 42a28b0dfb.
2020-03-20 08:18:41 +01:00
Bernhard Voelker
73734a24cf maint: fix clean rule in doc/ directory
'make clean' removed the file 'doc/find.texi' which is version controlled.

* doc/Makefile.am (CLEANFILES): Remove 'find.texi' to avoid that the
'clean' target removes that file.
Bug introduced in commit v4.6.0-228-g755a22b9.
2020-03-15 11:37:03 +01:00
Bernhard Voelker
6154e419b9 maint: ensure .deps/ in the project root is ignored by git
* .gitignore (.deps/): Add entry.
* find/.gitignore (/.deps/): Remove here.
* lib/.gitignore: Likewise.
* locate/.gitignore: Likewise.
* xargs/.gitignore: Likewise.
2020-03-15 11:07:13 +01:00
Bernhard Voelker
42a28b0dfb build: remove --without-fts configure option
Trying to use this option lead to this error since v4.5.17-6-gfc260795:
  configure: error: Using --without-fts is not longer supported

* configure.ac (FIND_WITH_FTS): Remove.
* m4/withfts.m4: Remove file.
* NEWS: Document this build-related change.
2020-03-15 10:57:15 +01:00
Bernhard Voelker
8f4dd0f712 doc: prefer https:// over http:// in more places
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.
2020-03-15 10:54:36 +01:00
Bernhard Voelker
9282ea9e16 maint: fix issue in syntax-check
* cfg.mk (sc_prohibit_colon_redirection): Don't expect `|` to denote
the pipe character in git grep.
Sync fix from:
https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=0e2d4e1425
2020-03-14 19:58:03 +01:00
Bernhard Voelker
7d226e6a45 maint: add sc_prohibit_or_fail syntax-check
The shell tests should use `cmd ... || fail=1` for detecting errors.
Add a syntax-check to ensure they don't use `cmd ... || fail` which
is a noop.

* cfg.mk (sc_prohibit_or_fail): Add syntax-check, borrowed from coreutils.
2020-03-14 19:51:33 +01:00
Peter Frost
10635bb14a doc: fix typo
* doc/find.texi (Name Directives): s/eample/example/
* find/find.1 (EXAMPLES): Likewise.

Fixes https://sv.gnu.org/bugs/?57807

Copyright-paperwork-exempt: Yes
2020-02-14 14:00:08 +01:00
Hugo Gabriel Eyherabide
ed1496f176 find.1: fix grammar issue in the description of -P
* find/find.1 (-P): Add "about".
Fixes https://savannah.gnu.org/bugs/?57775

Copyright-paperwork-exempt: Yes
2020-02-10 18:55:23 +01:00
Bernhard Voelker
2f9fff9e1f tests: avoid FP when run as root
Test 'sv-bug-54171' produced a false-positive error as 'find' would
not fail for an unreadable directory when run as root.
Migrate the test to the newer shell-based tests, and add the
'skip_if_root_' guard to avoid a false-positive.

* find/testsuite/find.posix/sv-bug-54171.exp: Remove.
* find/testsuite/find.posix/sv-bug-54171.xo: Remove.
* find/testsuite/Makefile.am (EXTRA_DIST_XO, EXTRA_DIST_EXP): Remove the
above deleted test.
* tests/find/depth-unreadable-dir.sh: Add test.
* tests/local.mk (all_tests): Reference it.

Test FP introduced in commit v4.6.0-178-gdf4610d0.
Fixes https://savannah.gnu.org/bugs/?57762
and https://bugzilla.redhat.com/1799064
2020-02-10 18:54:40 +01:00
Bernhard Voelker
28f11d689d maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to avoid a gnulib test failure.

  > tests: Avoid GCC over-optimization caused by _GL_ARG_NONNULL attributes.

* gnulib: Update to latest.

Fixes: https://sv.gnu.org/bugs/index.php?57277
2020-01-06 01:53:37 +01:00
Bernhard Voelker
15528055c5 maint: avoid error from sc_prohibit_gnu_make_extensions
Since last gnulib update, the above syntax-check rule fails:

  Error: doc/Makefile: $< in a non implicit rule
  find_mono.html: find.texi
  ...
  make: *** [maint.mk:439: sc_prohibit_gnu_make_extensions] Error 1

* doc/Makefile.am (find_mono.html): Avoid $< in plain rules.
(findutils.texi_html_node.tar.gz): Likewise.

See also: <https://lists.gnu.org/r/bison-patches/2019-05/msg00017.html>
2020-01-01 17:45:20 +01:00
Bernhard Voelker
9820a15a43 maint: adjust to split out xstrtol-error gnulib module
* bootstrap.conf (gnulib_modules): Add the new module split from xstrtol.
* locate/locate.c: Include "xstrtol-error.h" for xstrtol_fatal.
2020-01-01 17:44:30 +01:00
Bernhard Voelker
d2d6c7abfe maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:

  > maint: update copyright notices

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
2020-01-01 17:42:40 +01:00
Bernhard Voelker
f7ea96d2b8 maint: update copyright year number ranges
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.
2020-01-01 16:22:52 +01:00
Bernhard Voelker
2497c63a29 maint: add entries to 'doc/.gitignore'
* doc/.gitignore (/find.html/, /find-maint.html/): Add entries for
HTML output directories.
(/find.pdf, /find-maint.pdf): Add entries for PDF files.
(/find-maint.dvi, /find-maint.ps): Add entries for other formats.
2020-01-01 16:22:48 +01:00
Bernhard Voelker
6ee9097249 parser.c: avoid "Condition 'nflags' is always false" in parse_version
* find/parser.c (parse_version): Remove 'nflags' variable.

Found by cppcheck.
2019-11-30 21:53:37 +01:00
Bernhard Voelker
3edff92a45 maint: adjust exemption list for sc_trailing_blanks
* cfg.mk (exclude_file_name_regexp--sc_trailing_blank): Remove the
regex part for 'find/testsuite/test_escapechars.golden' as that file
was removed in commit v4.6.0-214-g3f6b28c4.
2019-11-25 22:39:42 +01:00
Bernhard Voelker
6e55ad98b1 xargs: avoid trailing blank in -t,--verbose output
'xargs -t' had a trailing blank in the output, e.g.:
  $ echo a b | xargs -t 2>&1 | cat -e
  echo a b $
  a b$
POSIX mandates that the constructed command line "shall be written
to standard error, as it will be invoked", so avoid outputting the
trailing blank.
FWIW: This change still plays well with -p,--interactive, because
POSIX says to just output "?..." as a prompt after the -t output.

* xargs/xargs.c (print_args): Instead of outputting a blank after each
cmd_argv[i], output a blank before each item unless for the first one.
* tests/xargs/verbose-quote.sh: Remove trailing blanks from expected
stderr.
* xargs/testsuite/xargs.gnu/space-t-0.xe: Likewise.
* xargs/testsuite/xargs.sysv/empty-t.xe: Likewise.
* xargs/testsuite/xargs.sysv/empty_def-t.xe: Likewise.
* xargs/testsuite/xargs.sysv/s25-t.xe: Likewise.
* xargs/testsuite/xargs.sysv/space-t.xe: Likewise.
* xargs/testsuite/xargs.sysv/trace.xe: Likewise.
* NEWS: Mention the change.

Reported by 積丹尼 Dan Jacobson <jidanni@jidanni.org> in:
    https://bugs.gnu.org/?57291
2019-11-25 22:39:33 +01:00
Bernhard Voelker
a0169f9aac doc: use "symbolic link" instead of "symlink" consistently
* doc/find.texi (-printf): Change the shorter term "symlink" to
"symbolic link" for consistency with the rest of the Texinfo manual
and the man page.
(%Y): Likewise.
* find/find.1 (%Y): Likewise.

Suggested by 積丹尼 Dan Jacobson <jidanni@jidanni.org> in:
  https://lists.gnu.org/r/bug-findutils/2019-11/msg00003.html
2019-11-13 00:17:36 +01:00
Bernhard Voelker
4f8b9c3bc8 maint: fix typos in configure.ac
* configure.ac: Fix 2 typos in comments.
2019-09-13 20:06:48 +02:00
Bernhard Voelker
6975a373c1 doc: fix the command for pushing the tag in the release instructions
* doc/find-maint.texi (Making Releases): When pushing the tag, refer to
the remote name 'origin'.  Also avoid the --tags option because that
would publish all local tags, i.e., not only the given one.  Use RELTAG
instead of 'the-tag-name'.
2019-09-06 21:55:44 +01:00
Bernhard Voelker
74d0afd581 tests: output PATH value in log files
Adjust the PATH variable for the test setup a bit later, i.e., after
'tests/init.sh' has turned on 'set -x', so that the PATH value appears
in the test logfiles.

* init.cfg (fu_path_prepend_): Wrap immediate path_prepend_ call into
this new function.
* tests/find/debug-missing-arg.sh: Use it - right after sourcing in
'tests/init.sh'.
* tests/find/exec-plus-last-file.sh: Likewise.
* tests/find/execdir-fd-leak.sh: Likewise.
* tests/find/many-dir-entries-vs-OOM.sh: Likewise.
* tests/find/name-lbracket-literal.sh: Likewise.
* tests/find/printf_escape_c.sh: Likewise.
* tests/find/printf_escapechars.sh: Likewise.
* tests/find/printf_inode.sh: Likewise.
* tests/find/refuse-noop.sh: Likewise.
* tests/find/type_list.sh: Likewise.
* tests/misc/help-version.sh: Likewise.
* tests/sample-test: Likewise.
* tests/xargs/verbose-quote.sh: Likewise.
2019-09-03 21:13:30 +02:00
James Youngman
617e1392d2 doc: add missing newline in find.1, making some text non-bold. 2019-09-01 22:54:05 +01:00
James Youngman
a55895c183 doc: Add instructions on how to access source via git in README. 2019-09-01 22:43:44 +01:00
James Youngman
855dbdadbf find: Clarify description of %f and %h.
Fix https://savannah.gnu.org/bugs/index.php?35253
* doc/find.texi (Name Directives): Clarify description of %f and %h.
* find/find.1 (-printf): Likewise.
* NEWS: mention this change.
2019-09-01 14:55:57 +01:00
James Youngman
45d1608eb4 Fix Savannah bug 54730: additional examples for -quit.
* doc/find.texi (-quit): add another example.
* find/find.1 (-quit): add another example.
(-exec): Point out that -exec my-command {} + -quit
may not result in my-command being run.
(EXAMPLES): add an example for -quit.
* NEWS: mention this change.
2019-09-01 12:59:12 +01:00
Andreas Metzler
c31ef28989 Fix testsuite error on hurd and BSD related to ln
* find/testsuite/find.gnu/samefile-p-brokenlink.exp: Pass "-P" option to
enforce generation of hard link to symlink. link() behavior is
"implementation-defined" by POSIX and BSD/hurd chose a different behavior
than Linux.
This fixes http://bugs.debian.org/826357, https://savannah.gnu.org/bugs/index.php?48135
Also fix ln -s invocation to generate a valid symlink.
* NEWS: Mention that Savannah bug #48135 is fixed.
2019-09-01 09:22:56 +01:00
James Youngman
13c1d7faa5 gnulib: update to current. 2019-08-30 20:14:02 +01:00
James Youngman
416113ee3f gnulib: use nstrftime module instead of strftime.
These modules are actually synonymous, it's just that the module name
strftime is deprecated in favour of nstrftime.
2019-08-30 19:57:51 +01:00
James Youngman
7ada6ad941 doc: updates to release instructions.
Some additions to the release instructions:
 - Run bootstrap to update .po files
 - Enable fatal compiler warnings when performing the final build
 - Set RUN_EXPENSIVE_TESTS when running tests
 - Point out that configure.ac no longer contains the version.
 - Add a new Savannah "Release" value for the new release.
2019-08-30 19:46:43 +01:00
Bernhard Voelker
9ad78c90c7 find: fix minor memory leak in sharefile handling
When sharefile_fopen fails to open the given file, e.g. due to the lack
of permissions, then the name of the file is not freed.

$ valgrind -v --leak-check=full find/find . -maxdepth 0 -fprint /
...
==28139== 2 bytes in 1 blocks are definitely lost in loss record 2 of 11
==28139==    at 0x483677F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28139==    by 0x4923DBA: strdup (strdup.c:42)
==28139==    by 0x409E80: sharefile_fopen (sharefile.c:150)
==28139==    by 0x40CCA0: open_output_file (parser.c:3390)
==28139==    by 0x40CFA8: parse_fprint (parser.c:1010)
==28139==    by 0x408341: build_expression_tree (tree.c:1295)
==28139==    by 0x403AF7: main (ftsfind.c:712)

This memory leak is a trivial issue because find will terminate anyway
due to the error.

* find/sharefile.c (sharefile_open): Call entry_free instead of simple
free to also free the strdup-ed filename.
2019-08-30 00:24:27 +02:00
Bernhard Voelker
fe33eaa06c maint: post-release administrativa
* NEWS: Add new dummy release header.
2019-08-29 22:46:51 +02:00
Bernhard Voelker
de9f5bf4b2 NEWS: update version to 4.7.0 2019-08-29 21:49:58 +02:00
Bernhard Voelker
333ce56380 find: improve warning when global option is specified after other argument
Global options like -maxdepth should be specified before other arguments
like tests, operators, etc.  The corresponding warning diagnostic was
obviously misleading, so that at least the French and the German
translations - and maybe even the English original - were not well
understood by users.

* find/parser.c (found_parser): Improve diagnostic, thus hopefully
also avoiding translation issues.  Remove extra newline.

Fixes https://sv.gnu.org/bugs/?56820
2019-08-29 21:10:57 +02:00
James Youngman
278e8fbb12 doc: add some previously-missing steps to the release instructions.
doc/find-maint.texi: point out that the version number in
configure.ac also needs to be updated.  Point out that if you did the
release update on a branch it needs to be merged and in any case that
these changes need to be pushed to origin/master.  Also prompt the
maintainer to check that the FTP upload actually worked.
2019-08-29 19:55:05 +01:00
James Youngman
0acf198f36 Fix missing word in NEWS.
NEWS: add missing "the" in description of GNU_FINDUTILS_FD_LEAK_CHECK
for xargs.
2019-08-29 19:44:07 +01:00
Bernhard Voelker
eeefd1dc72 xargs: in -t,-p output, quote the command to be executed when needed
To improve readability for the user, xargs(1) shall quote each part
of the command to be executed when printing it to stderr, i.e. for
the -t (--verbose) and -p (--interactive) options.  Example:
  $ echo "some file" | ../xargs -p -I'{}' rm '{}.c' '{}.o'
  rm 'some file.c' 'some file.o' ?...

* xargs/xargs.c (print_args): Apply "shell-escape" quoting.
* xargs/testsuite/xargs.gnu/space-t-0.xe: Adjust test.
* tests/xargs/verbose-quote.sh: Add test.
* tests/local.mk: Reference it.
* README (Improvements): Mention the change.
2019-07-29 08:44:29 +02:00
Bernhard Voelker
f2542a4fe3 gnulib: update to the latest
Run 'make update-gnulib-to-latest'.

* gnulib: Update.
* tests/init.sh: Sync from 'gnulib/tests/init.sh'.
2019-05-11 22:08:06 +02:00
Bernhard Voelker
c07f6924c8 maint: change from gettext to gettext-h gnulib module
This avoids this bootstrap warning:
  Notice from module gettext:
    This module is obsolete. Use the module 'gettext-h' instead to make
    your program capable of internationalization, when GNU gettext is also
    used.

* bootstrap.conf (gnulib_modules): s/gettext/&-h/
2019-05-11 21:34:26 +02:00
Bernhard Voelker
54b543a8ff maint: bump build prerequisite versions
* bootstrap.conf (buildreq): Require at least autoconf-2.59,
automake-1.11.2, and gettext-0.19.2.
2019-05-11 21:34:21 +02:00
Bernhard Voelker
9930316f51 doc: add PDF file to the online manual
* build-aux/update-online-manual.sh: Add the PDF file.
While at it, properly close the <LI> tags with </LI>.
2019-05-10 08:05:30 +02:00
Bernhard Voelker
6743fefc3a find.1: correct description about -prune when -depth is in effect
The -prune action always returns true, also if -depth is in effect.

* find/find.1 (-prune): Remove the wrong statement that -prune would
return false when -depth is given.  Furthermore, move the example down
from -path.

Reported by Cristian Zoicas in
https://lists.gnu.org/r/bug-findutils/2019-04/msg00024.html
2019-05-10 08:05:08 +02:00
James Youngman
cc130437f0 Fixes for 'make syntax-check'.
* doc/Makefile.am: Remove trailing newlines.
2019-05-05 18:53:15 +01:00
Pavel Modilaynen
5699fb78d4 xargs: use GNU_FINDUTILS_FD_LEAK_CHECK as for find
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
2019-05-05 18:10:40 +01:00
James Youngman
755a22b982 doc: add a tool for updating the online manual.
* build-aux/update-online-manual.sh: add a script (originally
written in 2005 but not previously included in the source
distribution) which automates the updating of the online manual.
* doc/Makefile.am: Add some targets useful for update-online-manual.sh.
* doc/find-maint.texi (Documentation): Explain how to check out
the web pages and how to update the findutils documentation there.
2019-05-05 17:32:05 +01:00
James Youngman
e599052685 doc: fix bug #56142 by specifying which actions inhibit the default -print
* find/find.1: specify which actions inhibit the default -print
action.
* doc/find.texi (find Expressions): Likewise.
2019-05-04 00:46:42 +01:00
Bernhard Voelker
161b838754 doc: clarify find options -newer, -anewer, -cnewer
The previous description "File was modified more recently than file."
was hard to understand without markup, e.g. over the phone.

Furthermore, the description for symbolic links as reference file was
wrong in the man page for the -anewer and -cnewer options: in fact,
find(1) always uses the mtime of the reference file.

* doc/find.texi (Comparing Timestamps): Improve the wording for the
-anewer/-cnewer/-newer options.  Use 'reference' as the argument name.
Add the note from find.1 that the -H/-L options make find(1) use
the data modification time of the file being referenced.
* find/find.1 (-anewer,-cnewer,-newer): Improve the wording, and use
'reference' as argument name.
Fix the description for -anewer/-cnewer: when -H/-L is used with a
symbolic link as reference, then find always uses the mtime of that,
not atime or ctime.

Reported by Dan Jacobson <jidanni@jidanni.org> in
https://lists.gnu.org/r/bug-findutils/2019-04/msg00002.html
2019-04-14 20:59:08 +02:00
Bernhard Voelker
235f21673c find: make pred_empty safer and avoid fd leaks
There is a small race condition between the previous stat call
and openat/fdopendir (which cannot be avoided): if the directory
got replaced by another file type, then openat would succeed but the
subsequent fdopendir would fail with ENOTDIR.  Detect this earlier
by passing the O_DIRECTORY flag.
Furthermore, the opened file descriptor was leaked in that case
(bug introduced in FINDUTILS_4_3_2-1-80-gb46b0d89 in 2007).
Later on, after a readdir error, also the directory stream was leaked
(bug introduced by myself in commit 7a6e548690b1).

* find/pred.c (pred_empty): Add more flags to the openat call,
especially O_DIRECTORY; inspired by gnulib's opendirat module.
Close the file descriptor when fdopendir failed.
Close the directory stream when readdir failed.
2019-02-09 15:57:19 +01:00
Bernhard Voelker
8ff1a199f3 build: ensure no VLA is used
Cause developer builds to fail for any use of a VLA.
VLAs (variable length arrays) limit portability.

* configure.ac (findutils_gnulib_noise_warnings): Remove as the only
suppressed warning for gnulib was -Wvla, thus enabling the warning
when configured with --enable-compiler-warnings.
(compiler-warnings-are-errors): Likewise.
(GNULIB_NO_VLA) Define, disabling use of VLAs in gnulib.  This commit
is functionally equivalent to coreutils' v8.30-44-gd26dece5d

Discussed for other GNU packages in:
https://lists.gnu.org/r/coreutils/2019-01/msg00058.html
2019-01-22 23:20:45 +01:00
Bernhard Voelker
64b802e568 gnulib: update to the latest
Run 'make update-gnulib-to-latest'.

* gnulib: Update to a version supporting GNULIB_NO_VLA.
2019-01-22 23:14:55 +01:00
Bernhard Voelker
0b483d326c tests: remove last traces of old shell tests
* find/testsuite/Makefile.am (test_shell_progs): Remove.
(EXTRA_DIST): Remove $(test_shell_progs) and 'binary_locations.sh'.
(TESTS): Remove.
* find/testsuite/binary_locations.sh: Remove utility script.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
b9604dc2b2 tests: migrate 'type_list' to the new testsuite
Make this test a "check-root" test to increase test coverage.
This test runs for non-privileged users as well, but skips the tests
for block and character devices as mknod(1) will fail with EPERM.

* find/testsuite/test_type-list.sh: Move to ...
* tests/find/type_list.sh: ... this, and apply the above.
Simplify, and make more robust.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_root_tests): ... and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
8b1bb60543 tests: migrate 'debug-missing-arg' to the new testsuite
* find/testsuite/sv-52220.sh: Move to ...
* tests/find/debug-missing-arg.sh: ... this, and apply the above.
Simplify, and make more robust.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
fb99de8a29 tests: migrate 'refuse-noop' to the new testsuite
* find/testsuite/sv-48180-refuse-noop.sh: Move to ...
* tests/find/refuse-noop.sh: ... this, and apply the above.
Simplify, and make more robust.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
dbc218f5f5 tests: migrate 'exec-plus-last-file' to the new testsuite
* find/testsuite/sv-48030-exec-plus-bug.sh: Move to ...
* tests/find/exec-plus-last-file.sh: ... this, and apply the above.
Simplify, and make more robust.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
1027613d0f tests: migrate 'execdir-fd-leak' to the new testsuite
* find/testsuite/sv-34976-execdir-fd-leak.sh: Move to ...
* tests/find/execdir-fd-leak.sh: ... this, and apply the above.
Simplify, and make more robust.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
c809ce8fa2 tests: migrate 'printf_inode' to the new testsuite
* find/testsuite/test_inode.sh: Move to ...
* tests/find/printf_inode.sh: ... this, and apply the above.  Simplify.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
1cc45855e5 tests: migrate 'printf_escape_c' to the new testsuite
* find/testsuite/test_escape_c.sh: Move to ...
* tests/find/printf_escape_c.sh: ... this, and apply the above.  Simplify.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
3f6b28c4fb tests: migrate test 'printf_escapechars' to the new testsuite
For migrating, merge with the basic structure from 'tests/sample-test',
i.e., source in 'tests/init.sh', call 'print_ver_', "Exit $fail",  etc.
Also remove now-common functions like die() and framework_failure_().

* find/testsuite/test_escapechars.golden: Remove, as the axpected output
is created on the fly by the new test.
* find/testsuite/test_escapechars.sh: Move to ...
* tests/find/printf_escapechars.sh: ... this, and apply the above.
Create the expected output on the fly, and also check for the expected
error diagnostic on stderr.
* find/testsuite/Makefile.am (EXTRA_DIST_GOLDEN): Remove.
(EXTRA_DIST): Remove $(EXTRA_DIST_GOLDEN).
(tests_shell_progs): Remove the reference to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
77df15aa8b tests: migrate 'name-lbracket-literal' to the new testsuite
For migrating, merge with the basic structure from 'tests/sample-test',
i.e., source in 'tests/init.sh', call 'print_ver_', "Exit $fail",  etc.
Also remove now-common functions like die() and framework_failure_().

* find/testsuite/sv-bug-32043.sh: Move to ...
* tests/find/name-lbracket-literal.sh: ... this, and apply the above.
Simplify.
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
8a2f24d5ff tests: migrate 'many-dir-entries-vs-OOM' to the new testsuite
For migrating, merge with the basic structure from 'tests/sample-test',
i.e., source in 'tests/init.sh', call 'print_ver_', "Exit $fail",  etc.
Also remove now-common functions like die() and framework_failure_().

* find/testsuite/sv-34079.sh: Move to ...
* tests/find/many-dir-entries-vs-OOM.sh: ... this, and apply the above.
While at it, loosely pull in changes from the related test in the
GNU coreutils [1]:
Create only 200,000 files, rather than 4 million.  The latter was overkill,
and was too likely to fail due to inode exhaustion.  Now that this test
doesn't take so long, label it as merely "expensive", rather than
"very expensive".
Furthermore, simplify the test data creation, and use the ulimit specifically
for each program under test (find, oldfind).
* find/testsuite/Makefile.am (tests_shell_progs): Remove the reference
to this test ...
* tests/local.mk (all_tests): .. and add it here.

[1]
https://git.sv.gnu.org/cgit/coreutils.git/tree/tests/rm/many-dir-entries-vs-OOM.sh?id=4711c49312d5
2019-01-09 00:24:34 +01:00
Bernhard Voelker
f72b299cdd tests: add shell-style test framework
Borrow the 'tests' framework from GNU coreutils.  This allows better
shell-style tests with more control over stdin, stdout, stderr, signals,
preparatory steps, cleanup, return code verification, root-only tests,
etc.

* .gitignore: Add entries for per-test *.log and *.trs files, and the
'test-suite.log'.
* .x-update-copyright: Exempt 'tests/init.sh' as this comes from gnulib.
* Makefile.am: Include 'tests/local.mk'.
(EXTRA_DIST): Add 'tests/GNUmakefile'.
(SUBDIRS): Move 'gnulib-tests' to the end, i.e., run our own tests first.
(ALL_RECURSIVE_TARGETS): Initialize.
(update-gnulib-to-latest): Copy 'tests/init.sh' from gnulib.
* cfg.mk: Add some syntax-check rules.
* init.cfg: Add file.
* tests/GNUmakefile: Likewise.
* tests/envvar-check: Likewise.
* tests/init.sh: Likewise.
* tests/lang-default: Likewise.
* tests/local.mk: Likewise.
* tests/misc/help-version.sh: Likewise.
* tests/other-fs-tmpdir: Likewise.
* tests/sample-test: Likewise.
* tests/.gitignore: Likewise.
* NEWS (Changes to the build process): Mention the new test framework.
2019-01-09 00:24:34 +01:00
Bernhard Voelker
763c4725fc maint: add NEWS entry for bug #55272
* NEWS (Bug Fixes): Add news entry for the change in commit 66174c10c6.
2019-01-08 11:34:27 +01:00
Bernhard Voelker
2758f513f0 build: work around dependency issue of 'make' on the BSDs
'make' on all of FreeBSD, NetBSD and OpenBSD fails to understand that
'./libfindtools.a' and 'libfindtools.a' are the same, and - unless one
builds that target manually - fails with:

  make[3]: don't know how to make ./libfindtools.a. Stop

* find/Makefile.am (LDADD): Change './libfindtools.a' to 'libfindtools.a'.
2019-01-05 16:45:36 +01:00
Bernhard Voelker
66174c10c6 find: improve warning diagnostic for the -name/-iname with '/' in pattern
* find/parser.c (check_name_arg): Add parameter ALT for the alternative
option to suggest.  Avoid confusing quoting in the warning by making
the message more terse.
(parse_iname): Pass "-iwholename" as alternative parameter.
(parse_name): Pass "-wholename" as alternative parameter.

Reported by Andreas Metzler in
    https://sv.gnu.org/bugs/?55272
2019-01-05 12:57:11 +01:00
Bernhard Voelker
04f1fbee5d maint: fix typo in comment
* find/parser.c (found_parser): s/fid/find/ in a comment.
2019-01-05 01:20:21 +01:00
Bernhard Voelker
487d0701c5 maint: update copyright year number ranges
Run 'make update-copyright'.

* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
2019-01-04 23:47:26 +01:00
Bernhard Voelker
c53c52827c maint: update gnulib to latest
Run 'make update-gnulib-to-latest', mainly to update the copyright
year numbers with:

> maint: Run 'make update-copyright'

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
2019-01-04 22:57:53 +01:00
Bernhard Voelker
b23a2693c8 gnulib: use https URL scheme instead of git
This is apparently more secure (against MITM attacks).

* .gitmodules (gnulib): Change url scheme from "git://" to "https://".

Discussed at:
https://lists.gnu.org/r/bug-gnulib/2018-12/msg00051.html
2018-12-12 01:18:49 +01:00
Bernhard Voelker
042afd9f00 maint: avoid non-portable C99 printf size specifiers %z and %j
* cfg.mk (sc_prohibit-c99-printf-format): Add SC rule.
* find/parser.c (parse_time): Change %ju to PRIuMAX.
(insert_num): Likewise.
* xargs/xargs.c (xargs_do_exec): Change %zu to PRIuMAX.
2018-12-02 15:52:53 +01:00
Bernhard Voelker
4c5cebf4eb maint: avoid continued strings
* 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.
2018-12-02 15:52:49 +01:00
Bernhard Voelker
bac58c5178 maint: adjust preprocessor indentation via cppi
Run 'cppi -a' for all *.[ch] files, and add a syntax-check rule for it.

* cfg.mk (sc_preprocessor_indentation): Add rule.
* find/defs.h: Run 'cppi -a' on this file.
* find/fstype.c: Likewise.
* find/oldfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/print.h: Likewise.
* find/sharefile.h: Likewise.
* gnulib-local/lib/gcc-function-attributes.h: Likewise.
* lib/bugreports.h: Likewise.
* lib/buildcmd.c: Likewise.
* lib/buildcmd.h: Likewise.
* lib/extendbuf.h: Likewise.
* lib/fdleak.h: Likewise.
* lib/findutils-version.h: Likewise.
* lib/listfile.c: Likewise.
* lib/printquoted.h: Likewise.
* lib/regextype.h: Likewise.
* lib/safe-atoi.h: Likewise.
* lib/splitstring.h: Likewise.
* lib/system.h: Likewise.
* locate/locatedb.h: Likewise.
* xargs/xargs.c: Likewise.
2018-12-02 15:52:44 +01:00
Bernhard Voelker
74534e07a7 doc: remove configure option --enable-id-cache from README
* README (--enable-id-cache): Remove here, as the option has already
been removed in commit v4.6.0-11-gbcd85897.
2018-12-02 15:52:38 +01:00
Bernhard Voelker
e3fc99dbda doc: fix grammar issue in texinfo manual
* doc/find.texi (Systems without O_NOFOLLOW): Remove superfluous 'the'.

Reported by Martin Castillo in https://sv.gnu.org/bugs/?55022
2018-11-14 22:48:22 +01:00
Bernhard Voelker
815c737b42 maint: fix typo in comment in safe-atoi.c
* lib/safe-atoi.c (safe_atoi): s/chack/check/
2018-11-10 23:42:28 +01:00
Bernhard Voelker
e3a1254e5c doc: remove already retired configure --enable-debug from README
That configure option has been removed with commit 995151807658,
so also remove it from README.

* README (Special configure options): Do the above.
2018-11-10 23:36:08 +01:00
Bernhard Voelker
9b6fe18848 maint: update gnulib to latest
Run 'make update-gnulib-to-latest'.

* bootstrap: Sync from gnulib/build-aux/bootstrap.
* gnulib: Update to latest.
* configure.ac (AC_PREREQ): Change from very old 2.59 to current 2.69
to avoid gnulib-tool complaining about "minimum supported autoconf
version is 2.63".
2018-11-02 23:05:54 +01:00
Bernhard Voelker
42e134a484 maint: provide make target to update gnulib to latest
* Makefile.am (gnulib-sync, update-gnulib-to-latest): Add targets to
pull the latest commit of the gnulib submodule, and also to copy over
the files we keep in sync.
* doc/find-maint.texi (How to update Gnulib to latest): Add section.
2018-11-02 21:35:17 +01:00
Bernhard Voelker
e8599a9e33 find: add '-D all' to enable all debug flags
* find/defs.h (DebugOption): Add DebugAll, which includes all other
debug options but DebugHelp.
* find/util.c (debugassoc): Add an entry for DebugAll, and move DebugHelp
to the end.
* doc/find.texi (node Debug Options): Document the new option.
* find/find.1: Likewise.
* NEWS (Improvements): Likewise.
2018-11-02 15:53:19 +01:00
Bernhard Voelker
8fc3403211 doc: use portable 'tail' call in texinfo example
* doc/find.texi (node Updating A Timestamp File): Use more portable
'tail -n1' instead of the deprecated form 'tail -1'.
2018-11-02 15:50:28 +01:00
Bernhard Voelker
7741d79fa3 doc: fix typo in 'xargs -l' examples in texinfo manual
* doc/find.texi (node Controlling Parallelism): Change from 'xargs -1'
(minus one) to 'xargs -l' (minus El) in three places.

Reported by Ahmad ElKomey in
https://sv.gnu.org/bugs/index.php?54859
2018-10-18 13:19:32 +02:00
Bernhard Voelker
013054ffc2 doc: fix the examples of the -perm option in the texinfo documentation
* doc/find.texi (Mode Bits): Move the misplaced '-perm -g+w,o+w' example
up to the '-perm -022' example to where it belongs.  The former got
accidentally separated from the latter in commit 7ade936bc2c4: the patch
proposed in https://sv.gnu.org/bugs/?14619 was applied in the wrong place.
* NEWS (Bug fixes): Mention the fix.

Reported by Ahmad ElKomey in https://sv.gnu.org/bugs/?54838
2018-10-15 08:46:04 +02:00
James Youngman
e06438bbb6 doc: don't mention indirect blocks. Clarify how -size is measured.
This fixes Savannah bug 36763.
2018-09-23 14:33:12 +01:00
James Youngman
2e9bd1892e README: refer user to README-hacking when there is no INSTALL file. 2018-09-23 13:47:18 +01:00
Bernhard Voelker
77ff826985 doc: clarify again exit status handling of -exec command {} +
A non-zero exit status of a command launched via the -exec predicate
family only leads to a non-zero exit status of 'find' itself when
the '+' form of the punctuation for the command is used.  This is
also what POSIX requires [1].
To put it the other way round: when the ';' form is used, the exit
status of 'find' is not affected.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html

* find/find.1 (-exec ... +): Explicitly mention that the exit status of
the launched command affects find's exit status when the '+' form is used.
To allow a future change, deliberately leave the behavior for failing
commands with the ';' form undocumented.
(-execdir): Likewise.
Previously, in the form committed with v4.6.0-63-gae424b95, that sentence
did not explicitly limit the behavior to the '+' form, and therefore
might have confused the user.

Fixes https://sv.gnu.org/bugs/?54509
2018-08-14 22:45:51 +02:00
Aron Barath
5dae49b4fc fdleak.c: avoid compiler error on platforms lacking getrlimit
* 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
2018-08-08 15:27:58 +02:00
Bernhard Voelker
84e8644d06 maint: update gnulib to latest
* COPYING: Merge fom gnulib/doc/COPYINGv3.
* bootstrap: Merge from gnulib/build-aux/bootstrap.
* gnulib: Update, mainly to avoid the following warnings from GCC-8.1.1:
  cc1: warning: -Wabi won't warn about anything [-Wabi]
  cc1: note: -Wabi warns about differences from the most up-to-date ABI,\
       which is also used by default
  cc1: note: use e.g. -Wabi=11 to warn about changes from GCC 7
2018-07-26 08:03:17 +02:00
Bernhard Voelker
ba6be28896 find -printf %Y: handle ENOTDIR also as broken symlink
The above command should output 'N' (for broken symlinks) not only in
the ENOENT case, but also when an intermediate part of the symlink target
file name is a file (ENOTDIR):

  $ touch file
  $ ln -s file/ENOTDIR link
  $ find link -printf '%Y %p\n'
  N link

Previously, find output 'l' as for a resolvable symlink.

* find/print.c (do_fprintf): Treat ENOTDIR the same as ENOENT to detect
broken symlinks.
* find/testsuite/find.gnu/printf-symlink.exp: Extend the test, and ...
* find/testsuite/find.gnu/printf-symlink.xo: ... the expected output.
* NEWS (Bug fixes, #54262): Explicitly mention that both ENOENT and ENOTDIR
are used to detect broken symlinks.

Suggested by Tavian Barnes.
2018-07-24 08:37:52 +02:00
Bernhard Voelker
88fc3a4644 print.c: move 'else' into #ifdef S_ISLNK
* find/print.c (do_fprintf): Move the 'else' statment into the #ifdef'ed
block to avoid compilation failure on systems without S_ISLNK (although
it seems nobody tried to build on such a platform since 2005).

Bug introduced in commit 'FINDUTILS_4_2_23-1-63-g238d9547'.
2018-07-24 08:37:48 +02:00
Bernhard Voelker
efcf94c4d3 doc: document -printf %Y output consistently
* doc/find.texi (node Location Directives): Mention 'L' and '?' as well.
* find/find.1 (%Y): Mention '?'.
* NEWS (Documentation Changes): Mention the fix.
2018-07-24 08:37:45 +02:00
Bernhard Voelker
7b7a19c95f find: fix -printf %Y output to 'N' for broken links
The format %Y shall output 'N' for broken links (ENOENT), 'L' for ELOOP,
and '?' for any other error when stat()ing the symlink target.

The %Y implementation implicitly fell back to lstat(); therefore it
output 'l' for dangling symlinks.

  $ ln -s ENOENT DANGLE
  $ find -D stat DANGLE -printf '%y %Y %p\n'
  fallback_stat(): stat(DANGLE) failed; falling back on lstat()
  l l DANGLE

* find/print.c (do_fprintf): For %Y, always follow links to determine
the type of the symlink target.
* find/testsuite/find.gnu/printf-symlink.exp: Add a test case for broken
links and the ELOOP case ...
* find/testsuite/find.gnu/printf-symlink.xo: ... with the expected output.
* NEWS (Bug fixes): Mention the fix.

Bug introduced in version v4.5.8 with commit '25e7c5fbf9'.
2018-07-24 08:37:40 +02:00
Christopher Leonard
a981ebe8d6 doc: improve readability of find-maint.texi
* doc/find-maint.texi: s/fuly/fully/, and re-phrase some sentences,
e.g. use active voice.

Copyright-paperwork-exempt: Yes
2018-07-16 21:53:37 +02:00
Jim Meyering
e3b9af8ab2 maint: use gnulib's intprops module to avoid magic numbers
* bootstrap.conf (gnulib_modules): Add intprops.
* find/ftsfind.c (get_fts_info_name): Use the INT_BUFSIZE_BOUND macro
to calculate the size of BUF.
2018-07-11 17:58:13 +02:00
Bernhard Voelker
c7344d3358 ftsfind.c: avoid buffer overflow in -D code
Reported by GCC 8.1.1:

ftsfind.c: In function ‘get_fts_info_name’:
ftsfind.c:164:23: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 9 [-Wformat-overflow=]
       sprintf (buf, "[%d]", info);
                       ^~
ftsfind.c:164:7: note: ‘sprintf’ output between 4 and 14 bytes into a destination of size 10
       sprintf (buf, "[%d]", info);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~

* find/ftsfind.c (get_fts_info_name): Increase buffer from 10 to 14
to be able to hold the 11-char string representation of the %d format,
the surrounding '[' and ']', plus the terminating NULL character.
2018-07-08 01:08:56 +02:00
Andreas Metzler
df4610d08d tests: test find -depth with unreadable directory
* find/testsuite/find.posix/sv-bug-54171.exp: Add testcase ...
* find/testsuite/find.posix/sv-bug-54171.xo: .. and expected output.
* find/testsuite/Makefile.am: Include newly added tests in
distribution.
2018-07-08 00:56:34 +02:00
Bernhard Voelker
22ff99e150 find: process unreadable directories with -depth
* find/ftsfind.c (consider_visiting): Split the FTS_ERR and FTS_DNR
cases to be able to continue processing that entry in the latter case
(unreadable directory) when the -depth option is given.
* NEWS (Bug Fixes): Mention the fix.

Reported by Tavian Barnes in https://savannah.gnu.org/bugs/?54171.
2018-07-08 00:56:34 +02:00
James Youngman
bb51d3581d Shorten output of qmark_chars after replacing a multibyte characer.
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.
2018-07-06 09:46:46 +01:00
Bernhard Voelker
371b3017f8 oldfind.c: port to GCC 8
oldfind.c:277:1: error: function might be candidate for attribute 'malloc' if it is known to return normally [-Werror=suggest-attribute=malloc]
 specific_dirname (const char *dir)
 ^~~~~~~~~~~~~~~~

* find/oldfind.c (specific_dirname): Mark with _GL_ATTRIBUTE_MALLOC.
2018-06-23 23:54:42 +02:00
Bernhard Voelker
d2fee47412 xargs.c: port to GCC 8
GCC 8 issues the following warning diagnostic:

  xargs.c:1134:29: warning: '%u' directive output may be truncated writing \
  between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
     static const char *fmt = "%u";
                               ^~
  xargs.c:1161:7: note: 'snprintf' output between 2 and 11 bytes into a \
  destination of size 2
         snprintf (buf, size+1, fmt, n);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* xargs/xargs.c (set_slot_var): Simplify BUF handling to pacify GCC 8
about safe use of snprintf wrt truncated writing.
2018-06-23 23:45:34 +02:00
Bernhard Voelker
ccf25d6233 maint: update gnulib to latest
* gnulib: Do the above, mainly for:
  > fts: treat CIFS like NFS
  > fts: fix bug in find across filesystems
* bootstrap: Update from gnulib/build-aux/bootstrap.

This fixes a bug reported for Fedora which had already newer gnulib
than what was upstream - here - in 4.6.0:
  https://bugzilla.redhat.com/show_bug.cgi?id=1558249
Reported by Kamil Dudka for gnulib in:
  https://lists.gnu.org/r/bug-gnulib/2018-04/msg00015.html
2018-06-23 23:45:09 +02:00
Bernhard Voelker
b94be7a071 maint: update gnulib to latest
* gnulib: Do the above.
* bootstrap: Update from gnulib/build-aux/bootstrap.
2018-03-14 20:56:00 +01:00
Bernhard Voelker
70c91e7a21 tests: port sv-48030-exec-plus-bug.sh to Alpine Linux
On Alpine Linux v3.6, the test failed because the created 'tstcmd'
script lacks a shebang - see shortened log:

  + echo printf "%s\n" "$@"
  + chmod +x bin/tstcmd
  + PATH=/tmp/tmp.10fq3tSrnx/bin:...
  + .../find/find bin -maxdepth 0 -exec tstcmd {} +
  find: ‘tstcmd’: Exec format error
  + [ = bin ]
  sh: bin: unknown operand
  + return 1

* find/testsuite/sv-48030-exec-plus-bug.sh: Add a shebang to the
generated 'tstcmd' script, and add quotes around the find call to
avoid the "unknown operand" error.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
15f9a4903c tests: skip sv-34079.sh properly if setting up the test fails
The test exited as a test failure (exit 1) also when set-up failed,
e.g. when running the test with TMPDIR on a file system with too
few free inodes.  Instead, the test should exit with 77 to skip the
test.  In other cases, exit properly with 99 to signal a test
framework failure.

* find/testsuite/sv-34079.sh (very_expensive_): Move the check for
RUN_VERY_EXPENSIVE_TESTS to the beginning, thus decreasing the
indentation level of the test code.  This is also a preparation
step for moving this check to a central place.
(skip_,framework_failure_): Define utility functions to skip the test
or terminate it as a test framework failure.
(get_ifree_): Define function to determine the number of free inodes.
(make_test_data): Use it, and skip early if we know that there are too
few free inodes on the current file system.
Use "seq -f" to build the file names, and directly feed them via xargs
to touch.  This avoids slower shell code.
Skip the test if touch fails; previously, the test exited as FAIL.
Move the creation of test files up, i.e., outside the if-condition,
and use trap to remove the temporary directory at exit.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
6f28880ef3 tests: skip some tests unless seq(1) is available
seq(1) is not required by POSIX and also not available on some
systems, e.g. the *BSDs.  Skip tests requiring it.

* find/testsuite/sv-34079.sh: Add a check whether seq(1) is available,
and exit 77 (SKIP) otherwise.
* find/testsuite/sv-48030-exec-plus-bug.sh: Likewise.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
a22f795891 build: remove obsolete ALL_LINGUAS list
The list of languages is in po/LINGUAS since gettext-0.11.
Removing ALL_LINGUAS avoids the following warning:
  config.status: setting ALL_LINGUAS in configure.in is obsolete

* configure.ac (ALL_LINGUAS): Remove.
* Makefile.am (findutils-check-pofiles): Remove check.
(dist-hook): Remove dependency to findutils-check-pofiles.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
0f3822c284 build: remove PO files from version control
Let bootstrap auto-update the PO files from "translationproject.org".

* bootstrap.conf (SKIP_PO): Remove, thus letting bootstrap download
the PO files now.
* po/.gitignore: Add entries now created during the build.
* doc/find-maint.texi (Internationalisation): Mention the change.
* NEWS (Changes to the build process): Likewise.
(Translations): Remove section.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
0e7a378e8c build: port generating updatedb to the BSDs
sed(1) on FreeBSD-11.1 and OpenBSD 6.2 requires the last command inside
'{...}' groups to be terminated with a semicolon, otherwise it fails with:

  sed: 1: "/^# Copyright /{s/^..// ...: extra characters at the end \
  of q command

* locate/Makefile.am (updatedb): Add a ';' after the last command in the
'{...}' group - introduced in commit v4.6.0-133-g6d186665.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
76d7e2dcb4 maint: add missing va_end
'va_start' must have a corresponding 'va_end'.  Depending on the
implementation, the consequence of a missing 'va_end' may be a
corrupted stack.

* find/print.c (checked_fprintf): Add va_end.

Spotted by coverity analysis.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
8b27459ef9 parser.c: avoid -Wreturn-type warning on GCC-4.8.5 on NetBSD 7.1
parser.c: In function 'collect_arg_stat_info':
parser.c:755:1: warning: control reaches end of non-void function [-Wreturn-type]

* find/parser.c (collect_arg_stat_info): Invert condition to work
around the above warning for compilers failing to detect that
fatal_target_file_error does never return.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
565bbeb89d maint: prevent multiple inclusion of header files
* find/print.h: Add #ifndef / #define / #endif guard to prevent
multiple inclusion of this header file.
* lib/fdleak.h: Likewise.
* lib/findutils-version.h: Likewise.
* lib/regextype.h: Likewise.
* lib/splitstring.h: Likewise.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
e9340a8bd7 build: avoid use of $(RM)
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.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
e551cfec0f maint: move NLS-related macros to a central place
Add definition like in coreutils, thus also silencing GCC on NetBSD 7.1:
  warning: "textdomain" redefined

* lib/system.h: Include <locale.h> and gnulib's "gettext.h" here,
and define the macros textdomain, bindtextdomain, _ and N_.
* find/exe.c: Use it.
* 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/bugreports.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/dircallback.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.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.
* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add exemption
for some non-main sources to pass the syntax-check.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
0afb2efada find: make -delete honour the -ignore_readdir_race option
* find/pred.c (pred_delete): Return true when the -ignore_readdir_race
option is active and unlinkat() came back with ENOENT.
* doc/find.texi (Option -ignore_readdir_race): Document the change.
(Action -delete): Likewise.
* find/find.1: Likewise.
* NEWS (Bug Fixes): Mention the fix.

For now, it seems a bit hard to add a proper test for this,
so the following shell snippet demonstrates the race:

  $ seq 10 | xargs touch
  $ env time -f 'find exit status: %x\nfind time: %e' \
      find -ignore_readdir_race -type f \
        -delete \
        -exec sh -c 'sleep $(basename {})' \; \
        -printf 'find deleted: %p\n' \
        & \
    sleep 20; \
    seq 10 | xargs rm -fv; \
    wait $!

Reported by Alexander Golubev in
https://savannah.gnu.org/bugs/?52981
2018-03-14 20:44:14 +01:00
Bernhard Voelker
2d6ce760f1 build: add gnupload
This may be used by 'make emit_upload_commands' and 'make stable' /
'make alpha' later on.

* bootstrap.conf (gnulib_modules): Add entry for 'gnupload'.
* build-aux/.gitignore (/gnupload): Add entry.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
b028f53140 maint: give gnulib's test directory a better name
Rename from 'tests' to 'gnulib-tests' to make clearer that these
are the tests of gnulib, and not those of findutils.

* .gitignore (tests): Remove.
(/gnulib-tests/): Add entry.
* Makefile.am (SUBDIRS): s/tests/gnulib-tests/
(findutils-check-smells): Likewise.
(coverage-clean): Likewise.
* bootstrap.conf (gnulib_tool_option_extras): Add option
"--tests-base=gnulib-tests".
* configure.ac (AC_CONFIG_FILES): s/tests/gnulib-tests/ here, too.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
1cc207f6eb maint: make inter-release --version output more useful
Now, each snapshot has a version "number" like 4.6-131-219-gda920ee,
which indicates that it is built using the 131st change set
(in _some_ repository) following the "v4.6" tag, and that da920ee
is a prefix of the commit SHA1.

* bootstrap.conf (gnulib_modules): Add git-version-gen.
* build-aux/.gitigore (/git-version-gen): Add entry.
* configure.ac: Run it to set the version from .tarball-version.
* Makefile.am (EXTRA_DIST): Add git-version-gen.
(dist-hook): Create .tarball-version in distribution tarballs,
never in a checked-out repository.
(AUTOMAKE_OPTIONS): Change from 'gnits' to 'gnu std-options readme-alpha'.
* .gitignore (.tarball-version): Add entry.
* doc/find-maint.texi (Making Releases): Adjust: tag before the build,
changed handling in NEWS, etc.
* NEWS (Changes to the build process): Document the change.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
b00d14e97e build: colorize test output on capable terminals
* configure.ac (AM_INIT_AUTOMAKE): Add 'color-tests' option.
2018-03-14 20:44:14 +01:00
Bernhard Voelker
d4aac2d443 build: make --enable-silent-rules the default
* configure.ac (AM_SILENT_RULES): Use this, with it's undocumented
[yes] argument.  Those who want verbose build output may configure
with --disable-silent-rules or use "make V=1".
2018-03-14 20:44:14 +01:00
Bjarni Ingi Gislason
a0fada430a doc: fix various syntax issues in find.1
Changes:
- Avoid warning "(macro BR): only 1 argument, but more are expected".
- Change misused SI (metric) numeric prefixes to the binary ones, like
a bare "1K blocks" to "1 KB blocks".
- Protect a full stop (.) with "\&", if it has a blank (white-space)
in front of or (ignoring transparent characters to the full stop) after
it, and it does not mean an end of a sentence.
- Change the name of a macro for two fonts (e.g., BR and IR) to one
letter, if there is only one argument.
- Use a macro to change to the italic font, instead of \fI [1], if
possible.
- Remove space in the first column, if not intented.
- Move a full stop (period) and a comma outside of a quoted text, if
it is at the end of the quote and does not end a quoted sentence.
- Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front
of a name for an option.
- Split lines longer than 80 characters into two or more lines.
- Separate the sentences and subordinate clauses; each begins on a new
line. Or: Adjust space between sentences (two spaces).
- Fix the spelling of "kibi", "mebi", and "gibi".

* find/find.1: Do the above.

Patch contributed via https://sv.gnu.org/patch/?9585
Copyright-paperwork-exempt: Yes
2018-03-13 21:52:06 +01:00
Bernhard Voelker
040f20b91e maint: add remove-potcdate.sed to po/.gitignore
* po/.gitignore: Add the above entry which may remains after
running 'make distcheck'.
2018-01-01 19:27:32 +01:00
Bernhard Voelker
e0c68db5c0 maint: run 'make -C po update-po'
Mainly for changed line numbers, but also for one white-space change
in 'tree.c'.

* po/be.po: Update via the above 'update-po' target.
* po/bg.po: Likewise.
* po/ca.po: Likewise.
* po/cs.po: Likewise.
* po/da.po: Likewise.
* po/de.po: Likewise.
* po/el.po: Likewise.
* po/eo.po: Likewise.
* po/es.po: Likewise.
* po/et.po: Likewise.
* po/fi.po: Likewise.
* po/findutils.pot: Likewise.
* po/fr.po: Likewise.
* po/ga.po: Likewise.
* po/gl.po: Likewise.
* po/hr.po: Likewise.
* po/hu.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/ja.po: Likewise.
* po/ko.po: Likewise.
* po/lg.po: Likewise.
* po/lt.po: Likewise.
* po/ms.po: Likewise.
* po/nb.po: Likewise.
* po/nl.po: Likewise.
* po/pl.po: Likewise.
* po/pt.po: Likewise.
* po/pt_BR.po: Likewise.
* po/ro.po: Likewise.
* po/ru.po: Likewise.
* po/sk.po: Likewise.
* po/sl.po: Likewise.
* po/sr.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/zh_TW.po: Likewise.
2018-01-01 19:27:21 +01:00
Bernhard Voelker
8705455ce0 maint: update copyright year number ranges
Run 'make update-copyright'.

* lib/regexprops.c (copying): Update the year number manually.
* All other files: Update copyright years via the above make run.
2018-01-01 19:27:15 +01:00
Bernhard Voelker
7a7dc443d7 build: add -Wno-unused-parameter
The following new warning sneaked in with the gnulib update in the
previous commit:
  In file included from parser.c:49:0:
  ../gl/lib/stat-time.h: In function 'stat_time_normalize':
  ../gl/lib/stat-time.h:215:47: error: unused parameter 'st' \
  [-Werror=unused-parameter]
   stat_time_normalize (int result, struct stat *st)
                                                 ^~

* configure.ac: Add the -Wno-unused-parameter option explicitly as it
is implied - and thus overridden - by the more general -Wunused option.
2018-01-01 19:27:05 +01:00
Bernhard Voelker
b755fd9252 maint: update gnulib to latest
* bootstrap: Merge from gnulib/build-aux/bootstrap.
2018-01-01 19:26:48 +01:00
Bernhard Voelker
25db51a53c find.1: document that access()-based options apply to the current user
* find/find.1 (-executable): Mention to whom the matching files are
accessible: to the current user.
(-readable): Likewise.
(-writable): Likewise.

Reported by 積丹尼 Dan Jacobson <jidanni@jidanni.org> in
https://lists.gnu.org/r/bug-findutils/2017-12/msg00017.html
2018-01-01 19:11:34 +01:00
Bernhard Voelker
2c3dde5afc maint: remove bootstrap from distribution
* Makefile.am (EXTRA_DIST): Remove bootstrap.
2017-11-17 19:53:01 +01:00
James Youngman
1b53838ddf regexprops: don't mention regex dialects we're not going to document.
* 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.
2017-11-14 22:22:36 +00:00
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
James Youngman
e34eaa2695 po: delete po/remove-potcdate.sed so that "make distcheck" works.
* po/remove-potcdate.sed: the presence of this generated file
causes "make distcheck" to fail on VPATH builds.  Deleting it
fixes this.
2017-11-14 13:42:37 +00:00
Bernhard Voelker
1063a3667e maint: shorten https://lists.gnu.org/archive/html/... links
Each /archive/html/ part can be replace with /r/.
Run this to induce the change:
git grep -l archive/html|xargs perl -pi -e 's,/archive/html/,/r/,g'
* README: Perform that substitution.
* find/testsuite/find.posix/depth1.exp: Likewise.
* gnulib-local/lib/gcc-function-attributes.h
2017-11-13 18:40:29 +01:00
Bernhard Voelker
d43734ced4 maint: include the module year2038 from gnulib
* bootstrap.conf (gnulib_modules): Add 'year2038' to ensure that time_t
is 64-bit (and thus works after 2038).

Suggested by Bruno Haible in
https://lists.gnu.org/r/bug-gnulib/2017-11/msg00022.html
2017-11-13 18:40:29 +01:00
Bernhard Voelker
8c40dd213b maint: update gnulib to latest
* gnulib: Update - mainly for the recent year2038 changes.
* bootstrap: Update from gnulib/build-aux/bootstrap.
2017-11-13 18:40:29 +01:00
Bernhard Voelker
2de2618e5e maint: document the https change in NEWS
* NEWS (Documentation Changes): Mention the switch from http to https
done in commit 2cb10332.
2017-11-13 18:40:29 +01: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
cf66ca4c83 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: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
6d186665f5 updatedb: use Copyright header of updatedb.sh
Previously, the Copyright header output by 'updatedb --version' was
not updated by 'make update-copyright', so it still showed 2010 as
the Copyright year.

* locate/updatedb.sh (version): Replace the Copyright header by
the placeholder "@COPYRIGHT@" ...
* locate/Makefile.am (updatedb): ... set here from the Copyright line
extracted from 'updatedb.sh'.
2017-10-30 21:18:49 +01:00
Bernhard Voelker
657d602689 tests: cleanup files left behind by sv-52220.sh
'make distcheck' failed with:
  ...
  ERROR: files left in build directory after distclean:
  ./find/testsuite/find.err
  ./find/testsuite/oldfind.err
  Makefile:2064: recipe for target 'distcleancheck' failed

* find/testsuite/sv-52220.sh: Add command to remove the temporary
files used for stderr output.

Bug introduced in commit v4.6.0-123-gef1581e.
2017-10-30 18:54:10 +01:00
Bernhard Voelker
da920ee0a7 maint: use an optimal-for-findutils xz compression setting
* cfg.mk: Set XZ_OPT = -7e (determined empirically).
The compressed tarball size is identical to the default settings (-9e),
but using -9e would force every decompression process to use 48 MiB
more memory.
2017-10-28 15:53:11 +02:00
Bernhard Voelker
43f0b3601d maint: run 'make -C po update-po'
Mainly for changed line numbers, but also for a couple of new
translation strings, and the switch to https.

* po/be.po: Update via the above 'update-po' target.
* po/bg.po: Likewise.
* po/ca.po: Likewise.
* po/cs.po: Likewise.
* po/da.po: Likewise.
* po/de.po: Likewise.
* po/el.po: Likewise.
* po/eo.po: Likewise.
* po/es.po: Likewise.
* po/et.po: Likewise.
* po/fi.po: Likewise.
* po/findutils.pot: Likewise.
* po/fr.po: Likewise.
* po/ga.po: Likewise.
* po/gl.po: Likewise.
* po/hr.po: Likewise.
* po/hu.po: Likewise.
* po/id.po: Likewise.
* po/it.po: Likewise.
* po/ja.po: Likewise.
* po/ko.po: Likewise.
* po/lg.po: Likewise.
* po/lt.po: Likewise.
* po/ms.po: Likewise.
* po/nb.po: Likewise.
* po/nl.po: Likewise.
* po/pl.po: Likewise.
* po/pt.po: Likewise.
* po/pt_BR.po: Likewise.
* po/ro.po: Likewise.
* po/ru.po: Likewise.
* po/sk.po: Likewise.
* po/sl.po: Likewise.
* po/sr.po: Likewise.
* po/sv.po: Likewise.
* po/tr.po: Likewise.
* po/uk.po: Likewise.
* po/vi.po: Likewise.
* po/zh_CN.po: Likewise.
* po/zh_TW.po: Likewise.
2017-10-23 00:57:57 +02: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
079eb4cdb6 doc: add copyright section to man pages
* find/find.1: Add copyright section, deriving first copyright year from
the corresponding *.c file.
* locate/locate.1: Likewise.
* locate/locatedb.5: Likewise.
* locate/updatedb.1: Likewise.
* xargs/xargs.1: 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
64f5f93900 gnulib: update to latest
* bootstrap: Merge from gnulib/build-aux/.
* bootstrap.conf: Likewise.
2017-10-22 20:56:44 +02:00
Bernhard Voelker
ef1581ea51 find: avoid segfault with -D without argument
On some platforms, 'find -D' without any further argument crashed.

* find/util.c (process_leading_options): Output an error diagnostic
when the -D option is the last argument.  Previously, 'find -D'
without any further arguments crashed on some platforms where the
following strtok_r does not expect a NULL pointer argument in the
first call.
* NEWS (Bug Fixes): Mention the fix.
* find/testsuite/sv-52220.sh: Add a test.
* find/testsuite/Makefile.am (test_shell_progs): Reference the test.

Fixes https://savannah.gnu.org/bugs/?52220
2017-10-22 20:50:50 +02:00
Bernhard Voelker
77e4a7f17f maint: fix typos in commments
* find/fstype.c: s/unneccessary/unnecessary/
* xargs/xargs.c: s/utliity/utility/
2017-10-10 07:34:54 +02:00
Bernhard Voelker
abb69e6ade find.1: improve explanation in the NON-BUGS section
* find/find.1 (NON-BUGS): Update the sample error diagnostic to match
the latest code of the unquoted pattern example for the -name predicate.
Also improve the explanation about what is happening in that case.
2017-09-14 00:50:10 +02:00
Andreas Metzler
bcf55b0fff tests: test more printf format specifiers
* find/testsuite/find.gnu/printf.exp: Add coverage for %T* (limited to
strftime sequences mandated by POSIX), %M, %t, %y, and %Y. Run this test
with TZ=UTC. (Latter fix by Bernhard Voelker.)
* find/testsuite/find.gnu/printf.xo: Likewise.
2017-09-08 21:59:17 +02:00
James Youngman
41dd17cb87 intl: update Brazilian Portuguese, Slovak, Dutch translations.
* po/pt_BR.po: Update Brazilian Portuguese translation.
* po/sk.po: Update Slovak translation.
* po/nl.po: Update Dutch translation.
2017-09-03 12:46:10 +01:00
Bernhard Voelker
febde26dd0 find: avoid buffer-overflow with -printf '%T+'
* find/print.c (format_date): Increase size of local variable
FMT to match the longest possible content.

Fixes https://bugs.debian.org/873032 reported upstream by
Andreas Metzler in https://savannah.gnu.org/bugs/?51841;
fix proposed by Kamil Dudka.

Bug introduced in commit v4.6.0-111-g95816b2, so no released version
ever saw this; therefore not adding a NEWS entry.
2017-08-28 23:15:12 +02:00
Bernhard Voelker
971d3422b6 maint: fix typo in comment
* locate/locate.c (dolocate): Change a double comma to a
single one: s/,,/,/

Reported by Reuben Thomas in
http://lists.gnu.org/archive/html/bug-findutils/2017-08/msg00023.html
2017-08-28 22:46:24 +02:00
Bernhard Voelker
a8fc03d980 doc: add a NEWS entry for the previous commit
* NEWS (Improvements): Add an entry for v4.6.0-115-g9530e31.
2017-08-18 20:43:39 +02:00
Assaf Gordon
9530e31f6d find: give helpful hint for unquoted patterns errors
Try to detect cases where the user provided an unquoted shell-glob
pattern (which was expanded by the shell before calling find(1),
resulting in an invalid usage).

  $ touch a.txt b.txt c.txt
  $ find -name *.txt
  find: paths must precede expression: `b.txt'
  find: possible unquoted pattern after predicate `-name'?

Continuation of
   https://savannah.gnu.org/bugs/?51711
   https://lists.gnu.org/archive/html/bug-findutils/2017-08/msg00000.html
   https://git.sv.gnu.org/cgit/findutils.git/commit/?id=50a7c5d1f572

* find/tree.c (build_expression_tree): If the offending argument is an
existing file, print a hint with the last (valid) predicate.
2017-08-17 08:14:52 +02:00
Bernhard Voelker
50a7c5d1f5 find: avoid usage() in more error cases
When the user passes a bad command line, then find(1) outputs the
error message followed by a short usage() text, e.g. (wrapped):

  $ find . -name a* b*
  find: paths must precede expression: bfile
  Usage: find [-H] [-L] [-P] [-Olevel] \
  [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Omit the usage() text in more cases like this in order to make the
error diagnostic more eye-catching.

* find/tree.c (build_expression_tree): Exit with EXIT_FAILURE
immediately in more cases, i.e., without outputting also a short
usage() text.  While at it, add quotes around the offending argument
in one another place.
* NEWS (Improvements): Mention the fix.

Reported in https://savannah.gnu.org/bugs/?51711
2017-08-10 08:45:56 +02:00
James Youngman
808d8aa612 po/*.po: update line numbers. 2017-07-29 13:13:16 +01:00
James Youngman
79e8e03cda gnulib: update to f42d5af5ba76970309c5704db1c229143043bcc0.
* build-aux/.gitignore: arg-nonnull.h, ar-lib, c++defs.h.
2017-07-29 13:03:15 +01:00
James Youngman
95816b29d4 find: avoid strftime's non-portable %F specifier.
* find/print.c (format_date): Avoid passing %F to strftime since
some implementation lack it.  Pass the synonymous %Y-%m-%d
instead.  This fixes a bug manifesting on HP Tru64 UNIX V5.1B.
Reported by Steven M. Schweda <sms@antinode.info>.
2017-07-23 22:19:42 +01:00
James Youngman
f1f03e0c47 ChangeLog: fix some incorrectly-formatted messages.
* build-aux/git-log-fix: Ignore a recent incorrectly-formatted
change-log message (5e56fe96bc5cf5c0b616dc0251dddebb7e480074)
which is replaced by another
(f146a243400c211a19c9b76e5f598b6d7c57b1b0).  Also don't copy the
resulting merge commit message into the ChangeLog.
2017-07-23 21:05:17 +01:00
James Youngman
3e94355b19 Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/findutils 2017-07-23 20:39:10 +01:00
James Youngman
f146a24340 locate: don't warn about slocate databases any more.
* locate/locate.c (search_one_database): Remove warning about
support for slocate databases being new.
2017-07-23 20:38:12 +01:00
James Youngman
5e56fe96bc 2017-07-23 James Youngman <jay@gnu.org>
* locate/locate.c (search_one_database): Remove warning about
	support for slocate databases being new.
2017-07-23 20:36:32 +01:00
Bernhard Voelker
0e74f89b5c doc: update the "STANDARDS CONFORMANCE" section in find.1
* find/find.1 (STANDARDS CONFORMANCE): Change the reference to the
POSIX standard from the 2003 Edition to the 2016 Edition.
In the list of supported primaries, add the missing ones:
-exec, -ok and -path.  Remove the stray duplicates from the list.
2017-06-29 19:02:08 +02:00
Bernhard Voelker
e4d77529d7 doc: clarify 'find -size' values prefixed with '+' and '-'
* doc/find.texi (node Size): Add a sentence to make even clearer that
values prefixed with '+' or '-' do not find files with an exact match
of N in file size.
* find/find.1 (-size): Likewise.
2017-06-29 18:50:29 +02:00
Bernhard Voelker
d2f3e014a0 doc: fix explanation of 'find -size' example
'find -size -1048576c' also matches empty files.

* doc/find.texi (node Size): Change "1 to 1,048,575 bytes" to
"0 to 1,048,575 bytes".
* find/find.1 (-size): Likewise.
2017-06-29 18:36:23 +02:00
Bernhard Voelker
79bc9191c7 doc: use correct IEC unit prefixes in the documentation of 'find -size'
find(1) uses binary-based units for the suffixes 'k', 'M', and 'G' of
the argument of the '-size' option: 1024, 1024*1024 and 1024^3.
Therefore, the documentation should use the correct IEC prefixes
kibibyte, mebibyte and gibibyte respectively (or their abbreviations
'KiB', 'MiB' and 'GiB').

* doc/find.texi (node Overview): Change 'Kilobytes' to the shorter
but correct 'KiB'.
(node Size): Use the above mentioned, correct IEC prefixes.
While at it, move the 'w' suffix up to match the man page.
* find/find.1 (-size): Likewise.
* find/parser.c (parse_size): Also change to IEX prefixes in some
comments for consistency.
* NEWS (Bug fixes): Mention the fix.

See also:
  https://en.wikipedia.org/wiki/Binary_prefix

Reported by Andreas Metzler in
  https://savannah.gnu.org/bugs/?51304
2017-06-29 18:31:07 +02:00
Andreas Metzler
3e4bb112ae doc: drop workarounds for missing xargs -o option
* doc/find.texi (Multiple Files): Mention the new --open-tty option
to be used as an alternative.
(Safe File Name Handling): Likewise.
* xargs/xargs.1 (EXAMPLES): Remove the tty redirection example.
2017-06-09 00:44:42 +02:00
Bernhard Voelker
40cd25147b xargs: add -o, --open-tty option
This option is available in the xargs implementation of FreeBSD, NetBSD,
OpenBSD and in the Apple variant.  Add it for compatibility.

* xargs/xargs.c (open_tty): Add static flag for the new option.
(longopts): Add member.
(main): Handle the 'o' case in the getopt_long() loop.
(prep_child_for_exec): Redirect stdin of the child to /dev/tty when
the -o option is given.  Furthermore, move the just-opened file
descriptor to STDIN_FILENO.
(usage): Document the new option.
* bootstrap.conf (gnulib_modules): Add dup2.
* xargs/xargs.1 (SYNOPSIS): Replace the too-long list of options by
"[options]" - they are listed later anyway.
(OPTIONS): Document the new option.
(STANDARDS CONFORMANCE): Mention that the -o option is an extension.
* doc/find.texi (xargs options): Document the new option.
(Invoking the shell from xargs): Amend the explanation of the
redirection example with a note about the -o option.
(Viewing And Editing): Likewise.
(Error Messages From xargs): Add the message when dup2() fails.
(NEWS): Mention the new option.

Fixes http://savannah.gnu.org/bugs/?51151
2017-06-09 00:44:42 +02:00
Bernhard Voelker
6dfd05ca58 doc: fix some -perm examples in find.info
* doc/find.texi (Mode Bits): Fix the description of the -perm examples
which search for the "022" mode bits: the match is for the file's group
and 'other' mode bits instead of for user and group.
While at it, remove a superfluous ';' in the adjacent example.
Bug introduced when adding the -perm examples in FINDUTILS-4.2.11.
* NEWS: Mention the fix.

Reported by Jacob Nevins <0jacobnk.gnu@chiark.greenend.org.uk> in
http://savannah.gnu.org/bugs/?50758
2017-04-13 08:41:20 +02:00
Bernhard Voelker
11a050cdb0 doc: clarify that -links counts hard links in find.1
* find/find.1 (TESTS): Mention that -links tests the number of
"hard links", not just "links".

Reported by Dan Jacobson <jidanni@jidanni.org>.
2017-03-13 08:12:11 +01:00
Bernhard Voelker
2a6129bfcc find: fix -printf '%h' for arguments with one or more trailing slashes
Previously, find would output the pathname name for the '%h' format
when that was passed with a trailing slash:

  $ mkdir foo
  $ find foo/ -printf '%h/%f\n'
  foo/foo/

* find/print.c (do_fprintf -> 'h'): Strip trailing slashes, i.e. any
number of directory separators, unless this is the root "/" directory.
* find/testsuite/find.gnu/printf-h.exp: Enhance test with various
combinations of "/", "./", "foo/", "./foo", "./foolink/", etc.
* find/testsuite/find.gnu/printf-h.xo: Add the expected output for the
above new test cases.
* NEWS: Mention the fix.

Bug introduced in commit FINDUTILS_4_2_18-1-6-g0fd15a4.

Reported by	Tavian Barnes <tavianator@gmail.com> in
  https://savannah.gnu.org/bugs/?50259
2017-02-20 18:54:08 +01:00
Bernhard Voelker
9d849f77d5 maint: add the bug number #50326 to NEWS
* NEWS (Bug Fixes): Add the above bug number to the NEWS entry
of commit v4.6.0-90-gc155689, now as this issue is also reported
as a bug.
2017-02-16 18:57:06 +01:00
Bernhard Voelker
f256654b5b gnulib: update to latest
* gnulib: Do the above.
2017-02-16 18:43:03 +01:00
Bernhard Voelker
6b7f2d6346 maint: improve readability of fstype.c
* find/fstype.c (fstype_known): Move variable from global context ...
(filesystem_type): ... here, and pass it on explicitly by reference
to file_system_type_uncached().
(file_system_type_uncached): Add fstype_known as parameter.
2017-02-08 23:13:05 +01:00
Bernhard Voelker
efb9fcf537 find: avoid unneccessary reading of the mount list
Add a static cache for mount list to fstype.c.

* find/fstype.c (get_file_system_list): Add wrapper around GNULIB's
read_file_system_list function with a static cache to avoid multiple
invocations of that GNULIB function.  Still re-read the list if the
first invocation didn't include the ME_TYPE members.
(is_used_fs_type): Use the above new wrapper.
(file_system_type_uncached): Likewise, and do not free the list here
anymore because this is now done in get_file_system_list() as needed.
2017-02-06 22:25:15 +01:00
Bernhard Voelker
f181bb2f8d maint: move is_used_fs_type to fstype.c
* find/parser.c (is_used_fs_type): Move to ...
* find/fstype.c: ... here.
* find/defs.h (is_used_fs_type): Add declaration.
2017-02-06 22:25:15 +01:00
Bernhard Voelker
92cf8145a2 maint: inline now last use of must_read_fs_list
* find/fstype.c (must_read_fs_list): Remove function and inline body ...
(file_system_type_uncached): ... here where its last use was.
(get_mounted_devices): Remove it from a comment.
2017-02-06 22:25:15 +01:00
Bernhard Voelker
8a08a8c048 maint: remove unused get_mounted_filesystems
* find/fstype.c (get_mounted_filesystems): Remove unused function ...
* find/defs.h (get_mounted_filesystems): ... and its declaration.
2017-02-06 22:25:15 +01:00
Goffredo Baroncelli
c1556892a6 find: fix memory leak in mount list handling
The following gnulib commit added the structure member me_mntroot
which our free_file_system_list function didn't consider, thus leading
to a memory leak:
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=c6148bca89e9

* find/fstype.c (free_file_system_list): Use gnulib's free_mount_entry
function to free the mount list instead of free()ing all members here
manually.
* NEWS (Bug Fixes): Mention the fix.

Reported in
http://lists.gnu.org/archive/html/findutils-patches/2016-12/msg00000.html
2017-02-06 22:25:15 +01:00
Bernhard Voelker
e4e142a8dc maint: avoid -Werror=missing-prototypes warning in oldfind
oldfind.c:169:1: error: no previous prototype for ‘get_current_dirfd’ [-Werror=missing-prototypes]
 get_current_dirfd (void)
 ^~~~~~~~~~~~~~~~~

* find/oldfind.c (get_current_dirfd): Remove unused function.
2017-02-06 22:25:01 +01:00
Bernhard Voelker
f2b49021e7 maint: avoid -Werror=unused-macros warning in oldfind
oldfind.c: At top level:
oldfind.c:88:0: error: macro "N_" is not used [-Werror=unused-macros]
 # define N_(String) gettext_noop (String)

cc1: all warnings being treated as errors

* find/oldfind.c (N_): Remove unused macro.
2017-02-06 22:25:01 +01:00
Bernhard Voelker
b161a1c6f3 maint: avoid -Werror=unsafe-loop-optimizations warning in oldfind
oldfind.c: In function ‘process_path’:
oldfind.c:1445:14: error: cannot optimize loop, the loop counter may overflow [-Werror=unsafe-loop-optimizations]
        while (cur_path_size < file_len)
              ^
cc1: all warnings being treated as errors

* find/oldfind.c (process_path): Replace loop by calculation, avoiding
the offending loop at all.
2017-02-06 22:25:01 +01: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
6faf2f529d gnulib: update to latest
* gnulib: Do the above.
* bootstrap: Update from gnulib.
* doc/find.texi: s/time stamp/timestamp/ to adhere to new syntax-check
rule from gnulib.
2017-02-06 22:25:01 +01:00
Bernhard Voelker
58faf1ac39 doc: fix typos in find.1
* find/find.1 (Positional options): s/optiona/options/; s/regulat/regular/

Reported by Yaroslav Chagovets in http://savannah.gnu.org/bugs/?49541
2016-11-06 18:10:15 +01:00
Bernhard Voelker
41b194e2ee maint: mention previous translation updates in NEWS
* NEWS (Translations): Add the languages updated with the previous
commit in alphabetical order.
2016-11-03 00:28:27 +01:00
Bernhard Voelker
06390954f2 maint: update po/*.po, po/findutils.pot with "make dist"
po/*.po: Update with "make dist".
po/findutils.pot: Likewise.
2016-11-02 23:43:42 +01:00
Bernhard Voelker
42ea242bdd doc: clarify that -path is part of POSIX in find.1
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html

* find/find.1: Change the description of the -path option mentioning
that it is now part of POSIX 2008.
* find/parser.c (parse_table): Change comment: -path is POSIX.
(insert_path_check): Likewise, plus remove the superfluous comment
about HP-UX.

Reported by Isabella Parakiss in
http://lists.gnu.org/archive/html/bug-findutils/2016-10/msg00001.html
2016-11-02 23:32:08 +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
7b6fd7b68b oldfind: fix compiler warnings
Avoid the following 2 warnings:

oldfind.c: In function ‘main’:
oldfind.c:228:5: warning: passing argument 1 of ‘ctime’ from incompatible pointer type [enabled by default]
     fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start/*.tv_sec*/));
     ^
In file included from ../gl/lib/time.h:41:0,
                 from ../gl/lib/sys/stat.h:44,
                 from oldfind.c:35:
/usr/include/time.h:264:14: note: expected ‘const time_t *’ but argument is of type ‘struct timespec *’
oldfind.c: In function ‘at_top’:
oldfind.c:1003:12: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
       base = pathname;
            ^

* find/oldfind.c (main): Correct the call to ctime; it takes time_t*,
so don't pass struct timeval*; instead, pass the address of the tv_sec
member.
(at_top): Declare base as const char*.
2016-11-02 23:32:01 +01:00
Bernhard Voelker
f704697121 maint: remove ChangeLog-2013 from distribution tarball
* Makefile.am (EXTRA_DIST): Remove ChangeLog-2013, as its content is
shipped in the generated ChangeLog file.

Reported by Steve in
http://lists.gnu.org/archive/html/bug-findutils/2016-10/msg00000.html
2016-11-02 23:31:56 +01:00
Bernhard Voelker
d93cbffd54 maint: merge README-alpha into README
As of findutils-4.6, this package is stable.

* README-alpha: Remove file, moving the useful content of it to ...
* README: ... here.
* doc/find-maint.texi: Remove README-alpha here, too.

Reported by Steve in
http://lists.gnu.org/archive/html/bug-findutils/2016-10/msg00000.html
2016-11-02 23:31:51 +01:00
James Youngman
54e1a86514 Updated the Bulgarian translation.
* po/bg.po: Updated the Bulgarian translation.
* NEWS: Mention this.
2016-07-17 20:17:32 +01:00
James Youngman
307e6dfef2 README-hacking: "./configure", not "configure".
* README-hacking: "./configure", not "configure".  Also fix a
grammatical error (missing "to") and point out that the "trivial
change" criterion is cumulative.
2016-07-17 20:05:54 +01:00
James Youngman
80a65cf7a8 find: manpage quoting fixes, including fixing missing quotes on "*~"
* find/find.1: quoting fixes; be consistent about quoting "!"
(it's likely not necessary in most places, but the previous
inconsistent approach was no more correct).  Use \(dq instead of
just ", where we specifically need a double quote.  This fixes a
quoting bug in which troff rendered "*~" as *~, presumably because
the "" was being eaten by macro argument processing.  We use \(aq
to ensure that quotes qre rendered correctly where double quotes
is needed, and `these quotes' where they are not.
2016-07-16 20:44:10 +01:00
James Youngman
0af0010884 gnulib: update to current master 2016-07-16 15:25:23 +01:00
Bernhard Voelker
155c9d1c22 Update gnulib submodule to latest
Fixes an FTS bug ignoring readdir() errors which also affected find(1).
See http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=6835fc458f

* gnulib: Update to latest.
* bootstrap: Likewise.
* NEWS: Specifically mention the fts readdir() fix.
2016-07-03 18:54:26 +02:00
Andreas Metzler
8727411b8c tests: avoid checking for features in installed find
* find/testsuite/test_type-list.sh: Run "${ftsfind}" (i.e. newly built
executable) instead of find (version installed on build-system).  The
latter may have prevented some tests to run.
Bug introduced in commit v4.6.0-61-g6c37ce4.
2016-07-03 13:15:16 +02:00
Andreas Metzler
19c786e277 tests: add basic -type checks to detect the previous regression
The regression (bug #48314) fixed in the previous commit was not
detected by the existing tests.

* find/testsuite/test_type-list.sh: Add checks for "-type f" and "-type l".
2016-07-03 13:15:11 +02:00
Maximiliano Curia
26d48c7cf9 Fix bug #48314: find: fix -type option regression on some platforms
Since commit v4.6.0-61-g6c37ce4, the option -type and -ltype is broken
on armel, armhf and mipsel at least.  The reason is that the union member
args of the struct predicate was not completely initialized as its new
bool types[] member may be implemented larger than the union member
initialized: str.

* find/tree.c (set_new_parent): Replace xmalloc() by xzalloc() to
initialize the complete new predicate structure.  Therefore, remove all
individual NULL and false initializations.
(get_new_pred): Likewise, plus move the xzmalloc() invocations before
the if-condition to have only one place left for the allocation, thus
improving readability.

Reported by Andreas Metzler <ametzler@bebt.de> in
https://savannah.gnu.org/bugs/?48314

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Copyright-paperwork-exempt: Yes
2016-07-03 13:15:08 +02:00
Bernhard Voelker
9364a43870 maint: make distcheck pass again
Since commit v4.6.0-67-g595060f, 'make distcheck' failed:

  ERROR: files left in build directory after distclean:
  ./find/oldfindnoop.out
  ./find/findnoop.out
  ./find/find--noop.err
  ./find/oldfind--noop.out
  ./find/find--noop.out
  ./find/oldfind--noop.err
  ./find/findnoop.err
  ./find/oldfindnoop.err
  Makefile:1985: recipe for target 'distcleancheck' failed

* find/testsuite/sv-48180-refuse-noop.sh: Change the names of the *out
and *err files to be located in the temporary directory.
2016-07-03 13:15:00 +02:00
Bernhard Voelker
595060f28e Fix bug #48180: find: avoid segfault for internal '-noop' option
The pseudo-option '-noop' was never meant to be exposed to the user
interface.  If specified by the user, find(1) segfaulted.
Bug introduced in commit FINDUTILS_4_3_0-1-12-g6b8a4db.

* find/parser.c (struct parser_table): Rename the parser_name element of
the ARG_NOOP entry from 'noop' to '--noop', thus indicating its pure
internal character.
(found_parser): Return NULL when the user has passed the '---noop' option;
the caller does the error handling.
* find/testsuite/sv-48180-refuse-noop.sh: Add test.
* find/testsuite/Makefile.am (test_shell_progs): Reference the test.
* NEWS (Bug fixes): Document the fix.

Reported by Tavian Barnes <tavianator@tavianator.com> in
    https://savannah.gnu.org/bugs/?48180
2016-06-14 20:49:42 +02: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
Andreas Metzler
9cb4175a17 maint: avoid implicit declaration of function warning
* find/parser.c: Remove unused #include "bugreports.h".
* find/util.c: Add #include "bugreports.h".
2016-05-30 03:27:15 +02:00
Steve Dougherty
85e8c810a2 doc: fix spelling of "output"
* doc/find.texi (node Controlling Parallelism): s/ouptut/output/
* xargs/xargs.1: Likewise.
* find/util.c (cleanup): While at it, fix the same typo here
in a comment, too.

Copyright-paperwork-exempt: Yes
2016-05-18 08:05:58 +02:00
Kamil Dudka
ae424b959c doc: clarify exit status handling of -exec command {} +
* find/find.1 (-exec): Explain how exit status is propagated if the
-exec command {} + syntax is used.
(-execdir): Likewise.

Reported at https://bugzilla.redhat.com/1325049
2016-04-18 11:47:47 +02:00
Young Mo Kang
9333e22e91 maint: correct some misspelled words in README-hacking
* README-hacking: Do the above.
2016-04-10 15:26:32 +02:00
Bernhard Voelker
6c37ce48a1 find: support list of file types for -type and -xtype
* find/defs.h (enum file_type): Add enumeration for all (supported)
file types.
(struct predicate): Replace 'type' by 'types' as an array of bool
for the above enum file_type.
* find/parser.c (insert_type): Treat the argument to -type and -xtype
as a comma-separated list of type letters: instead of storing the
single type of the predicate, save the searched type letters in the
above 'types' array.
* find/pred.c (pred_type): Change the comparison against the saved file
type predicate: now check if the type of the actual file is in the array
of searched 'types'.
* find/testsuite/test_type-list.sh: Add test.
* find/testsuite/Makefile.am: Reference the test.
* find/find.1: Document the new feature.
* doc/find.texi: Likewise.
* NEWS: Likewise.
RFE originally initiated by Young Mo Kang in
http://lists.gnu.org/archive/html/bug-findutils/2016-02/msg00025.html
2016-04-10 14:58:55 +02:00
James Youngman
b17b94fd8a fix bug #46784: frcode drops last char if no final newline
* locate/testsuite/config/unix.exp (locate_textonly): Don't append
a newline to the input file.  Instead use exactly the data
specified by the caller.  This means that in some cases the input
now lacks a final newline.  Ignore any warning message produced by
frcode.
* locate/frcode.c (main): If the final character of the line
returned by getdelim is not the delimiter, don't overwrite it with
a NUL character.  Instead, issue a warning message.
* NEWS: Mention this bugfix.
2016-03-25 09:12:30 +00:00
Stephane Chazelas
5701f40c5e Complete the fix for Savannah bug #26092.
* doc/find.texi (Warning Messages): A warning is no longer
produced when the -iname predicate is used.
Copyright-paperwork-exempt: Yes
2016-03-24 07:35:49 +00:00
James Youngman
1575cbd54c Update gnulib to the current head.
* gnulib: Update submodule to current git head.
2016-03-24 07:13:12 +00:00
James Youngman
4c1731e034 Update Greek translation from the Translation Project.
* po/el.po: Update Greek translation from the Translation Project.
* NEWS: Mention this change.
2016-03-24 07:00:13 +00:00
James Youngman
c97c9c4f17 Adopt the use of the gnulib module "gendocs".
* doc/.gitignore: Ignore gendocs_template and gendocs_template_min,
since these are copied from gnulib/doc/.
* cfg.mk (manual_title): Set $manual_title, since this is needed
for maint.mk's nvocation of gendocs.sh.  Also set
$gendocs_options_ so that the Texinfo tools can find
dblocation.texi.
* build-aux/.gitignore: Ignore gendocs.sh since it is copied into
this directory by gnulib-tool (the file is part of the gendocs
module).
* bootstrap.conf (maintainer_modules): Add gendocs, so that we can
automate the generation of HTML and other documentation for
http://www.gnu.org/software/findutils.
2016-03-24 06:56:15 +00:00
Bernhard Voelker
47d8fd38f7 doc: fix example in find.1
* find/find.1 (EXAMPLES): In the example to skip SCM administrative
directories, parenthesize "\( ... \)" the ORed tests.  Otherwise, only
the SCM roots matching the last test, "CVS", are printed.

Reported in http://savannah.gnu.org/bugs/?47482
2016-03-22 08:14:44 +01:00
Bernhard Voelker
19f6f691de build: stop distributing gzip'd releases; xz is enough
* configure.ac (AM_INIT_AUTOMAKE): Add no-dist-gzip and dist-xz.
* NEWS (Build-related): Mention that we're dropping .tar.gz.
2016-02-16 23:33:53 +01:00
Bernhard Voelker
afbee64a09 doc: improve description of the -D option in find.1
* find/find.1 (-D): Change argument name from "debugoptions" to
"debugopts" to match the synopsis, thus making searching in the man
page easier.  While at it, sort possible arguments alphabetically.
2016-02-16 23:33:30 +01:00
Bernhard Voelker
894d806c6c all: output full usage only when requested via the --help option
When there are invalid options or arguments, all utilities printed the
full usage in addition to the original error diagnostic.  The quite
large text distracted the user's attention from the error message.

* find/defs.h (usage): Mark as _GL_ATTRIBUTE_NORETURN, and remove the
arguments FP and MSG.
* find/parser.c (parse_help): Factor out the usage text from here ...
* find/util.c (usage): ... to here.  Unless called with EXIT_SUCCESS,
just emit a short hint to try again with the --help option rather than
emitting the full usage.  Afterward, exit the program with the given
status.
(debugassoc): Sort array, as it is used in that order when outputting
the usage text.
(process_debug_options): Also output an error diagnostic when no
argument to -D is passed.
(show_valid_options): Always output to stdout, always output the header
line.  Update all callers.
* find/tree.c (build_expression): Update invocation of usage().
Also call it for syntax errors like unknown or invalid predicates
or invalid or missing arguments.
* locate/frcode.c (usage): Similar to the change in util.c (usage).
(main): Update invocation of usage().  Also output an error diagnostic
when an unexpected argument is passed.
* locate/locate.c (usage):  Similar to the change in util.c (usage).
(dolocate): Update invocation of usage().  Also output an error
diagnostic when an unexpected argument is passed.
* locate/updatedb.sh: Output "Try ... --help ..." when an invalid option
is passed.
* xargs/xargs.c (usage): Similar to the change in util.c (usage).
(parse_num, main): Update all callers, removing the now-obsolete
return or exit().
* NEWS (Improvements): Mention the change.
2016-02-16 23:33:22 +01: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
a57ca182e0 maint: add new bugreports.c to POTFILES.in
* po/POTFILES.in (lib/bugreports.c): Add entry.
2016-02-16 23:27:31 +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
96bbf4267e Update Danish translation.
* po/da.po: Update Danish translation from the Translation Project.
* NEWS: Mention this change.
2016-01-25 23:59:49 +00:00
James Youngman
931fc967d1 updatedb: use the common definitions of the bug-report URL etc.
* locate/Makefile.am (updatedb): Substitute PACKAGE_BUGREPORT,
PACKAGE_BUGREPORT_URL and PACKAGE_URL.  We do this in the Makefile
directly since updatedb.sh is not an output file generated
directly by configure (instead, it's generated by the Makefile
itself).
* configure.ac (PACKAGE_BUGREPORT_URL): AC_DEFINE defines only a
preprocessor macro.  In order to get a similar effect for
substituted output files, we need to use AC_SUBST.  Hence
introduce a shell variable $bugreport_url which we pass to both
AC_SUBST and AC_DEFINE_UNQUOTED (replacing the previous call to
AC_DEFINE).
* locate/updatedb.sh (usage): Use PACKAGE_URL and PACKAGE_BUGREPORT_URL.
2016-01-25 23:56:17 +00: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
James Youngman
b182bf64db xargs: better error message for xargs -s notanumber.
* xargs/xargs.c (parse_num): Specify the value passed for the
invalid argument to make it easier to debug things when bug
reports don't specify the actual command line.
2016-01-24 23:32:19 +00:00
James Youngman
89ec0211ce updatedb: Remove support for the old pre-4.0 database format.
* locate/testsuite/Makefile.am (EXTRA_DIST_EXP): Remove
locate.gnu/old_prefix.exp and locate.gnu/oldformat.exp.
(EXTRA_DIST_XO): Remove locate.gnu/old_prefix.xo and
locate.gnu/oldformat.xo.
* doc/find.texi (Database Formats): Remove the warning about old
versions of locate failing to read the LOCATE02 database format.
Mention that the slocate database format is also supported.
(Old Database Format): Point out that updatedb will no longer
produce the old format.
(Invoking updatedb): Remove mention of the --old-format option.
Remove mention of --dbformat=old.
(Long File Name Bugs with Old-Format Databases): Remove this
section.
* locate/updatedb.sh: remove support for --dbformat=old and
--old-format.
(checkbinary): Don't look for the bigram and code binaries.
* locate/updatedb.1: Explain that support for the old database
format has been removed from updatedb and will shortly be removed
from locate also.  Remove the documentation for the removed
option --old-format and mention of --dbformat-old.
* locate/code.c: remove since this program was only used to
generate old-format databases.
* locate/bigram.c: remove since this program was only used to
generate old-format databases.
* po/POTFILES.in: Remove bigram.c and code.c.
* locate/word_io.c (putword): Remove this function, since it was
only needed for making old-format databases.
* find/find.1 (NON-BUGS): Don't mention bigram.c and code.c in the
example.
* locate/locatedb.h: Remove declaration of putword, which has been
deleted.
* locate/Makefile.am (libexec_PROGRAMS): Remove bigram and code
(since they were only used to generate old-format databases).
(updatedb): Don't substitute @bigram@ and @code@.
(code_SOURCES): Delete.
* locate/testsuite/locate.gnu/old_prefix.exp: delete test case for
the old database format.
* locate/testsuite/locate.gnu/old_prefix.xo: Likewise.
* locate/testsuite/locate.gnu/oldformat.exp: Likewise.
* locate/testsuite/locate.gnu/oldformat.xo: Likewise.
* TODO: manpages for bigram and code are no longer needed.
* NEWS: Mention these changes.
2016-01-10 17:23:13 +00:00
James Youngman
69e308b286 updatedb: the order of file name is changed, but still unspecified.
* locate/updatedb.sh: fix typo in comment pointed out by Bernhard
Voelker.
* NEWS: point out that the order of file names in the locate
database is now different, but still unspecified.
2016-01-10 16:56:41 +00:00
James Youngman
4b8a67d3ec updatedb: run in the C locale, don't do case-folding.
* locate/updatedb.sh: Set LC_ALL to C to avoid unexpected character
encodings in path names causing sort to fail (idea from Clarence
Risher).  Don't do case-folding, since the character set in now C,
which is likely inconsistent with the user's expectations anyway.
Honour $TMPDIR. Correct the error message you get if you specify
both --old-format and --dbformat.
* NEWS: Explain these changes.
2016-01-09 21:15:39 +00:00
Bernhard Voelker
7b1afb1caa maint: make copyright statements more consistent
Avoid growing lists of copyright year numbers by collapsing consecutive
years like "1996, 1997-2015, 2016" into a single range like "1996-2016".
This change may take effect the next time 'make update-copyright' is run.

* cfg.mk (update-copyright-env): Add with UPDATE_COPYRIGHT_USE_INTERVALS=1
as described above.  Also add UPDATE_COPYRIGHT_FORCE=1 to rejoin some
split lines if necessary.
2016-01-06 12:45:29 +01:00
Bernhard Voelker
939f78506a maint: add copyright header to configure.ac
* configure.ac: Do the above.
2016-01-06 12:26:25 +01:00
Bernhard Voelker
0a581f3bc7 maint: clarify that .x-update-copyright entries are EREs
The entries in the exemption list are processed by
"grep -vEf ./.x-update-copyright" and therefore evaluated as an
extended regular expression (ERE).  Thus, e,g, a "bootstrap" entry
would also match for "bootstrap.conf" which we may want to be updated.
The current entries are unambiguous so far, but to avoid confusion when
adding further entries in the future, turn them into proper EREs.

* .x-update-copyright: Change all entries to EREs, i.e. including
the caret ^ and dollar sign $ meta-characters matching the beginning
and the end of a line.
2016-01-06 12:09:25 +01:00
James Youngman
b6a7e39937 find: point out more clearly that -a has a higher precendence than -o.
* find/find.1 (OPERATORS): Point out that -o has lower precendence
than -a, even when the -a is implicit.
(NON-BUGS): Explain the same thing here.
2016-01-05 18:13:31 +00:00
Bernhard Voelker
be4566f079 maint: don't use obsolete gnulib modules
Avoid bootstrap warnings:

  Notice from module malloc:
    This module is deprecated. Use the module 'malloc-gnu' instead.
  Notice from module realloc:
    This module is deprecated. Use the module 'realloc-gnu' instead.

* bootstrap.conf (gnulib_modules): Use malloc-gnu and realloc-gnu
modules, rather than malloc and realloc.  The shorter-named modules
are deprecated.
2016-01-04 08:34:50 +01:00
Bernhard Voelker
538143cae9 doc: fix typo in find.1
* find/find.1 (GLOBAL OPTIONS): s/occurr/occur/
2016-01-04 08:34:45 +01:00
Bernhard Voelker
98f3d96a52 maint: fix file name in message of findutils-check-pofiles
* Makefile.am (findutils-check-pofiles): s/configure\.in/configure.ac/,
as that file has been renamed long ago (FINDUTILS_4_3_8-1-50-gc4ef190).
While at it, re-indent the lines to shorten the lines for readability.
(coverage-clean): Re-indent likewise.
(gen-ChangeLog): While at it, replace leading blanks by a tab here for
a proper make syntax; introduced in previous commit (v4.6.0-17-g48bf0d0).
2016-01-04 08:34:30 +01: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
Bernhard Voelker
36f8598d80 maint: remove po/Makevars as it is created during bootstrap
* po/Makevars: Remove.  This also avoids an sc_trailing_blank failure
due to a blank character after the empty EXTRA_LOCALE_CATEGORIES.
2016-01-04 08:21:55 +01:00
Bernhard Voelker
fb823ba984 build: avoid bootstrap error on clean tree
Avoid the following error when running ./bootstrap on a clean tree:

  autoreconf: running: aclocal -I gl/m4 --force -I gl/m4 -I m4
  configure.ac:129: error: AC_PROG_CC cannot be called after AM_PROG_CC_C_O
  ../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
  ../../lib/autoconf/general.m4:1462: AC_ARG_ENABLE is expanded from...
  configure.ac:129: the top level
  autom4te: /usr/bin/m4 failed with exit status: 1
  aclocal: error: echo failed with exit status: 1
  autoreconf: aclocal failed with exit status: 1
  ./bootstrap: autoreconf failed

* configure.ac (compiler-warnings-are-errors): Remove AC_PROG_CC, as this
has already run before and is not allowed at this point anyway.
2016-01-04 08:21:45 +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
44a9409d66 configure: Add option --enable-compiler-warnings-are-errors, limit --enable-compiler-warnings.
* configure.ac: For --enable-compiler-warnings, don't enable
warnings that flag usage common in gnulib (such as variable-length
arrays) or which provide no value (such as switch statements
lacking a default case that would never be used).  Also don't
enable some useful warnings (such as missed opportunitied to mark
a function as pure) which we don't yet have a portable way of
avoiding.
Also add a new option --enable-compiler-warnings-are-errors,
turning GCC compiler warnings into errors.  This is off by
default.
2016-01-03 17:53:26 +00:00
James Youngman
3068ecae8f find: Avoid dynamic format strings.
* find/print.c (do_fprintf): Don't use a dynamic format string,
even when we know it contains no formatting directives, because
this confuses whatever produces the GCC warning
-Wformat-security.
2016-01-03 17:53:26 +00:00
James Youngman
bcbfcb86be find: fix some compiler warnings.
* find/util.c (check_nofollow): Avoid compiler warnings about
comparison between the float variable release and some double
constants by changing the constants to be floats, too.
* find/parser.c (estimate_file_age_success_rate): Avoid warnings
of comparison of float against other types by consistently using
float constants.
(insert_type): move the definition of type_cell and set it in the
switch cases handling S_IFLINK and other types of file which may
not be defined on the platform we're building for.  We do this in
order to silence a compiler warning about use of an uninitialised
value.  It's not really used uninitialised, it's just that the
compiler doesn't know that the way we're calling error() will
cause that function not to return.
(parse_time): Avoid a compiler warning about signed/unsigned
comparison by using a cast.
* find/ftsfind.c: Don't #define USE_SAFE_CHDIR, it's unused.
Likewise STRINGIFY.
(show_outstanding_execdirs): Avoid overflowing int variable seen
by making a bool and setting it to true, instead of incrementing
it.
(main): Correct the call to ctime; it takes time_t*, so don't pass
struct timeval* (instead, pass the address of the tv_sec member).
* find/exec.c (launch): Avoid warnign of unused parameter ctl.  We
really don't use it, but this function takes the parameter as
it's a callback.
* find/pred.c (struct pred_assoc): make the pred_name member const.
* find/defs.h: Declare pred_quit as _GL_ATTRIBUTE_NORETURN.
2016-01-03 17:32:05 +00:00
James Youngman
44ab86cdc9 locate: Fix compiler warnings.
* locate/word_io.c (decode_value): Fix typo in comment.
(getword): Remove unused parameter minvalue.
* locate/locatedb.h: Adjust declaration of decode_value to remove
minvalue parameter.
* locate/locate.c: Declare dolocate().  Make that function static.
(visit_old_format): Don't pass a minvalue parameter to getword()
since it no longer wants it.
2016-01-03 17:29:36 +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
194c20be07 xargs: Avoid unused-macro warnings.
* xargs/xargs.c (main): Use __STDC_LIMIT_MACROS to avoid a
compiler warning about an unused macro.  Don't define N_() at all, since
we don't use it.
2016-01-03 17:29:36 +00:00
James Youngman
e7b976a7e8 find: Fix a number of compiler warnings (mostly const-correctness).
* find/find.c (get_current_dirfd): remove unused function.
(process_dir): make parameters const: parent, pathname, name.
(process_path): make parameters const: parent, pathname, name.
(at_top): Modify the function pointer parameter accordingly.
* find/ftsfind.c (get_fts_info_name): Now returns const char*, not
char*.
(show_outstanding_execdirs): Fix type of loop variable to avoid
possible overflow.
(process_all_startpoints): Avoid compiler warning about overflow
of int loop variable.
* find/defs.h (struct predicate): Make p_name const.
(struct state): make rel_pathname const.
* find/exec.c (impl_pred_exec): Make prefix const.
(launch): Silence compiler warning about unused parameter argc.
* find/pred.c (blank_rtrim): Make str parameter const, since we do
not modify it.
* find/util.c (debug_option_assoc): name and docstring are now
const qualified.
(show_valid_debug_options): Avoid signed/unsigned comparison by
using a size_t array index.
(set_stat_placeholders): Avoid a compiler warning on systems
lacking birth time fields (and on which this function therefore
does nothing).
2016-01-03 17:29:35 +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
36c63d385b maint: Remove --I../intl from AM_CPPFLAGS; the directory is gone.
* find/Makefile.am (AM_CPPFLAGS): Remove -I../intl, since that
directory does not exist; it was removed in 2006 by Paul Eggert
(commit 9499a434f9da547373fa9d236cb397717ebb0c50).
* locate/Makefile.am (AM_CPPFLAGS): Likewise.
* xargs/Makefile.am (AM_CPPFLAGS): Likewise.
2016-01-03 17:29:35 +00:00
James Youngman
34c53b7637 Make use of suggested GCC function attributes.
* gnulib-local/lib/gcc-function-attributes.h: New header file,
providing macros to allow portable use of GCC function attributes.
* gnulib-local/modules/gcc-attributes: New (local) module.
* bootstrap.conf (local_gl_dir): Set local_gl_dir so that we can
use our new module.  Use the gcc-attributes module.
* find/defs.h:
Include gcc-function-attributes.h.  Delete our local macro
ATTRIBUTE_NORETURN and use the one from the header file.
* find/parser.c: Include gcc-function-attributes.h.  Add
_GL_ATTRIBUTE_NORETURN to parse_help, parse_version and
pred_quit.
* find/print.c (checked_fprintf): add attribute
_GL_ATTRIBUTE_FORMAT_PRINTF to the function declaration.
2016-01-03 17:13:10 +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
James Youngman
68cb1d8cad gnulib: update to current head. 2016-01-03 00:02:18 +00:00
James Youngman
48bf0d0c0d Add a shell script to generate ChangeLog; strip cherrypick comments.
* build-aux/gen-changelog.sh: Shell script for generating the
ChangeLog.  The effect is much the same as the previous version of
the gen-ChangeLog rule, but it is easier to run this script to
discover what the ChangeLog resulting from a recent commit is.
The only change is that we now also use --strip-cherry-pick.
* build-aux/Makefile.am (EXTRA_DIST): Distribute gen-changelog.sh.
* Makefile.am (gen-ChangeLog): Simplify the gen-ChangeLog rule by
calling gen-changelog.sh.
2016-01-02 09:29:08 +00:00
James Youngman
5e27ee053e Update the German and Dutch translations.
* po/de.po: Update from the Translation Project.
* po/nl.po: Likewise.
* NEWS: Mention this change.
2016-01-02 09:14:42 +00:00
James Youngman
781382a623 Update estimated success rates from a survey of a real file system.
* find/pred.c (print_optlist): output now distinguishes more
clearly between estimated and actual success rates.
* find/parser.c (insert_type): Use estimated success rates
computed by surveying a real file system.  Use 4 digits of
precision for est_success_rate.
* find/tree.c (print_tree): Consistently use 4 digits of precision
for est_success_rate.
2016-01-01 23:54:48 +00:00
James Youngman
dc958f5f01 Avoid a test's unnecessary dependence on xargs.
Problem report from Ludovic Courtès (though this fix is unlike the one he
suggested).
* find/testsuite/sv-34976-execdir-fd-leak.sh (make_test_data):
Don't assume that there is an xargs binary already on the path.
2016-01-01 11:48:41 +00:00
James Youngman
9951518076 Retire configure --enable-debug in favour of find -D ...
* find/defs.h (enum DebugOption): add DebugTime.
* find/util.c (debugassoc): -D time sets the DebugTime debug flag.
* find/oldfind.c (main): print the value of options.cur_day_start
when "-D time" is in effect (instead of when DEBUG is #defined).
* find/ftsfind.c (main): Likewise.
* find/pred.c (pred_table): Instantiate pred_table even if DEBUG
is not #defined.
* find/parser.c (parse_version): DEBUG is no longer a (distinct)
feature.
* configure.ac: Remove the --enable-debug option (all debugging is
now controlled via find's -D option).  Don't #define the
preprocessor macro DEBUG.
* NEWS: Mention this change.
2016-01-01 09:50:56 +00:00
James Youngman
869d1d4333 Eliminate the need for the DEBUG_STAT preprocessor macro.
* configure.ac: We no longer need to #define DEBUG_STAT with
--enable-debug, since the relevant debug messages are controlled
instead with find's command-line option -D stat.
* find/defs.h (enum DebugOption): bitmask values are now expressed
as 1 << N instead of decimal values, simply to make it clearer
when we need to start worrying about which integer type is used to
hold the bitmask.
* find/parser.c (fallback_getfilecon): Print a debug message when
the -D stat option is in effect, whether or not find was
configured with --enable-debug.
(parse_version): DEBUG_STAT is no longer a (distinct) feature.
2016-01-01 09:50:34 +00:00
James Youngman
bcd85897c2 Remove the --enable-id-cache configure option.
* configure.ac: Remove the --enable-id-cache option.  This option
became a no-op in findutils-4.5.15.  Before that it did something
but the code was buggy.  See https://savannah.gnu.org/bugs/?45062
for details.
* NEWS: State that this configure option is removed.
2016-01-01 09:50:34 +00:00
James Youngman
3f823dbe42 Update the Hungarian translation 2016-01-01 09:49:21 +00:00
Andreas Metzler
27fd9e050e Add/elaborate on warning about find -size -1M.
* find/find.1: Elaborate on warning about find -size -1M.
* find.texi: Copy warning about find -size -1M from manpage.
2016-01-01 09:43:10 +00:00
Andreas Metzler
0025eb3c93 Document that %AT/%AX prints nanoseconds.
* doc/find.texi: Both %AT and %AX printf format specifiers print
nanoseconds since 4.3.3. - Document this.
* find/find.1: Likewise.
2016-01-01 09:43:10 +00:00
James Youngman
0f4da2007f Remove unused spell-checker LocalWords from TODO.
* TODO (LocalWords): Remove words which aren't actually used in
the document.
2015-12-31 10:26:34 +00:00
James Youngman
00501d3e58 Update the Slovak translation.
* po/sk.po: Update from the Translation Project.
* NEWS: mention this.
2015-12-30 23:59:43 +00:00
James Youngman
3e82cfaeb6 Retire the Kinyarwanda translation.
For some time now, this translation has had 0 out of the possible 283
messages actually translated, so the po file has no current value.  If
any findutils are once again translated this translation can be
reinstated.
* configure.ac: Remove rw from ALL_LINGUAS.
* po/rw.po: Delete.
2015-12-30 19:58:02 +00:00
James Youngman
4290cf1f05 Update release number to indicate that the Git tree no longer matches 4.6.0.
* configure.ac: Update version number to indicate that the Git
repository has moved on from 4.6.0 (the trunk will be 4.7.x release
series).
* NEWS: Likewise.
2015-12-30 19:58:01 +00:00
Bernhard Voelker
52e990c5f0 doc: mention 'make syntax-check' in README-hacking
* README-hacking (Submitting patches): Add the above.
2015-12-30 17:51:40 +01:00
Bernhard Voelker
f858ad088d doc: mention copyright assignment check prior to 'git push'
* README-hacking (Required format for check-in messages): Add a paragraph
aiming at maintainers to check that the author of the commit has proper
copyright assignment in place, or otherwise how to document that this
is not needed.
2015-12-30 17:51:40 +01:00
Bernhard Voelker
cdcf38dbeb doc: fix typos in README-hacking
* README-hacking (Required format for check-in messages): s/maded/made/;
s/modifies/modified/
2015-12-30 17:51:40 +01:00
James Youngman
992a6b62ab Release findutils version 4.6.0. This is a stable release.
* configure.ac: Update the version number to 4.6.0.
* NEWS: Update the version number to 4.6.0.  Add a release date.
Summarize the changes since the previous stable release.  Explain
that all bugs fixed in 4.4.x are also fixed in this release.
2015-12-28 21:18:30 +00:00
James Youngman
17f6f02e4c Update the Danish translation.
* po/da.po: Update the Danish translation.
* NEWS: Mention this update.
2015-12-28 21:03:54 +00:00
James Youngman
248be69b6b Fix a typo in bootstrap.conf.
* bootstrap.conf (maintainer_modules): Fix typo 'consder'.
2015-12-28 18:25:14 +00:00
Dmitry V. Levin
e28e76c14d Fix compilation warning.
xargs.c: In function 'fopen_cloexec_for_read_only':
xargs.c:387:1: warning: control reaches end of non-void function [-Wreturn-type]
* xargs/xargs.c (fopen_cloexec_for_read_only): Return result.
2015-12-28 18:18:22 +00:00
James Youngman
020ba5727f Move on from release 4.5.19.
* configure.ac: Advance the version to 4.5.20-git, signifying that
the code in the repository is no longer identical to that of the
4.5.19 release.
* NEWS: Likewise.
2015-12-28 18:17:20 +00:00
James Youngman
0082987996 Release findutils version 4.5.19.
* configure.ac: Update version number to 4.5.19.
* NEWS: Likewise, and also specify the release date.
2015-12-28 13:38:08 +00:00
James Youngman
a45d8a22f0 Previous spelling fix was from a Savannah-managed patch, not a bug report.
* NEWS: Correct the description of the previous change.
* build-aux/git-log-fix: Correct previous ChangeLog entry.
2015-12-28 13:06:54 +00:00
Ville Skyttä
dd7c9c6ee7 Spelling fixes (fixing Savannah bug #8688).
* locate/locate.c: typo fix: whcih
* doc/find.texi: typo fix: futher
* bootstrap.conf: spelling fix: consistant
* NEWS: Mention this change.
Copyright-paperwork-exempt: Yes
2015-12-28 12:59:44 +00:00
Bjarni Ingi Gislason
0193dbcda2 Improved formatting.
Patch contributed via http://bugs.debian.org/726870
* find/find.1: A full stop (.) that starts or ends a string and is a
part of it, is now protected with \& and the space between some
sentences has been reduced or increased.
Copyright-paperwork-exempt: Yes
2015-12-28 12:14:38 +00:00
Bjarni Ingi Gislason
ba448a7aa1 Typo and grammar fixes.
Issue and patch via http://bugs.debian.org/726870
Copyright-paperwork-exempt: Yes
* find/find.1: correct typos: filsystem, signifiy, immeidately
* find/find.1: correct grammar: which would -> which you would
2015-12-28 12:14:00 +00:00
James Youngman
601cef07bb Apply some improvements suggested by Mike Frysinger.
These improvements were suggested at https://savannah.gnu.org/bugs/?46714.
* find/Makefile.am (check_PROGRAMS): Put oldfind in check_PROGRAMS
instead of noinst_PROGRAMS, so that we don't build it when it is
not needed.
* m4/withfts.m4 (FIND_WITH_FTS): Fix whitespace alignment.
(FIND_WITH_FTS): The WITH_FTS C preprocessor macro and the
accompanying Automake conditional are no longer needed.
* THANKS: Add Mike Frysinger.
2015-12-28 10:38:28 +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
James Youngman
07968e17e4 Move on from the previous release.
* configure.ac: Update version number to 4.5.19-git, signifying
that the source tree in Git is not the same as the 4.5.18 release.
* NEWS: Likewise.
2015-12-28 10:03:58 +00:00
James Youngman
d6c033391f Release findutils-4.5.18.
* configure.ac: Update version number to 4.5.18.
* NEWS: Likewise, and set the release date to 2015-12-27.
2015-12-27 21:21:15 +00:00
James Youngman
9900125072 Updated po files as a side effect of "make dist".
* po/*.po: updated by "make dist".
* po/findutils.pot: updated by "make dist".
2015-12-27 21:10:04 +00:00
James Youngman
efd03fa50e Rename find/find.c to find/oldfind.c.
* find/Makefile.am (oldfind_SOURCES): rename find.c to oldfind.c.
* find/.gitignore: Likewise.
* po/POTFILES.in: rename find/find.c to find/oldfind.c
* find/defs.h: Change references to find.c to oldfind.c.
* doc/find-maint.texi (Factor Out Repeated Code): Likewise.
* find/ftsfind.c: Point out that this file is derived from
oldfind.c (instead of leaving a reference to the old name of the
renamed file).
* find/testsuite/config/unix.exp: Look for ftsfind.o instead of find.o
when checking that we're really looking at the build directory.
2015-12-27 21:09:46 +00:00
James Youngman
fc260795fd Remove support for installing oldfind.
This fulfills a reqeust made as Savannah bug #46714.
* NEWS: Mention this change.
* m4/withfts.m4 (FIND_WITH_FTS): --with-fts is the only supported
choice.  The configure script now fails if run using --without-fts
or --with-fts=no.
* find/Makefile.am (noinst_PROGRAMS): Never install oldfind.
Delete the oldfind.1 and ftsfind.1 manpages, leaving only find.1.
Fix a typo and remove some commented-out lines.
* find/find.c (main): add a comment pointing out that this is not
the main() function of th binary that actually gets installed.
* find/ftsfind.1: delete.
* find/oldfind.1: delete.
* find/find.1: Remove the section "BINARIES" since there are no
longer two binaries.
* find/testsuite/config/unix.exp: Assume --with-fts; hence the binaries
are always called oldfind and find (and there is no ftsfind binary).
2015-12-27 21:07:56 +00:00
James Youngman
2b39a561df Updated the Slovenian translation 2015-12-27 15:52:51 +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
Andreas Metzler
a6a525cdb2 Fix bashism ([[ ... ]] instead of [ ... ]).
* find/testsuite/test_escape_c.sh: Use [...] instead of [[...]].
2015-12-24 18:25:53 +00:00
James Youngman
9faa72296a Fix typo in NEWS file entry for 4.5.17.
* NEWS: Fix typo.
2015-12-24 17:43:59 +00:00
James Youngman
5b2fa3f385 Update version number indicating the code post-dates findutils-4.5.17.
* NEWS: Update version number.
* configure.ac (AC_INIT): Update version.
2015-12-24 17:42:31 +00:00
James Youngman
629e887dff Update version number in preparation for release of findutils-4.5.17.
* NEWS: Update version number.
* configure.ac (AC_INIT): Update version.
2015-12-24 16:39:45 +00:00
James Youngman
69e453dceb Mention upcoming changes to release signing keys.
* NEWS: Mention upcoming changes to release signing keys.
2015-12-24 16:37:34 +00:00
James Youngman
3de8c4f24a Documentation fix for bug #36960 and greater effect of POSIXLY_CORRECT.
* find/parser.c (parse_table): -warn is now parsed as a positional
option instead of a global one. This does not affect the effect of
-warn.  (found_parser): Warnings are no longer issued for global
options specified in confusing positions when the POSIXLY_CORRECT
environment variable is set.  POSIXLY_CORRECT also suppresses warnings
about -d and the use of '/' in the argument to -name.  * find/find.1:
Eliminate the duplicate section name OPTIONS, using the OPTIONS
section just for -L, -P and so on.  Other options are now documented
in the subsection POSITIONAL OPTIONS (if they take effect only on
items on the command line which appear later) or GLOBAL OPTIONS (if
they take effect even on tests/actions appearing before them).  The
-regextype option in particular is now correctly documented as being
positional.  We rename the EXPRESSIONS section to EXPRESSION in order
to match the usage summary.  The OPERATORS heading is demoted to a
subheading so that it fits within EXPRESSION.  (POSITIONAL OPTIONS):
be more explicit about how warnings are controlled by -warn, -nowarn
and POSIXLY_CORRECT.  * NEWS: Describe the changes to the find manual
page and warnings.
2015-12-24 16:08:40 +00:00
James Youngman
4b1f16d1b7 Update some control files in po/ for new version of gettext.
* po/Rules-quot: Updated as a result of updating gettext.
* po/Makevars.template: Likewise.
* po/Makevars: Likewise.
2015-12-24 11:41:59 +00:00
James Youngman
d286cf67dd Avoid an fd leak in fopen_cloexec_for_read_only.
* xargs/xargs.c (fopen_cloexec_for_read_only): when fdopen fails,
close the file descriptor instead of leaking it.  Also, use GNU-style
brace positioning. Both problems were noticed by Paul Eggert.
2015-12-23 23:23:05 +00:00
James Youngman
9ebef301ac Tweak 2015-12-23 ChangeLog entry to remove a spurious newline.
* build-aux/git-log-fix: Remove a spurious extra newline in the
change log entry for the 2015-12-23 change by Dmitry V. Levin.
2015-12-23 23:09:57 +00:00
James Youngman
cf19ebe4b4 Fix wording in the NEWS for 4.5.16.
* NEWS: fix wording: add missing "to" in the changes for 4.5.16.
2015-12-23 23:04:45 +00:00
James Youngman
175862af7b xargs: Don't leak file descriptors over an exec boundary.
This fixes a bug reported by Kyle Sallee (by email, so there is no
Savannah bug number for it).
* xargs/xargs.c (fopen_cloexec_for_read_only): New function; like
fopen (..., "r") but sets the resulting file to be closed on exec.
(main): Remember any non-O_CLOEXEC file desciptors that were open
on startup so that we don't get false positives later.
(prep_child_for_exec): Call complain_about_leaky_fds.
(main): Any file opened to support the -a option is marked
close-on-exec.  If we open /dev/tty to support the -p option, mark
that file close-on-exec, too.
* NEWS: mention this bugfix.
2015-12-23 22:45:18 +00:00
James Youngman
034a638eae Update the Serbian translation.
* po/sr.po: Update the Serbian translation.
* NEWS: mention this.
2015-12-23 22:03:17 +00:00
James Youngman
b3f4c467ee Update the Brazilian Portuguese translation.
* po/pt_BR.po: Updated Brazilian Portuguese translation.
* NEWS: mention this.
2015-12-23 22:01:04 +00:00
Dmitry V. Levin
f4d77401d0 Fix save_cwd/restore_cwd error diagnostics.
Before this change, a pointer to struct saved_cwd was used in place
of char*, leading to incorrect error diagnostics, e.g.:
$ chmod a-x . && find / -maxdepth 0 -exec true \;
find: Failed to change directory: ÿÿÿÿ: Permission denied
find: failed to restore initial working directory: ÿÿÿÿ: Permission denied

* find/exec.c (prep_child_for_exec): Fix error diagnostics.
* find/util.c (record_initial_cwd, cleanup_initial_cwd): Likewise.
2015-12-23 21:44:33 +00:00
James Youngman
2135babdee Fix menu item ordering in chapter "Coding Conventions".
* doc/find-maint.texi (Coding Conventions): Re-order menu items to
match the section ordering.
2015-12-23 21:02:19 +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
4796acc972 Update version number to make clear the current code is newer than 4.5.16.
* configure.ac: Update the version number to 4.5.17-git.
* NEWS: Likewise, begin a new section for 4.5.17.
2015-12-23 17:49:38 +00:00
264 changed files with 16037 additions and 88695 deletions

View File

@ -1,23 +0,0 @@
Makefile
Makefile.in
aclocal.m4
build
config.cache
autom4te.cache
config.h
config.h.in
configure
config.log
config.status
stamp-h1
config.sub
config.rpath
config.guess
gnulib
install-sh
link-warning.h
gnulib-git
tests
findutils-*
GNUmakefile
maint.mk

36
.gitignore vendored
View File

@ -1,26 +1,30 @@
/ABOUT-NLS
*~
ABOUT-NLS
ChangeLog
Makefile
Makefile.in
aclocal.m4
build
config.cache
autom4te.cache
build
ChangeLog
config.cache
config.guess
config.h
config.h.in
configure
config.log
config.status
stamp-h1
config.sub
config.rpath
config.guess
gl
config.status
config.sub
configure
.deps/
/gl/
/gnulib-tests/
/GNUmakefile
INSTALL
install-sh
link-warning.h
tests
*~
patches
INSTALL
/GNUmakefile
/maint.mk
Makefile
Makefile.in
patches
stamp-h1
.tarball-version
/tool-versions.txt

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "gnulib"]
path = gnulib
url = git://git.sv.gnu.org/gnulib.git
url = https://git.savannah.gnu.org/git/gnulib.git

5
.x-update-copyright Normal file
View File

@ -0,0 +1,5 @@
^ChangeLog-2013$
^COPYING$
^bootstrap$
^doc/fdl\.texi$
^tests/init\.sh$

26
COPYING
View File

@ -1,12 +1,11 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
@ -69,7 +68,7 @@ patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
TERMS AND CONDITIONS
0. Definitions.
@ -77,7 +76,7 @@ modification follow.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
@ -510,7 +509,7 @@ actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
@ -619,9 +618,9 @@ an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -646,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -665,12 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -211,7 +211,7 @@
More removal of support for -perm +MODE.
* find/parser.c (parse_perm): Remove no-longer-needed local var
and associated code. Reported by Eric Blake in
<http://savannah.gnu.org/bugs/?38474#comment9>.
<https://savannah.gnu.org/bugs/?38474#comment9>.
2013-04-21 Paul Eggert <eggert@cs.ucla.edu>
@ -532,7 +532,7 @@
When reallocating buf, be sure to update its buf_size.
Also free "altbuf".
Reported by Nemo Maelstrom Thorx in http://bugs.debian.org/687358
via Andreas Metzler in http://savannah.gnu.org/bugs/?37356
via Andreas Metzler in https://savannah.gnu.org/bugs/?37356
find: minor tweaks
* find/print.c (do_time_format): Use memcpy in place of sprintf.

View File

@ -1,15 +1,43 @@
AUTOMAKE_OPTIONS=gnits
# readme-alpha
# Make findutils.
# Copyright (C) 1996-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = gnu std-options subdir-objects readme-alpha
AM_CFLAGS = $(WARN_CFLAGS)
EXTRA_DIST = COPYING ChangeLog ChangeLog-2013 TODO config.h.in stamp-h.in \
THANKS bootstrap \
tool-versions.txt README-hacking
EXTRA_DIST = \
COPYING \
ChangeLog \
README-hacking \
THANKS \
TODO \
build-aux/git-version-gen \
config.h.in \
stamp-h.in \
tests/GNUmakefile \
tool-versions.txt
DISTCLEANFILES = tool-versions.txt
# "tests" is the gnulib unit test dir.
SUBDIRS = gl tests build-aux lib find xargs locate doc po m4
# "gnulib-tests" is the gnulib unit test dir.
SUBDIRS = gl build-aux lib find xargs locate doc po m4 gnulib-tests
ALL_RECURSIVE_TARGETS =
ACLOCAL_AMFLAGS = -I gl/m4 -I m4
@ -24,8 +52,9 @@ tool-versions.txt: Makefile
runtest --version ; echo ; \
makeinfo --version ) > $@
dist-hook: gen-ChangeLog findutils-check-pofiles findutils-check-testfiles
# Have .tarball-version based versions only in tarball builds.
dist-hook: gen-ChangeLog findutils-check-testfiles
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
# gen-Changelog must still work when $(top_srcdir)/.git does not exist
# because "make distcheck" verifies that you can "make dist" from the
@ -33,31 +62,14 @@ dist-hook: gen-ChangeLog findutils-check-pofiles findutils-check-testfiles
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d $(top_srcdir)/.git; then \
gen_start_date='2014-01-01' ; \
log_fix="$(top_srcdir)/build-aux/git-log-fix" ; \
test -e "$$log_fix" \
&& amend_git_log="--amend=$$log_fix" \
|| amend_git_log=; \
{ $(top_srcdir)/build-aux/gitlog-to-changelog \
--srcdir=$(top_srcdir) \
$$amend_git_log --since=$$gen_start_date \
&& cat $(top_srcdir)/ChangeLog-2013 ; \
} > $(distdir)/cl-t \
$(AUXDIR)/gen-changelog.sh $(top_srcdir) > $(distdir)/cl-t \
&& { rm -f $(distdir)/ChangeLog \
&& mv $(distdir)/cl-t $(distdir)/ChangeLog; } \
&& mv $(distdir)/cl-t $(distdir)/ChangeLog; } \
else \
echo "WARNING: $@: cannot generate ChangeLog since" >&2 && \
echo "$(top_srcdir) has no .git subdirectory" >&2 ; \
fi
## Check that we actually shipped all the .po files. If this rule fails,
## check ALL_LINGUAS in configure.in against the po files in the source
## directory (their names, not their contents)
findutils-check-pofiles:
@echo ; echo Checking to see if we distributed the full set of .po files
distcount=`ls $(distdir)/po/*.po | wc -l` ; srccount=`ls $(srcdir)/po/*.po | wc -l` ; test $$distcount -eq $$srccount || ( echo FAILED: Please check the value of ALL_LINGUAS in configure.in against the actual set of ".po" files >&2 ; false )
@echo All .po files distributed OK.
## Check that we actually shipped all the test files that exist in the source.
## runtest will run all the .exp files it finds, and so if we don't ship all
## of them, there will be some tests which people using the CVS code will be
@ -68,25 +80,53 @@ findutils-check-testfiles:
findutils-check-smells:
find $(srcdir) \( -path $(srcdir)/autom4te.cache -o \
-path $(srcdir)/gnulib -o \
-path $(srcdir)/gl -o \
-path $(srcdir)/tests -o \
-name .git -o \
\( -type d -name CVS \) \
\) -prune -o \
\( -type f -o -type l \) \
\! \( -name '*~' -o -name '*.xo' -o -name '*.xi' \) \
-print0 | \
xargs -0 python $(AUXDIR)/src-sniff.py
find $(srcdir) \
\( -path $(srcdir)/autom4te.cache -o \
-path $(srcdir)/gnulib -o \
-path $(srcdir)/gl -o \
-path $(srcdir)/gnulib-tests -o \
-name .git -o \
\( -type d -name CVS \) \
\) -prune -o \
\( -type f -o -type l \) \
\! \( -name '*~' -o -name '*.xo' -o -name '*.xi' \) \
-print0 \
| xargs -0 python $(AUXDIR)/src-sniff.py
# Update gnulib to latest, merging some additional files we take from there
# as well. This only works if the working tree of both findutils and gnulib
# are clean (which is checked first).
# The following is a good start to find additional candidates for copying:
# git ls-files \
# | sed 's,^.*/,,g; /^gnulib$/d; /^t-t$/d; /\.c$/d' \
# | grep -Ff - <( cd gnulib && git ls-files )
.PHONY: gnulib-sync update-gnulib-to-latest
gnulib-sync update-gnulib-to-latest:
@( cd $(srcdir) \
&& { printf 'gnulib: ' && git -C gnulib describe --always --dirty \
&& printf 'findutils: ' && git describe --always --dirty \
|| echo dirty; \
} | grep 'dirty$$' \
&& { echo "error: tree is dirty" >&2; exit 1; } || : \
&& git submodule foreach git pull origin master \
&& cp -v gnulib/doc/COPYINGv3 COPYING \
&& cp -v gnulib/doc/fdl.texi doc/fdl.texi \
&& cp -v gnulib/build-aux/bootstrap bootstrap \
&& git status --short -- gnulib COPYING doc/fdl.texi bootstrap \
)
# Clean coverage files generated by running binaries built with gcc
# -fprofile-arcs -ftest-coverage. We touch subdirectories here
# because the relecvant Makefile.am files (which we would otherwise
# because the relevant Makefile.am files (which we would otherwise
# edit to add an $(RM) command in their own coverage-clean rule) are
# generated by gnulib-tool and therefore we cannot add the rule to
# those files.
coverage-clean:
for dir in . gl/lib gl/lib/glthread gl/lib/uniwidth tests tests/uniwidth; do $(RM) $${dir}/*.gcno $${dir}/*.gcda $${dir}/*.gcov $${dir}/*.lcov; done
for dir in . gl/lib gl/lib/glthread gl/lib/uniwidth gnulib-tests \
gnulib-tests/uniwidth; do \
rm -f $${dir}/*.gcno $${dir}/*.gcda $${dir}/*.gcov $${dir}/*.lcov; \
done
clean-local: coverage-clean
include $(top_srcdir)/tests/local.mk

566
NEWS
View File

@ -1,15 +1,532 @@
GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Noteworthy changes in release ?.? (????-??-??) [?]
** Bug Fixes
find no longer crashes when diagnosing a directory cycle (without a symlink
being involved pointing to a parent directory).
[Bug present since the FTS implementation.]
'find -ignore_readdir_race' now better handles races between FTS reading a
directory and visiting its entries when the file or directory was meanwhile
removed. [#45930]
To fix a POSIX compatibility bug, -exec foo Z{} + is no longer a
complete predicate, because '+' is only a terminator when it follows
an argument which is exactly '{}'. The findutils documentation
already states this, and now find's behaviour matches the
documentation.
** Changes in find
As announced since the release of 4.7.0 (2019) and mandated by POSIX 2024,
the behaviour of the -mount option changed: while it was a mere alias for
the -xdev option to prevent descending into directories of another device,
the -mount option now makes find(1) ignore files on another device, i.e.,
'find -mount' will skip the entry of active mount points already.
Example, assuming the PROC filesystem is mounted on '/proc':
$ find / -mount -path /proc -print
$ find / -xdev -path /proc -print
/proc
[#54745]
The actions -execdir and -okdir now refuse the '{}' replacement in the zeroth
argument of the command to be run. While POSIX allows this for -exec, this is
deemed insecure as an attacker could influence which files could be found.
find now issues a warning when the punctuation operators '(', ')', '!' and ','
are passed with a leading dash, e.g. '-!'. Future releases will not accept
that any more. Accepting that was rather a bug "since the beginning".
** Documentation Changes
The forthcoming Issue 8 of the POSIX standard will standardise "find
-print0" and "xargs -0". Our documentation now points this out.
The code example for "Finding the Shallowest Instance" in the Texinfo manual
and the corresponding one in the EXAMPLES section in the find.1 man page have
been fixed. [#62259]
Translators contributed numerous fixes for issues in the find.1 man page.
The list of actions that suppress the default -print action has been
supplemented with the missing '-print0' and '-fprint0' actions.
* Noteworthy changes in release 4.10.0 (2024-06-01) [stable]
** Bug Fixes
Find now defaults to optimization level 1 rather than 2 and the
cost-based optimizer will only run at level 2 and above. This
should prevent changes of operation order which result in
user-visible differences in behaviour. [#58427]
If the -P option to xargs is not used, xargs will not change the way
in which the SIGUSR1 and SIGUSR2 signals are handled. This means
that they will cause the program to terminate if the signals were
not ignored in the process which started xargs. This also means that
xargs does not use parallel execution at all.
If you start xargs with '-P 1', then xargs will not be killed by these
signals, and they instead change the degree of parallelism.
This change improves xargs' POSIX compliance.
'xargs -P' now waits for all its child processes to complete before
exiting, even if one of them exits with status 255. [#64451]
If the -P option of xargs is in use, reads on standard input which are
interrupted by a signal are re-started. [#64442]
'find -name /' no longer outputs a warning, because that is a valid pattern
to match the root directory "/". Previously, a diagnostic falsely claimed
that this pattern would not match anything. [#62227]
'find -gid' (without the mandatory argument) now outputs a correct error
diagnostic. Previously it output: "find: invalid argument `-gid' to `-gid'".
The error diagnostic for non-numeric arguments has been improved as well.
Likewise for -inum, -links and -uid.
'find -user' and 'find -group' now allow to specify larger UIDs/GIDs.
Previously, that was limited to INT_MAX, although the types uid_t and gid_t
are larger on many systems, including x86_64 GNU/Linux. [#64900]
'find -xtype l' no longer fails on symbolic links that point to
themselves. These are treated similarly to broken links. [#51926]
** Improvements
The find predicates -used, -amin, -cmin, -mmin, -atime, -ctime, and -mtime
now properly diagnose a not-a-number argument. Previously, find dumped
core via an assertion. [#64717]
** Changes to the build process
findutils now builds again on systems with musl-libc.
This requires gettext-0.19.8.
findutils programs no longer fail for timestamps past the year 2038
on obsolete configurations with 32-bit signed time_t, because the
build procedure now rejects these configurations.
On systems without any year2038 support configure with --disable-year2038.
** Documentation Changes
When generating the Texinfo manual, `makeinfo` is invoked with the --no-split
option for all output formats now; this avoids files like find.info-[12].
The xargs documentation now describes the double dash "--" option delimiter.
The xargs examples in the Texinfo manual now use the -L and --replace options
instead of the deprecated -l and -i options. [#64480]
The TexInfo manual now uses upper-case 'B' as birthtime for the -newerXY
comparison consistently. [#65378]
** Translations
Updated the following translations: Belarusian, Brazilian Portuguese,
Bulgarian, Catalan, Chinese (simplified), Chinese (traditional),
Croatian, Czech, Danish, Dutch, Esperanto, Estonian, Finnish, French,
Galician, Georgian, German, Greek, Hungarian, Indonesian, Irish,
Italian, Japanese, Korean, Lithuanian, Luganda, Malay, Norwegian
Bokmaal, Polish, Portuguese, Romanian, Russian, Serbian, Slovak,
Slovenian, Spanish, Swedish, Turkish, Ukrainian, Vietnamese.
* Noteworthy changes in release 4.9.0 (2022-02-22) [stable]
** New features in find
find now supports the -files0-from option to be able to safely pass an
arbitrary number of starting points to the tool. The option requires a file
name as argument, or "-" to read from standard input. The entries in that
file have to be separated by NUL characters. [#60383]
** Changes in locate / updatedb
updatedb now skips (fuse-mounted) s3fs filesystems by default,
i.e., unless PRUNEFS is set.
** Bug Fixes
'find -D stat -L ...' no longer determines SELinux security information as
if the -L option was not given.
[Bug present since the SELinux implementation in 4.5.6]
'find -inum' and 'find -printf %i' now also work on platforms which allow
the inode number Zero; e.g. the GNU/Hurd uses inode number 0 for /dev/console.
Previously, find(1) would abort when visiting such a file.
[Bug present since FINDUTILS_4_5_4-1.]
findutils-4.8.0 failed to build on some MacOS versions.
Fixed by a gnulib update. [#59972, #59991]
** Documentation Changes
The find.1 man page and the Texinfo manual now show environment variables
in a consistent style. [#59963]
Furthermore, both add the description of the -printf format directive '%B',
for a file's birth time, and its limitations. [#61327]
The description of the -delete action has been improved and aligned among
the manual page and the Texinfo documentation. [#61774]
Various other documentation fixes - syntax issues and typos.
[#61303, #60823, #61341]
The output of 'find --help' now reads better.
The HTML online manual is using the official GNU stylesheet again.
** Changes to the build process
The find version without FTS, oldfind, has been completely removed. It has
not been installed since 4.5.18 (2015), and was only still used in tests.
* Noteworthy changes in release 4.8.0 (2021-01-09) [stable]
** Changes in xargs
'xargs -t' no longer outputs a trailing blank to stderr after the last argument
of each constructed command line to be executed. [#57291]
xargs now warns when more than one of the conflicting options --max-lines (-L,
-l), --replace (-i/-I) and --max-args (-n) are specified on the command line.
[#52137]
** Bug Fixes
find no longer crashes when an XFS filesystem is heavily changed during the run.
Discussed at: <https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html>
find -used works again. This predicate was not working properly since adding
the support for sub-second timestamp resolution for various predicates in
FINDUTILS_4_3_3-1 back in 2007.
Discussed at: <https://lists.gnu.org/r/bug-findutils/2019-11/msg00010.html>
** Improvements
'find -D exec' now diagnoses all -exec, -execdir, -ok and -okdir runs including
the call arguments and the exit code of the launched process. [#59083]
** Documentation Changes
The documentation of 'find -printf %Ak' has been improved: it now refers to the
strftime(3) documentation for a complete list of supported conversion
specifiers, and documents the 'F' conversion specifier ('yyyy-mm-dd').
The man pages (find.1, locate.1, locatedb.5, updatedb.1, and xargs.1) now
consistently end with the sections "REPORTING BUGS", "COPYRIGHT" and "SEE ALSO",
with the latter referring to the online page on the GNU web server.
The "EXAMPLES" section in the find.1 man page now shows the examples in a better
structure and uses consistent formatting.
Various man page fixes - syntax issues and typos.
[#59745, #59330, #59012, #58193, #57807, #57775]
Other documentation changes:
#58654: doc: clarify that 'find -perm +MODE' is unrelated to umask
#58458: doc: improve section 'Hard links', especially fix the description
regarding 'find -L -samefile FILE'.
#58205: find.1: clarify double dash '--' option
#58149: 'xargs --help' now mentions that --replace (-I, -i) splits the input
at newline characters.
#57025: doc: enhance description of tests accepting numeric arguments in find.1
[see also #49640].
#54730: Add additional valuable example of find -quit
#48135: Fix testsuite error on Hurd and BSD related to ln
#35253: Clarify descriptions of -printf %f, %h.
** Changes to the build process
The configure option --without-fts has been removed. The attempt to use
it stopped configure with an error message since 4.5.18 (2015) anyway.
* Major changes in release 4.7.0, 2019-08-29
** Changes to locate / updatedb
Support for generating old-format databases (with updatedb
--old-format or updatedb --dbformat=old) has been removed. The old
database format was deprecated in 2007 (and updatedb has warned about
this since that time). The locate program will will read old-format
databases, though this support also will be removed.
The updatedb script now operates in the C locale only. This means
that character encoding issues are now not likely to cause sort to
fail. It also honours the TMPDIR environment variable if that was
set, and no longer sorts file names case-insensitively.
The (unspecified) order in which filenames are stored in the locate
database is now different to previous versions. However, you should
not rely on locate's output appearing in any particular order in any
case.
** Improvements
All utilities now only show the full usage text when requested via
the --help option. Previously, when the user passed invalid options
or arguments, the user's attention to the corresponding error
diagnostic was distracted by that lengthy text.
find now accepts multiple file type arguments to the -type and -xtype
options separated by comma ','. For example, to search for symbolic
links and directories simply provide the shorter '-type l,d' instead
of the - yet more portable - '( -type l -o -type d )'.
find now diagnoses failures returned by readdir(). This bug was inherent
in the use of FTS.
find now exits in more cases immediately after the error diagnostic, i.e.,
without the following usage text, to make the former more eye-catching.
find now outputs a better hint in case the user passed an unquoted shell-
glob pattern to options like -name, i.e., when the offending argument is
an existing file.
find now supports the debug option '-D all' to include all of the other
debug options at once.
xargs now supports the -o, --open-tty option to reopen stdin as /dev/tty
in the child process before executing the command; useful to run an
interactive application. Added for compatibility with BSD.
xargs now supports the GNU_FINDUTILS_FD_LEAK_CHECK environment
variable to enable/disable fd leak check.
'xargs -t' (--verbose) now properly quotes each part of the command to the
executed if needed when printing it to stderr; likewise -p (--interactive).
** Documentation Changes
Prefer https:// over http:// links where possible, e.g. for '*.gnu.org' servers.
Both find.1 and the find texinfo manual now consistently document all of the
'N', 'L' and '?' possibilities in '-printf %Y' output when the determination of
the type of a symlink target fails.
find.1 now correctly states the -prune has no effect when the -depth option is
given. Before, it wrongly stated that -prune would return false in that case.
Some minor documentation improvements are listed in "Bug Fixes" below.
** Bug Fixes
#56820: find: improve diagnostic when a global option like -maxdepth is
specified after another argument like a test, thus hopefully avoiding
translation issues (at least French, German).
#56142: doc: fix bug #56142 by specifying which actions inhibit the
default -print.
#55272: find: improve diagnostic when -name or -iname is used with a pattern
containing a directory separator ('/'), suggesting to use -wholename
or -iwholename respectively.
#54859: doc: fix typo in 'xargs -l' examples in texinfo manual.
Change from 'xargs -1' (minus one) to 'xargs -l' (minus El) in 3 places.
#54838: doc: fix the examples of the -perm option in the texinfo documentation.
The example '-perm -g+w,o+w' was misplaced.
Bug present since FINDUTILS_4_2_27-1.
#54262: 'find -printf "%Y"' now correctly outputs 'N' for broken symlinks
(ENOENT or ENOTDIR). Previously, it output 'l' in such a case.
Bug introduced while attempting to fix #29460 in version v4.5.8.
#54171: 'find -depth' now outputs the name of unreadable directories.
Previously, FTS-based find missed to output those entries.
Bug present since the FTS implementation in FINDUTILS_4_3_0-1.
#52981: find: the '-delete' action no longer complains about disappeared files
when the '-ignore_readdir_race' option is given, too. That action will
also returns true in such a case now.
#52220: 'find -D' without any further argument no longer crashes.
Bug present since the implementation of -D in FINDUTILS_4_3_1-1.
#51304: doc: use correct IEC unit prefixes in the documentation of 'find -size'.
find(1) uses binary-based units for the suffixes 'k', 'M', and 'G' of
the argument of the '-size' option: 1024, 1024*1024 and 1024^3.
Therefore, the documentation should use the correct IEC prefixes
kibibyte, mebibyte and gibibyte respectively (or their abbreviations
'KiB', 'MiB' and 'GiB').
#50758: doc: fix the description of the -perm examples matching the permission
mode "022" in find's texinfo manual: the match is for the file's group
and 'other' mode bits instead of for user and group.
Bug introduced when adding the -perm examples in FINDUTILS-4.2.11.
#50326: find no longer leaks memory for a recently added member in gnulib's
mount list structure.
#50259: find -printf '%h' now outputs the correct path for arguments with one or
more trailing slashes. Previously, it would e.g. output "foo" instead
of "." when "foo/" was passed; likewise, it would output "/user/xxx/"
instead of "/user" when "/user/xxx//" was passed.
Bug introduced in FINDUTILS-4.2.19.
#48180: find -noop (an internal option not intended to be exposed to the user)
no longer crashes. Bug introduced in FINDUTILS-4.3.1.
#48030: find -exec + does not pass all arguments for certain specific filename
lengths. After the internal (usually 128k) buffer is full and find(1)
executed the given command with these arguments, it would miss to run
the command yet another time if only one other file argument has to be
processed. Bug introduced in FINDUTILS-4.2.12.
#46784: frcode drops last char if no final newline
** Changes to the build process
The configure option --enable-id-cache has been removed. It has been
a no-op since findnutils-4.5.15.
The configure option --enable-debug has been removed. Debugging in
find is now controlled by its -D option only.
The configure option --enable-silent-rules is the default now.
Use --disable-silent-rules or "make V=1" to get verbose build output.
"make dist" no longer builds .tar.gz files.
xz is portable enough and in wide-enough use that distributing
only .tar.xz files is enough.
Maintainer builds from the Git repository now derive the version string from
the version control system instead of using a fixed string (changed after each
release manually). As a result, the inter-release builds can now be
distinguished: e.g. "4.6.0.152-fe9c" is the 152th commit after the tag "v4.6.0"
and has the Git short hash "fe9c". Builds from an unclean tree are marked with
the suffix "-dirty".
The translation files in the PO directory are no longer version controlled;
instead bootstrap auto-updates them from "translationproject.org" during a
maintainer build.
A shell-style test framework borrowed from GNU coreutils has been added.
This allows better tests with more control over stdin, stdout, stderr,
signals, preparatory steps, cleanup, return code verification, root-only
tests, etc.
* Major changes in release 4.6.0, 2015-12-28
** Stable Release
This is the first stable release since findutils-4.4.2. The entries
below in this file detail the changes that have occurred since release
4.3.13 (which is the common ancestor of this release and
findutils-4.4.0). This release includes all the bug fixes
incorporated into the 4.4.x release series, since those bug fixes were
also applied to the 4.5.x release series.
** Summary of Changes
The most significant changes since the 4.4.2 release are:
1. Some backward-incompatible changes have been made to find:
- egrep regular expressions now work like GNU grep -E
- Minor changes to the way nanoseconds fields are printed
- find -perm +mode is now fully POSIX compliant (if you want the old
behaviour use -perm /mode).
- find -perm +numeric_mode is not supported any more. This syntax is
unspecified by POSIX. The prior functionality continues to be
available with -perm /numeric_mode. For more details see Savannah
bug #38474.
2. Some backward-incompatible changes have been made to xargs:
- if the child exits with status 126 or 127, xargs exits with status
123.
3. There are also a large number of bugfixes, performance enhancements
and documentation improvements, as detailed below.
4. The "oldfind" binary is no longer installed.
** Translations
Updated the Danish translation.
* Major changes in release 4.5.19, 2015-12-28
** Bug Fixes:
Applied patch #8688: Spelling fixes.
* Major changes in release 4.5.18, 2015-12-27
** Changes to find
Only the ftsfind binary will be installed, as "find". Installing
oldfind, under any name, is no longer supported. The configure option
--with-fts is still allowed, but trying to use it to enable the
installation of oldfind (for example by using --with-fts=no) results
in configure stopping with an error message.
** Translations
Updated the Slovenian translation.
* Major changes in release 4.5.17, 2015-12-24
** Future Changes to Release Signing Keys
Future findutils releases will be signed with a new GPG key, though
this release will be signed with the existing key. Here are the old
and new key fingerprints:
pub 1024R/64A95EE5 1996-04-04
Key fingerprint = 0C 1C D7 CA 66 33 D2 E9 14 E0 5F 16 D5 24 60 E9
uid James Youngman <jay@gnu.org>
uid James Youngman <JYoungman@vggas.com>
pub 4096R/C5DDACB9 2015-12-24
Key fingerprint = 0CF4 E8D8 7159 3224 8428 32B8 88DD 9E08 C5DD ACB9
uid James Youngman <james@youngman.org>
uid James Youngman <jay@gnu.org>
sub 4096R/771CE15D 2015-12-24
** Functional changes to find
When the POSIXLY_CORRECT environment variable is set, a warning is no
longer issued when '/' is found in the argument to -name. Use of
POSIXLY_CORRECT also turns off warnings about use of the deprecated
option -d and the use of global options in surprising positions.
** Documentation Changes
The EXPRESSION section of the find manpage is now organised somewhat
more clearly. The -regextype option is now correctly documented as
being positional.
** Bug Fixes:
When the -a option of xargs is used, xargs no longer leaks a file
descriptor (fixing a bug reported by Kyle Sallee).
** Translations
Updated the Brazilian Portuguese and Serbian translations.
* Major changes in release 4.5.16, 2015-12-23
** Functional Changes to find
Using -regextype egrep now has the same effect -regextype
Using -regextype egrep now has the same effect as -regextype
posix-egrep. This is the result of a change to gnulib to bring it
into line with GNU grep (see
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20974#22).
into line with GNU grep (see https://debbugs.gnu.org/20974#22).
** Translations
Updated translations: Estonian, Swedish, Polish, Vietnamese, Ukranian,
Updated translations: Estonian, Swedish, Polish, Vietnamese, Ukrainian,
Norwegian Bokmaal, Czech, Russian, French, Hungarian.
** Bug Fixes:
@ -38,7 +555,7 @@ Norwegian Bokmaal, Czech, Russian, French, Hungarian.
#45062: Enabling CACHE_IDS causes segfaults (this bug affects many
historic releases, probably since release 3.0 in 1991). You
would not have been affected by this problem unless you used
the option --enable-id-cache when invoking confgure.
the option --enable-id-cache when invoking configure.
#42903: checklists.py now supports Python 3.
@ -86,7 +603,7 @@ Some minor documentation improvements are listed in "Bug Fixes" below.
** Translations
Updated translations: Estonian, Polish, Ukranian.
Updated translations: Estonian, Polish, Ukrainian.
* Major changes in release 4.5.12, 2013-09-22
@ -185,7 +702,7 @@ For example use "xargs /bin/echo < foo" rather than "xargs < foo".
A new option is provided, --process-slot-var. If you set this, xargs
will set the indicated environment variable in each child. The values
are re-used, but no executing child process will have the same value
are reused, but no executing child process will have the same value
as another executing child process. This wishlist item was Savannah
bug #29512.
@ -215,7 +732,7 @@ expression types selected by the -regextype option have slightly
changed, to bring them into line with the behaviour of the GNU C
library. For "awk", character classes (such as [[:digit:]]) are now
supported. For "gnu-awk" and "posix-awk", intervals are supported and
invalid interval specifcations are treated as literals (for example
invalid interval specifications are treated as literals (for example
'a{1' is treated as 'a\{1').
@ -298,7 +815,7 @@ Updated Vietnamese, Czech, Dutch, Polish, Russian translations.
** Performance changes
If you use the -fstype FOO predicate and specify a filsystem type FOO
If you use the -fstype FOO predicate and specify a filesystem type FOO
which is not known (e.g. present in /etc/mtab) at the time find
starts, that predicate is now equivalent to -false. This substitution
currently occurs at optimisation level 2 and above.
@ -374,7 +891,7 @@ in the text).
#22708: Exit status 126 and 127 from the utility invoked from xargs
now makes xargs return 123, meaning that exit status values 126 and
127 now unambigously mean that the utility could not be run or could
127 now unambiguously mean that the utility could not be run or could
not be found, respectively.
** Documentation Changes
@ -414,13 +931,13 @@ unknown user or is missing.
#25154: Allow compilation with C compilers that don't allow
declarations to follow statements.
#24342: -inum predicate shoud use dirent.d_ino instead of stat.st_ino
#24342: -inum predicate should use dirent.d_ino instead of stat.st_ino
(this is a performance bug).
** Translations
Updated translations for Bulgarian, German, Irish, Hungarian,
Lithuanian, Dutch, Polish, Slovenian, Swedish, Turkish, Ukranian,
Lithuanian, Dutch, Polish, Slovenian, Swedish, Turkish, Ukrainian,
Vietnamese.
** Documentation Changes
@ -438,7 +955,7 @@ The file README-CVS has been renamed to README-hacking and improved.
Changes to gnulib's fts code should provide performance improvements
in find when processing very large directories (for example
directories containing significantly more than 10000 filenames).
Performance imporvements may only exist for some find command lines
Performance improvements may only exist for some find command lines
(performance testing was done for the fts implementation itself but
we haven't done the analogous performance tests in find).
@ -901,7 +1418,7 @@ servers.
#11668: FreeBSD extensions for time specification are now
implemented. In fact, these were included in findutils-4.3.3. The
change was listed as a functional change (whcih it is) and this bug
change was listed as a functional change (which it is) and this bug
report was not mentioned.
** Documentation Fixes
@ -1126,7 +1643,7 @@ problem was worse for -exec.
Savannah bug #16579: Updatedb now works if it is running as a user
whose login shell is not actually a shell.
There have also been a number of documentation improvements (includng
There have also been a number of documentation improvements (including
Savannah bug #16269).
** Functional changes
@ -1446,7 +1963,7 @@ Some typos in the manual pages have been fixed. Various parts of the
manual now point out that it is good practice to quote the argument of
"-name". The manpage now has a "NON-BUGS" section which explains some
symptoms that look like bugs but aren't. The explanations of the "%k"
and "%b" directives to "find -printf" have been imrpoved.
and "%b" directives to "find -printf" have been improved.
* Major changes in release 4.2.21, 2005-06-07
@ -1662,7 +2179,7 @@ New Vietnamese message translation.
have it.
*** Bugfix to the findutils 4.2.6 automount handling (which hadn't been enabled
on Solaris).
*** Reenabled internationalisation support (which had been accidentally
*** Re-enabled internationalisation support (which had been accidentally
disabled in findutils-4.2.5).
* Major changes in release 4.2.6, 2004-11-21
@ -1700,7 +2217,7 @@ New Vietnamese message translation.
*** If you specify a 'find' option after non-option, a warning message
is now issued. Options should be specified immediately after the
list of paths to search. These warnings are enabled if you
specify the -warn option, or if stdin is a tty. They are diabled
specify the -warn option, or if stdin is a tty. They are disabled
by the use of the -nowarn option.
*** Like find, the locate program now supports an option --null (short form -0)
which changes the result separator from newline to NULL.
@ -1766,14 +2283,14 @@ New Vietnamese message translation.
** Bug Fixes
*** 'find -name \*bar now matches .foobar, because the POSIX standard
requires it, as explained at
http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
https://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
* Major changes in release 4.2.1, 2004-10-17
** Bug Fixes
*** find -iname now works correctly on systems that have an fnmatch() function
that does not support FNM_CASEFOLD
*** updatedb now uses signal names for "trap" instead of numbers,
as per bug #9465 (see http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html)
as per bug #9465 (see https://www.opengroup.org/onlinepubs/009695399/utilities/trap.html)
*** Better support for systems lacking intmax_t
** Other Changes
**** findutils now uses a newer version of gnulib (dated 2004-10-17).
@ -1933,12 +2450,11 @@ LocalWords: strncasecmp strcasecmp LIBOBJS FUNC prunefs allout libexec
LocalWords: testsuite Texinfo chdir inode fstype afs fls ls EOF lname
LocalWords: regex ilname iname ipath iregex printf fprintf
Copyright (C) 1996, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1996-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free
Documentation License'' file as part of this distribution.
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the ``GNU Free Documentation
License'' file as part of this distribution.

90
README
View File

@ -1,41 +1,30 @@
This package contains the GNU find, xargs, and locate programs. find
and xargs comply with POSIX 1003.2, as far as I know (with the
exception of the "+" modifier for the "-exec" action, which isn't
implemented yet). They also support a large number of additional
options, some borrowed from Unix and some unique to GNU.
and xargs comply with POSIX 1003.2. They also support a large number
of additional options, some borrowed from Unix and some unique to GNU.
See the file NEWS for a list of major changes in the current release.
See the file COPYING for copying conditions.
See the file INSTALL for compilation and installation instructions.
If there is no file INSTALL, you must be looking at the checked-out
source code instead of at an unpacked source tarball ("release"). In
that case, you should first please read and follow the instructions in
the file README-hacking. Those instructions explain how to generate
the auto-generated files needed to build findutils, and this includes
generating the INSTALL file.
To verify the GPG signature of the release, you will need the public
key of the findutils maintainer. You can download this from
ftp://ftp.gnu.org/gnu/gnu-keyring.gpg. Alternatively, you could query
a PGP keyserver, but you will need to use one that can cope with
subkeys containing photos. Many older key servers cannot do this. I
use subkeys.pgp.net. I think that one works. See also the
"Downloading" section of http://www.gnu.org/software/findutils/.
"Downloading" section of https://www.gnu.org/software/findutils/.
Special configure options:
--with-afs
Make find support "-fstype afs". Requires /afs, /usr/afsws/lib, and
/usr/afsws/include. configure doesn't add AFS support
automatically because it adds considerably to find's size, and the
AFS libraries need -lucb on Solaris, which breaks find.
--enable-id-cache
Make tables of used UIDs and GIDs at startup instead of using
getpwuid or getgrgid when needed. Speeds up -nouser and -nogroup
unless you are running NIS or Hesiod, which make password and group
calls very expensive.
--enable-debug
Produce output on the standard error output indicating what find is
doing. This information includes details about how the command line
has been parsed and what files have been stat()ed. This output is
normally interesting only to the maintainer, and so is off by default.
DEFAULT_ARG_SIZE=<value>
If this environment variable is defined to a numeric expression
during configure, it determines the default argument size limits used
@ -62,5 +51,60 @@ searching has been moved to a separate program, `locate'; the same
thing has been done in 4.4BSD. If you use locate, you should run the
included `updatedb' script from cron periodically (typically nightly).
The latest full release is available at
http://ftp.gnu.org/gnu/findutils.
The latest test release (if any) is available at
http://alpha.gnu.org/gnu/findutils
Discussion of the findutils package and ways to improve it takes place
on the "bug-findutils" mailing list, which you can join by sending
mail to bug-findutils-request@gnu.org. An archive of patches to the
bug-findutils mailing list is available at
https://lists.gnu.org/r/bug-findutils/.
Bug reports, suggested patches and enhancement requests for findutils
should be logged at https://savannah.gnu.org/bugs/?group=findutils.
Changes to the findutils code are sent to the findutils-patches
mailing list. To join, please send email to
findutils-patches@gnu.org. You are also welcome to send patches to
that list, but unless you are a list subscriber, you won't be able to
follow any resulting discussion. An archive of posts to the
findutils-patches mailing list is available at
https://lists.gnu.org/r/findutils-patches/.
See https://savannah.gnu.org/git/?group=findutils for instructions on
how to use git to access the findutils source code.
Mail suggestions and bug reports for these programs to
bug-findutils@gnu.org.
GNU Project notice
==================
GNU findutils is part of the GNU Operating System, developed by the GNU Project.
If you are the author of an awesome program and want to join us in writing
Free (libre) Software, please consider making it an official GNU program and
become a GNU Maintainer. Instructions on how to do this are here:
https://www.gnu.org/help/evaluation
Don't have a program to contribute? Look at all the other ways to help:
https://www.gnu.org/help/help.html
And to learn more about Free (libre) Software in general, please read and
share this page:
https://gnu.org/philosophy/free-sw.html
We are looking forward to hacking with you!
========================================================================
Copyright (C) 1996-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the "GNU Free
Documentation License" file as part of this distribution.

View File

@ -1,25 +0,0 @@
This is a test release of GNU findutils.
The latest test release (if any) is available at
ftp://alpha.gnu.org/gnu/findutils
The latest full release is available at
ftp://ftp.gnu.org/gnu/findutils.
Discussion of the findutils package and ways to improve it takes place
on the "bug-findutils" mailing list, which you can join by sending
mail to bug-findutils-request@gnu.org. An archive of patches to the
bug-findutils mailing list is available at
http://lists.gnu.org/archive/html/bug-findutils/.
Bug reports, suggested patches and enhancement requests for findutils
should be logged at http://savannah.gnu.org/bugs/?group=findutils.
Changes to the findutils code are sent to the findutils-patches
mailing list. To join, please send email to
findutils-patches@gnu.org. You are also welcome to send patches to
that list, but unless you are a list subscriber, you won't be able to
follow any resulting discussion. An archive of posts to the
findutils-patches mailing list is available at
http://lists.gnu.org/archive/html/findutils-patches/.

View File

@ -10,15 +10,16 @@ Prerequisites
* git (to check out both findutils and gnulib).
* A C compiler, linker and software development libraries (the standard
C library). Any compiler compliant with the 1990 ICO C standard running
C library). Any compiler compliant with the 1990 ISO C standard running
on a POSIX system should work.
* GNU Autoconf
* GNU Automake
* GNU Bison
* GNU m4
* GNU gettext
* GNU Dejagnu
Dejagnu is in fact optional, but it's strongly recommened, since it is
Dejagnu is in fact optional, but it's strongly recommended, since it is
needed to run findutils' test suite (which is how you know that find
works once it is built on your system).
@ -59,10 +60,10 @@ If you already have a copy you can refresh it with:
This will also run Autoconf and Automake to generate the "configure"
script and "Makefile.in" files.
3. Run "configure" and "make" in the normal way.
3. Run "./configure" and "make" in the normal way.
If you have GNU libintl installed, you can just run "configure".
Otherwise, run "configure --disable-nls".
If you have GNU libintl installed, you can just run "./configure".
Otherwise, run "./configure --disable-nls".
You are now at the point where your local directory looks just like it
would after building a source release, except that your copy is more
@ -105,15 +106,15 @@ proc_max.
MAX_PROC_MAX.
--- example ends ---
There are several things to notice about this checkin message. Most
importatly, it begins with a single line summary of the whole change.
There are several things to notice about this check-in message. Most
importantly, it begins with a single line summary of the whole change.
This needs to be short. It would be used as the subject line of
patches mailed by "git send-email". Some people begin that line with
a one-word tag indicating what is addected (for example find: for
a one-word tag indicating what is affected (for example find: for
changes to find, doc: to changes to the documentation, maint: for
changes to the maintainer automation and so forth).
All changes a file are grouped together in an entry which begins with
All changes to a file are grouped together in an entry which begins with
an asterisk (*) and the file name. The name of the modified function
(if any) follows immediately in parentheses followed by a colon. If
you're modifying a file for which "function" isn't the logical unit of
@ -122,11 +123,20 @@ modifying the Texinfo source, use the section name.
After the colon, describe the change you made to that function. If
you made a related change mention the places you made that change,
too. If you maded many individually small changes, you can summarise
too. If you made many individually small changes, you can summarise
these if they're not individually interesting. For example you could
just say "Update all callers to remove this function argument". If
that change spans several files, mention the other files modifies.
that change spans several files, mention the other files modified.
Note for maintainers:
Prior to pushing a commit in the name of someone else to the public
Git repository, please check if that person has undergone the
"Copyright assignment" process for GNU findutils described below, or -
in case of a trivial change (<10 lines, cumulatively with all their
previous contributions) - document that such paperwork is not required
by adding this line to the commit message:
Copyright-paperwork-exempt: Yes
Making commits locally
@ -164,7 +174,7 @@ Submitting patches
==================
If you plan to submit changes to findutils, please make sure you have
read the GNU coding standard (http://www.gnu.org/prep/standards/).
read the GNU coding standard (https://www.gnu.org/prep/standards/).
Some common things you might have forgotten to do are:
- document your change in both the manual pages and the Texinfo file
@ -194,6 +204,7 @@ Here is a complete session
emacs NEWS
# make sure you didn't break anything
make syntax-check
make distcheck
# commit the change and send the patches.
@ -223,26 +234,26 @@ The forms to choose from are in gnulib's doc/Copyright/ directory.
If you want to assign a single change, you should use the file,
doc/Copyright/request-assign.changes:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.changes;hb=HEAD
https://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.changes;hb=HEAD
If you would like to assign past and future contributions to a project,
you'd use doc/Copyright/request-assign.future:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.future;hb=HEAD
https://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.future;hb=HEAD
You may make assignments for up to four projects at a time.
In case you're wondering why we bother with all of this, read this:
http://www.gnu.org/licenses/why-assign.html
https://www.gnu.org/licenses/why-assign.html
========================================================================
Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc.
Copyright (C) 2009-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free
Documentation License'' file as part of this distribution.
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the ``GNU Free Documentation
License'' file as part of this distribution.

1
THANKS
View File

@ -34,6 +34,7 @@ Mark Kettenis <kettenis@gnu.org>
Martin Buchholz
Matt Mueller <donut@azstarnet.com>
Michael Haubenwallner <michael.haubenwallner@salomon.at>
Mike Frysinger <vapier@gentoo.org>
Nelson Beebe
Nigel Stepp <stepp@atistart.net>
Nix <nix@esperi.org.uk>

27
TODO
View File

@ -2,7 +2,7 @@
* Internationalization
** updatedb.sh should be internationalized
* man pages for frcode, bigram, and code
* man page for frcode
Perhaps a better description in texi pages as well.
* Add option for find to sort output in lexical order for use for updatedb
@ -81,9 +81,22 @@ Locale-dependent coverage:
--//--
This is used by Emacs' spell checker ispell.el:
LocalWords: strftime xargs updatedb sh strcpy
LocalWords: lib frcode bigram texi depcomp automake
LocalWords: LIBOBJS FUNC findutils
LocalWords: LIBC TOLOWER TOUPPER tolower isupper
LocalWords: Debian cron
LocalWords: Haible BeOS
LocalWords: xargs updatedb sh lib frcode bigram texi
LocalWords: findutils Debian cron
-----
Copyright (C) 1996-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

1773
bootstrap

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
# Bootstrap configuration.
# Copyright (C) 2006-2015 Free Software Foundation, Inc.
# Copyright (C) 2006-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
@ -13,7 +13,7 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Automake requires that ChangeLog exists.
touch ChangeLog
@ -36,9 +36,10 @@ maintainer_modules='
gitlog-to-changelog
maintainer-makefile
update-copyright
gendocs
'
# 'consder' comments copied from 'import-gnulib.config':
# 'consider' comments copied from 'import-gnulib.config':
# consider using do-release-commit-and-tag
# consider using gendocs
@ -54,7 +55,7 @@ update-copyright
# consider using gendocs
# consider using sig2str in xargs
# consider using signal (why not: maybe we don't need those features)
# consider using the dev-ino moduile to support -samefile.
# consider using the dev-ino module to support -samefile.
# consider removing stpcpy
# We have rpmatch, either use it for -ok and xargs or remove the dependency
@ -73,25 +74,29 @@ gnulib_modules="
alloca
areadlinkat
argmatch
argv-iter
assert
byteswap
basename-lgpl
bool
c-strcasestr
c-strstr
canonicalize
cloexec
closein
closeout
ctype
ctype-h
d-ino
d-type
dirent-safer
dirname
errno
dup2
endian
errno-h
error
faccessat
fchdir
fcntl
fdl
fcntl-safer
fdopendir
fflush
fileblocks
@ -99,23 +104,27 @@ gnulib_modules="
fnmatch-gnu
fopen-safer
fts
gcc-attributes
getdelim
getline
getopt-gnu
gettext
gettimeofday
gettext-h
gettime
git-version-gen
gnupload
gpl-3.0
hash
human
idcache
inline
inttypes
intprops
inttypes-h
isblank
locale
locale-h
lstat
malloc
malloc-gnu
manywarnings
math
math-h
mbrtowc
mbscasestr
mbswidth
@ -124,17 +133,20 @@ gnulib_modules="
modechange
modf
mountlist
nstrftime
open
openat-safer
parse-datetime
pathmax
perror
progname
quotearg
readlink
realloc
realloc-posix
regex
rpmatch
safe-read
same-inode
save-cwd
savedir
selinux-at
@ -143,58 +155,57 @@ gnulib_modules="
stat-macros
stat-size
stat-time
stdarg
stdbool
stddef
stdio
stdint
stdlib
stdarg-h
stddef-h
stdio-h
stdint-h
stdlib-h
stpcpy
strcasestr
strdup-posix
strftime
string
string-h
strndup
strtoull
strtoumax
sys_stat
sys_time
sys_wait
sys_stat-h
sys_time-h
sys_types-h
sys_wait-h
timespec
uname
unistd-safer
unlinkat
verify
version-etc
version-etc-fsf
warnings
wchar
wchar-h
wcwidth
xalloc
xalloc-die
xgetcwd
xstrtod
xstrtol
xstrtol-error
xstrtoumax
year2038-recommended
yesno
${maintainer_modules}
"
# Override bootstrap's defaults, with values consistant with
# Override bootstrap's defaults, with values consistent with
# 'import-gnulib.sh'
local_gl_dir='gnulib-local'
source_base=gl/lib
m4_base=gl/m4
# use 'libgnulib' instead of the default lib$package (=libfindutils)
# 'libgnulib' is mentioned in various 'Makefile.am' files.
gnulib_name=libgnulib
# PO files are checked-in in findutils, don't auto-update.
SKIP_PO=t
# Create 'gl/Makefile.am' which is mentioned in 'configure.ac'.
hack_gnulib_tool_makefile() {
cat > gl/Makefile.am <<EOF
# Copyright (C) 2004, 2009 Free Software Foundation, Inc.
# Copyright (C) 2006-2026 Free Software Foundation, Inc.
#
# This file is free software, distributed under the terms of the GNU
# General Public License. As a special exception to the GNU General
@ -212,12 +223,15 @@ EOF
# after 'gnulib-tool' is done, create the 'gl/Makefile.am' to be backward
# compatible with 'import-gnulib.sh'.
bootstrap_post_import_hook() {
hack_gnulib_tool_makefile
hack_gnulib_tool_makefile
# Copy tests/init.sh from Gnulib.
$gnulib_tool --copy-file tests/init.sh
}
# For compatibility with 'import-gnulib.sh', add gnulib's test directory.
# 'tests/Makefile' is mentioned in 'configure.ac'
gnulib_tool_option_extras="--with-tests"
# 'gnulib-tests/Makefile' is mentioned in 'configure.ac'
gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink"
# Additional xgettext options to use. Use "\\\newline" to break lines.
@ -261,9 +275,16 @@ fi
# Build prerequisites
buildreq="\
autoconf 2.59
automake 1.9.6
autoconf 2.64
automake 1.11.2
autopoint 0.19.2
bison -
gettext 0.19.2
git 1.5.5
m4 -
makeinfo 6.1
texi2pdf 6.1
tar -
gettext 0.18.1
wget -
xz -
"

View File

@ -1,22 +0,0 @@
compile
config.guess
config.rpath
config.sub
depcomp
install-sh
mdate-sh
missing
texinfo.tex
link-warning.h
Makefile.in
Makefile
mkinstalldirs
ylwrap
arg-nonnull.h
warn-on-use.h
c++defs.h
useless-if-before-free
vc-list-files
update-copyright
unused-parameter.h
gitlog-to-changelog

42
build-aux/.gitignore vendored
View File

@ -1,21 +1,29 @@
config.guess
config.rpath
config.sub
depcomp
install-sh
mdate-sh
missing
texinfo.tex
link-warning.h
Makefile.in
mkinstalldirs
ylwrap
compile
/config.rpath~
/arg-nonnull.h
/warn-on-use.h
/ar-lib
/c++defs.h
/compile
/config.guess
/*~
/config.rpath
/config.sub
/depcomp
/gitlog-to-changelog
/gnupload
/install-sh
/link-warning.h
/Makefile.in
/mdate-sh
/missing
/mkinstalldirs
/snippet/
/test-driver
/texinfo.tex
/unused-parameter.h
/update-copyright
/useless-if-before-free
/vc-list-files
/update-copyright
/unused-parameter.h
/gitlog-to-changelog
/warn-on-use.h
/ylwrap
/gendocs.sh
/git-version-gen

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007,2015 Free Software Foundation, Inc.
# Copyright (C) 2007-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,6 +11,6 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
EXTRA_DIST = check-testfiles.sh man-lint.sh
EXTRA_DIST = check-testfiles.sh man-lint.sh gen-changelog.sh

View File

@ -1,6 +1,6 @@
#! /bin/sh
# check-testfiles.sh -- Check we distributed all the test files we need
# Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
# Copyright (C) 2007-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
rv=0

30
build-aux/gen-changelog.sh Executable file
View File

@ -0,0 +1,30 @@
#! /bin/sh
# Generate the ChangeLog for findutils.
# Copyright (C) 2015-2026 Free Software Foundation, Inc.
# Written by James Youngman.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -u
top_srcdir="$1"
"${top_srcdir}/build-aux/gitlog-to-changelog" \
--srcdir="${top_srcdir}" \
--amend="${top_srcdir}/build-aux/git-log-fix" \
--ignore-matching='IGNORE_THIS' \
--no-cluster \
--since='2014-01-01' \
--strip-cherry-pick \
&& cat "${top_srcdir}/ChangeLog-2013"

View File

@ -2,6 +2,28 @@
# option. It specifies what changes to make to each given SHA1's commit
# log and metadata, using Perl-eval'able expressions.
# Fix bug reference URL:
# https://debbugs.gnu.org/?57291 -> https://sv.gnu.org/bugs/?57291
6e55ad98b1d8c66b524fb415f08cd2a599c7e654
s,bugs.gnu.org,sv.gnu.org/bugs,
# Suppress a merge log message.
3e94355b192ffd647ec22031c61c5df61b27f334
s,Merge branch 'master'.*,IGNORE_THIS,
# Suppress a badly-formatted checkin message (a later checkin contains
# the correct message, so the ChangeLog will still reflect the actual
# changes).
5e56fe96bc5cf5c0b616dc0251dddebb7e480074
s,2017-07-23.*,IGNORE_THIS,
dd7c9c6ee7fea07759e0a52716d4096598375638
s,fixing Savannah bug,applying Savannah patch,
# Remove a spurious blank line.
f4d77401d08cfb4aa90143f1b5905546f7912992
s,Permission denied\n\n,Permission denied\n,
# Ignore the revert message (since it reverts a commit which just had an incorrect
# log message)
4bce720c01367736e101f484b0939f5e0e56debb
@ -42,4 +64,3 @@ s,(find),* $1,
1d6d1afa52f40ad7c776e3ff0d4415409377e6fb
s/Mark/* po\/POTFILES.in: mark/;
s/(translation)/$1./

View File

@ -1,5 +1,5 @@
#! /bin/sh
# Copyright (C) 2007-2015 Free Software Foundation, Inc.
# Copyright (C) 2007-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -12,22 +12,62 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
case "${GROFF}" in
:)
echo "groff is not installed, so we cannot check manual pages. Continuing without checking them." >&2
exit 0
;;
"")
echo "The GROFF environment is not set; this is normally set when invoking this command from the Makefile; assuming GNU groff is at 'groff'." >&2
GROFF=groff
;;
*)
;;
esac
rv=0
srcdir="$1" ; shift
for manpage
do
what="lint check on manpage $manpage"
echo -n "$what: "
messages="$( troff -t -man ${srcdir}/${manpage} 2>&1 >/dev/null )"
if test -z "$messages" ; then
echo "passed"
else
echo "FAILED:" >&2
echo "$messages" >&2
rv=1
fi
done
exit $rv
fixed_width_context_message_without_newline() {
printf '%-45s (%15s): ' "$1" "$2"
}
check_manpages_format_without_error_messages() {
for manpage
do
fixed_width_context_message_without_newline \
'check_manpages_format_without_error_messages' "${manpage}"
messages="$( ${GROFF} -t -man ${srcdir}/${manpage} 2>&1 >/dev/null )"
if test -z "$messages"
then
printf 'OK\n'
else
printf 'FAILED\n%s\n' "$messages" >&2
return 1
fi
done
return 0
}
check_manpages_with_groff_checkstyle_2() {
for manpage
do
fixed_width_context_message_without_newline \
'check_manpages_with_groff_checkstyle_2' "${manpage}"
messages="$( ${GROFF} -t -z -ww -rCHECKSTYLE=2 -man ${srcdir}/${manpage} 2>&1 )"
if test -z "$messages"
then
printf 'OK\n'
else
printf 'FAILED\n%s\n' "$messages" >&2
return 1
fi
done
return 0
}
rv=0
check_manpages_format_without_error_messages "$@" &&
check_manpages_with_groff_checkstyle_2 "$@"

View File

@ -1,7 +1,7 @@
#! /usr/bin/env python
# src-sniff.py: checks source code for patterns that look like common errors.
# Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
# Copyright (C) 2007-2026 Free Software Foundation, Inc.
#
#
# This program is free software: you can redistribute it and/or modify
@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Many of these would probably be better as gnulib syntax checks, because
# gnulib provides a way of disabling checks for particular files, and

108
build-aux/tabs-to-spaces.sh Normal file
View File

@ -0,0 +1,108 @@
#! /bin/sh
# You might use this tool like this:
#
# sh build-aux/tabs-to-spaces.sh check $( find find lib locate tests xargs -regextype posix-extended -regex '.*[.]([ch]|cc)$' )
set -u
error() {
echo "$@" >&2
exit 1
}
cleanup() {
if ! rm -f "$@"
then
error "failed to delete temporary file(s) $@"
return 1
fi
}
usage_error() {
error "Please specify a sub-command (either 'check' or 'fix')."
}
make_expanded_file() {
if output="$(mktemp)"
then
expand -- "$1" > "${output}" && echo "${output}"
else
error 'failed to create temporary file'
fi
}
check() {
result=0
for input
do
if expanded="$(make_expanded_file ${input})"
then
cmp -s -- "${input}" "${expanded}"
rv="$?"
if ! cleanup "${expanded}"
then
return 1
fi
case "$rv" in
0) ;;
1) echo "${input} is incorrectly formatted (it contains tabs)"
result=1
;;
*) error "failed to compare ${input} with ${expanded}"
;;
esac
else
exit 1
fi
done
return $result
}
fix() {
for input
do
if expanded="$(make_expanded_file ${input})"
then
cmp -s -- "${input}" "${expanded}"
rv="$?"
case "$rv" in
0) if ! cleanup "${expanded}"
then
return 1
fi
# Otherwise, continue with next file.
;;
1) if ! mv "${expanded}" "${input}"
then
cleanup "${expanded}"
error "failed to replace ${input} with tab-expanded version ${expanded}"
else
unset expanded
fi
# Otherwise, continue with next file.
;;
*) error "failed to compare ${input} with ${expanded}"
;;
esac
else
exit 1
fi
done
}
main() {
if [ $# -eq 0 ]
then
usage_error
fi
case "$1" in
check) shift; check "$@" ;;
fix) shift; fix "$@" ;;
*) usage_error ;;
esac
}
main "$@"

225
build-aux/update-online-manual.sh Executable file
View File

@ -0,0 +1,225 @@
#! /bin/sh
# Copyright (C) 2019-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
##
## This script updates the online manual for findutils.
##
## When you run it, make sure you are in the "manual" directory.
PACKAGE=findutils
TITLE="Findutils"
TEXIBASE=find
set -e
usage() {
cat <<EOF
usage: $0 location-of-${PACKAGE}-build-directory
EOF
}
checkfiles="CVS ${TEXIBASE}.html html_node html_mono info ps texi text ${TEXIBASE}.pdf"
if [ $# -ne 1 ]; then
usage >&2
exit 1
fi
BUILDDIR="$1"
DOC_OUTPUT_DIR="`pwd`"
echo Current directory is `pwd`
echo "Are we in the right place? "
for f in $checkfiles
do
if test -e "$f"; then
echo " $f seems to be there"
else
printf " No, %s is missing.\n" "$f" >&2
exit 1
fi
done
echo "Yes, we are in the right place"
printf "Can we see the build directory? "
if [ -d "$BUILDDIR" ]; then
echo Yes.
else
echo "No." >&2 ; exit 1
fi
printf "Does the build directory have a 'doc' subdirectory? "
if [ -d "$BUILDDIR/doc" ]; then
echo Yes.
else
echo "No." >&2 ; exit 1
fi
printf "Does the build directory have a Makefile? "
if [ -f "$BUILDDIR"/Makefile ]; then
echo Yes.
else
echo "No." >&2 ; exit 1
fi
##
## Figure out where the source code lives by asking Make.
##
REL_SRCDIR="$(cd $BUILDDIR && grep '^srcdir =' Makefile | cut -d= -f2)"
echo "Build directory: '$BUILDDIR'"
echo "Relative path to source directory: '$REL_SRCDIR'"
SRCDIR="$(cd $BUILDDIR && cd $REL_SRCDIR && /bin/pwd)"
unset REL_SRCDIR
echo "Source directory: '$SRCDIR'"
if true
then
##
## Build (most of) the files we need.
## We collect them from the build directory afterwards.
##
make -C "$BUILDDIR" web-manual
cp ${BUILDDIR}/doc/manual/${TEXIBASE}.texi.tar.gz texi/${TEXIBASE}.texi.tar.gz
cp ${BUILDDIR}/doc/manual/${TEXIBASE}.info.tar.gz info/${TEXIBASE}-info.tar.gz
echo Collecting the PDF file...
cp $BUILDDIR/doc/manual/${TEXIBASE}.pdf .
echo "Collecting the text files (compressed and uncompressed)..."
cp $BUILDDIR/doc/manual/${TEXIBASE}.txt text
cp $BUILDDIR/doc/manual/${TEXIBASE}.txt.gz text
echo "Collecting the all-in-one-file HTML (compressed and uncompressed)..."
cp $BUILDDIR/doc/manual/${TEXIBASE}.html html_mono
cp $BUILDDIR/doc/manual/${TEXIBASE}.html.gz html_mono
echo "Collecting the file-per-node HTML tar file..."
find html_node/${TEXIBASE}_html -name '*.html' -type f -delete
cp $BUILDDIR/doc/manual/${TEXIBASE}.html_node.tar.gz html_node/${PACKAGE}.texi_html_node.tar.gz
echo "Unpacking the node-per-node HTML tar file..."
(set -x; cd html_node/${TEXIBASE}_html&& tar -zxf ../${PACKAGE}.texi_html_node.tar.gz )
fi
size () {
du -sh --apparent-size "$1" | awk '{print $1;}'
}
linkfor() {
what="$1"
type="$2"
shift 2
printf '<A HREF="%s">%s (%s %s)</A>' \
"$what" "$*" "$(size $what)" "$type"
}
##
##
## Now the rather complex bit; generate the index page!
##
##
echo "Generating the index page..."
cat >${TEXIBASE}.html <<EOF
<!--#include virtual="/server/header.html" -->
<TITLE>Finding Files: Table of Contents - GNU Project - Free Software Foundation (FSF)</TITLE>
<LINK REV="made" HREF="mailto:webmasters@www.gnu.org">
<META NAME="keywords" CONTENT="GNU, findutils, xargs, find, locate, finding files, file search, disk search, file name database, expand arguments, free software">
<meta http-equiv="Description" content="Tools for searching file systems" />
<BASE HREF="https://www.gnu.org/software/findutils/manual/find.html">
<!--#include virtual="/server/banner.html" -->
<H2>Findutils: Table of Contents</H2>
<P>
This manual is available in the following formats:
<P>
<UL>
<LI>
$(linkfor html_mono/${TEXIBASE}.html "characters" HTML)
entirely on one web page.
</LI>
<LI>
$(linkfor html_mono/${TEXIBASE}.html.gz "gzipped characters" HTML)
entirely on one web page.
</LI>
<LI> <a href="html_node/${TEXIBASE}_html/index.html">HTML (total size $(size html_node/${TEXIBASE}_html))</a>
with one web page per node.
</LI>
<LI> $(linkfor "html_node/${PACKAGE}.texi_html_node.tar.gz" "gzipped tar file" HTML)
with one web page per node.
</LI>
<LI>
$(linkfor "info/${TEXIBASE}-info.tar.gz" "gzipped tar file" "Info document")
</LI>
<LI>
$(linkfor "text/${TEXIBASE}.txt" "characters" "ASCII text")
</LI>
<LI>
$(linkfor "text/${TEXIBASE}.txt.gz" "gzipped characters" "ASCII text")
</LI>
<LI>
$(linkfor "${TEXIBASE}.pdf" "PDF file" PDF)
</LI>
<LI>the original
$(linkfor "texi/${TEXIBASE}.texi.tar.gz" "character gzipped tar file" "Texinfo source")
</LI>
</UL>
</div><!-- for id="content", starts in the include above -->
<!--#include virtual="/server/footer.html" -->
<div id="footer">
<P>
Return to <A HREF="/home.html">GNU's home page</A>.
<P>
Please send FSF &amp; GNU inquiries &amp; questions to
<A HREF="mailto:gnu@gnu.org"><EM>gnu@gnu.org</EM></A>.
Other <A HREF="https://www.fsf.org/about/contact.html">ways to contact</A> the FSF.
<P>
Please send comments on these web pages to
<A HREF="mailto:webmasters@www.gnu.org"><EM>webmasters@www.gnu.org</EM></A>,
send other questions to
<A HREF="mailto:gnu@gnu.org"><EM>gnu@gnu.org</EM></A>.
<P>
Copyright &copy; 1997-2026 Free Software Foundation, Inc.,
&lt;<A HREF="https://fsf.org/">https://fsf.org/</A>&gt;
<P>
Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.
<!-- This document was updated $(LC_TIME=C date +"%B %d, %Y") by $0 "$@" -->
<P>
Updated:
\$Date: 2019/05/05 15:13:38 $ \$Author: james $
<P>
<HR>
</BODY>
</HTML>
EOF
echo "All done."

275
cfg.mk
View File

@ -1,5 +1,5 @@
# cfg.mk -- configuration file for the maintainer makefile provided by gnulib.
# Copyright (C) 2010 Free Software Foundation, Inc.
# Copyright (C) 2010-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -12,15 +12,24 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
manual_title = Finding Files
# We need to pass the -I option to gendocs so that the texinfo tools
# can find dblocation.texi, which is a generated file.
gendocs_options_ = -s find.texi -I $(abs_builddir)/doc
local-checks-to-skip :=
# Tools used to bootstrap this package, used for "announcement".
bootstrap-tools = autoconf,automake,gnulib,bison
# Errors I think are too picky anyway.
local-checks-to-skip += sc_error_message_period sc_error_message_uppercase \
sc_file_system
sc_file_system sc_indent
exclude_file_name_regexp--sc_obsolete_symbols = build-aux/src-sniff\.py
exclude_file_name_regexp--sc_fsf_postal = build-aux/src-sniff\.py
exclude_file_name_regexp--sc_space_tab = \
xargs/testsuite/(inputs/.*\.xi|xargs.(gnu|posix|sysv)/.*\.xo)|find/testsuite/test_escapechars\.golden$$
@ -29,9 +38,36 @@ exclude_file_name_regexp--sc_space_tab = \
# any case we don't use help2man at all.
local-checks-to-skip += sc_two_space_separator_in_usage
# Comparing tarball sizes compressed using different xz presets, we see that
# an -7e-compressed tarball has the same size as the -9e-compressed one.
# Using -7e is preferred, since that lets the decompression process use less
# memory (19MiB rather than 67MiB).
# $ pkg=x; out=x.out; \
# printf "%3s %8s %6s %s\n" OPT PKGSIZE RESMEM TIME; \
# for i in {5..9}{e,}; do \
# xz -$i < findutils-4.7.0-git.tar > $pkg; \
# s=$(wc -c < $pkg); \
# env time -v xz -d - < $pkg >/dev/null 2> $out; \
# m=$(sed -n '/Maximum resident set size/{s/^.*: //;p;q}' < $out); \
# t=$(sed -n '/User time/{s/^.*: //;p;q}' < $out); \
# printf "%3s %8d %6d %s\n" "$i" "$s" "$m" "$t"; \
# done | sort -k2,2nr
#OPT PKGSIZE RESMEM TIME
# 5 1994080 10484 0.12
# 6 1956672 10564 0.11
# 5e 1935660 10456 0.11
# 6e 1930628 10396 0.11
# 8 1881520 34880 0.11
# 9 1881520 67732 0.12
# 7 1881496 18564 0.11
# 7e 1855268 18584 0.11
# 8e 1855268 35016 0.11
# 9e 1855268 67844 0.11
export XZ_OPT = -7e
# Some test inputs/outputs have trailing blanks.
exclude_file_name_regexp--sc_trailing_blank = \
^COPYING|(po/.*\.po)|(find/testsuite/(test_escapechars\.golden|find.gnu/printf\.xo))|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
^COPYING|(po/.*\.po)|(find/testsuite/find.gnu/printf\.xo)|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
^(.*/testsuite/.*\.(xo|xi|xe))|COPYING|doc/regexprops\.texi|m4/order-(bad|good)\.bin$$
@ -46,13 +82,244 @@ exclude_file_name_regexp--sc_prohibit_doubled_word = \
exclude_file_name_regexp--sc_program_name = \
^lib/test_splitstring\.c$$
# Suppress syntax-check failure regarding possibly evil strncpy use for now.
exclude_file_name_regexp--sc_prohibit_strncpy = ^(find/print.c|lib/buildcmd.c)$$
# sc_texinfo_acronym: perms.texi from coreutils uses @acronym{GNU}.
exclude_file_name_regexp--sc_texinfo_acronym = doc/perm\.texi
# List syntax-check exemptions.
exclude_file_name_regexp--sc_bindtextdomain = \
^(locate/frcode|lib/regexprops|lib/test_splitstring|find/getlimits|tests/xargs/test-sigusr)\.c$$
# sc_unmarked_diagnostics: exempt internal programs.
exclude_file_name_regexp--sc_unmarked_diagnostics = \
^(tests/xargs/test-sigusr)\.c$$
# Things that 'codespell' mistakenly flags as typos.
codespell_ignore_words_list = afile,bu,debbugs,filll,fo,hel,ois,siz,ublic,TE,
# Files to exclude from sc_codespell
exclude_file_name_regexp--sc_codespell = \
^(THANKS|build-aux/git-log-fix)$$
# sc_prohibit_strcmp is broken because it gives false positives for
# cases where neither argument is a string literal.
local-checks-to-skip += sc_prohibit_strcmp
# Ensure that each root-requiring test is run via the "check-root" rule.
sc_root_tests:
@t1=sc-root.expected; t2=sc-root.actual; \
grep -nl '^ *require_root_$$' `$(VC_LIST) tests` | \
sed 's|.*/tests/|tests/|' | sort > $$t1; \
for t in $(all_root_tests); do echo $$t; done | sort > $$t2; \
st=0; diff -u $$t1 $$t2 || st=1; \
rm -f $$t1 $$t2; \
exit $$st
# Ensure that all version-controlled test cases are listed in $(all_tests).
sc_tests_list_consistency:
@bs="\\"; \
test_extensions_rx=`echo $(TEST_EXTENSIONS) \
| sed -e "s/ /|/g" -e "s/$$bs./$$bs$$bs./g"`; \
{ \
for t in $(all_tests); do echo $$t; done; \
cd $(top_srcdir); \
$(SHELL) build-aux/vc-list-files tests \
| grep -Ev '^tests/init\.sh$$' \
| grep -E "($$test_extensions_rx)$$" \
| sed 's/\.c$$//'; \
} | sort | uniq -u | grep . && exit 1; :
# Ensure that all version-controlled test scripts are executable.
sc_tests_executable:
@set -o noglob 2>/dev/null || set -f; \
find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
find $(srcdir)/tests \( $$find_ext \) \! -perm -u+x -print \
| { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
| sort | uniq -d \
| grep -Ev '^tests/.*\.c$$' \
| sed -e "s/^/$(ME): Please make test executable: /" | grep . \
&& exit 1; :
# Avoid :>file which doesn't propagate errors
sc_prohibit_colon_redirection:
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>.*\|\|' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" >&2; \
exit 1; } \
|| :
sc_prohibit-skip:
@prohibit='\|\| skip ' \
halt='Use skip_ not skip' \
$(_sc_search_regexp)
# Disallow the C99 printf size specifiers %z and %j as they're not portable.
# The gnulib printf replacement does support them, however the printf
# replacement is not currently explicitly depended on by the gnulib error()
# module for example. Also we use fprintf() in a few places to output simple
# formats but don't use the gnulib module as it is seen as overkill at present.
# We'd have to adjust the above gnulib items before disabling this.
sc_prohibit-c99-printf-format:
@cd $(srcdir) \
&& GIT_PAGER= git grep -n '%[0*]*[jz][udx]' -- "*/*.c" \
&& { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
|| :
# Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
# The "exclude" expression allows common idioms like `test ... && fail=1`
# and the 2>... portion allows commands that redirect stderr and so probably
# independently check its contents and thus detect any crash messages.
sc_prohibit_and_fail_1:
@prohibit='&& fail=1' \
exclude='(returns_|stat|kill|test |EGREP|grep|compare|2> *[^/])' \
halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that tests don't use `cmd ... || fail` as that's a noop.
sc_prohibit_or_fail:
@prohibit='\|\| fail$$' \
exclude=':#' \
halt='|| fail detected. Please use: || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that env vars are not passed through returns_ as
# that was seen to fail on FreeBSD /bin/sh at least
sc_prohibit_env_returns:
@prohibit='=[^ ]* returns_ ' \
exclude='_ returns_ ' \
halt='Passing env vars to returns_ is non portable' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Use framework_failure_, not the old name without the trailing underscore.
sc_prohibit_framework_failure:
@prohibit='\<framework_''failure\>' \
halt='use framework_failure_ instead' \
$(_sc_search_regexp)
# Prohibit the use of `...` in tests/. Use $(...) instead.
sc_prohibit_test_backticks:
@prohibit='`' in_vc_files='^tests/' \
halt='use $$(...), not `...` in tests/' \
$(_sc_search_regexp)
# Ensure that compare is used to check empty files
# so that the unexpected contents are displayed
sc_prohibit_test_empty:
@prohibit='test -s.*&&' in_vc_files='^tests/' \
halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
$(_sc_search_regexp)
# Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
sc_prohibit_test_ulimit_without_require_:
@cd $(srcdir) \
&& (GIT_PAGER= git grep -l get_min_ulimit_v_ -- tests; \
GIT_PAGER= git grep -l 'ulimit -v' -- tests) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
# Ensure that tests call the cleanup_ function if using background processes
sc_prohibit_test_background_without_cleanup_:
@cd $(srcdir) \
&& (GIT_PAGER= git grep -El '( &$$|&[^&]*=\$$!)' -- tests; \
GIT_PAGER= git grep -l 'cleanup_()' -- tests | sed p) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should use cleanup_ for background processes" 1>&2; exit 1; } || :
# Ensure that tests call the print_ver_ function for programs which are
# actually used in that test.
sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
@cd $(srcdir) \
&& GIT_PAGER= git grep -w print_ver_ -- tests \
| sed 's#:print_ver_##' \
| { fail=0; \
while read file name; do \
for i in $$name; do \
grep -w "$$i" $$file|grep -vw print_ver_|grep . >/dev/null \
|| { fail=1; \
echo "*** Test: $$file, offending: $$i." 1>&2; };\
done; \
done; \
test $$fail = 0 || exit 1; \
} || { echo "$(ME): the above test(s) call print_ver_ for" \
"program(s) they don't use" 1>&2; exit 1; }
# Exempt the contents of any usage function from the following.
_continued_string_col_1 = \
s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
# Ding any source file that has a continued string with an alphabetic in the
# first column of the following line. We prohibit them because they usually
# trigger false positives in tools that try to map an arbitrary line number
# to the enclosing function name. Of course, very many strings do precisely
# this, *when they are part of the usage function*. That is why we exempt
# the contents of any function named "usage".
sc_prohibit_continued_string_alpha_in_column_1:
@perl -0777 -ne '$(_continued_string_col_1)' \
$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
|| { echo '$(ME): continued string with word in first column' \
1>&2; exit 1; } || :
# Use this to list offending lines:
# git ls-files |grep '\.[ch]$' | xargs \
# perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
# | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
exit 1; }; \
else \
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
exclude_file_name_regexp--sc_prohibit_test_backticks = \
^tests/(local\.mk|init\.sh)$$
# Ensure to use hyphenated "end-of-file".
sc_prohibit_unhyphenated_eof:
@prohibit='end[^-]of[^-]file' \
halt='use "end-of-file", not "e''nd of file"' \
$(_sc_search_regexp)
# Prohibit the use of tabs in findutils C source files (but not
# gnulib). This is not the same as sc_space_tab which prohibits only
# tabs which follow spaces.
sc_spaces_not_tabs:
@cd $(srcdir) \
&& GIT_PAGER= git grep -n ' ' -- \
"find/*.[ch]" \
"lib/*.[ch]" \
"locate/*.[ch]" \
"tests/*.[ch]" \
"xargs/*.[ch]" \
&& { echo '$(ME): Indent C sources with spaces, not tabs (fix with build-aux/tabs-to-spaces.sh)' 1>&2; exit 1; } \
|| :
# Enforce standard references "standard input/output/error".
sc_standard_outputs:
@cd $(srcdir) || exit 1; \
GIT_PAGER= git grep -En '_\("[^"]*std(in|out|err)' -- '*/*.c' \
&& { echo '$@: use "standard ....." in translated strings' 1>&2; \
fail=1; } || :; \
GIT_PAGER= git grep -En '[^/]std(in|out|err)' -- \
'*/*.1' '*/*.5' 'doc/*.texi' \
&& { echo '$@: use "standard ....." in user docs' 1>&2; \
fail=1; } || :; \
exit $$fail
# Now that we have better tests, make this the default.
export VERBOSE = yes
# During 'make update-copyright', convert a sequence with gaps to the minimal
# containing range.
update-copyright-env = \
UPDATE_COPYRIGHT_FORCE=1 \
UPDATE_COPYRIGHT_USE_INTERVALS=2 \
UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
# NEWS hash. We use this to detect unintended edits to bits of the NEWS file
# other than the most recent section. If you do need to retrospectively update

View File

@ -1,26 +1,57 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1996-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Written by James Youngman.
dnl Process this file with autoconf to produce a configure script.
AC_INIT([GNU findutils], 4.5.16, [bug-findutils@gnu.org])
# Make inter-release version strings look like, e.g., v4.6-131-gda920ee, which
# indicates that it is built from the 131st delta (in _some_ repository)
# following the v4.6 tag, and that da920ee is a prefix of the commit SHA1.
AC_INIT([GNU findutils],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[bug-findutils@gnu.org])
dnl Set the bug-report URL
dnl
dnl The call to AC_INIT causes AC_PACKAGE_BUGREPORT to be defined
dnl and we've used an email address. However, we would also like to
dnl specify an URL at which to report bugs (and in fact we prefer
dnl people to use that). Se we define that here, too.
bugreport_url='https://savannah.gnu.org/bugs/?group=findutils'
dnl Ensure that PACKAGE_BUGREPORT_URL shows up in config.h so that
dnl it can be picked up by bugreport.c.
AC_DEFINE_UNQUOTED([PACKAGE_BUGREPORT_URL], ["$bugreport_url"],
[URL at which bugs should be reported])
dnl Also ensure that it is substituted in output files so that it
dnl turns up in locate/Makefile so that we can generate the correct
dnl content in the updatedb script.
AC_SUBST([PACKAGE_BUGREPORT_URL],[$bugreport_url])
AC_CONFIG_AUX_DIR(build-aux)
AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([no-dist-gzip dist-xz color-tests])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AC_CONFIG_SRCDIR([find/pred.c])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
AC_CONFIG_MACRO_DIR(gl/m4)
dnl Set of available languages.
ALL_LINGUAS="be bg cs ca da de el eo es et fi fr ga gl hr hu id it ja ko lg lt ms nb nl pl pt pt_BR ro ru rw sk sl sr sv tr uk vi zh_CN zh_TW"
AC_SUBST(AUXDIR,$ac_aux_dir)
dnl check for --with-fts
FIND_WITH_FTS
AC_ARG_ENABLE(id-cache,
[ --enable-id-cache This currently has no effect.],)
AC_ARG_ENABLE(debug,
AS_HELP_STRING(--enable-debug,Enable debugging output which is likely to be interesting to people debugging findutils),
[ac_cv_debug=$enableval],[ac_cv_debug=no])
AC_ARG_ENABLE(leaf-optimisation,
AS_HELP_STRING(--enable-leaf-optimisation,Enable an optimisation which saves lstat calls to identify subdirectories on filesystems having traditional Unix semantics),
@ -38,15 +69,6 @@ AC_ARG_ENABLE(d_type-optimisation,
[ac_cv_d_type=$enableval],[])
AC_MSG_CHECKING([whether debug output should be produced])
if test x$ac_cv_debug = xno; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes])
AC_DEFINE([DEBUG], 1, [Define if you want to see find's innards])
AC_DEFINE([DEBUG_STAT], 1, [Define if you want to see a message every time find calls the stat() system call])
fi
AC_MSG_CHECKING([for leaf optimisation])
if test x$ac_cv_leaf_optimisation = xno; then
AC_MSG_RESULT([no])
@ -67,6 +89,7 @@ fi
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_EGREP
dnl for gnulib
gl_EARLY
@ -78,41 +101,83 @@ dnl AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_SYS_LARGEFILE
gl_INIT
dnl Enable various GCC warnings.
gl_MANYWARN_ALL_GCC([warnings])
# Set up the list of the pointless, undesired warnings.
nw=
nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
nw="$nw -Wundef" # All compiler preprocessors support #if UNDEF
nw="$nw -Wtraditional" # All compilers nowadays support ANSI C
nw="$nw -Wconversion" # These warnings usually don't point to mistakes.
nw="$nw -Wsign-conversion" # Likewise.
nw="$nw -Wc++-compat" # malloc returns void* and a cast would be ugly.
# Warnings we might enable in the future, but not yet (because they generate a
# lot of noise).
marginal=""
marginal="$marginal -Wtraditional-conversion"
marginal="$marginal -Wpadded"
marginal="$marginal -Wformat-nonliteral"
marginal="$marginal -Wunreachable-code"
marginal="$marginal -Wunused-parameter"
excluded_warnings="$nw $marginal"
# Enable all GCC warnings not in this list.
gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$excluded_warnings])
AC_ARG_ENABLE(compiler-warnings,
AS_HELP_STRING(--enable-compiler-warnings,Enable many compiler warnings),
[
for w in $warnings
do
gl_WARN_ADD([$w])
done
]
)
dnl Enable various GCC warnings.
gl_MANYWARN_ALL_GCC([warnings])
# Ensure VLAs are not used.
# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
# Set up the list of the pointless, undesired warnings.
findutils_nw=
findutils_nw="$findutils_nw -Wundef" # All compiler preprocessors support #if UNDEF
findutils_nw="$findutils_nw -Wtraditional" # All compilers nowadays support ANSI C
findutils_nw="$findutils_nw -Wconversion" # These warnings usually don't point to mistakes.
findutils_nw="$findutils_nw -Wsign-conversion" # Likewise.
findutils_nw="$findutils_nw -Wc++-compat" # malloc returns void* and a cast would be ugly.
findutils_nw="$findutils_nw -Wswitch-default" # A switch on an enum value needs no default.
# Warnings we might enable in the future, but not yet (because they generate a
# lot of noise).
findutils_marginal=""
findutils_marginal="$findutils_marginal -Wtraditional-conversion"
findutils_marginal="$findutils_marginal -Wpadded"
findutils_marginal="$findutils_marginal -Wformat-nonliteral"
findutils_marginal="$findutils_marginal -Wunreachable-code"
# -Wdouble-promotion generates many warnings when printing values with fprintf.
findutils_marginal="$findutils_marginal -Wdouble-promotion"
findutils_marginal="$findutils_marginal -Woverlength-strings"
# Also disable some other warnings that we do in principle want, but currently lack
# a way to portably avoid.
findutils_tmp_nowarning=
findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=pure"
findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=format"
# And some other warnings that we should fix but haven't, yet.
findutils_tmp_nowarning="$findutils_tmp_nowarning -Wsuggest-attribute=const"
# Enable all GCC warnings not in our list of excluded warnings.
gl_MANYWARN_COMPLEMENT(
[warnings], [$warnings],
[$findutils_nw $findutils_marginal $findutils_tmp_nowarning])
for w in $warnings
do
gl_WARN_ADD([$w])
done
# -Wextra implies -Wsign-compare, so removing -Wsign-compare from $warnings does not
# actually eliminate this warning, as manywarnings will have included -Wextra.
# We should actually eliminate the uses that cause this warning, but some of them are
# tricky as they're comparisons between a type we choose and a type the implementation
# chooses without stating whether or not it is signed (e.g. time_t).
WARN_CFLAGS="$WARN_CFLAGS -Wno-sign-compare"
# Likewise for -Wunused-parameter: it is implied by -Wunused and -Wextra.
gl_WARN_ADD([-Wno-unused-parameter])
# Likewise for -Wformat-nonliteral: it is implied by -Wformat.
gl_WARN_ADD([-Wno-format-nonliteral])
])
dnl For --enable-compiler-warnings-are-errors, any GCC compiler
dnl warning is actually an error which results in a non-zero result
dnl from the compiler (that is, the code will fail to compile). We do
dnl this late in the configure script so that it doesn't interfere
dnl with the compilation tests run by other parts of the configure
dnl script.
AC_ARG_ENABLE(compiler-warnings-are-errors,
AS_HELP_STRING(--enable-compiler-warnings-are-errors,Compiler warnings are errors),
[
AC_MSG_CHECKING([whether it is safe to use -Werror])
if test -n "$GCC"; then
CFLAGS="$CFLAGS -Werror"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, because $CC is not GCC])
fi
])
dnl Older versions of gl/m4/nls.m4 provide AM_MKINSTALLDIRS.
dnl The current version of gnulib does not, but the version of
@ -139,10 +204,11 @@ AC_CHECK_LIB([m],[fabs],[FINDLIBS="-lm $FINDLIBS"]
AC_SUBST([FINDLIBS])
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_INCLUDES_DEFAULT
AC_CHECK_HEADERS(sys/param.h mntent.h sys/mnttab.h sys/mntio.h sys/mkdev.h)
dnl fdleak.c needs sys/resource.h because it calls getrlimit(2).
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_FUNCS(getrlimit)
AC_HEADER_MAJOR
dnl TODO: it's possible gnulib eliminates the need for AC_HEADER_DIRENT.
AC_HEADER_DIRENT
@ -186,11 +252,6 @@ AC_CHECK_FUNCS(getmntent)
AC_CHECK_FUNCS(setmntent endmntent)
dnl Checks for library functions that are provided by findlib.
FINDLIB_REPLACE_FUNCS(waitpid strspn)
FINDLIB_REPLACE_FUNCS(forcefindlib)
# Check for common but not-POSIX functions.
AC_CHECK_FUNCS(setgroups)
@ -204,7 +265,7 @@ dnl #11710) (Sun Sep 4 20:15:11 2005: gl_INCLUDED_REGEX no longer seems
dnl to be available in gnulib CVS)
gl_REGEX
AC_PREREQ(2.59)
AC_PREREQ([2.69])
jy_SORTZ
@ -215,9 +276,12 @@ AC_CHECK_MEMBER(struct dirent.d_type,,,[
jy_AC_ATTRIBUTE_NORETURN
dnl internationalization macros
dnl Internationalization macros.
dnl AM_GNU_GETTEXT_REQUIRE_VERSION makes autopoint pull the latest available
dnl version instead of the exact specified version.
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.19.3])
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8])
dnl regextype.c and regexprops.c are designed to be usable outside findutils,
dnl but findutils doesn't want to support all the regex types in gnulib,
@ -232,6 +296,11 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
AC_CHECK_PROGS([FAKETIME],[faketime],[:])
AM_CONDITIONAL([HAVE_FAKETIME], [test "$FAKETIME" != :])
dnl Manpage linting.
AC_ARG_VAR(GROFF,[Location of GNU groff])
AC_CHECK_PROGS([GROFF], [groff],[:])
# This is necessary so that .o files in LIBOBJS are also built via
# the ANSI2KNR-filtering rules.
#LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
@ -253,7 +322,7 @@ locate/testsuite/Makefile
m4/Makefile
po/Makefile.in
po/Makefile
tests/Makefile
gnulib-tests/Makefile
xargs/Makefile
xargs/testsuite/Makefile
])

View File

@ -1,33 +0,0 @@
Makefile
Makefile.in
mdate-sh
*.aux
*.cp
*.cps
*.dvi
*.fn
*.fns
*.html
*.info
*.info-*
*.ky
*.log
*.pdf
*.pg
*.ps
*.toc
*.tp
*.vr
*.vrs
regexprops.texi
stamp-vti
version.texi
texinfo.tex
getdate.texi
find-maint.info
stamp-1
versionmaint.texi
fdl.texi
gpl-3.0.texi
regexprops-generic.texi
parse-datetime.texi

62
doc/.gitignore vendored
View File

@ -1,30 +1,34 @@
Makefile
Makefile.in
mdate-sh
find.aux
find.cp
find.cps
find.dvi
find.fn
find.fns
find.info
find.info-1
find.info-2
find.ky
find.log
find.pg
find.ps
find.toc
find.tp
find.vr
stamp-vti
version.texi
texinfo.tex
getdate.texi
versionmaint.texi
stamp-1
find-maint.info
fdl.texi
gpl-3.0.texi
regexprops-generic.texi
/Makefile
/Makefile.in
/mdate-sh
/find.aux
/find.cp
/find.cps
/find.fn
/find.fns
/find.html/
/find.info
/find.ky
/find.log
/find.pdf
/find.pg
/find.ps
/find.toc
/find.tp
/find.vr
/find-maint.html/
/find-maint.pdf
/find-maint.ps
/stamp-vti
/version.texi
/texinfo.tex
/getdate.texi
/versionmaint.texi
/stamp-1
/find-maint.info
/gpl-3.0.texi
/regexprops-generic.texi
/parse-datetime.texi
/dblocation.texi
/gendocs_template
/gendocs_template_min

View File

@ -1,4 +1,4 @@
# Copyright (C) 1996,1999,2000,2001,2003-2015 Free Software Foundation, Inc.
# Copyright (C) 1996-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,7 +11,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
AM_CFLAGS = $(WARN_CFLAGS)
info_TEXINFOS = find.texi find-maint.texi
@ -20,10 +20,20 @@ BUILT_SOURCES = dblocation.texi
nodist_find_TEXINFOS = dblocation.texi
find_maint_TEXINFOS = fdl.texi
MOSTLYCLEANFILES = find.cps
CLEANFILES = find.txt find_mono.html findutils.texi_html_node.tar.gz dblocation.texi
CLEANFILES = find.txt find_mono.html findutils.texi_html_node.tar.gz dblocation.texi \
find_mono.html findutils.texi_html_node.tar.gz \
find-info.tar.gz find.texi.tar.gz \
find.txt tmp-doc-install find_mono.html.gz
MAKEINFOTXT = $(MAKEINFO) --plaintext
# --no-split: tell makeinfo to put everything in a single info file,
# "<package>.info". Otherwise, it would generate into several files.
# CHECK_NORMAL_MENU_STRUCTURE (for makeinfo versions >= 6.8):
# Warn if the nodes pointers (either explicitly or automatically set)
# are not consistent with the order of node menu entries.
AM_MAKEINFOFLAGS = --no-split -c CHECK_NORMAL_MENU_STRUCTURE=1
find.txt: find.texi $(srcdir)/version.texi $(find_TEXINFOS)
# find.txt is a file which we need to know how to build
@ -49,8 +59,8 @@ find.txt: find.texi $(srcdir)/version.texi $(find_TEXINFOS)
# This rule is derived from the generic .texi.html rule.
find_mono.html: find.texi
rm -rf $(@:.html=.htp)
if $(MAKEINFOHTML) --no-split $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $(@:.html=.htp) $<; \
if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $(@:.html=.htp) find.texi; \
then \
rm -rf $@; \
if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
@ -68,8 +78,25 @@ find_mono.html: find.texi
# by the maintainer, and we don't need to build the file
# for "make all" or "make install" (or even "make check").
findutils.texi_html_node.tar.gz: find.html
tar zcf $@ $<
tar zcf $@ find.html
dblocation.texi: ../locate/dblocation.texi
$(LN_S) ../locate/dblocation.texi $@
find-info.tar.gz:
$(MKDIR_P) tmp-doc-install/info
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="tmp-doc-install" distdir="tmp-doc-install/info" \
dist-info
( cd tmp-doc-install && tar -c -f - info ) | GZIP=$(GZIP_ENV) gzip -c >| $@
rm -rf tmp-doc-install/info
rmdir tmp-doc-install
find.texi.tar.gz: $(TEXINFOS) $(find_TEXINFOS) $(nodist_find_TEXINFOS) $(info_TEXINFOS) $(find_maint_TEXINFOS) $(srcdir)/version.texi $(srcdir)/versionmaint.texi Makefile
$(MKDIR_P) tmp-doc-install/texi
for f in $(TEXINFOS) $(find_TEXINFOS) $(info_TEXINFOS) $(find_maint_TEXINFOS) version.texi versionmaint.texi ; \
do cp $(srcdir)/"$$f" tmp-doc-install/texi/ || break; done && cp dblocation.texi tmp-doc-install/texi/
( cd tmp-doc-install/texi/ && tar -c -f - *.texi ) | GZIP=$(GZIP_ENV) gzip -c >| $@
rm -rf tmp-doc-install/texi
rmdir tmp-doc-install

505
doc/fdl.texi Normal file
View File

@ -0,0 +1,505 @@
@c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{https://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, La@TeX{} input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG@. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{https://www.gnu.org/licenses/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.''@: line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

View File

@ -1,13 +1,13 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename find-maint.info
@settitle Maintaining Findutils
@include versionmaint.texi
@settitle Maintaining GNU Findutils @value{VERSION}
@c For double-sided printing, uncomment:
@c @setchapternewpage odd
@c %**end of header
@include versionmaint.texi
@iftex
@finalout
@end iftex
@ -21,24 +21,23 @@
This manual explains how GNU findutils is maintained, how changes should
be made and tested, and what resources exist to help developers.
This is edition @value{EDITION}, for findutils version @value{VERSION}.
This document corresponds to version @value{VERSION} of the GNU findutils.
Copyright @copyright{} 2007, 2008, 2010, 2011 Free Software Foundation,
Inc.
Copyright @copyright{} 2007--2026 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled
``GNU Free Documentation License''.
@end quotation
@end copying
@titlepage
@title Maintaining Findutils
@subtitle Edition @value{EDITION}, for GNU findutils version @value{VERSION}
@subtitle @value{UPDATED}
@title Maintaining GNU Findutils
@subtitle version @value{VERSION}, @value{UPDATED}
@author by James Youngman
@page
@ -88,7 +87,7 @@ This manual aims to be useful without necessarily being verbose. It's
also a recent document, so there will be a many areas in which
improvements can be made. If you find that the document misses out
important information or any part of the document is be so terse as to
be unuseful, please ask for help on the @email{bug-findutils@@gnu.org}
be useless, please ask for help on the @email{bug-findutils@@gnu.org}
mailing list. We'll try to improve this document too.
@ -235,9 +234,9 @@ circumstances.
@menu
* Make the Compiler Find the Bugs::
* Factor Out Repeated Code::
* The File System Is Being Modified::
* Don't Trust the File System Contents::
* Debugging is For Users Too::
* Don't Trust the File System Contents::
* The File System Is Being Modified::
@end menu
@node Make the Compiler Find the Bugs
@ -264,9 +263,9 @@ relating to problems with the program's execution environment should
be diagnosed with a user-oriented error message. An assertion failure
should always denote a bug in the program.
Don't use @code{assert} to catch not-fuly-implemented features of your
code. Finish the implementation, disable the code, or leave the
unfinished version on a local branch.
Avoid using @code{assert} to mark not-fully-implemented features of
your code as such. Finish the implementation, disable the code, or
leave the unfinished version on a local branch.
Several programs in the findutils suite perform self-checks. See for
example the function @code{pred_sanity_check} in @file{find/pred.c}.
@ -358,16 +357,13 @@ to be fixed. It's all to easy to miss some out when trying to fix the
bug. Equally, it's quite possible that when pasting the code into
some function, the pasted code was not quite adapted correctly to its
new environment. To pick a contrived example, perhaps it modifies a
global variable which it that code shouldn't be touching in its new
home. Worse, perhaps it makes some unstated assumption about the
nature of the input arguments which is in fact not true for the
global variable which it (that [original] code) shouldn't be touching
in its new home. Worse, perhaps it makes some unstated assumption about
the nature of the input arguments which is in fact not true for the
context of the now duplicated code.
A good example of the use of refactoring in findutils is the
@code{collect_arg} function in @file{find/parser.c}. A less clear-cut
but larger example is the factoring out of code which would otherwise
have been duplicated between @file{find/find.c} and
@code{find/ftsfind.c}.
@code{collect_arg} function in @file{find/parser.c}.
The findutils test suite is comprehensive enough that refactoring code
should not generally be a daunting prospect from a testing point of
@ -436,7 +432,7 @@ file is deleted from the one directory you are interested in, but if
less helpful.
Bear in mind also that it is possible for the directory @code{find} is
currently searching could be moved to another point in the filesystem,
searching to be concurrently moved elsewhere in the file system,
and that the directory in which @code{find} was started could be
deleted.
@ -484,7 +480,7 @@ information.
@node Using the GNU Portability Library
@chapter Using the GNU Portability Library
The Gnulib library (@url{http://www.gnu.org/software/gnulib/}) makes a
The Gnulib library (@url{https://www.gnu.org/software/gnulib/}) makes a
variety of systems look more like a GNU/Linux system and also applies
a bunch of automatic bug fixes and workarounds. Some of these also
apply to GNU/Linux systems too. For example, the Gnulib regex
@ -541,7 +537,7 @@ Make sure your editor follows symbolic links so that your changes to
directory you checked out earlier. Observe that your test now passes.
@item Prepare a Gnulib patch
In the gnulib subdirectory, use @code{git format-patch} to prepare the
patch. Follow the normal usage for checkin comments (take a look at
patch. Follow the normal usage for check-in comments (take a look at
the output of @code{git log}). Check that the patch conforms with the
GNU coding standards, and email it to the Gnulib mailing list.
@item Wait for the patch to be applied
@ -555,6 +551,23 @@ local diffs to be patched into gnulib beneath the
@file{gnulib-local}. Normally however, there is no need for this,
since gnulib updates are very prompt.
@section How to update Gnulib to latest
With a non-dirty working tree, the command @code{make update-gnulib-to-latest}
(or the shorter alias @code{make gnulib-sync} allows, well, to update the
gnulib submodule. In detail, that is:
@enumerate
@item Fetching the latest upstream gnulib reference.
@item Copying the files which should stay in sync like
@file{bootstrap} from gnulib into the findutils working tree.
@item And finally showing the @code{git status} for the gnulib submodule
and the above copied files.
@end enumerate
After that, the maintainer compares if all is correct, if the findutils build
and run correct, and finally commits with the new gnulib version, e.g. via
@code{git gui}.
The @code{gnulib-sync} target can be run any time - after a @code{configure}
run -, and only rejects to run if the working tree is dirty.
@node Documentation
@chapter Documentation
@ -593,6 +606,32 @@ Texinfo documentation. The manual pages are suitable for reference
use, but the Texinfo manual should also include introductory and
tutorial material.
We make the user documentation available on the web, on the GNU
project web site. These web pages are source-controlled via CVS
(still!). If you are a member of the @samp{findutils} project on
Savannah you should be able to check the web pages out like this
(@samp{$USER} is a placeholder for your Savannah username):
@smallexample
cvs -d :ext:$USER@@cvs.savannah.gnu.org:/web/findutils checkout findutils/manual
@end smallexample
You can automatically update the documentation in this repository
by using the script @samp{build-aux/update-online-manual.sh} with the
path to the findutils Git repository as parameter.
@smallexample
build-aux/update-online-manual.sh $HOME/git/findutils
@end smallexample
That script will generate the documentation in the directory
@samp{doc/manual/}
by calling the @code{make} target @samp{web-manual};
then it will copy over the files into the CVS checkout.
There you can check the documentation once again before committing
to CVS. The Savannah CVS server will automatically initiate the
transfer to the web server.
@section Build Guidance
@ -610,8 +649,6 @@ version 3.
Generic installation instructions for installing GNU programs.
@item README
Information about how to compile findutils in particular
@item README-alpha
A README file which is included with testing releases of findutils.
@item README-hacking
Describes how to build findutils from the code in git.
@item THANKS
@ -637,7 +674,7 @@ changes). The level of detail used for this file should be sufficient
to answer the questions ``what changed?'' and ``why was it changed?''.
The file is generated from the git commit messages during @code{make dist}.
If a change fixes a bug, always give the bug reference number in the
@file{NEWS} file and of course also in the checkin message.
@file{NEWS} file and of course also in the check-in message.
In general, it should be possible to enumerate all
material changes to a function by searching for its name in
@file{ChangeLog}. Mention when each release is made.
@ -654,7 +691,7 @@ the DejaGnu documentation.
@chapter Bugs
Bugs are logged in the Savannah bug tracker
@url{http://savannah.gnu.org/bugs/?group=findutils}. The tracker
@url{https://savannah.gnu.org/bugs/?group=findutils}. The tracker
offers several fields but their use is largely obvious. The
life-cycle of a bug is like this:
@ -719,9 +756,10 @@ which provides a replacement @code{locate}.
@chapter Internationalisation
Translation is essentially automated from the maintainer's point of
view. The TP mails the maintainer when a new PO file is available,
and we just download it and check it in. We copy the @file{.po} files
into the git repository. For more information, please see
@url{http://translationproject.org/domain/findutils.html}.
and we just download it and check it in. The @file{bootstrap} script
copies @file{.po} files into the working tree. For more information,
please see
@url{https://translationproject.org/domain/findutils.html}.
@node Security
@ -768,7 +806,7 @@ I. BACKGROUND
GNU findutils is a set of programs which search for files on Unix-like
systems. It is maintained by the GNU Project of the Free Software
Foundation. For more information, see
@url{http://www.gnu.org/software/findutils}.
@url{https://www.gnu.org/software/findutils}.
II. DESCRIPTION
@ -909,7 +947,7 @@ VI. VENDOR RESPONSE
The GNU project discovered the problem while 'locate' was being worked
on; this is the first public announcement of the problem.
The GNU findutils mantainer has issued a patch as p[art of this
The GNU findutils maintainer has issued a patch as part of this
announcement. The patch appears below.
A source release of findutils-4.2.31 will be issued on 2007-05-30.
@ -1056,7 +1094,7 @@ signature, of course, but that has been omitted from the example.
Once a fixed release is available, announce the new release using the
normal channels. Any CVE number assigned for the problem should be
included in the @file{ChangeLog} and @file{NEWS} entries. See
@url{http://cve.mitre.org/} for an explanation of CVE numbers.
@url{https://cve.mitre.org/} for an explanation of CVE numbers.
@ -1065,39 +1103,79 @@ included in the @file{ChangeLog} and @file{NEWS} entries. See
This section will explain how to make a findutils release. For the
time being here is a terse description of the main steps:
@set RELEASE X.Y.Z
@set RELTAG v@value{RELEASE}
@enumerate
@item Commit changes; make sure your working directory has no
uncommitted changes.
@item Update translation files; re-run bootstrap to download the
newest @samp{.po} files.
@item Make sure compiler warnings would block the release; re-run
@samp{configure} with the options
@code{--enable-compiler-warnings --enable-compiler-warnings-are-errors}.
@item Test; make sure that all changes you have made have tests, and
that the tests pass. Verify this with @code{make distcheck}.
that the tests pass.
Verify this with @code{env RUN_EXPENSIVE_TESTS=yes make distcheck}.
@c The RUN_EXPENSIVE_TESTS environment variable is checked in init.cfg.
@item Bugs; make sure all Savannah bug entries fixed in this release
are fixed.
@item NEWS; make sure that the NEWS and configure.in file are updated
with the new release number (and checked in).
are marked as fixed in Savannah. Optionally close them too to save
duplicate work (otherwise, close them after the release is uploaded).
@item Add new release in Savannah field values; see the @code{Bugs >
Edit Field Values} menu item. Add a field value for the release you
are about to make so that users can report bugs in it.
@item Update version; make sure that the NEWS file
is updated with the new release number (and checked in).
@c There is no longer any need to update configure.ac, since it no
@c longer contains version information.
@item Tag the release; findutils releases are tagged like this for
example: v4.5.5. You can create a tag with the a command like this:
@c we use @example here because @value will not work within @code or @samp.
@example
git tag -s -m "Findutils release @value{RELEASE}" @value{RELTAG}
@end example
@noindent
@item Build the release tarball; do this with @code{make distcheck}.
Copy the tarball somewhere safe.
@item Tag the release; findutils releases are tagged like this for
example: v4.5.5. Previously a different format was in use:
FINDUTILS_4_3_8-1. You can create a tag with the a command like this:
@code{git tag -s -m "Findutils release v4.5.7" v4.5.7}.
@item Merge; if the release (and signed tag) were made on a
local branch, merge the branch to your local master.
@item Push; push your master to origin/master.
@item Push the new release tag; assuming that the name of your remote is
@samp{origin}, this is:
@example
git push origin tag @value{RELTAG}
@end example
@item Prepare the upload and upload it.
You can do this with
@c we use @example here because @value will not work within @code or @samp.
@example
build-aux/gnupload --to ftp.gnu.org:findutils findutils-@value{RELEASE}.tar.xz
@end example
@noindent
Use @code{alpha.gnu.org:findutils} for an alpha or beta release.
@xref{Automated FTP Uploads, ,Automated FTP
Uploads, maintain, Information for Maintainers of GNU Software},
for detailed upload instructions.
@item Check the FTP upload worked; you can look for an email from the
robot or check the contents of the actual FTP site.
@item Make a release announcement; include an extract from the NEWS
file which explains what's changed. Announcements for test releases
should just go to @email{bug-findutils@@gnu.org}. Announcements for
stable releases should go to @email{info-gnu@@gnu.org} as well.
@item Bump the release numbers in git; edit the @file{configure.in}
and @file{NEWS} files to advance the release numbers. For example,
if you have just released @samp{4.6.2}, bump the release number to
@samp{4.6.3-git}. The point of the @samp{-git} suffix here is that a
findutils binary built from git will bear a release number indicating
it's not built from the ``official'' source release.
@item Post-release administrativa: add a new dummy release header in NEWS:
@code{* Major changes in release ?.?.?, YYYY-MM-DD}
and update the @code{old_NEWS_hash} in @file{cfg.mk} with
@code{make update-NEWS-hash}.
Commit both changes.
@c make update-NEWS-hash supports make news-check but we normally
@c don't do that (and I'm not sure that the current NEWS file would
@c pass the check anyway).
@item Close bugs; any bugs recorded on Savannah which were fixed in this
release should now be marked as closed. Update the @samp{Fixed
Release} field of these bugs appropriately and make sure the
@samp{Assigned to} field is populated.
release should now be marked as closed if there were not already.
Update the @samp{Fixed Release} field of these bugs appropriately and
make sure the @samp{Assigned to} field is populated.
@end enumerate

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,14 @@
@c File mode bits
@c Copyright (C) 1994--2026 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.
Each file has a set of @dfn{permissions} that control the kinds of
access that users have to that file. The permissions for a file are
also called its @dfn{access mode}. They can be represented either in

View File

@ -1,11 +1,10 @@
@c Copyright (C) 1994, 1996, 1998, 2000, 2001, 2003, 2004, 2005, 2006,
@c 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
@c Copyright (C) 1994--2026 Free Software Foundation, Inc.
@c
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
@c A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.
@c this regular expression description is for: findutils
@ -43,7 +42,8 @@ matches a @samp{?}.
@end table
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored. Within square brackets, @samp{\} is taken literally. Character classes are not supported, so for example you would need to use @samp{[0-9]} instead of @samp{[[:digit:]]}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -74,11 +74,10 @@ The alternation operator is @samp{\|}.
The character @samp{^} only represents the beginning of a string when it appears:
@enumerate
@item
At the beginning of a regular expression
@item At the beginning of a regular expression
@item After an open-group, signified by @samp{\(}
@item After an open-group, signified by
@samp{\(}
@item After the alternation operator @samp{\|}
@ -90,8 +89,8 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the end of a regular expression
@item Before a close-group, signified by
@samp{\)}
@item Before a close-group, signified by @samp{\)}
@item Before the alternation operator @samp{\|}
@end enumerate
@ -102,13 +101,15 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{\(}
@item After an open-group, signified by @samp{\(}
@item After the alternation operator @samp{\|}
@end enumerate
Intervals are specified by @samp{\@{} and @samp{\@}}.
Invalid intervals such as @samp{a\@{1z} are not accepted.
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@ -136,21 +137,24 @@ matches a @samp{?}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} can be used to quote the following character. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are not supported and so @samp{\w}, @samp{\W}, @samp{\<}, @samp{\>}, @samp{\b}, @samp{\B}, @samp{\`}, and @samp{\'} match @samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively.
Grouping is performed with parentheses @samp{()}. An unmatched @samp{)} matches just itself. A backslash followed by a digit matches that digit.
The alternation operator is @samp{|}.
The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
@samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{(}
@item After an open-group, signified by @samp{(}
@item After the alternation operator @samp{|}
@end enumerate
@ -183,6 +187,7 @@ matches a @samp{?}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -211,9 +216,12 @@ The alternation operator is @samp{|}.
The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression.
Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
Intervals are specified by @samp{@{} and @samp{@}}.
Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@ -238,7 +246,8 @@ matches a @samp{?}.
@end table
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored. Within square brackets, @samp{\} is taken literally. Character classes are not supported, so for example you would need to use @samp{[0-9]} instead of @samp{[[:digit:]]}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are ignored. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -269,11 +278,10 @@ The alternation operator is @samp{\|}.
The character @samp{^} only represents the beginning of a string when it appears:
@enumerate
@item
At the beginning of a regular expression
@item At the beginning of a regular expression
@item After an open-group, signified by @samp{\(}
@item After an open-group, signified by
@samp{\(}
@item After the alternation operator @samp{\|}
@ -285,8 +293,8 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the end of a regular expression
@item Before a close-group, signified by
@samp{\)}
@item Before a close-group, signified by @samp{\)}
@item Before the alternation operator @samp{\|}
@end enumerate
@ -297,13 +305,15 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{\(}
@item After an open-group, signified by @samp{\(}
@item After the alternation operator @samp{\|}
@end enumerate
Intervals are specified by @samp{\@{} and @samp{\@}}.
Invalid intervals such as @samp{a\@{1z} are not accepted.
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@ -331,6 +341,7 @@ matches a @samp{?}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} can be used to quote the following character. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -359,19 +370,21 @@ The alternation operator is @samp{|}.
The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
@samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{(}
@item After an open-group, signified by @samp{(}
@item After the alternation operator @samp{|}
@end enumerate
Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
Intervals are specified by @samp{@{} and @samp{@}}.
Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@ -391,11 +404,13 @@ indicates that the regular expression should match one or more occurrences of th
indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
@item + and ?
match themselves.
@end table
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -425,11 +440,10 @@ The alternation operator is @samp{\|}.
The character @samp{^} only represents the beginning of a string when it appears:
@enumerate
@item
At the beginning of a regular expression
@item At the beginning of a regular expression
@item After an open-group, signified by @samp{\(}
@item After an open-group, signified by
@samp{\(}
@item After a newline
@ -443,8 +457,8 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the end of a regular expression
@item Before a close-group, signified by
@samp{\)}
@item Before a close-group, signified by @samp{\)}
@item Before a newline
@item Before the alternation operator @samp{\|}
@ -457,8 +471,8 @@ The character @samp{$} only represents the end of a string when it appears:
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{\(}
@item After an open-group, signified by @samp{\(}
@item After a newline
@item After the alternation operator @samp{\|}
@ -466,7 +480,9 @@ The character @samp{$} only represents the end of a string when it appears:
@end enumerate
Intervals are specified by @samp{\@{} and @samp{\@}}. Invalid intervals such as @samp{a\@{1z} are not accepted.
Intervals are specified by @samp{\@{} and @samp{\@}}.
Invalid intervals such as @samp{a\@{1z} are not accepted.
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@ -493,34 +509,127 @@ matches a @samp{?}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} can be used to quote the following character. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are not supported and so @samp{\w}, @samp{\W}, @samp{\<}, @samp{\>}, @samp{\b}, @samp{\B}, @samp{\`}, and @samp{\'} match @samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively.
Grouping is performed with parentheses @samp{()}. An unmatched @samp{)} matches just itself. A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis @samp{(}.
The alternation operator is @samp{|}.
The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
@samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are not allowed:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{(}
@item After an open-group, signified by @samp{(}
@item After the alternation operator @samp{|}
@end enumerate
Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
Intervals are specified by @samp{@{} and @samp{@}}.
Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\@{1}
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@node posix-basic regular expression syntax
@subsection @samp{posix-basic} regular expression syntax
This is a synonym for ed.
The character @samp{.} matches any single character except the null character.
@table @samp
@item \+
indicates that the regular expression should match one or more occurrences of the previous atom or regexp.
@item \?
indicates that the regular expression should match zero or one occurrence of the previous atom or regexp.
@item + and ?
match themselves.
@end table
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@item @samp{\w} matches a character within a word
@item @samp{\W} matches a character which is not within a word
@item @samp{\<} matches the beginning of a word
@item @samp{\>} matches the end of a word
@item @samp{\b} matches a word boundary
@item @samp{\B} matches characters which are not a word boundary
@item @samp{\`} matches the beginning of the whole input
@item @samp{\'} matches the end of the whole input
@end enumerate
Grouping is performed with backslashes followed by parentheses @samp{\(}, @samp{\)}. A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis @samp{\(}.
The alternation operator is @samp{\|}.
The character @samp{^} only represents the beginning of a string when it appears:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by @samp{\(}
@item After the alternation operator @samp{\|}
@end enumerate
The character @samp{$} only represents the end of a string when it appears:
@enumerate
@item At the end of a regular expression
@item Before a close-group, signified by @samp{\)}
@item Before the alternation operator @samp{\|}
@end enumerate
@samp{\*}, @samp{\+} and @samp{\?} are special at any point in a regular expression except:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by @samp{\(}
@item After the alternation operator @samp{\|}
@end enumerate
Intervals are specified by @samp{\@{} and @samp{\@}}.
Invalid intervals such as @samp{a\@{1z} are not accepted.
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.
@node posix-egrep regular expression syntax
@subsection @samp{posix-egrep} regular expression syntax
This is a synonym for egrep.
@ -546,6 +655,7 @@ matches a @samp{?}.
Bracket expressions are used to match ranges of characters. Bracket expressions where the range is backward, for example @samp{[z-a]}, are invalid. Within square brackets, @samp{\} is taken literally. Character classes are supported; for example @samp{[[:digit:]]} will match a single decimal digit.
GNU extensions are supported:
@enumerate
@ -574,19 +684,22 @@ The alternation operator is @samp{|}.
The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified.
@samp{*}, @samp{+} and @samp{?} are special at any point in a regular expression except the following places, where they are not allowed:
@enumerate
@item At the beginning of a regular expression
@item After an open-group, signified by
@samp{(}
@item After an open-group, signified by @samp{(}
@item After the alternation operator @samp{|}
@end enumerate
Intervals are specified by @samp{@{} and @samp{@}}. Invalid intervals such as @samp{a@{1z} are not accepted.
Intervals are specified by @samp{@{} and @samp{@}}.
Invalid intervals such as @samp{a@{1z} are not accepted.
The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups.

View File

@ -1,5 +0,0 @@
.deps
Makefile
Makefile.in
find
oldfind

23
find/.gitignore vendored
View File

@ -1,16 +1,7 @@
.deps
Makefile
Makefile.in
find
oldfind
*~
finddata.o
find.o
fstype.o
ftsfind.o
parser.o
pred.o
sharefile.o
tree.o
util.o
libfindtools.a
/*.o
/*~
/Makefile
/Makefile.in
/find
/getlimits
/libfindtools.a

View File

@ -1,55 +1,53 @@
## Copyright (C) 1996-2026 Free Software Foundation, Inc.
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = std-options
AM_CFLAGS = $(WARN_CFLAGS)
localedir = $(datadir)/locale
# noinst_PROGRAMS = regexprops
# regexprops_SOURCES = regexprops.c
noinst_LIBRARIES = libfindtools.a
libfindtools_a_SOURCES = finddata.c fstype.c parser.c pred.c exec.c tree.c util.c sharefile.c print.c
# We always build two versions of find, one with fts, one without.
# Their names depend on whether the user specified --with-fts.
#
# --with-fts find extra binary
# yes with fts 'oldfind', without fts
# no without fts 'ftsfind', with fts
#
if WITH_FTS
bin_PROGRAMS = find oldfind
# We only build the version of find with fts (called "find"),
# i.e., no longer the one called "oldfind".
bin_PROGRAMS = find
find_SOURCES = ftsfind.c
oldfind_SOURCES = find.c
man_MANS = find.1 oldfind.1
else
bin_PROGRAMS = find ftsfind
find_SOURCES = find.c
ftsfind_SOURCES = ftsfind.c
man_MANS = find.1 ftsfind.1
endif
man_MANS = find.1
# We don't just include man_MANS in EXTRA_DIST because while the value of
# man_MANS is not always the same, we want to distribute all of those files.
EXTRA_DIST = defs.h sharefile.h print.h find.1 ftsfind.1 oldfind.1
AM_CPPFLAGS = -I../gl/lib -I$(top_srcdir)/lib -I$(top_srcdir)/gl/lib -I../intl -DLOCALEDIR=\"$(localedir)\"
LDADD = ./libfindtools.a ../lib/libfind.a ../gl/lib/libgnulib.a $(LIBINTL) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) $(LIB_SELINUX) $(LIB_CLOSE) $(MODF_LIBM) $(FINDLIBS) $(GETHOSTNAME_LIB) $(LIB_EACCESS)
EXTRA_DIST = defs.h sharefile.h print.h $(man_MANS)
AM_CPPFLAGS = -I../gl/lib -I$(top_srcdir)/lib -I$(top_srcdir)/gl/lib -DLOCALEDIR=\"$(localedir)\"
LDADD = libfindtools.a ../lib/libfind.a ../gl/lib/libgnulib.a $(LIBINTL) $(CLOCK_TIME_LIB) $(EUIDACCESS_LIBGEN) $(LIB_SELINUX) $(MODF_LIBM) $(FINDLIBS) $(GETHOSTNAME_LIB) $(EUIDACCESS_LIBGEN) $(SETLOCALE_NULL_LIB) $(MBRTOWC_LIB)
# gnulib advises we link against <first> because we use <second>:
# $(GETHOSTNAME_LIB) uname
# $(LIB_CLOCK_GETTIME) (some inditrect dependency)
# $(LIB_EACCESS) faccessat
# $(CLOCK_TIME_LIB) gettime
# $(EUIDACCESS_LIBGEN) faccessat
# $(LIB_SELINUX) selinux-h
# $(MODF_LIBM) modf
SUBDIRS = . testsuite
#$(PROGRAMS): ../lib/libfind.a
noinst_PROGRAMS = getlimits
dist-hook: findutils-check-manpages
check-local: findutils-check-manpages
# Clean coverage files generated by running binaries built with
# gcc -fprofile-arcs -ftest-coverage
coverage-clean:
$(RM) *.gcno *.gcda *.gcov *.lcov
rm -f *.gcno *.gcda *.gcov *.lcov
clean-local: coverage-clean
findutils-check-manpages:
$(top_srcdir)/build-aux/man-lint.sh $(srcdir) $(man_MANS)
env GROFF=$(GROFF) $(top_srcdir)/build-aux/man-lint.sh $(srcdir) $(man_MANS)

View File

@ -1,6 +1,5 @@
/* defs.h -- data types and declarations.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,14 +12,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INC_DEFS_H
#define INC_DEFS_H 1
# define INC_DEFS_H 1
#if !defined ALREADY_INCLUDED_CONFIG_H
# if !defined ALREADY_INCLUDED_CONFIG_H
/*
* Savannah bug #20128: if we include some system header and it
* includes some other second system header, the second system header
@ -30,47 +29,40 @@
* configure script fragments. So <config.h> should be the first
* thing included.
*/
#error "<config.h> should be #included before defs.h, and indeed before any other header"
# error "<config.h> should be #included before defs.h, and indeed before any other header"
Please stop compiling the program now
#endif
# endif
#include <sys/types.h>
# include <sys/types.h>
/* XXX: some of these includes probably don't belong in a common header file */
#include <sys/stat.h>
#include <stdio.h> /* for FILE* */
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <limits.h> /* for CHAR_BIT */
#include <stdbool.h> /* for bool */
#include <stdint.h> /* for uintmax_t */
#include <sys/stat.h> /* S_ISUID etc. */
#include <selinux/selinux.h>
# include <sys/stat.h>
# include <stdio.h> /* for FILE* */
# include <string.h>
# include <stdlib.h>
# include <unistd.h>
# include <time.h>
# include <limits.h> /* for CHAR_BIT */
# include <stdbool.h> /* for bool */
# include <stdint.h> /* for uintmax_t */
# include <sys/stat.h> /* S_ISUID etc. */
# include <selinux/selinux.h>
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
# ifndef CHAR_BIT
# define CHAR_BIT 8
# endif
# include <inttypes.h>
#include "regex.h"
#include "timespec.h"
#include "buildcmd.h"
#include "quotearg.h"
#include "sharefile.h"
#ifndef ATTRIBUTE_NORETURN
# if HAVE_ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# else
# define ATTRIBUTE_NORETURN /* nothing */
# endif
#endif
# include "regex.h"
# include "timespec.h"
# include "buildcmd.h"
# include "quotearg.h"
# include "sharefile.h"
# include "gcc-function-attributes.h"
int optionl_stat (const char *name, struct stat *p);
int optionp_stat (const char *name, struct stat *p);
@ -81,11 +73,11 @@ void set_stat_placeholders (struct stat *p);
int get_statinfo (const char *pathname, const char *name, struct stat *p);
#define MODE_WXUSR (S_IWUSR | S_IXUSR)
#define MODE_R (S_IRUSR | S_IRGRP | S_IROTH)
#define MODE_RW (S_IWUSR | S_IWGRP | S_IWOTH | MODE_R)
#define MODE_RWX (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
#define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
# define MODE_WXUSR (S_IWUSR | S_IXUSR)
# define MODE_R (S_IRUSR | S_IRGRP | S_IROTH)
# define MODE_RW (S_IWUSR | S_IWGRP | S_IWOTH | MODE_R)
# define MODE_RWX (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
# define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
struct predicate;
@ -95,7 +87,7 @@ struct options;
typedef bool (*PRED_FUNC)(const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
/* The number of seconds in a day. */
#define DAYSECS 86400
# define DAYSECS 86400
/* Argument structures for predicates. */
@ -136,7 +128,7 @@ enum predicate_precedence
struct long_val
{
enum comparison_type kind;
bool negative; /* Defined only when representing time_t. */
bool negative; /* Defined only when representing time_t. */
uintmax_t l_val;
};
@ -146,14 +138,6 @@ struct perm_val
mode_t val[2];
};
/* dir_id is used to support loop detection in find.c
*/
struct dir_id
{
ino_t ino;
dev_t dev;
};
/* samefile_file_id is used to support the -samefile test.
*/
struct samefile_file_id
@ -170,6 +154,27 @@ struct size_val
uintmax_t size;
};
/* Supported file types for the -type/-xtype options. */
enum file_type
{
FTYPE_BLK,
FTYPE_CHR,
FTYPE_DIR,
FTYPE_REG,
# ifdef S_IFLNK
FTYPE_LNK,
# endif
# ifdef S_IFIFO
FTYPE_FIFO,
# endif
# ifdef S_IFSOCK
FTYPE_SOCK,
# endif
# ifdef S_IFDOOR
FTYPE_DOOR,
# endif
FTYPE_COUNT
};
enum xval
{
@ -186,14 +191,14 @@ struct time_val
struct exec_val
{
bool multiple; /* -exec {} \+ denotes multiple argument. */
bool multiple; /* -exec {} \+ denotes multiple argument. */
struct buildcmd_control ctl;
struct buildcmd_state state;
char **replace_vec; /* Command arguments (for ";" style) */
char **replace_vec; /* Command arguments (for ";" style) */
int num_args;
bool close_stdin; /* If true, close stdin in the child. */
bool close_stdin; /* If true, close stdin in the child. */
struct saved_cwd *wd_for_exec; /* What directory to perform the exec in. */
int last_child_status; /* Status of the most recent child. */
int last_child_status; /* Status of the most recent child. */
};
/* The format string for a -printf or -fprintf is chopped into one or
@ -204,26 +209,26 @@ struct exec_val
/* Special values for the `kind' field of `struct segment'. */
enum SegmentKind
{
KIND_PLAIN=0, /* Segment containing just plain text. */
KIND_STOP=1, /* \c -- stop printing and flush output. */
KIND_FORMAT, /* Regular format */
KIND_PLAIN=0, /* Segment containing just plain text. */
KIND_STOP=1, /* \c -- stop printing and flush output. */
KIND_FORMAT, /* Regular format */
};
struct segment
{
enum SegmentKind segkind; /* KIND_FORMAT, KIND_PLAIN, KIND_STOP */
char format_char[2]; /* Format chars if kind is KIND_FORMAT */
char *text; /* Plain text or `%' format string. */
int text_len; /* Length of `text'. */
struct segment *next; /* Next segment for this predicate. */
char format_char[2]; /* Format chars if kind is KIND_FORMAT */
char *text; /* Plain text or `%' format string. */
int text_len; /* Length of `text'. */
struct segment *next; /* Next segment for this predicate. */
};
struct format_val
{
struct segment *segment; /* Linked list of segments. */
FILE *stream; /* Output stream to print on. */
const char *filename; /* We need the filename for error messages. */
bool dest_is_tty; /* True if the destination is a terminal. */
struct segment *segment; /* Linked list of segments. */
FILE *stream; /* Output stream to print on. */
const char *filename; /* We need the filename for error messages. */
bool dest_is_tty; /* True if the destination is a terminal. */
struct quoting_options *quote_opts;
};
@ -256,8 +261,7 @@ struct predicate
/* Pointer to the function that implements this predicate. */
PRED_FUNC pred_func;
/* Only used for debugging, but defined unconditionally so individual
modules can be compiled with -DDEBUG. */
/* Used for debugging */
const char *p_name;
/* The type of this node. There are two kinds. The first is real
@ -290,9 +294,6 @@ struct predicate
/* est_success_rate is a number between 0.0 and 1.0 */
float est_success_rate;
/* True if this predicate should display control characters literally */
bool literal_control_chars;
/* True if this predicate didn't originate from the user. */
bool artificial;
@ -303,19 +304,19 @@ struct predicate
Next to each member are listed the predicates that use it. */
union
{
const char *str; /* fstype [i]lname [i]name [i]path */
const char *str; /* fstype [i]lname [i]name [i]path */
struct re_pattern_buffer *regex; /* regex */
struct exec_val exec_vec; /* exec ok */
struct long_val numinfo; /* gid inum links uid */
struct size_val size; /* size */
uid_t uid; /* user */
gid_t gid; /* group */
struct time_val reftime; /* newer newerXY anewer cnewer mtime atime ctime mmin amin cmin */
struct perm_val perm; /* perm */
struct exec_val exec_vec; /* exec ok */
struct long_val numinfo; /* gid inum links uid */
struct size_val size; /* size */
uid_t uid; /* user */
gid_t gid; /* group */
struct time_val reftime; /* newer newerXY anewer cnewer mtime atime ctime mmin amin cmin */
struct perm_val perm; /* perm */
struct samefile_file_id samefileid; /* samefile */
mode_t type; /* type */
bool types[FTYPE_COUNT]; /* file type(s) */
struct format_val printf_vec; /* printf fprintf fprint ls fls print0 fprint0 print */
security_context_t scontext; /* security context */
char *scontext; /* security context */
} args;
/* The next predicate in the user input sequence,
@ -334,51 +335,49 @@ struct predicate
const struct parser_table* parser_entry;
};
/* find.c, ftsfind.c */
bool is_fts_enabled(int *ftsoptions);
/* ftsfind.c */
bool is_fts_cwdfd_enabled(void);
/* find library function declarations. */
/* find global function declarations. */
/* find.c */
/* SymlinkOption represents the choice of
* -P, -L or -P (default) on the command line.
*/
enum SymlinkOption
{
SYMLINK_NEVER_DEREF, /* Option -P */
SYMLINK_ALWAYS_DEREF, /* Option -L */
SYMLINK_DEREF_ARGSONLY /* Option -H */
SYMLINK_NEVER_DEREF, /* Option -P */
SYMLINK_ALWAYS_DEREF, /* Option -L */
SYMLINK_DEREF_ARGSONLY /* Option -H */
};
extern enum SymlinkOption symlink_handling; /* defined in find.c. */
void set_follow_state (enum SymlinkOption opt);
void cleanup(void);
/* fstype.c */
char *filesystem_type (const struct stat *statp, const char *path);
char * get_mounted_filesystems (void);
bool is_used_fs_type(const char *name);
dev_t * get_mounted_devices (size_t *);
enum arg_type
{
ARG_OPTION, /* regular options like -maxdepth */
ARG_NOOP, /* does nothing, returns true, internal use only */
ARG_POSITIONAL_OPTION, /* options whose position is important (-follow) */
ARG_TEST, /* a like -name */
ARG_SPECIAL_PARSE, /* complex to parse, don't eat the test name before calling parse_xx(). */
ARG_PUNCTUATION, /* like -o or ( */
ARG_ACTION /* like -print */
ARG_OPTION, /* regular options like -maxdepth */
ARG_NOOP, /* does nothing, returns true, internal use only */
ARG_POSITIONAL_OPTION, /* options whose position is important (-follow) */
ARG_TEST, /* a like -name */
ARG_SPECIAL_PARSE, /* complex to parse, don't eat the test name before calling parse_xx(). */
ARG_PUNCTUATION, /* like -o or ( */
ARG_ACTION /* like -print */
};
struct parser_table;
/* Pointer to a parser function. */
typedef bool (*PARSE_FUNC)(const struct parser_table *p,
char *argv[], int *arg_ptr);
char *argv[], int *arg_ptr);
struct parser_table
{
enum arg_type type;
@ -400,6 +399,7 @@ bool parse_closeparen (const struct parser_table* entry, char *argv[], int *arg_
/* pred.c */
typedef bool PREDICATEFUNCTION(const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr);
PREDICATEFUNCTION pred_amin;
PREDICATEFUNCTION pred_and;
PREDICATEFUNCTION pred_anewer;
@ -446,7 +446,6 @@ PREDICATEFUNCTION pred_perm;
PREDICATEFUNCTION pred_print;
PREDICATEFUNCTION pred_print0;
PREDICATEFUNCTION pred_prune;
PREDICATEFUNCTION pred_quit;
PREDICATEFUNCTION pred_readable;
PREDICATEFUNCTION pred_regex;
PREDICATEFUNCTION pred_samefile;
@ -460,17 +459,16 @@ PREDICATEFUNCTION pred_writable;
PREDICATEFUNCTION pred_xtype;
PREDICATEFUNCTION pred_context;
char *find_pred_name (PRED_FUNC pred_func);
bool pred_quit (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
_GL_ATTRIBUTE_NORETURN;
void print_predicate (FILE *fp, const struct predicate *p);
void print_tree (FILE*, struct predicate *node, int indent);
void print_list (FILE*, struct predicate *node);
void print_optlist (FILE *fp, const struct predicate *node);
void show_success_rates(const struct predicate *node);
bool predicate_uses_exec(const struct predicate*);
# define pred_is(node, fn) ( ((node)->pred_func) == (fn) )
/* tree.c */
bool matches_start_point(const char * glob, bool foldcase);
@ -479,15 +477,14 @@ struct predicate * get_eval_tree (void);
struct predicate *get_new_pred_noarg (const struct parser_table *entry);
struct predicate *get_new_pred (const struct parser_table *entry);
struct predicate *get_new_pred_chk_op (const struct parser_table *entry,
const char *arg);
const char *arg);
float calculate_derived_rates (struct predicate *p);
/* util.c */
bool fd_leak_check_is_enabled (void);
struct predicate *insert_primary (const struct parser_table *entry, const char *arg);
struct predicate *insert_primary_noarg (const struct parser_table *entry);
struct predicate *insert_primary_withpred (const struct parser_table *entry, PRED_FUNC fptr, const char *arg);
void usage (FILE *fp, int status, char *msg);
void usage (int status) _GL_ATTRIBUTE_NORETURN;
extern bool check_nofollow(void);
void complete_pending_execs(struct predicate *p);
void complete_pending_execdirs (void);
@ -495,28 +492,23 @@ const char *safely_quote_err_filename (int n, char const *arg);
void record_initial_cwd (void);
bool is_exec_in_local_dir(const PRED_FUNC pred_func);
void fatal_target_file_error (int errno_value, const char *name) ATTRIBUTE_NORETURN;
void fatal_nontarget_file_error (int errno_value, const char *name) ATTRIBUTE_NORETURN;
void fatal_target_file_error (int errno_value, const char *name) _GL_ATTRIBUTE_NORETURN;
void fatal_nontarget_file_error (int errno_value, const char *name) _GL_ATTRIBUTE_NORETURN;
void nonfatal_target_file_error (int errno_value, const char *name);
void nonfatal_nontarget_file_error (int errno_value, const char *name);
int process_leading_options (int argc, char *argv[]);
void set_option_defaults (struct options *p);
void error_severity (int level);
#if 0
#define apply_predicate(pathname, stat_buf_ptr, node) \
# if 0
# define apply_predicate(pathname, stat_buf_ptr, node) \
(*(node)->pred_func)((pathname), (stat_buf_ptr), (node))
#else
# else
bool apply_predicate(const char *pathname, struct stat *stat_buf, struct predicate *p);
#endif
# endif
#define pred_is(node, fn) ( ((node)->pred_func) == (fn) )
/* find.c. */
int get_info (const char *pathname, struct stat *p, struct predicate *pred_ptr);
/* util.c. */
bool following_links (void);
bool digest_mode (mode_t *mode, const char *pathname, const char *name, struct stat *pstat, bool leaf);
bool default_prints (struct predicate *pred);
@ -526,13 +518,16 @@ bool looks_like_expression (const char *arg, bool leading);
enum DebugOption
{
DebugNone = 0,
DebugExpressionTree = 1,
DebugStat = 2,
DebugSearch = 4,
DebugTreeOpt = 8,
DebugHelp = 16,
DebugExec = 32,
DebugSuccessRates = 64
DebugExpressionTree = 1 << 0,
DebugStat = 1 << 1,
DebugSearch = 1 << 2,
DebugTreeOpt = 1 << 3,
DebugHelp = 1 << 4,
DebugExec = 1 << 5,
DebugSuccessRates = 1 << 6,
DebugTime = 1 << 7,
DebugAll = ~DebugNone & ~DebugHelp, /* all but help */
};
struct options
@ -554,8 +549,11 @@ struct options
are non-directories. */
bool no_leaf_check;
/* If true, skip files on other devices. */
bool mount;
/* If true, don't cross filesystem boundaries. */
bool stay_on_filesystem;
bool xdev;
/* If true, we ignore the problem where we find that a directory entry
* no longer exists by the time we get around to processing it.
@ -577,7 +575,7 @@ struct options
*/
bool posixly_correct;
struct timespec start_time; /* Time at start of execution. */
struct timespec start_time; /* Time at start of execution. */
/* Either one day before now (the default), or the start of today (if -daystart is given). */
struct timespec cur_day_start;
@ -585,7 +583,7 @@ struct options
/* If true, cur_day_start has been adjusted to the start of the day. */
bool full_days;
int output_block_size; /* Output block size. */
int output_block_size; /* Output block size. */
/* bitmask for debug options */
unsigned long debug_options;
@ -609,7 +607,7 @@ struct options
int regex_options;
/* function used to get file context */
int (*x_getfilecon) (int, const char *, security_context_t *);
int (*x_getfilecon) (int, const char *, char **);
/* Optimisation level. One is the default.
*/
@ -619,6 +617,12 @@ struct options
/* How should we quote filenames in error messages and so forth?
*/
enum quoting_style err_quoting_style;
/* Read starting points from FILE (instead of argv). */
const char *files0_from;
/* True if actions like -ok, -okdir need a user confirmation via stdin. */
bool ok_prompt_stdin;
};
@ -632,11 +636,12 @@ struct state
/* If true, we know the type of the current path. */
bool have_type;
mode_t type; /* this is the actual type */
mode_t type; /* this is the actual type */
/* The file being operated on, relative to the current directory.
Used for stat, readlink, remove, and opendir. */
char *rel_pathname;
const char *rel_pathname;
/* The directory fd to which rel_pathname is relative. This is relevant
* when we're navigating the hierarchy with fts() and using FTS_CWDFD.
*/
@ -646,7 +651,7 @@ struct state
int starting_path_length;
/* If true, don't descend past current directory.
Can be set by -prune, -maxdepth, and -xdev/-mount. */
Can be set by -prune, -maxdepth, -mount and -xdev. */
bool stop_at_current_level;
/* Status value to return to system. */

View File

@ -1,7 +1,5 @@
/* exec.c -- Implementation of -exec, -execdir, -ok, -okdir.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003,
2004, 2005, 2006, 2007, 2008, 2009,
2010 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -14,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* config.h must be included first. */
@ -31,8 +29,7 @@
/* gnulib headers */
#include "cloexec.h"
#include "dirname.h"
#include "error.h"
#include "gettext.h"
#include "fcntl--.h"
#include "save-cwd.h"
#include "xalloc.h"
@ -40,19 +37,7 @@
#include "buildcmd.h"
#include "defs.h"
#include "fdleak.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifdef gettext_noop
# define N_(String) gettext_noop (String)
#else
/* See locate.c for explanation as to why not use (String) */
# define N_(String) String
#endif
#include "system.h"
/* Initialize exec->wd_for_exec.
@ -79,30 +64,30 @@ record_exec_dir (struct exec_val *execp)
if (!execp->state.todo)
{
/* working directory not already known, so must be a *dir variant,
and this must be the first arg we added. However, this may
be -execdir foo {} \; (i.e. not multiple). */
and this must be the first arg we added. However, this may
be -execdir foo {} \; (i.e. not multiple). */
assert (!execp->state.todo);
/* Record the WD. If we're using -L or fts chooses to do so for
any other reason, state.cwd_dir_fd may in fact not be the
directory containing the target file. When this happens,
rel_path will contain directory components (since it is the
path from state.cwd_dir_fd to the target file).
any other reason, state.cwd_dir_fd may in fact not be the
directory containing the target file. When this happens,
rel_path will contain directory components (since it is the
path from state.cwd_dir_fd to the target file).
We deal with this by extracting any directory part and using
that to adjust what goes into execp->wd_for_exec.
We deal with this by extracting any directory part and using
that to adjust what goes into execp->wd_for_exec.
*/
if (strchr (state.rel_pathname, '/'))
{
char *dir = mdir_name (state.rel_pathname);
bool result = initialize_wd_for_exec (execp, state.cwd_dir_fd, dir);
free (dir);
return result;
}
{
char *dir = mdir_name (state.rel_pathname);
bool result = initialize_wd_for_exec (execp, state.cwd_dir_fd, dir);
free (dir);
return result;
}
else
{
return initialize_wd_for_exec (execp, state.cwd_dir_fd, ".");
}
{
return initialize_wd_for_exec (execp, state.cwd_dir_fd, ".");
}
}
return true;
}
@ -120,7 +105,7 @@ impl_pred_exec (const char *pathname,
const char *target;
bool result;
const bool local = is_exec_in_local_dir (pred_ptr->pred_func);
char *prefix;
const char *prefix;
size_t pfxlen;
(void) stat_buf;
@ -141,7 +126,7 @@ impl_pred_exec (const char *pathname,
target = buf = base_name (state.rel_pathname);
if ('/' == target[0])
{
/* find / execdir ls -d {} \; */
/* find / -execdir ls -d {} \; */
prefix = NULL;
pfxlen = 0;
}
@ -232,13 +217,13 @@ impl_pred_exec (const char *pathname,
Possible returns:
ret errno status(h) status(l)
ret errno status(h) status(l)
pid x signal# 0177 stopped
pid x exit arg 0 term by _exit
pid x 0 signal # term by signal
-1 EINTR parent got signal
-1 other some other kind of error
pid x signal# 0177 stopped
pid x exit arg 0 term by _exit
pid x 0 signal # term by signal
-1 EINTR parent got signal
-1 other some other kind of error
Return true only if the pid matches, status(l) is
zero, and the exit arg (status high) is 0.
@ -252,27 +237,27 @@ prep_child_for_exec (bool close_stdin, const struct saved_cwd *wd)
const char inputfile[] = "/dev/null";
if (close (0) < 0)
{
error (0, errno, _("Cannot close standard input"));
ok = false;
}
{
error (0, errno, _("Cannot close standard input"));
ok = false;
}
else
{
if (open (inputfile, O_RDONLY
{
if (open (inputfile, O_RDONLY
#if defined O_LARGEFILE
|O_LARGEFILE
|O_LARGEFILE
#endif
) < 0)
{
/* This is not entirely fatal, since
* executing the child with a closed
* stdin is almost as good as executing it
* with its stdin attached to /dev/null.
*/
error (0, errno, "%s", safely_quote_err_filename (0, inputfile));
/* do not set ok=false, it is OK to continue anyway. */
}
}
) < 0)
{
/* This is not entirely fatal, since
* executing the child with a closed
* stdin is almost as good as executing it
* with its stdin attached to /dev/null.
*/
error (0, errno, "%s", safely_quote_err_filename (0, inputfile));
/* do not set ok=false, it is OK to continue anyway. */
}
}
}
/* Even if DebugSearch is set, don't announce our change of
@ -282,7 +267,9 @@ prep_child_for_exec (bool close_stdin, const struct saved_cwd *wd)
*/
if (0 != restore_cwd (wd))
{
error (0, errno, _("Failed to change directory: %s"), wd);
error (0, errno, _("Failed to change directory%s%s"),
(wd->desc < 0 && wd->name) ? ": " : "",
(wd->desc < 0 && wd->name) ? wd->name : "");
ok = false;
}
return ok;
@ -296,6 +283,22 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
static int first_time = 1;
struct exec_val *execp = usercontext;
(void) ctl; /* silence compiler warning */
(void) argc; /* silence compiler warning */
if (options.debug_options & DebugExec)
{
int i;
fprintf (stderr, "DebugExec: launching process (argc=%" PRIuMAX "):",
(uintmax_t) execp->state.cmd_argc - 1);
for (i=0; i<execp->state.cmd_argc -1; ++i)
{
fprintf (stderr, " %s",
safely_quote_err_filename (0, execp->state.cmd_argv[i]));
}
fprintf (stderr, "\n");
}
/* Make sure output of command doesn't get mixed with find output. */
fflush (stdout);
fflush (stderr);
@ -315,74 +318,84 @@ launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv)
/* We are the child. */
assert (NULL != execp->wd_for_exec);
if (!prep_child_for_exec (execp->close_stdin, execp->wd_for_exec))
{
_exit (1);
}
{
_exit (1);
}
else
{
if (fd_leak_check_is_enabled ())
{
complain_about_leaky_fds ();
}
}
{
if (fd_leak_check_is_enabled ())
{
complain_about_leaky_fds ();
}
}
if (bc_args_exceed_testing_limit (argv))
errno = E2BIG;
errno = E2BIG;
else
execvp (argv[0], argv);
execvp (argv[0], argv);
/* TODO: use a pipe to pass back the errno value, like xargs does */
error (0, errno, "%s",
safely_quote_err_filename (0, argv[0]));
safely_quote_err_filename (0, argv[0]));
_exit (1);
}
while (waitpid (child_pid, &(execp->last_child_status), 0) == (pid_t) -1)
{
if (errno != EINTR)
{
error (0, errno, _("error waiting for %s"),
safely_quote_err_filename (0, argv[0]));
state.exit_status = 1;
return 0; /* FAIL */
}
{
error (0, errno, _("error waiting for %s"),
safely_quote_err_filename (0, argv[0]));
state.exit_status = EXIT_FAILURE;
return 0; /* FAIL */
}
}
if (WIFSIGNALED (execp->last_child_status))
{
error (0, 0, _("%s terminated by signal %d"),
quotearg_n_style (0, options.err_quoting_style, argv[0]),
WTERMSIG (execp->last_child_status));
quotearg_n_style (0, options.err_quoting_style, argv[0]),
WTERMSIG (execp->last_child_status));
if (execp->multiple)
{
/* -exec \; just returns false if the invoked command fails.
* -exec {} + returns true if the invoked command fails, but
* sets the program exit status.
*/
state.exit_status = 1;
}
{
/* -exec \; just returns false if the invoked command fails.
* -exec {} + returns true if the invoked command fails, but
* sets the program exit status.
*/
state.exit_status = EXIT_FAILURE;
}
return 1; /* OK */
return 1; /* OK */
}
if (0 == WEXITSTATUS (execp->last_child_status))
int ex = WEXITSTATUS (execp->last_child_status);
if (options.debug_options & DebugExec)
{
return 1; /* OK */
/* pid_t is of type long on Solaris 11. Cast CHILD_PID for use with
* %ld as long as gnulib doesn't provide portable PRIdPID. */
fprintf (stderr,
"DebugExec: process (PID=%ld) terminated with exit status: %d\n",
(long) child_pid, ex);
}
if (0 == ex)
{
return 1; /* OK */
}
else
{
if (execp->multiple)
{
/* -exec \; just returns false if the invoked command fails.
* -exec {} + returns true if the invoked command fails, but
* sets the program exit status.
*/
state.exit_status = 1;
}
{
/* -exec \; just returns false if the invoked command fails.
* -exec {} + returns true if the invoked command fails, but
* sets the program exit status.
*/
state.exit_status = EXIT_FAILURE;
}
/* The child failed, but this is the exec callback. We
* don't want to run the child again in this case anwyay.
*/
return 1; /* FAIL (but don't try again) */
return 1; /* FAIL (but don't try again) */
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
/* finddata.c -- global data for "find".
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003, 2004, 2005,
2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* config.h must be included first. */

View File

@ -1,6 +1,5 @@
/* fstype.c -- determine type of file systems that files are on
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000,
2004, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@ -12,7 +11,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* Written by David MacKenzie <djm@gnu.org>.
@ -28,9 +27,6 @@
/* system headers. */
#include <errno.h>
#include <fcntl.h>
#if HAVE_MNTENT_H
# include <mntent.h>
#endif
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@ -52,27 +48,15 @@
#include "xalloc.h"
#include "xstrtol.h"
#include "mountlist.h"
#include "error.h"
#include "gettext.h"
/* find headers. */
#include "defs.h"
#include "extendbuf.h"
#include "system.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifdef gettext_noop
# define N_(String) gettext_noop (String)
#else
/* See locate.c for explanation as to why not use (String) */
# define N_(String) String
#endif
static char *file_system_type_uncached (const struct stat *statp, const char *path);
static char *file_system_type_uncached (const struct stat *statp,
const char *path,
bool *fstype_known);
static void
@ -81,14 +65,7 @@ free_file_system_list (struct mount_entry *p)
while (p)
{
struct mount_entry *pnext = p->me_next;
free (p->me_devname);
free (p->me_mountdir);
if (p->me_type_malloced)
free (p->me_type);
p->me_next = NULL;
free (p);
free_mount_entry (p);
p = pnext;
}
}
@ -97,17 +74,17 @@ free_file_system_list (struct mount_entry *p)
#ifdef AFS
#include <netinet/in.h>
#include <afs/venus.h>
#if __STDC__
# include <netinet/in.h>
# include <afs/venus.h>
# if __STDC__
/* On SunOS 4, afs/vice.h defines this to rely on a pre-ANSI cpp. */
#undef _VICEIOCTL
#define _VICEIOCTL(id) ((unsigned int ) _IOW('V', id, struct ViceIoctl))
#endif
#ifndef _IOW
# undef _VICEIOCTL
# define _VICEIOCTL(id) ((unsigned int ) _IOW('V', id, struct ViceIoctl))
# endif
# ifndef _IOW
/* AFS on Solaris 2.3 doesn't get this definition. */
#include <sys/ioccom.h>
#endif
# include <sys/ioccom.h>
# endif
static int
in_afs (char *path)
@ -121,13 +98,35 @@ in_afs (char *path)
if (pioctl (path, VIOC_FILE_CELL_NAME, &vi, 1)
&& (errno == EINVAL || errno == ENOENT))
return 0;
return 0;
return 1;
}
#endif /* AFS */
/* Nonzero if the current file system's type is known. */
static int fstype_known = 0;
/* Read the mount list into a static cache, and return it.
This is a wrapper around gnulib's read_file_system_list ()
to avoid unnecessary reading of the mount list. */
static struct mount_entry *
get_file_system_list (bool need_fs_type)
{
/* Local cache for the mount list. */
static struct mount_entry *mount_list = NULL;
/* Remember if the list contains the ME_TYPE members. */
static bool has_fstype = false;
if (mount_list && ! has_fstype && need_fs_type)
{
free_file_system_list (mount_list);
mount_list = NULL;
}
if (! mount_list)
{
mount_list = read_file_system_list(need_fs_type);
has_fstype = need_fs_type;
}
return mount_list;
}
/* Return a static string naming the type of file system that the file PATH,
described by STATP, is on.
@ -137,20 +136,52 @@ static int fstype_known = 0;
char *
filesystem_type (const struct stat *statp, const char *path)
{
/* Nonzero if the current file system's type is known. */
static bool fstype_known = false;
static char *current_fstype = NULL;
static dev_t current_dev;
if (current_fstype != NULL)
{
if (fstype_known && statp->st_dev == current_dev)
return current_fstype; /* Cached value. */
return current_fstype; /* Cached value. */
free (current_fstype);
}
current_dev = statp->st_dev;
current_fstype = file_system_type_uncached (statp, path);
current_fstype = file_system_type_uncached (statp, path, &fstype_known);
return current_fstype;
}
bool
is_used_fs_type(const char *name)
{
if (0 == strcmp("afs", name))
{
/* I guess AFS may not appear in /etc/mtab (or equivalent) but still be in use,
so assume we always need to check for AFS. */
return true;
}
else
{
const struct mount_entry *entries = get_file_system_list(false);
if (entries)
{
const struct mount_entry *entry;
for (entry = entries; entry; entry = entry->me_next)
{
if (0 == strcmp(name, entry->me_type))
return true;
}
}
else
{
return true;
}
}
return false;
}
static int
set_fstype_devno (struct mount_entry *p)
{
@ -160,42 +191,26 @@ set_fstype_devno (struct mount_entry *p)
{
set_stat_placeholders (&stbuf);
if (0 == (options.xstat)(p->me_mountdir, &stbuf))
{
p->me_dev = stbuf.st_dev;
return 0;
}
{
p->me_dev = stbuf.st_dev;
return 0;
}
else
{
return -1;
}
{
return -1;
}
}
return 0; /* not needed */
return 0; /* not needed */
}
static struct mount_entry *
must_read_fs_list (bool need_fs_type)
{
struct mount_entry *entries = read_file_system_list (need_fs_type);
if (NULL == entries)
{
/* We cannot determine for sure which file we were trying to
* use because gnulib has abstracted all that stuff away.
* Hence we cannot issue a specific error message here.
*/
error (EXIT_FAILURE, 0, _("Cannot read mounted file system list"));
}
return entries;
}
/* Return a newly allocated string naming the type of file system that the
file PATH, described by STATP, is on.
RELPATH is the file name relative to the current directory.
Return "unknown" if its file system type is unknown. */
static char *
file_system_type_uncached (const struct stat *statp, const char *path)
file_system_type_uncached (const struct stat *statp, const char *path,
bool *fstype_known)
{
struct mount_entry *entries, *entry, *best;
char *type;
@ -205,84 +220,53 @@ file_system_type_uncached (const struct stat *statp, const char *path)
#ifdef AFS
if (in_afs (path))
{
fstype_known = 1;
*fstype_known = true;
return xstrdup ("afs");
}
#endif
best = NULL;
entries = must_read_fs_list (true);
entries = get_file_system_list (true);
if (NULL == entries)
{
/* We cannot determine for sure which file we were trying to
* use because gnulib has abstracted all that stuff away.
* Hence we cannot issue a specific error message here.
*/
error (EXIT_FAILURE, 0, _("Cannot read mounted file system list"));
}
for (type=NULL, entry=entries; entry; entry=entry->me_next)
{
#ifdef MNTTYPE_IGNORE
if (!strcmp (entry->me_type, MNTTYPE_IGNORE))
continue;
continue;
#endif
if (0 == set_fstype_devno (entry))
{
if (entry->me_dev == statp->st_dev)
{
best = entry;
/* Don't exit the loop, because some systems (for
example Linux-based systems in which /etc/mtab is a
symlink to /proc/mounts) can have duplicate entries
in the filesystem list. This happens most frequently
for /.
*/
}
}
{
if (entry->me_dev == statp->st_dev)
{
best = entry;
/* Don't exit the loop, because some systems (for
example Linux-based systems in which /etc/mtab is a
symlink to /proc/mounts) can have duplicate entries
in the filesystem list. This happens most frequently
for /.
*/
}
}
}
if (best)
{
type = xstrdup (best->me_type);
}
free_file_system_list (entries);
/* Don't cache unknown values. */
fstype_known = (type != NULL);
*fstype_known = (type != NULL);
return type ? type : xstrdup (_("unknown"));
}
char *
get_mounted_filesystems (void)
{
char *result = NULL;
size_t alloc_size = 0u;
size_t used = 0u;
struct mount_entry *entries, *entry;
void *p;
entries = must_read_fs_list (false);
for (entry=entries; entry; entry=entry->me_next)
{
size_t len;
#ifdef MNTTYPE_IGNORE
if (!strcmp (entry->me_type, MNTTYPE_IGNORE))
continue;
#endif
len = strlen (entry->me_mountdir) + 1;
p = extendbuf (result, used+len, &alloc_size);
if (p)
{
result = p;
strcpy (&result[used], entry->me_mountdir);
used += len; /* len already includes one for the \0 */
}
else
{
break;
}
}
free_file_system_list (entries);
return result;
}
dev_t *
get_mounted_devices (size_t *n)
{
@ -291,7 +275,7 @@ get_mounted_devices (size_t *n)
struct mount_entry *entries, *entry;
dev_t *result = NULL;
/* Use read_file_system_list () rather than must_read_fs_list()
/* Ignore read_file_system_list () not returning a valid list
* because on some system this is always called at startup,
* and find should only exit fatally if it needs to use the
* result of this operation. If we can't get the fs list
@ -303,19 +287,19 @@ get_mounted_devices (size_t *n)
{
void *p = extendbuf (result, sizeof(dev_t)*(used+1), &alloc_size);
if (p)
{
result = p;
if (0 == set_fstype_devno (entry))
{
result[used] = entry->me_dev;
++used;
}
}
{
result = p;
if (0 == set_fstype_devno (entry))
{
result[used] = entry->me_dev;
++used;
}
}
else
{
free (result);
result = NULL;
}
{
free (result);
result = NULL;
}
}
free_file_system_list (entries);
if (result)

View File

@ -1,31 +0,0 @@
.TH FTSFIND 1 \" -*- nroff -*-
.SH NAME
ftsfind \- search for files in a directory hierarchy
.SH SYNOPSIS
.B ftsfind
[\-H] [\-L] [\-P] [\-D debugopts] [\-Olevel] [path...] [expression]
.SH DESCRIPTION
The
.B ftsfind
and
.B find
programs are functionally identical. The only difference between them
is the implementation internals of how the filesystem is searched.
The
.B find
binary has a recursive implementation while
.B ftsfind
uses
.BR fts (3).
The fts-based implementation will replace the recursive implementation
but for the moment both implementations are installed.
.P
The implementation which is installed as
.B find
on this system is the recursive implementation, since the
.B \-\-without\-fts
option was passed to the
.B configure
script when findutils was built.
.SH "SEE ALSO"
\fBfind\fP(1), \fBfts\fP(3), \fBFinding Files\fP (on-line in Info, or printed).

View File

@ -1,6 +1,5 @@
/* find -- search for files in a directory hierarchy (fts version)
Copyright (C) 1990, 1091, 1992, 1993, 1994, 2000, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,10 +12,10 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* This file was written by James Youngman, based on find.c.
/* This file was written by James Youngman, based on oldfind.c.
GNU find was written by Eric Decker <cire@soe.ucsc.edu>,
with enhancements by David MacKenzie <djm@gnu.org>,
@ -35,47 +34,33 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <locale.h>
#include <sys/stat.h>
#include <unistd.h>
/* gnulib headers. */
#include "argv-iter.h"
#include "cloexec.h"
#include "closeout.h"
#include "error.h"
#include "fts_.h"
#include "gettext.h"
#include "intprops.h"
#include "progname.h"
#include "quotearg.h"
#include "same-inode.h"
#include "save-cwd.h"
#include "xgetcwd.h"
#include "xalloc.h"
/* find headers. */
#include "defs.h"
#include "dircallback.h"
#include "fdleak.h"
#include "unused-result.h"
#include "system.h"
#define USE_SAFE_CHDIR 1
#undef STAT_MOUNTPOINTS
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)
#endif
#ifdef gettext_noop
# define N_(String) gettext_noop (String)
#else
/* See locate.c for explanation as to why not use (String) */
# define N_(String) String
#endif
/* FTS_TIGHT_CYCLE_CHECK tries to work around Savannah bug #17877
* (but actually using it doesn't fix the bug).
*/
@ -96,10 +81,10 @@ left_dir (void)
if (ftsoptions & FTS_CWDFD)
{
if (curr_fd >= 0)
{
close (curr_fd);
curr_fd = -1;
}
{
close (curr_fd);
curr_fd = -1;
}
}
else
{
@ -121,28 +106,28 @@ inside_dir (int dir_fd)
state.cwd_dir_fd = dir_fd;
if (curr_fd < 0)
{
if (AT_FDCWD == dir_fd)
{
curr_fd = AT_FDCWD;
}
else if (dir_fd >= 0)
{
curr_fd = dup_cloexec (dir_fd);
}
else
{
/* curr_fd is invalid, but dir_fd is also invalid.
* This should not have happened.
*/
assert (curr_fd >= 0 || dir_fd >= 0);
}
}
{
if (AT_FDCWD == dir_fd)
{
curr_fd = AT_FDCWD;
}
else if (dir_fd >= 0)
{
curr_fd = dup_cloexec (dir_fd);
}
else
{
/* curr_fd is invalid, but dir_fd is also invalid.
* This should not have happened.
*/
assert (curr_fd >= 0 || dir_fd >= 0);
}
}
}
else
{
/* FTS_CWDFD is not in use. We can always assume that
* AT_FDCWD refers to the directory we are currentl searching.
* AT_FDCWD refers to the directory we are currently searching.
*
* Therefore there is nothing to do.
*/
@ -155,13 +140,12 @@ inside_dir (int dir_fd)
static void init_mounted_dev_list (void);
#endif
#define STRINGIFY(X) #X
#define HANDLECASE(N) case N: return #N;
static char *
static const char *
get_fts_info_name (int info)
{
static char buf[10];
static char buf[1 + INT_BUFSIZE_BOUND (info) + 1];
switch (info)
{
HANDLECASE(FTS_D);
@ -204,27 +188,6 @@ visit (FTS *p, FTSENT *ent, struct stat *pstat)
}
}
static const char*
partial_quotearg_n (int n, char *s, size_t len, enum quoting_style style)
{
if (0 == len)
{
return quotearg_n_style (n, style, "");
}
else
{
char saved;
const char *result;
saved = s[len];
s[len] = 0;
result = quotearg_n_style (n, style, s);
s[len] = saved;
return result;
}
}
/* We've detected a file system loop. This is caused by one of
* two things:
*
@ -234,7 +197,7 @@ partial_quotearg_n (int n, char *s, size_t len, enum quoting_style style)
*
* 2. We have hit a real cycle in the directory hierarchy. In this
* case, we issue a diagnostic message (POSIX requires this) and we
* skip that directory entry.
* will skip that directory entry.
*/
static void
issue_loop_warning (FTSENT * ent)
@ -242,8 +205,8 @@ issue_loop_warning (FTSENT * ent)
if (S_ISLNK(ent->fts_statp->st_mode))
{
error (0, 0,
_("Symbolic link %s is part of a loop in the directory hierarchy; we have already visited the directory to which it points."),
safely_quote_err_filename (0, ent->fts_path));
_("Symbolic link %s is part of a loop in the directory hierarchy; we have already visited the directory to which it points."),
safely_quote_err_filename (0, ent->fts_path));
}
else
{
@ -256,13 +219,9 @@ issue_loop_warning (FTSENT * ent)
* to /a/b/c.
*/
error (0, 0,
_("File system loop detected; "
"%s is part of the same file system loop as %s."),
safely_quote_err_filename (0, ent->fts_path),
partial_quotearg_n (1,
ent->fts_cycle->fts_path,
ent->fts_cycle->fts_pathlen,
options.err_quoting_style));
_("File system loop detected; "
"the following directory is part of the cycle: %s"),
safely_quote_err_filename (0, ent->fts_path));
}
}
@ -281,53 +240,6 @@ symlink_loop (const char *name)
}
static void
show_outstanding_execdirs (FILE *fp)
{
if (options.debug_options & DebugExec)
{
int seen=0;
struct predicate *p;
p = get_eval_tree ();
fprintf (fp, "Outstanding execdirs:");
while (p)
{
const char *pfx;
if (pred_is (p, pred_execdir))
pfx = "-execdir";
else if (pred_is (p, pred_okdir))
pfx = "-okdir";
else
pfx = NULL;
if (pfx)
{
size_t i;
const struct exec_val *execp = &p->args.exec_vec;
++seen;
fprintf (fp, "%s ", pfx);
if (execp->multiple)
fprintf (fp, "multiple ");
fprintf (fp, "%" PRIuMAX " args: ", (uintmax_t) execp->state.cmd_argc);
for (i=0; i<execp->state.cmd_argc; ++i)
{
fprintf (fp, "%s ", execp->state.cmd_argv[i]);
}
fprintf (fp, "\n");
}
p = p->pred_next;
}
if (!seen)
fprintf (fp, " none\n");
}
else
{
/* No debug output is wanted. */
}
}
static void
consider_visiting (FTS *p, FTSENT *ent)
{
@ -337,14 +249,14 @@ consider_visiting (FTS *p, FTSENT *ent)
if (options.debug_options & DebugSearch)
fprintf (stderr,
"consider_visiting (early): %s: "
"fts_info=%-6s, fts_level=%2d, prev_depth=%d "
"fts_path=%s, fts_accpath=%s\n",
quotearg_n_style (0, options.err_quoting_style, ent->fts_path),
get_fts_info_name (ent->fts_info),
(int)ent->fts_level, prev_depth,
quotearg_n_style (1, options.err_quoting_style, ent->fts_path),
quotearg_n_style (2, options.err_quoting_style, ent->fts_accpath));
"consider_visiting (early): %s: "
"fts_info=%-6s, fts_level=%2d, prev_depth=%d "
"fts_path=%s, fts_accpath=%s\n",
quotearg_n_style (0, options.err_quoting_style, ent->fts_path),
get_fts_info_name (ent->fts_info),
(int)ent->fts_level, prev_depth,
quotearg_n_style (1, options.err_quoting_style, ent->fts_path),
quotearg_n_style (2, options.err_quoting_style, ent->fts_accpath));
if (ent->fts_info == FTS_DP)
{
@ -360,16 +272,30 @@ consider_visiting (FTS *p, FTSENT *ent)
statbuf.st_ino = ent->fts_statp->st_ino;
/* Cope with various error conditions. */
if (ent->fts_info == FTS_ERR
|| ent->fts_info == FTS_DNR)
if (ent->fts_info == FTS_ERR)
{
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
return;
}
if (ent->fts_info == FTS_DNR)
{
/* Ignore ENOENT error for vanished directories. */
if (ENOENT == ent->fts_errno && options.ignore_readdir_race)
return;
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
if (options.do_dir_first)
{
/* Return for unreadable directories without -depth.
* With -depth, the directory itself has to be processed, yet the
* error message above has to be output.
*/
return;
}
}
else if (ent->fts_info == FTS_DC)
{
issue_loop_warning (ent);
error_severity (EXIT_FAILURE);
state.exit_status = EXIT_FAILURE;
return;
}
else if (ent->fts_info == FTS_SLNONE)
@ -382,45 +308,49 @@ consider_visiting (FTS *p, FTSENT *ent)
* of the file (fts_path) in the error message.
*/
if (symlink_loop (ent->fts_accpath))
{
nonfatal_target_file_error (ELOOP, ent->fts_path);
return;
}
{
nonfatal_target_file_error (ELOOP, ent->fts_path);
return;
}
}
else if (ent->fts_info == FTS_NS)
{
if (ent->fts_level == 0)
{
/* e.g., nonexistent starting point */
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
return;
}
{
/* e.g., nonexistent starting point */
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
return;
}
else
{
/* The following if statement fixes Savannah bug #19605
* (failure to diagnose a symbolic link loop)
*/
if (symlink_loop (ent->fts_accpath))
{
nonfatal_target_file_error (ELOOP, ent->fts_path);
return;
}
else
{
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
/* Continue despite the error, as file name without stat info
* might be better than not even processing the file name. This
* can lead to repeated error messages later on, though, if a
* predicate requires stat information.
*
* Not printing an error message here would be even more wrong,
* though, as this could cause the contents of a directory to be
* silently ignored, as the directory wouldn't be identified as
* such.
*/
}
{
/* The following if statement fixes Savannah bug #19605
* (failure to diagnose a symbolic link loop)
*/
if (symlink_loop (ent->fts_accpath))
{
nonfatal_target_file_error (ELOOP, ent->fts_path);
return;
}
else
{
/* Ignore ENOENT error for vanished files. */
if (ENOENT == ent->fts_errno && options.ignore_readdir_race)
return;
}
nonfatal_target_file_error (ent->fts_errno, ent->fts_path);
/* Continue despite the error, as file name without stat info
* might be better than not even processing the file name. This
* can lead to repeated error messages later on, though, if a
* predicate requires stat information.
*
* Not printing an error message here would be even more wrong,
* though, as this could cause the contents of a directory to be
* silently ignored, as the directory wouldn't be identified as
* such.
*/
}
}
}
/* Cope with the usual cases. */
@ -439,11 +369,11 @@ consider_visiting (FTS *p, FTSENT *ent)
state.type = mode = statbuf.st_mode;
if (00000 == mode)
{
/* Savannah bug #16378. */
error (0, 0, _("WARNING: file %s appears to have mode 0000"),
quotearg_n_style (0, options.err_quoting_style, ent->fts_path));
}
{
/* Savannah bug #16378. */
error (0, 0, _("WARNING: file %s appears to have mode 0000"),
quotearg_n_style (0, options.err_quoting_style, ent->fts_path));
}
}
/* update state.curdepth before calling digest_mode(), because digest_mode
@ -453,7 +383,7 @@ consider_visiting (FTS *p, FTSENT *ent)
if (mode)
{
if (!digest_mode (&mode, ent->fts_path, ent->fts_name, &statbuf, 0))
return;
return;
}
/* examine this item. */
@ -477,12 +407,12 @@ consider_visiting (FTS *p, FTSENT *ent)
if (options.maxdepth >= 0)
{
if (ent->fts_level >= options.maxdepth)
{
fts_set (p, ent, FTS_SKIP); /* descend no further */
{
fts_set (p, ent, FTS_SKIP); /* descend no further */
if (ent->fts_level > options.maxdepth)
ignore = 1; /* don't even look at this one */
}
if (ent->fts_level > options.maxdepth)
ignore = 1; /* don't even look at this one */
}
}
if ( (ent->fts_info == FTS_D) && !options.do_dir_first )
@ -502,11 +432,11 @@ consider_visiting (FTS *p, FTSENT *ent)
if (options.debug_options & DebugSearch)
fprintf (stderr,
"consider_visiting (late): %s: "
"fts_info=%-6s, isdir=%d ignore=%d have_stat=%d have_type=%d \n",
quotearg_n_style (0, options.err_quoting_style, ent->fts_path),
get_fts_info_name (ent->fts_info),
isdir, ignore, state.have_stat, state.have_type);
"consider_visiting (late): %s: "
"fts_info=%-6s, isdir=%d ignore=%d have_stat=%d have_type=%d \n",
quotearg_n_style (0, options.err_quoting_style, ent->fts_path),
get_fts_info_name (ent->fts_info),
isdir, ignore, state.have_stat, state.have_type);
if (!ignore)
{
@ -550,67 +480,66 @@ find (char *arg)
break;
}
if (options.stay_on_filesystem)
if (options.mount)
ftsoptions |= FTS_MOUNT;
if (options.xdev)
ftsoptions |= FTS_XDEV;
p = fts_open (arglist, ftsoptions, NULL);
if (NULL == p)
{
error (0, errno, _("cannot search %s"),
safely_quote_err_filename (0, arg));
error_severity (EXIT_FAILURE);
safely_quote_err_filename (0, arg));
state.exit_status = EXIT_FAILURE;
}
else
{
int level = INT_MIN;
while ( (errno=0, ent=fts_read (p)) != NULL )
{
if (state.execdirs_outstanding)
{
/* If we changed level, perform any outstanding
* execdirs. If we see a sequence of directory entries
* like this: fffdfffdfff, we could build a command line
* of 9 files, but this simple-minded implementation
* builds a command line for only 3 files at a time
* (since fts descends into the directories).
*/
if ((int)ent->fts_level != level)
{
show_outstanding_execdirs (stderr);
complete_pending_execdirs ();
}
}
level = (int)ent->fts_level;
{
if (state.execdirs_outstanding && ((int)ent->fts_level != level))
{
/* If we changed level, perform any outstanding
* execdirs. If we see a sequence of directory entries
* like this: fffdfffdfff, we could build a command line
* of 9 files, but this simple-minded implementation
* builds a command line for only 3 files at a time
* (since fts descends into the directories).
*/
complete_pending_execdirs ();
}
level = (int)ent->fts_level;
state.already_issued_stat_error_msg = false;
state.have_stat = false;
state.have_type = !!ent->fts_statp->st_mode;
state.type = state.have_type ? ent->fts_statp->st_mode : 0;
consider_visiting (p, ent);
}
state.already_issued_stat_error_msg = false;
state.have_stat = false;
state.have_type = !!ent->fts_statp->st_mode;
state.type = state.have_type ? ent->fts_statp->st_mode : 0;
consider_visiting (p, ent);
}
/* fts_read returned NULL; distinguish between "finished" and "error". */
if (errno)
{
error (0, errno,
"failed to read file names from file system at or below %s",
safely_quote_err_filename (0, arg));
error_severity (EXIT_FAILURE);
return false;
}
{
error (0, errno,
"failed to read file names from file system at or below %s",
safely_quote_err_filename (0, arg));
state.exit_status = EXIT_FAILURE;
return false;
}
if (0 != fts_close (p))
{
/* Here we break the abstraction of fts_close a bit, because we
* are going to skip the rest of the start points, and return with
* nonzero exit status. Hence we need to issue a diagnostic on
* stderr. */
error (0, errno,
_("failed to restore working directory after searching %s"),
arg);
error_severity (EXIT_FAILURE);
return false;
}
{
/* Here we break the abstraction of fts_close a bit, because we
* are going to skip the rest of the start points, and return with
* nonzero exit status. Hence we need to issue a diagnostic on
* stderr. */
error (0, errno,
_("failed to restore working directory after searching %s"),
arg);
state.exit_status = EXIT_FAILURE;
return false;
}
p = NULL;
}
return true;
@ -620,28 +549,162 @@ find (char *arg)
static bool
process_all_startpoints (int argc, char *argv[])
{
int i;
/* Did the user pass starting points on the command line? */
bool argv_starting_points = 0 < argc && !looks_like_expression (argv[0], true);
/* figure out how many start points there are */
for (i = 0; i < argc && !looks_like_expression (argv[i], true); i++)
FILE *stream = NULL;
char const* files0_filename_quoted = NULL;
struct argv_iterator *ai;
if (options.files0_from)
{
state.starting_path_length = strlen (argv[i]); /* TODO: is this redundant? */
if (!find (argv[i]))
return false;
/* Option -files0-from must not be combined with passing starting points
* on the command line. */
if (argv_starting_points)
{
error (0, 0, _("extra operand %s"), safely_quote_err_filename (0, argv[0]));
error (EXIT_FAILURE, 0,
_("file operands cannot be combined with -files0-from"));
}
if (0 == strcmp (options.files0_from, "-"))
{
/* Option -files0-from with argument "-" (=stdin) must not be combined
* with the -ok, -okdir actions: getting the user confirmation would
* mess with stdin. */
if (options.ok_prompt_stdin)
{
error (EXIT_FAILURE, 0,
_("option -files0-from reading from standard input"
" cannot be combined with -ok, -okdir"));
}
files0_filename_quoted = safely_quote_err_filename (0, _("(standard input)"));
stream = stdin;
}
else
{
files0_filename_quoted = safely_quote_err_filename (0, options.files0_from);
stream = fopen (options.files0_from, "r");
if (stream == NULL)
{
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
files0_filename_quoted);
}
const int fd = fileno (stream);
assert (fd >= 0);
if (options.ok_prompt_stdin)
{
/* Check if the given file is associated to the same stream as
* standard input - which is not allowed with -ok, -okdir. This
* is the case with special device names symlinks for stdin like
* $ find -files0-from /dev/stdin -ok
* or when the given FILE is also associated to stdin:
* $ find -files0-from FILE -ok < FILE
*/
struct stat sb1, sb2;
if (fstat (fd, &sb1) == 0 && fstat (STDIN_FILENO, &sb2) == 0
&& SAME_INODE (sb1, sb2))
{
error (EXIT_FAILURE, 0,
_("option -files0-from: standard input must not refer"
" to the same file when combined with -ok, -okdir:"
" %s"),
files0_filename_quoted);
}
}
set_cloexec_flag (fd, true);
}
ai = argv_iter_init_stream (stream);
}
else
{
if (!argv_starting_points)
{
/* If no starting points are given on the command line, then
* fall back to processing the current directory, i.e., ".".
* We use a temporary variable here because some actions modify
* the path temporarily. Hence if we use a string constant,
* we get a coredump. The best example of this is if we say
* "find -printf %H" (note, not "find . -printf %H").
*/
char defaultpath[2] = ".";
return find (defaultpath);
}
/* Process the starting point(s) from the command line. */
ai = argv_iter_init_argv (argv);
}
if (i == 0)
if (!ai)
xalloc_die ();
bool ok = true;
while (true)
{
/*
* We use a temporary variable here because some actions modify
* the path temporarily. Hence if we use a string constant,
* we get a coredump. The best example of this is if we say
* "find -printf %H" (note, not "find . -printf %H").
*/
char defaultpath[2] = ".";
return find (defaultpath);
enum argv_iter_err ai_err;
char *file_name = argv_iter (ai, &ai_err);
if (!file_name)
{
switch (ai_err)
{
case AI_ERR_EOF:
goto argv_iter_done;
case AI_ERR_READ: /* may only happen with -files0-from */
error (0, errno, _("%s: read error"), files0_filename_quoted);
state.exit_status = EXIT_FAILURE;
ok = false;
goto argv_iter_done;
case AI_ERR_MEM:
xalloc_die ();
default:
assert (!"unexpected error code from argv_iter");
}
}
/* Report and skip any empty file names before invoking fts.
This works around a glitch in fts, which fails immediately
(without looking at the other file names) when given an empty
file name. */
if (!file_name[0])
{
/* Diagnose a zero-length file name. When it's one
among many, knowing the record number may help. */
if (options.files0_from == NULL)
error (0, ENOENT, "%s", safely_quote_err_filename (0, file_name));
else
{
/* Using the standard 'filename:line-number:' prefix here is
not totally appropriate, since NUL is the separator, not NL,
but it might be better than nothing. */
unsigned long int file_number = argv_iter_n_args (ai);
error (0, 0, "%s:%lu: %s", files0_filename_quoted, file_number,
_("invalid zero-length file name"));
}
state.exit_status = EXIT_FAILURE;
ok = false;
continue;
}
/* Terminate loop when processing the start points from command line,
and reaching the first expression. */
if (!options.files0_from && looks_like_expression (file_name, true))
break;
state.starting_path_length = strlen (file_name); /* TODO: is this redundant? */
if (!find (file_name))
{
ok = false;
goto argv_iter_done;
}
}
return true;
argv_iter_done:
argv_iter_free (ai);
if (ok && options.files0_from && (ferror (stream) || fclose (stream) != 0))
error (EXIT_FAILURE, 0, _("error reading %s"), files0_filename_quoted);
return ok;
}
@ -661,7 +724,7 @@ main (int argc, char **argv)
record_initial_cwd ();
state.already_issued_stat_error_msg = false;
state.exit_status = 0;
state.exit_status = EXIT_SUCCESS;
state.execdirs_outstanding = false;
state.cwd_dir_fd = AT_FDCWD;
@ -674,7 +737,7 @@ main (int argc, char **argv)
if (NULL == state.shared_files)
{
error (EXIT_FAILURE, errno,
_("Failed to initialize shared-file hash table"));
_("Failed to initialize shared-file hash table"));
}
/* Set the option defaults before we do the locale initialisation as
@ -689,9 +752,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (atexit (close_stdout))
{
error (EXIT_FAILURE, errno, _("The atexit library function failed"));
}
error (EXIT_FAILURE, errno, _("The atexit library function failed"));
/* Check for -P, -H or -L options. Also -D and -O, which are
* both GNU extensions.
@ -701,9 +762,9 @@ main (int argc, char **argv)
if (options.debug_options & DebugStat)
options.xstat = debug_stat;
#ifdef DEBUG
fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start));
#endif /* DEBUG */
if (options.debug_options & DebugTime)
fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start.tv_sec));
/* We are now processing the part of the "find" command line
@ -736,7 +797,7 @@ main (int argc, char **argv)
* the wrong directory for example.
*/
if (process_all_startpoints (argc-end_of_leading_options,
argv+end_of_leading_options))
argv+end_of_leading_options))
{
/* If "-exec ... {} +" has been used, there may be some
* partially-full command lines which have been built,
@ -749,9 +810,7 @@ main (int argc, char **argv)
}
bool
is_fts_enabled (int *fts_options)
is_fts_cwdfd_enabled (void)
{
/* this version of find (i.e. this main()) uses fts. */
*fts_options = ftsoptions;
return true;
return ftsoptions & FTS_CWDFD;
}

81
find/getlimits.c Normal file
View File

@ -0,0 +1,81 @@
/* getlimits - print various platform dependent limits.
Copyright (C) 2023-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Based on 'getlimits' of GNU coreutils, written by Pádraig Brady.
* Stripped down to a minimal version by Bernhard Voelker. */
#include <config.h> /* sets _FILE_OFFSET_BITS=64 etc. */
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdint.h>
#include "system.h"
#include "intprops.h"
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
#ifndef GID_T_MAX
# define GID_T_MAX TYPE_MAXIMUM (gid_t)
#endif
#ifndef MIN
# define MIN(a,b) (a<b?a:b)
#endif
/* Silence GCC 14. */
#if 14 <= __GNUC__
# pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds"
#endif
/* Add one to the absolute value of the number whose textual
representation is BUF + 1. Do this in-place, in the buffer.
Return a pointer to the result, which is normally BUF + 1, but is
BUF if the representation grew in size. */
static char const *
decimal_absval_add_one (char *buf)
{
bool negative = (buf[1] == '-');
char *absnum = buf + 1 + negative;
char *p = absnum + strlen (absnum);
absnum[-1] = '0';
while (*--p == '9')
*p = '0';
++*p;
char *result = MIN (absnum, p);
if (negative)
*--result = '-';
return result;
}
int
main (int argc, char **argv)
{
char limit[100];
#define print_int(TYPE) \
sprintf (limit + 1, "%" "ju", (uintmax_t) TYPE##_MAX); \
printf (#TYPE"_MAX=%s\n", limit + 1); \
printf (#TYPE"_OFLOW=%s\n", decimal_absval_add_one (limit))
print_int (INT);
print_int (UID_T);
print_int (GID_T);
return EXIT_SUCCESS;
}

View File

@ -1,31 +0,0 @@
.TH OLDFIND 1 \" -*- nroff -*-
.SH NAME
oldfind \- search for files in a directory hierarchy
.SH SYNOPSIS
.B oldfind
[\-H] [\-L] [\-P] [\-D debugopts] [\-Olevel] [path...] [expression]
.SH DESCRIPTION
The
.B oldfind
and
.B find
programs are functionally identical. The only difference between them
is the implementation internals of how the filesystem is searched.
The
.B oldfind
binary has a recursive implementation while
.B find
uses
.BR fts (3).
The fts-based implementation will replace the recursive implementation
but for the moment both implementations are installed.
.P
The implementation which is installed as
.B find
on this system is the fts-based implementation, since the
.B \-\-without\-fts
option was not passed to the
.B configure
script when findutils was built.
.SH "SEE ALSO"
\fBfind\fP(1), \fBfts\fP(3), \fBFinding Files\fP (on-line in Info, or printed).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,5 @@
/* print.c -- print/printf-related code.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -14,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* We always include config.h first. */
@ -25,7 +23,6 @@
#include <ctype.h>
#include <errno.h>
#include <grp.h>
#include <locale.h>
#include <math.h>
#include <pwd.h>
#include <stdarg.h>
@ -35,9 +32,7 @@
/* gnulib headers. */
#include "areadlink.h"
#include "dirname.h"
#include "error.h"
#include "filemode.h"
#include "gettext.h"
#include "human.h"
#include "printquoted.h"
#include "stat-size.h"
@ -46,21 +41,10 @@
#include "xalloc.h"
/* find-specific headers. */
#include "system.h"
#include "defs.h"
#include "print.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#ifdef gettext_noop
# define N_(String) gettext_noop (String)
#else
/* See locate.c for explanation as to why not use (String) */
# define N_(String) String
#endif
#if defined STDC_HEADERS
# define ISDIGIT(c) isdigit ((unsigned char)c)
@ -70,6 +54,9 @@
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
static void checked_fprintf (struct format_val *dest, const char *fmt, ...)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(2, 3);
/* Create a new fprintf segment in *SEGMENT, with type KIND,
from the text in FORMAT, which has length LEN.
@ -451,7 +438,7 @@ scan_for_digit_differences (const char *p, const char *q,
{
if (p[i] != q[i])
{
if (!isdigit ((unsigned char)q[i]) || !isdigit ((unsigned char)q[i]))
if (!isdigit ((unsigned char)p[i]) || !isdigit ((unsigned char)q[i]))
return false;
if (!seen)
@ -601,7 +588,7 @@ format_date (struct timespec ts, int kind)
* For example, some systems return junk in the tv_nsec part of
* st_birthtime. An example of this is the NetBSD-4.0-RELENG kernel
* (at Sat Mar 24 18:46:46 2007) running a NetBSD-3.1-RELEASE
* runtime and examining files on an msdos filesytem. So for that
* runtime and examining files on an msdos filesystem. So for that
* reason we set NS_BUF_LEN to 32, which is simply "long enough" as
* opposed to "exactly the right size". Note that the behaviour of
* NetBSD appears to be a result of the use of uninitialized data,
@ -616,7 +603,7 @@ format_date (struct timespec ts, int kind)
char ns_buf[NS_BUF_LEN]; /* -.9999999990 (- sign can happen!)*/
int charsprinted, need_ns_suffix;
struct tm *tm;
char fmt[6];
char fmt[12];
/* human_readable() assumes we pass a buffer which is at least as
* long as LONGEST_HUMAN_READABLE. We use an assertion here to
@ -636,7 +623,11 @@ format_date (struct timespec ts, int kind)
/* Format the main part of the time. */
if (kind == '+')
{
strcpy (fmt, "%F+%T");
/* Avoid %F, some Unix versions lack it. For example:
HP Tru64 UNIX V5.1B (Rev. 2650); Wed Feb 17 22:59:59 CST 2016
Also, some older HP-UX versions expand %F as the full month (like %B).
Reported by Steven M. Schweda <sms@antinode.info> */
strcpy (fmt, "%Y-%m-%d+%T");
need_ns_suffix = 1;
}
else
@ -707,7 +698,7 @@ format_date (struct timespec ts, int kind)
*--p = '-'; /* XXX: Ugh, relying on internal details of human_readable(). */
/* Add the nanoseconds part. Because we cannot enforce a
* particlar implementation of human_readable, we cannot assume
* particular implementation of human_readable, we cannot assume
* any particular value for (p-buf). So we need to be careful
* that there is enough space remaining in the buffer.
*/
@ -802,6 +793,7 @@ file_sparseness (const struct stat *p)
}
}
static void
checked_fprintf (struct format_val *dest, const char *fmt, ...)
{
@ -810,13 +802,14 @@ checked_fprintf (struct format_val *dest, const char *fmt, ...)
va_start (ap, fmt);
rv = vfprintf (dest->stream, fmt, ap);
va_end (ap);
if (rv < 0)
nonfatal_nontarget_file_error (errno, dest->filename);
}
static void
checked_print_quoted (struct format_val *dest,
const char *format, const char *s)
const char *format, const char *s)
{
int rv = print_quoted (dest->stream, dest->quote_opts, dest->dest_is_tty,
format, s);
@ -952,13 +945,8 @@ do_fprintf (struct format_val *dest,
checked_fprintf (dest, segment->text, g->gr_name);
break;
}
else
{
/* Do nothing. */
/*FALLTHROUGH*/
}
}
/*FALLTHROUGH*/ /*...sometimes, so 'G' case.*/
FALLTHROUGH; /*...sometimes, so 'G' case.*/
case 'G': /* GID number */
/* UNTRUSTED, probably unexploitable */
@ -969,8 +957,18 @@ do_fprintf (struct format_val *dest,
case 'h': /* leading directories part of path */
/* sanitised */
{
cp = strrchr (pathname, '/');
if (cp == NULL) /* No leading directories. */
char *pname = xstrdup (pathname);
/* Remove trailing slashes - unless it's the root '/' directory. */
char *s = pname + strlen (pname) -1;
for ( ; pname <= s; s--)
if (*s != '/')
break;
if (pname < s && *(s+1) == '/')
*(s+1) = '\0';
s = strrchr (pname, '/');
if (s == NULL) /* No leading directories. */
{
/* If there is no slash in the pathname, we still
* print the string because it contains characters
@ -980,11 +978,10 @@ do_fprintf (struct format_val *dest,
}
else
{
char *s = strdup (pathname);
s[cp - pathname] = 0;
checked_print_quoted (dest, segment->text, s);
free (s);
*s = '\0';
checked_print_quoted (dest, segment->text, pname);
}
free (pname);
}
break;
@ -1022,7 +1019,7 @@ do_fprintf (struct format_val *dest,
/* sanitised */
#ifdef S_ISLNK
{
char *linkname = 0;
char *linkname = NULL;
if (S_ISLNK (stat_buf->st_mode))
{
@ -1030,7 +1027,7 @@ do_fprintf (struct format_val *dest,
if (linkname == NULL)
{
nonfatal_target_file_error (errno, pathname);
state.exit_status = 1;
state.exit_status = EXIT_FAILURE;
}
}
if (linkname)
@ -1132,7 +1129,7 @@ do_fprintf (struct format_val *dest,
case 'S': /* sparseness */
/* UNTRUSTED, probably unexploitable */
checked_fprintf (dest, segment->text, file_sparseness (stat_buf));;
checked_fprintf (dest, segment->text, file_sparseness (stat_buf));
break;
case 't': /* mtime in `ctime' format */
@ -1157,9 +1154,8 @@ do_fprintf (struct format_val *dest,
checked_fprintf (dest, segment->text, p->pw_name);
break;
}
/* else fallthru */
}
/* FALLTHROUGH*/ /* .. to case U */
FALLTHROUGH; /* .. to case U */
case 'U': /* UID number */
/* UNTRUSTED, probably unexploitable */
@ -1178,13 +1174,14 @@ do_fprintf (struct format_val *dest,
if (S_ISLNK (stat_buf->st_mode))
{
struct stat sbuf;
/* If we would normally follow links, do not do so.
* If we would normally not follow links, do so.
/* %Y needs to stat the symlink target regardless of
* whether we would normally follow symbolic links or not.
* (Actually we do not even come here when following_links()
* other than the ENOENT case.)
*/
if ((following_links () ? optionp_stat : optionl_stat)
(state.rel_pathname, &sbuf) != 0)
if (fstatat (state.cwd_dir_fd, state.rel_pathname, &sbuf, 0) != 0)
{
if ( errno == ENOENT )
if ( (errno == ENOENT) || (errno == ENOTDIR) )
{
checked_fprintf (dest, segment->text, "N");
break;
@ -1199,7 +1196,7 @@ do_fprintf (struct format_val *dest,
checked_fprintf (dest, segment->text, "?");
error (0, errno, "%s",
safely_quote_err_filename (0, pathname));
/* exit_status = 1;
/* exit_status = EXIT_FAILURE;
return ; */
break;
}
@ -1207,8 +1204,8 @@ do_fprintf (struct format_val *dest,
checked_fprintf (dest, segment->text,
mode_to_filetype (sbuf.st_mode & S_IFMT));
}
#endif /* S_ISLNK */
else
#endif /* S_ISLNK */
{
checked_fprintf (dest, segment->text,
mode_to_filetype (stat_buf->st_mode & S_IFMT));
@ -1226,7 +1223,7 @@ do_fprintf (struct format_val *dest,
case 'Z': /* SELinux security context */
{
security_context_t scontext;
char *scontext;
int rv = (*options.x_getfilecon) (state.cwd_dir_fd, state.rel_pathname,
&scontext);
if (rv < 0)
@ -1238,7 +1235,7 @@ do_fprintf (struct format_val *dest,
error (0, errno, _("getfilecon failed: %s"),
safely_quote_err_filename (0, pathname));
state.exit_status = 1;
state.exit_status = EXIT_FAILURE;
}
else
{
@ -1248,9 +1245,18 @@ do_fprintf (struct format_val *dest,
}
break;
case 0:
case '%':
checked_fprintf (dest, segment->text);
checked_fwrite (segment->text, 1, segment->text_len, dest);
break;
case 0:
/* Trailing single %. This should have been rejected by
insert_fprintf. We use %s here in the error message
simply to ensure that the error message matches the one
in insert_fprintf, easing the translation burden.
*/
error (EXIT_FAILURE, 0, _("error: %s at end of format string"), "%");
/*NOTREACHED*/
break;
}
/* end of KIND_FORMAT case */

View File

@ -1,5 +1,5 @@
/* print.h -- declarations for symbols in print.c.
Copyright (C) 2011-2015 Free Software Foundation, Inc.
Copyright (C) 2011-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -12,9 +12,12 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "defs.h"
#ifndef PRINT_H
# define PRINT_H
# include "defs.h"
struct format_val;
struct parser_table;
@ -22,11 +25,13 @@ struct predicate;
struct segment;
struct segment **make_segment (struct segment **segment,
char *format, int len,
int kind, char format_char,
char aux_format_char,
struct predicate *pred);
char *format, int len,
int kind, char format_char,
char aux_format_char,
struct predicate *pred);
bool
insert_fprintf (struct format_val *vec,
const struct parser_table *entry,
char *format);
const struct parser_table *entry,
char *format);
#endif /* PRINT_H */

View File

@ -1,5 +1,5 @@
/* sharefile.c -- open files just once.
Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 2008-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* config.h always comes first. */
@ -29,7 +29,7 @@
/* gnulib headers. */
#include "cloexec.h"
#include "hash.h"
#include "stdio-safer.h"
#include "stdio--.h"
/* find headers. */
#include "sharefile.h"
@ -80,7 +80,7 @@ entry_free (void *pv)
if (p->fp)
{
if (0 != fclose (p->fp))
fatal_nontarget_file_error (errno, p->name);
fatal_nontarget_file_error (errno, p->name);
}
free (p->name);
free (p);
@ -105,25 +105,25 @@ sharefile_init (const char *mode)
{
p->mode = strdup (mode);
if (p->mode)
{
p->table = hash_initialize (DefaultHashTableSize, NULL,
entry_hashfunc,
entry_comparator,
entry_free);
if (p->table)
{
return p;
}
else
{
free (p->mode);
free (p);
}
}
{
p->table = hash_initialize (DefaultHashTableSize, NULL,
entry_hashfunc,
entry_comparator,
entry_free);
if (p->table)
{
return p;
}
else
{
free (p->mode);
free (p);
}
}
else
{
free (p);
}
{
free (p);
}
}
return NULL;
}
@ -154,9 +154,9 @@ sharefile_fopen (sharefile_handle h, const char *filename)
return NULL;
}
if (NULL == (new_entry->fp = fopen_safer (filename, p->mode)))
if (NULL == (new_entry->fp = fopen (filename, p->mode)))
{
free (new_entry);
entry_free (new_entry);
return NULL;
}
else
@ -168,36 +168,36 @@ sharefile_fopen (sharefile_handle h, const char *filename)
set_cloexec_flag (fd, true);
if (fstat (fd, &st) < 0)
{
entry_free (new_entry);
entry_free (new_entry);
return NULL;
}
else
{
void *existing;
void *existing;
new_entry->device = st.st_dev;
new_entry->inode = st.st_ino;
existing = hash_lookup (p->table, new_entry);
if (existing) /* We have previously opened that file. */
{
entry_free (new_entry); /* don't need new_entry. */
return ((const struct SharefileEntry*)existing)->fp;
}
if (existing) /* We have previously opened that file. */
{
entry_free (new_entry); /* don't need new_entry. */
return ((const struct SharefileEntry*)existing)->fp;
}
else /* We didn't open it already */
{
if (hash_insert (p->table, new_entry))
{
return new_entry->fp;
}
else /* failed to insert in hashtable. */
{
const int save_errno = errno;
entry_free (new_entry);
errno = save_errno;
return NULL;
}
}
{
if (hash_insert (p->table, new_entry))
{
return new_entry->fp;
}
else /* failed to insert in hashtable. */
{
const int save_errno = errno;
entry_free (new_entry);
errno = save_errno;
return NULL;
}
}
}
}
}

View File

@ -1,5 +1,5 @@
/* sharefile.h -- open files just once.
Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 2008-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -12,15 +12,15 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INC_SHAREFILE_H
#define INC_SHAREFILE_H 1
# define INC_SHAREFILE_H 1
#include <stdlib.h>
#include <stdio.h>
# include <stdlib.h>
# include <stdio.h>
typedef void * sharefile_handle;

View File

@ -1,6 +0,0 @@
Makefile
Makefile.in
dbg.log
find.log
find.sum
site.exp

View File

@ -1,6 +1,9 @@
Makefile
Makefile.in
dbg.log
find.log
find.sum
site.exp
/configured-testfiles.txt
/dbg.log
/find.log
/find.sum
/*.log
/Makefile
/Makefile.in
/site.exp
/*.trs

View File

@ -1,4 +1,4 @@
# Copyright (C) 2001,2003-2015 Free Software Foundation, Inc.
# Copyright (C) 2001-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,7 +11,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# The 2001 copyright line above was added in 2015 based on James
# Youngman's best estimate of the original publication date of this
@ -249,26 +249,13 @@ find.posix/typesize.exp \
find.posix/user-empty.exp \
find.posix/user-missing.exp
EXTRA_DIST_GOLDEN = \
test_escapechars.golden
test_shell_progs = \
sv-bug-32043.sh \
test_escapechars.sh \
test_escape_c.sh \
test_inode.sh \
sv-34079.sh \
sv-34976-execdir-fd-leak.sh
EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) $(EXTRA_DIST_GOLDEN) \
$(test_shell_progs) binary_locations.sh checklists.py
EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) \
checklists.py
CLEANFILES = *.log *.sum site.exp site.bak configured-testfiles.txt
#DIST_SUBDIRS = config
TESTS = $(test_shell_progs)
TEST_EXTENSIONS = .sh .py
check-local: checklists
@ -281,5 +268,3 @@ configured-testfiles.txt: Makefile
checklists: configured-testfiles.txt Makefile
$(PYTHON) $(srcdir)/checklists.py configured-testfiles.txt $(srcdir) config find.gnu find.posix

View File

@ -1,34 +0,0 @@
# Source this file, don't execute it.
#
# Copyright (C) 2011-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if [ -z "${testname}" ]; then
echo 'Please set $testname before sourcing binary_locations.sh.' >&2
exit 1
fi
parent="$(cd .. && pwd)"
if [ -f "${parent}/ftsfind" ]; then
ftsfind="${parent}/ftsfind"
oldfind="${parent}/find"
elif [ -f "${parent}/oldfind" ]; then
ftsfind="${parent}/find"
oldfind="${parent}/oldfind"
else
echo "Cannot find the executables to test." >&2
exit 1
fi

View File

@ -1,4 +1,4 @@
# Copyright (C) 2014, 2015 Free Software Foundation, Inc.
# Copyright (C) 2014-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,7 +11,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
"""Check that the list of test files in Makefile.am is complete and not redundant.

View File

@ -1,7 +1,6 @@
# -*- TCL -*-
# Test-specific TCL procedures required by DejaGNU.
# Copyright (C) 2000, 2003, 2004, 2005, 2006, 2010, 2011 Free Software
# Foundation, Inc.
# Copyright (C) 2000-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -14,53 +13,35 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Modified by Kevin Dalley <kevind@rahul.net> from the xargs files.
# Modified by David MacKenzie <djm@gnu.ai.mit.edu> from the gcc files
# written by Rob Savoye <rob@cygnus.com>.
global OLDFIND
global FTSFIND
verbose "base_dir is $base_dir" 2
global env;
set env(GNU_FINDUTILS_FD_LEAK_CHECK) "1"
# look for OLDFIND and FTSFIND
if { ![info exists OLDFIND] || ![info exists FTSFIND] } {
verbose "Searching for oldfind"
# look for FTSFIND
if { ![info exists FTSFIND] } {
verbose "Searching for find"
set dir "$base_dir/.."
set objfile "find.o"
set objfile "ftsfind.o"
if ![file exists "$dir/$objfile"] then {
error "dir is $dir, but I cannot see $objfile in that directory"
}
if ([findfile $dir/oldfind 1 0]) {
verbose "found oldfind, so ftsfind must be called find"
set OLDFIND [findfile $dir/oldfind $dir/oldfind [transform oldfind]]
set FTSFIND [findfile $dir/find $dir/find [transform find ]]
} else {
verbose "did not find oldfind, so ftsfind must be called ftsfind"
set OLDFIND [findfile $dir/find $dir/find [transform find ]]
set FTSFIND [findfile $dir/ftsfind $dir/ftsfind [transform ftsfind]]
}
set FTSFIND [findfile $dir/find $dir/find [transform find ]]
}
verbose "ftsfind is at $FTSFIND" 2
verbose "oldfind is at $OLDFIND" 2
if { [ string equal $FTSFIND $OLDFIND ] } {
error "OLDFIND and FTSFIND are set to $FTSFIND, which can't be right"
}
if [file exists $FTSFIND] then {
if [file exists $OLDFIND] then {
verbose "FTSFIND=$FTSFIND and OLDFIND=$OLDFIND both exist." 2
} else {
error "OLDFIND=$OLDFIND, but that program does not exist"
}
verbose "FTSFIND=$FTSFIND exists." 2
} else {
error "FTSFIND=$FTSFIND, but that program does not exist (base_dir is $base_dir)"
}
@ -206,10 +187,8 @@ proc optimisation_levels_to_test {} {
}
proc find_start { passfail options {infile ""} {output ""} {setup ""}} {
global OLDFIND
global FTSFIND
global FINDFLAGS
global SKIP_OLD
global SKIP_NEW
if {$infile != ""} then {
@ -222,18 +201,10 @@ proc find_start { passfail options {infile ""} {output ""} {setup ""}} {
error "$FTSFIND, program does not exist"
exit 1
}
if {[which $OLDFIND] == 0} then {
error "$OLDFIND, program does not exist"
exit 1
}
# Now run the test with each binary, once with each optimisation level.
foreach optlevel [optimisation_levels_to_test] {
set flags "$FINDFLAGS -O$optlevel"
if { ![info exists SKIP_OLD] || ! $SKIP_OLD } {
eval $setup
do_find_start old-O$optlevel $OLDFIND $flags $passfail $options $infile $output
}
if { ![info exists SKIP_NEW] || !$SKIP_NEW } {
eval $setup
do_find_start new-O$optlevel $FTSFIND $flags $passfail $options $infile $output
@ -285,8 +256,8 @@ proc mkdir { dirname } {
proc safe_path [ ] {
if { [ path_setting_is_unsafe ] } {
warning { Cannot perform test as your $PATH environment variable includes a reference to the current directory or a directory name which is not absolute }
untested { skipping this test because your $PATH variable is wrongly set }
warning { Cannot perform test as your PATH environment variable includes a reference to the current directory or a directory name which is not absolute }
untested { skipping this test because your PATH variable is wrongly set }
return 0
} else {
return 1

View File

@ -1,4 +1,4 @@
# If -exec \; fails, it should return false. The return
# value of find should stil; be 0, unless another error has
# value of find should still be 0, unless another error has
# happened.
find_start p { /tmp -exec false \; -o \( -printf "yep\n" -quit \) }

View File

@ -1,5 +1,5 @@
# tests for -execdir ... \+
# Specifically, ensure that output for separate directoires is not mixed.
# Specifically, ensure that output for separate directories is not mixed.
if { [ safe_path ] } {
exec rm -rf tmp
exec mkdir tmp tmp/two

View File

@ -22,8 +22,7 @@ set -e
here=`pwd`
d=`basename $here`
for arg;
do
for arg; do
echo "$d" "$arg"
done | LC_ALL=C sort
}

View File

@ -1,6 +1,6 @@
# Verifies that -name '*bar' will match quux/.foobar.
# See http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
# Also see http://savannah.gnu.org/bugs/?func=detailitem&item_id=10757
# See https://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
# Also see https://savannah.gnu.org/bugs/?func=detailitem&item_id=10757
exec rm -rf tmp
exec mkdir tmp
exec mkdir tmp/top

View File

@ -1,5 +1,91 @@
# Test case for Savannah bug ID #12085.
exec rm -rf tmp
exec touch tmp
find_start p {tmp -printf "RESULT: %h %f\n" }
exec rm -rf tmp
exec rm -rf foo
exec mkdir foo foo/bar
exec ln -s foo foolink
#
# Create the combinations with:
# $ printf '%s \\\n' {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} | sort -u
#
# Manual check against installed version:
# $ for opt in '' -H -L -P ; do
# printf "\n=== Differences for option: '%s' ===\n" "$opt"
# diff -u0 \
# <( /usr/bin/find $opt {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} \
# -maxdepth 1 -printf "%h/%f,%%p=%p,%%h='%h',%%f='%f'\n" ) \
# <( ./find $opt {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} \
# -maxdepth 1 -printf "%h/%f,%%p=%p,%%h='%h',%%f='%f'\n" )
# done | column -t -s,
find_start p {\
/ \
// \
/// \
///. \
//. \
. \
./ \
.// \
./// \
.//// \
.///// \
./////. \
.////. \
.///. \
.//. \
.//./ \
.//.// \
.//.//. \
.//./. \
./. \
././ \
./.// \
././/. \
././. \
.//foo \
.//foo/ \
.//foo// \
.//foo//. \
.//foo/. \
./foo \
./foo/ \
./foo// \
./foo//. \
./foo/. \
foo \
foo/ \
foo// \
foo//. \
foo/. \
.//foo/bar \
.//foo/bar/ \
.//foo/bar// \
.//foo/bar//. \
.//foo/bar/. \
./foo/bar \
./foo/bar/ \
./foo/bar// \
./foo/bar//. \
./foo/bar/. \
foo/bar \
foo/bar/ \
foo/bar// \
foo/bar//. \
foo/bar/. \
.//foolink \
.//foolink/ \
.//foolink// \
.//foolink//. \
.//foolink/. \
./foolink \
./foolink/ \
./foolink// \
./foolink//. \
./foolink/. \
foolink \
foolink/ \
foolink// \
foolink//. \
foolink/. \
-maxdepth 0 -printf "%p,%h,%f\n" }
exec rm -rf foo foolink

View File

@ -1 +1,69 @@
RESULT: . tmp
/,,/
//,/,/
///,//,/
///.,//,.
//.,/,.
.,.,.
./,.,./
.//,./,./
.///,.//,./
.////,.///,./
./////,.////,./
./////.,.////,.
.////.,.///,.
.///.,.//,.
.//.,./,.
.//./,./,./
.//.//,./,./
.//.//.,.//./,.
.//./.,.//.,.
./.,.,.
././,.,./
././/,.,./
././/.,././,.
././.,./.,.
.//foo/bar,.//foo,bar
.//foo/bar/,.//foo,bar/
.//foo/bar//,.//foo,bar/
.//foo/bar//.,.//foo/bar/,.
.//foo/bar/.,.//foo/bar,.
./foo/bar,./foo,bar
./foo/bar/,./foo,bar/
./foo/bar//,./foo,bar/
./foo/bar//.,./foo/bar/,.
./foo/bar/.,./foo/bar,.
foo/bar,foo,bar
foo/bar/,foo,bar/
foo/bar//,foo,bar/
foo/bar//.,foo/bar/,.
foo/bar/.,foo/bar,.
.//foo,./,foo
.//foo/,./,foo/
.//foo//,./,foo/
.//foo//.,.//foo/,.
.//foo/.,.//foo,.
./foo,.,foo
./foo/,.,foo/
./foo//,.,foo/
./foo//.,./foo/,.
./foo/.,./foo,.
foo,.,foo
foo/,.,foo/
foo//,.,foo/
foo//.,foo/,.
foo/.,foo,.
.//foolink,./,foolink
.//foolink/,./,foolink/
.//foolink//,./,foolink/
.//foolink//.,.//foolink/,.
.//foolink/.,.//foolink,.
./foolink,.,foolink
./foolink/,.,foolink/
./foolink//,.,foolink/
./foolink//.,./foolink/,.
./foolink/.,./foolink,.
foolink,.,foolink
foolink/,.,foolink/
foolink//,.,foolink/
foolink//.,foolink/,.
foolink/.,foolink,.

View File

@ -2,5 +2,9 @@ exec rm -rf tmp
exec mkdir tmp
exec touch tmp/file
exec ln -s file tmp/LINK
find_start p {tmp/LINK -printf "RESULT: %y %Y %p\n" -printf "RESULT2: %Y %y %p\n" }
exec ln -s ENOENT tmp/DANGLE
exec ln -s file/ENOTDIR tmp/ENOTDIR
exec ln -s SELF tmp/SELF
exec ls -ls tmp
find_start p {tmp/LINK tmp/DANGLE tmp/ENOTDIR tmp/SELF -printf "RESULT: %y %Y %p\n" -printf "RESULT2: %Y %y %p\n" }
exec rm -rf tmp

View File

@ -1,2 +1,8 @@
RESULT: l f tmp/LINK
RESULT2: f l tmp/LINK
RESULT: l N tmp/DANGLE
RESULT2: N l tmp/DANGLE
RESULT: l N tmp/ENOTDIR
RESULT2: N l tmp/ENOTDIR
RESULT: l L tmp/SELF
RESULT2: L l tmp/SELF

View File

@ -2,5 +2,7 @@ exec rm -rf tmp
exec mkdir tmp
exec touch tmp/file
exec chmod 600 tmp/file
find_start p {tmp -type f -printf "a %d\n" -printf "b %f\n" -printf "c %h\n" -printf "d %H\n" -printf "e %l\n" -printf "f %m\n" -printf "g %n\n" -printf "h %p\n" -printf "i %P\n" -printf "j %y\n" -printf "k %Y\n" -printf "percent it%%works%%\n" -printf "string-right !%10p!\n" -printf "string-left !%-10p!\n" -printf "trunc-R !%10.6p!\n" -printf "trunc-L !%-10.6p!\n" -printf "a5 !%5d!\n" -printf "a05 !%05d!\n" -printf "a+ %+d\n" }
exec touch -d 1990-06-22T12:00Z tmp/file
set env(TZ) "UTC"
find_start p {tmp -type f -printf "a %d\n" -printf "b %f\n" -printf "c %h\n" -printf "d %H\n" -printf "e %l\n" -printf "f %m\n" -printf "g %n\n" -printf "h %p\n" -printf "i %P\n" -printf "j %y\n" -printf "k %Y\n" -printf "percent it%%works%%\n" -printf "string-right !%10p!\n" -printf "string-left !%-10p!\n" -printf "trunc-R !%10.6p!\n" -printf "trunc-L !%-10.6p!\n" -printf "a5 !%5d!\n" -printf "a05 !%05d!\n" -printf "a+ %+d\n" -printf "l1 %T+ %T@ TH=%TH TI=%TI TM=%TM TT=%TT Td=%Td TD=%TD Tj=%Tj Tm=%Tm TU=%TU Tw=%Tw TW=%TW Ty=%Ty TY=%TY\n" -printf "l2 M=%M\n" -printf "l3 t=%t\n" -printf "l4 y=%y Y=%Y\n" }
exec rm -rf tmp

View File

@ -12,6 +12,10 @@ h tmp/file
i file
j f
k f
l1 1990-06-22+12:00:00.0000000000 646056000.0000000000 TH=12 TI=12 TM=00 TT=12:00:00.0000000000 Td=22 TD=06/22/90 Tj=173 Tm=06 TU=24 Tw=5 TW=25 Ty=90 TY=1990
l2 M=-rw-------
l3 t=Fri Jun 22 12:00:00.0000000000 1990
l4 y=f Y=f
percent it%works%
string-left !tmp/file !
string-right ! tmp/file!

View File

@ -3,9 +3,9 @@ exec rm -rf tmp
exec mkdir tmp
exec touch tmp/file1
exec ln tmp/file1 tmp/link
exec ln -s tmp/file1 tmp/symlink
exec ln -s file1 tmp/symlink
exec ln -s tmp/file2 tmp/broken
exec ln tmp/broken tmp/blink
exec ln -P tmp/broken tmp/blink
find_start p { -P tmp -samefile tmp/broken -print}
exec rm -rf tmp

View File

@ -1,6 +1,8 @@
# tests for Savannah bug 27563 (result of find -L -exec ls {} \;)
exec rm -rf tmp
exec mkdir tmp
exec touch tmp/yyyy
find_start p {-L tmp -name yyyy -execdir ls \{\} \; }
exec rm -rf tmp
if { [ safe_path ] } {
# tests for Savannah bug 27563 (result of find -L -exec ls {} \;)
exec rm -rf tmp
exec mkdir tmp
exec touch tmp/yyyy
find_start p {-L tmp -name yyyy -execdir ls \{\} \; }
exec rm -rf tmp
}

View File

@ -1,4 +1,4 @@
exec rm -rf tmp
exec mkdir tmp
# shoud not result in a fatal error.
# should not result in a fatal error.
find_start p { tmp \( -depth \) -false -print }

View File

@ -1,4 +1,4 @@
# tests for the bug reported at http://lists.gnu.org/archive/html/bug-findutils/2005-02/msg00077.html
# tests for the bug reported at https://lists.gnu.org/r/bug-findutils/2005-02/msg00077.html
exec rm -rf tmp
exec mkdir tmp
exec mkdir tmp/1 tmp/1/2 tmp/1/2/3 tmp/1/2/20 tmp/1/2/37 tmp/1/2/54 tmp/1/2/55 tmp/1/2/55/56 tmp/1/2/55/57 tmp/1/2/55/58 tmp/1/2/55/59

View File

@ -1,6 +1,6 @@
# Test entries starting with "..", e.g. "..tmp".
# Commit v4.5.10-95-ga29e61b introduced a regression
# which made oldfind(1) skip such entries.
# which made (no longer built) oldfind(1) skip such entries.
# This is Savannah bug #45090.
exec rm -rf tmp
exec mkdir tmp tmp/..tmp

View File

@ -21,7 +21,7 @@ for f; do echo "$f"; done
close $script
exec chmod 0500 tmp/list.sh
send_log "creeating files $file_list\n"
send_log "creating files $file_list\n"
foreach filename $file_list {
}

View File

@ -2,7 +2,7 @@ set files "\(1 "
foreach file $files { touch $file }
# shoud not result in a fatal error.
# should not result in a fatal error.
find_start p { \(1 }
foreach file $files { file delete -- $file }

View File

@ -2,7 +2,7 @@ set files "!2"
foreach file $files { touch $file }
# shoud not result in a fatal error.
# should not result in a fatal error.
find_start p { !2 }
foreach file $files { file delete -- $file }

View File

@ -2,7 +2,7 @@ set files "\)"
foreach file $files { touch $file }
# shoud not result in a fatal error.
# should not result in a fatal error.
find_start p { \) }
foreach file $files { file delete -- $file }

View File

@ -1,79 +0,0 @@
#! /bin/sh
# Copyright (C) 2011 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This test verifies that find does not have excessive memory consumption
# even for large directories. It's not executed by default; it will only
# run if the environment variable RUN_VERY_EXPENSIVE_TESTS is set.
testname="$(basename $0)"
. "${srcdir}"/binary_locations.sh
make_test_data() {
d="$1"
(
cd "$1" && echo "Creating test data in $(pwd -P)" >&2 || exit 1
max=400
for i in $(seq 0 400)
do
printf "\r%03d/%03d" $i $max >&2
for j in $(seq 0 10000)
do
printf "%03d_%04d " $i $j
done
done | xargs sh -c 'touch "$@" || exit 255' fnord || exit 1
printf "\rTest files created.\n" >&2
)
}
if [ -n "${RUN_VERY_EXPENSIVE_TESTS}" ]; then
if outdir=$(mktemp -d); then
# Create some test files.
bad=""
printf "Generating test data in %s (this may take some time...):\n" \
"${outdir}" >&2
if make_test_data "${outdir}"; then
# We don't check oldfind, as it uses savedir, meaning that
# it stores all the directory entries. Hence the excessive
# memory consumption bug applies to oldfind even though it is
# not using fts.
for exe in "${ftsfind}" "${oldfind}"; do
echo "Checking memory consumption of ${exe}..." >&2
if ( ulimit -v 50000 && ${exe} "${outdir}" >/dev/null; ); then
echo "Memory consumption of ${exe} is reasonable" >&2
else
bad="${bad}${bad:+\n}Memory consumption of ${exe} is too high"
fi
done
else
bad="failed to set up the test in ${outdir}"
fi
rm -rf "${outdir}" || exit 1
if [ -n "${bad}" ]; then
echo "${bad}" >&2
exit 1
fi
else
echo "FAIL: could not create a test output file." >&2
exit 1
fi
else
echo "${testname} was not run because" '${RUN_VERY_EXPENSIVE_TESTS}' \
"is unset."
fi

View File

@ -1,48 +0,0 @@
#! /bin/sh
# Copyright (C) 2011-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
testname="$(basename $0)"
parent="$(cd .. && pwd)"
if [ -f "${parent}/ftsfind" ]; then
ftsfind="${parent}/ftsfind"
oldfind="${parent}/find"
elif [ -f "${parent}/oldfind" ]; then
ftsfind="${parent}/find"
oldfind="${parent}/oldfind"
else
echo "Cannot find the executables to test." >&2
exit 1
fi
if tstdir=$(mktemp -d); then
touch "$tstdir/["
expected="$tstdir/["
for executable in "$oldfind" "$ftsfind"; do
if result=$("$executable" "$tstdir" -name '[' -print); then
if ! [ "$result" = "$expected" ]; then
echo "FAIL: $testname with $executable returned '$result' but '$expected' was expected" >&2
exit 1
fi
else
echo "FAIL: $executable returned $?" >&2
exit 1
fi
done
rm -rf "$tstdir"
else
echo "FAIL: could not create a test directory." >&2
exit 1
fi

View File

@ -1,43 +0,0 @@
#! /bin/sh
# Copyright (C) 2011-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
testname="$(basename $0)"
. "${srcdir}"/binary_locations.sh
goldenfile="${srcdir}/test_escapechars.golden"
expected='hello^.^world'
for executable in "$oldfind" "$ftsfind"
do
if result="$($executable . -maxdepth 0 \
-printf 'hello^\cthere' \
-exec printf %s {} \; \
-printf '^world\n' )"; then
if [[ "${result}" != "${expected}" ]]; then
exec >&2
echo "$executable produced incorrect output:"
echo "${result}"
echo "Expected output was:"
echo "${expected}"
exit 1
fi
else
echo "$executable returned $?" >&2
exit 1
fi
done

View File

@ -1,13 +0,0 @@
OCTAL1: 
OCTAL2: 
OCTAL3: 
OCTAL4: 4
OCTAL8: 8
BEL: 
CR:
FF:
TAB:
VTAB:
BS: 
BACKSLASH: \
UNKNOWN: \z

View File

@ -1,59 +0,0 @@
#! /bin/sh
# Copyright (C) 2011-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
testname="$(basename $0)"
. "${srcdir}"/binary_locations.sh
goldenfile="${srcdir}/test_escapechars.golden"
if outfile=$(mktemp); then
for executable in "$oldfind" "$ftsfind"
do
if "$executable" . -maxdepth 0 \
-printf 'OCTAL1: \1\n' \
-printf 'OCTAL2: \02\n' \
-printf 'OCTAL3: \003\n' \
-printf 'OCTAL4: \0044\n' \
-printf 'OCTAL8: \0028\n' \
-printf 'BEL: \a\n' \
-printf 'CR: \r\n' \
-printf 'FF: \f\n' \
-printf 'TAB: \t\n' \
-printf 'VTAB: \v\n' \
-printf 'BS: \b\n' \
-printf 'BACKSLASH: \\\n' \
-printf 'UNKNOWN: \z\n' \
>| "${outfile}" 2>/dev/null; then
if cmp "${outfile}" "${goldenfile}"; then
rm "${outfile}"
else
exec >&2
echo "FAIL: $executable produced incorrect output:"
od -c "${outfile}"
echo "Expected output was:"
od -c "${goldenfile}"
exit 1
fi
else
echo "FAIL: $executable returned $?" >&2
exit 1
fi
done
else
echo "FAIL: could not create a test output file." >&2
exit 1
fi

View File

@ -1,65 +0,0 @@
#! /bin/sh
# Copyright (C) 2011-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Essentially this test verifies that ls -i and find -printf %i produce
# the same output.
testname="$(basename $0)"
. "${srcdir}"/binary_locations.sh
make_canonical() {
sed -e 's/ /_/g'
}
test_percent_i() {
if "${executable}" "${tmpfile}" -printf '%i_%p\n' |
make_canonical >| "${outfile}"; then
cmp "${outfile}" "${goldfile}" || {
exec >&2
cat <<EOF
${executable} ${printf_format} produced incorrect output.
Actual output:
$(cat ${outfile})
Expected output:
$(cat ${goldfile})
EOF
rm -f "${outfile}" "${goldfile}" "${tmpfile}"
exit 1
}
fi
}
if tmpfile=$(mktemp); then
if goldfile=$(mktemp); then
ls -i "${tmpfile}" | make_canonical >| "${goldfile}"
if outfile=$(mktemp); then
for executable in "${oldfind}" "${ftsfind}"
do
test_percent_i
done
rm -f "${outfile}"
fi
rm -f "${goldfile}"
fi
rm -f "${tmpfile}"
fi

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
gnulib

@ -1 +1 @@
Subproject commit c97b8b9030de7c9a9f9f6d7dcdc3505c6b3f7f98
Subproject commit 43d801a0234994cf97f5d7c34a5fb9b23b9be55a

View File

@ -0,0 +1,233 @@
/* gcc-function-attribtues.h -- GCC-specific function attributes
Copyright (C) 2016-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*
Be aware that some function attributes do not work with function
pointers. See
https://lists.gnu.org/r/bug-gnulib/2011-04/msg00007.html
for details.
*/
#ifndef _GCC_FUNCTION_ATTRIBUTES_H
# define _GCC_FUNCTION_ATTRIBUTES_H
# ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
# endif
/*
The following attributes are currently (GCC-4.4.5) defined for
functions on all targets. Where this file provides a macro
for using it, the macro name is given in the second column.
Attribute Macro (if implemented in this file)
-------------------------------------------------------------------------------
alias
aligned
alloc_size _GL_ATTRIBUTE_ALLOC_SIZE(arg_num)
always_inline
artificial
cold
const
constructor
deprecated _GL_ATTRIBUTE_DEPRECATED
destructor
error
externally_visible
flatten
format _GL_ATTRIBUTE_FORMAT(spec)
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(fmt,firstarg)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(fmt,firstarg)
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(fmt,firstarg)
_GL_ATTRIBUTE_FORMAT_SCANF(fmt,firstarg)
format_arg
gnu_inline
hot
malloc _GL_ATTRIBUTE_MALLOC
no_instrument_function
noinline
nonnull _GL_ATTRIBUTE_NONNULL(args)
_GL_ARG_NONNULL(args)
noreturn _GL_ATTRIBUTE_NORETURN
nothrow
pure _GL_ATTRIBUTE_PURE
returns_twice
section
sentinel _GL_ATTRIBUTE_SENTINEL
unused
used
warn_unused_result _GL_ATTRIBUTE_WUR
warning
weak
*/
/*
Attributes used in gnulib, but which appear to be platform-specific
regparm
stdcall
*/
/*
Attributes used in gnulib with special arguments
Macro Args
visibility "default"
*/
/*
The __attribute__ feature is available in gcc versions 2.5 and later.
The underscored __format__ spelling of the attribute names requires 2.6.4 (we check for 2.7).
*/
# ifndef _GL_ATTRIBUTE_ALLOC_SIZE
# if __GNUC_PREREQ(4,3)
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
# else
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_DEPRECATED
# if __GNUC_PREREQ(3,1)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
# else
# define _GL_ATTRIBUTE_DEPRECATED /* empty */
# endif
# endif
# ifndef _GL_ATTRIBUTE_FORMAT
# if __GNUC_PREREQ(2,7)
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
# else
# define _GL_ATTRIBUTE_FORMAT(spec) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM
# if __GNUC_PREREQ(2,7)
# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
# else
# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(spec) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
# if __GNUC_PREREQ(2,7)
# if __GNUC_PREREQ(4,4)
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
# else
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
# endif
# else
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(spec) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM
# if __GNUC_PREREQ(2,7)
# define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
# else
# define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(spec) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_FORMAT_SCANF
# if __GNUC_PREREQ(2,7)
# if __GNUC_PREREQ(4,4)
# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
# else
# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
# endif
# else
# define _GL_ATTRIBUTE_FORMAT_SCANF(spec) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_MALLOC
# if __GNUC_PREREQ(3,0)
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
# else
# define _GL_ATTRIBUTE_MALLOC /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_NONNULL
# if __GNUC_PREREQ(3,3)
# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
# else
# define _GL_ATTRIBUTE_NONNULL(m) /* unsupported */
# endif
# endif
# ifndef _GL_ARG_NONNULL
/* alternative spelling used in gnulib's stdio.h */
# define _GL_ARG_NONNULL(m) _GL_ATTRIBUTE_NONNULL(m)
# endif
# ifndef _GL_ATTRIBUTE_NORETURN
# if __GNUC_PREREQ(2,8)
# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# else
# define _GL_ATTRIBUTE_NORETURN /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_PURE
# if __GNUC_PREREQ(2,96)
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
# define _GL_ATTRIBUTE_PURE /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_SENTINEL
# if __GNUC_PREREQ(4,0)
/* gnulib uses the __attribute__((__sentinel__)) variant, for which the
argument number 0 is assumed. Arguments are counted backwards, the last
being 0.
*/
# define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) __attribute__ ((__sentinel__(backward_arg_num)))
# else
# define _GL_ATTRIBUTE_SENTINEL(backward_arg_num) /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_WUR
# if __GNUC_PREREQ(3,4)
# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn__unused_result__))
# else
# define _GL_ATTRIBUTE_WUR /* unsupported */
# endif
# endif
# ifndef _GL_ATTRIBUTE_RETURN_CHECK
/* gnulib is inconsistent in which macro it uses; support both for now. */
# define _GL_ATTRIBUTE_RETURN_CHECK _GL_ATTRIBUTE_WUR
# endif
#endif /* _GCC_FUNCTION_ATTRIBUTES_H */

View File

@ -0,0 +1,14 @@
Description:
Macros allowing portable use of GCC's __attribute__ feature.
Files:
lib/gcc-function-attributes.h
Include:
"lib/gcc-function-attributes.h"
License:
GPL
Maintainer:
James Youngman

714
init.cfg Normal file
View File

@ -0,0 +1,714 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This goes hand in hand with the "exec 9>&2;" in tests/Makefile.am's
# TESTS_ENVIRONMENT definition.
stderr_fileno_=9
# Having an unsearchable directory in PATH causes execve to fail with EACCES
# when applied to an unresolvable program name, contrary to the desired ENOENT.
# Avoid the problem by rewriting PATH to exclude unsearchable directories.
# Also, if PATH lacks /sbin and/or /usr/sbin, append it/them.
sanitize_path_()
{
# FIXME: remove double quotes around $IFS when all tests use init.sh.
# They constitute a work-around for a bug in FreeBSD 8.1's /bin/sh.
local saved_IFS="$IFS"
IFS=:
set -- $PATH
IFS=$saved_IFS
local d d1
local colon=
local new_path=
for d in "$@"; do
test -z "$d" && d1=. || d1=$d
if ls -d "$d1/." > /dev/null 2>&1; then
new_path="$new_path$colon$d"
colon=':'
fi
done
for d in /sbin /usr/sbin ; do
case ":$new_path:" in
*:$d:*) ;;
*) new_path="$new_path:$d" ;;
esac
done
PATH=$new_path
export PATH
}
getlimits_()
{
eval $(getlimits)
test "$INT_MAX" || fatal_ "running getlimits"
}
require_no_default_acl_()
{
if getfacl --version < /dev/null > /dev/null 2>&1; then
getfacl "$1" | grep '^default:' && skip_ 'Default ACL detected'
else
ls -ld "$1" | grep '.........+' && skip_ 'ACL detected'
fi
}
require_acl_()
{
getfacl --version < /dev/null > /dev/null 2>&1 \
&& setfacl --version < /dev/null > /dev/null 2>&1 \
|| skip_ "This test requires getfacl and setfacl."
id -u bin > /dev/null 2>&1 \
|| skip_ "This test requires a local user named bin."
}
is_local_dir_()
{
test $# = 1 || framework_failure_
df --local "$1" >/dev/null 2>&1
}
require_mount_list_()
{
local mount_list_fail='cannot read table of mounted file systems'
df --local 2>&1 | grep -F "$mount_list_fail" >/dev/null &&
skip_ "$mount_list_fail"
}
dump_mount_list_()
{
cat /proc/self/mountinfo ||
cat /proc/self/mounts ||
cat /proc/mounts ||
cat /etc/mtab
}
require_local_dir_()
{
require_mount_list_
is_local_dir_ . ||
skip_ "This test must be run on a local file system."
}
require_selinux_()
{
# When in a chroot of an SELinux-enabled system, but with a mock-simulated
# SELinux-*disabled* system, recognize that SELinux is disabled system wide:
grep 'selinuxfs$' /proc/filesystems > /dev/null \
|| skip_ "this system lacks SELinux support"
# Independent of whether SELinux is enabled system-wide,
# the current file system may lack SELinux support.
# Also the current build may have SELinux support disabled.
case $(ls -Zd .) in
'? .'|'unlabeled .')
test -z "$CONFIG_HEADER" \
&& framework_failure_ 'CONFIG_HEADER not defined'
grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
&& selinux_missing_="(file) system" || selinux_missing_="build"
skip_ "this $selinux_missing_ lacks SELinux support"
;;
esac
}
# Return the SELinux type component if available
get_selinux_type() { ls -Zd "$1" | sed -n 's/.*:\(.*_t\)[: ].*/\1/p'; }
# Whether SELinux Multi Level Security is enabled
mls_enabled_() {
sestatus 2>&1 |
grep 'Policy MLS status:.*enabled' > /dev/null
}
# Skip this test if we're not in SELinux "enforcing" mode.
require_selinux_enforcing_()
{
require_selinux_
test "$(getenforce)" = Enforcing \
|| skip_ "This test is useful only with SELinux in Enforcing mode."
}
require_smack_()
{
grep 'smackfs$' /proc/filesystems > /dev/null \
|| skip_ "this system lacks SMACK support"
test "$(ls -Zd .)" != '? .' \
|| skip_ "this file system lacks SMACK support"
}
require_openat_support_()
{
# Skip this test if your system has neither the openat-style functions
# nor /proc/self/fd support with which to emulate them.
test -z "$CONFIG_HEADER" \
&& framework_failure_ 'CONFIG_HEADER not defined'
_skip=yes
grep '^#define HAVE_OPENAT' "$CONFIG_HEADER" > /dev/null && _skip=no
test -d /proc/self/fd && _skip=no
if test $_skip = yes; then
skip_ 'this system lacks openat support'
fi
}
# Return true if command runs with the
# ulimit specified in the first argument
ulimit_supported_()
{
local v
v="$1"
shift
(
# Try to disable core dumps which may
# occur with memory constraints
trap '' SEGV; ulimit -c 0;
ulimit -v $v && "$@"
) >/dev/null 2>&1
}
# Determine the minimum required VM limit to run the given command.
# Output that value to stdout ... to be used by the caller.
# Return 0 in case of success, and a non-Zero value otherwise.
get_min_ulimit_v_()
{
local v
local page_size
# Increase result by this amount to avoid alignment issues
page_size=$(getconf PAGESIZE || echo 4096)
page_size=$(($page_size / 1024))
for v in $( seq 5000 5000 50000 ); do
if ulimit_supported_ $v "$@"; then
local prev_v
prev_v=$v
for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
ulimit_supported_ $v "$@" ||
{
ret_v=$((prev_v + $page_size))
echo $ret_v
return 0
}
prev_v=$v
done
fi
done
# The above did not find a working limit. Echo a very small number - just
# in case the caller does not handle the non-Zero return value.
echo 1; return 1
}
require_readable_root_()
{
test -r / || skip_ "/ is not readable"
}
# Skip the current test if strace is not available or doesn't work
# with the named syscall. Usage: require_strace_ unlink
require_strace_()
{
test $# = 1 || framework_failure_
strace -V < /dev/null > /dev/null 2>&1 ||
skip_ 'no strace program'
strace -qe "$1" echo > /dev/null 2>&1 ||
skip_ 'strace -qe "'"$1"'" does not work'
# On some linux/sparc64 systems, strace works fine on 32-bit executables,
# but prints only one line of output for every 64-bit executable.
strace -o log-help ls --help >/dev/null || framework_failure_
n_lines_help=$(wc -l < log-help)
rm -f log-help
if test $n_lines_help = 0 || test $n_lines_help = 1; then
skip_ 'strace produces no more than one line of output'
fi
}
# Skip the current test if valgrind doesn't work,
# which could happen if not installed,
# or hasn't support for the built architecture,
# or hasn't appropriate error suppressions installed etc.
require_valgrind_()
{
valgrind --error-exitcode=1 true 2>/dev/null ||
skip_ "requires a working valgrind"
}
# Skip the current test if setfacl doesn't work on the current file system,
# which could happen if not installed, or if ACLs are not supported by the
# kernel or the file system, or are turned off via mount options.
#
# Work around the following two issues:
#
# 1) setfacl maps ACLs into file permission bits if on "noacl" file systems.
#
# On file systems which do not support ACLs (e.g. ext4 mounted with -o noacl),
# setfacl operates on the regular file permission bits, and only fails if the
# given ACL spec does not fit into there. Thus, to test if ACLs really work
# on the current file system, pass an ACL spec which can't be mapped that way.
# "Default" ACLs (-d) seem to fulfill this requirement.
#
# 2) setfacl only invokes the underlying system call if the ACL would change.
#
# If the given ACL spec would not change the ACLs on the file, then setfacl
# does not invoke the underlying system call - setxattr(). Therefore, to test
# if setting ACLs really works on the current file system, call setfacl twice
# with conflictive ACL specs.
require_setfacl_()
{
local d='acltestdir_'
mkdir $d || framework_failure_
local f=0
setfacl -d -m user::r-x $d \
&& setfacl -d -m user::rwx $d \
|| f=1
rm -rf $d || framework_failure_
test $f = 0 \
|| skip_ "setfacl does not work on the current file system"
}
# Require a controlling input 'terminal'.
require_controlling_input_terminal_()
{
have_input_tty=yes
tty -s || have_input_tty=no
test -t 0 || have_input_tty=no
if test "$have_input_tty" = no; then
skip_ 'requires controlling input terminal
This test must have a controlling input "terminal", so it may not be
run via "batch", "at", or "ssh". On some systems, it may not even be
run in the background.'
fi
}
require_built_()
{
skip_=no
for i in "$@"; do
case " $built_programs " in
*" $i "*) ;;
*) echo "$i: not built" 1>&2; skip_=yes ;;
esac
done
test $skip_ = yes && skip_ "required program(s) not built"
}
require_file_system_bytes_free_()
{
local req=$1
local expr=$(stat -f --printf "$req / %S <= %a" .)
$AWK "BEGIN{ exit !($expr) }" \
|| skip_ "this test needs at least $req bytes of free space"
}
uid_is_privileged_()
{
# Make sure id -u succeeds.
my_uid=$(id -u) \
|| { echo "$0: cannot run 'id -u'" 1>&2; return 1; }
# Make sure it gives valid output.
case $my_uid in
0) ;;
*[!0-9]*)
echo "$0: invalid output ('$my_uid') from 'id -u'" 1>&2
return 1 ;;
*) return 1 ;;
esac
}
get_process_status_()
{
sed -n '/^State:[ ]*\([[:alpha:]]\).*/s//\1/p' /proc/$1/status
}
# Convert an ls-style permission string, like drwxr----x and -rw-r-x-wx
# to the equivalent chmod --mode (-m) argument, (=,u=rwx,g=r,o=x and
# =,u=rw,g=rx,o=wx). Ignore ACLs.
rwx_to_mode_()
{
case $# in
1) rwx=$1;;
*) echo "$0: wrong number of arguments" 1>&2
echo "Usage: $0 ls-style-mode-string" 1>&2
return;;
esac
case $rwx in
[ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-]) ;;
[ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-][+.]) ;;
*) echo "$0: invalid mode string: $rwx" 1>&2; return;;
esac
# Perform these conversions:
# S s
# s xs
# T t
# t xt
# The 'T' and 't' ones are only valid for 'other'.
s='s/S/@/;s/s/x@/;s/@/s/'
t='s/T/@/;s/t/x@/;s/@/t/'
u=$(echo $rwx|sed 's/^.\(...\).*/,u=\1/;s/-//g;s/^,u=$//;'$s)
g=$(echo $rwx|sed 's/^....\(...\).*/,g=\1/;s/-//g;s/^,g=$//;'$s)
o=$(echo $rwx|sed 's/^.......\(...\).*/,o=\1/;s/-//g;s/^,o=$//;'$s';'$t)
echo "=$u$g$o"
}
skip_if_()
{
case $1 in
root) skip_ must be run as root ;;
non-root) skip_ must be run as non-root ;;
*) ;; # FIXME?
esac
}
very_expensive_()
{
if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then
skip_ 'very expensive: disabled by default
This test is very expensive, so it is disabled by default.
To run it anyway, rerun make check with the RUN_VERY_EXPENSIVE_TESTS
environment variable set to yes. E.g.,
env RUN_VERY_EXPENSIVE_TESTS=yes make check
or use the shortcut target of the toplevel Makefile,
make check-very-expensive
'
fi
}
expensive_()
{
if test "$RUN_EXPENSIVE_TESTS" != yes; then
skip_ 'expensive: disabled by default
This test is relatively expensive, so it is disabled by default.
To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
environment variable set to yes. E.g.,
env RUN_EXPENSIVE_TESTS=yes make check
or use the shortcut target of the toplevel Makefile,
make check-expensive
'
fi
}
# Test whether we can run our just-built root owned find,
# i.e., that $NON_ROOT_USERNAME has access to the build directory.
nonroot_has_perm_()
{
require_built_ chroot
local find_version=$(
chroot --skip-chdir --user=$NON_ROOT_USERNAME / env PATH="$PATH" \
find --version |
sed -n '1s/.* //p'
)
case ":$find_version:" in
:$PACKAGE_VERSION:) ;;
*) return 1;;
esac
}
require_root_()
{
uid_is_privileged_ || skip_ "must be run as root"
NON_ROOT_USERNAME=${NON_ROOT_USERNAME=nobody}
NON_ROOT_GID=${NON_ROOT_GID=$(id -g $NON_ROOT_USERNAME)}
# When the current test invokes chroot, call nonroot_has_perm_
# to check for a common problem.
grep '^[ ]*chroot' "../$0" \
&& { nonroot_has_perm_ \
|| skip_ "user $NON_ROOT_USERNAME lacks execute permissions"; }
}
skip_if_root_() { uid_is_privileged_ && skip_ "must be run as non-root"; }
# Set 'groups' to a space-separated list of at least two groups
# of which the user is a member.
require_membership_in_two_groups_()
{
test $# = 0 || framework_failure_
groups=${FINDUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
case "$groups" in
*' '*) ;;
*) skip_ 'requires membership in two groups
this test requires that you be a member of more than one group,
but running '\''id -G'\'' either failed or found just one. If you really
are a member of at least two groups, then rerun this test with
FINDUTILS_GROUPS set in your environment to the space-separated list
of group names or numbers. E.g.,
env FINDUTILS_GROUPS='\''users cdrom'\'' make check
'
;;
esac
}
# Is /proc/$PID/status supported?
require_proc_pid_status_()
{
sleep 2 &
local pid=$!
sleep .5
grep '^State:[ ]*[S]' /proc/$pid/status > /dev/null 2>&1 ||
skip_ "/proc/$pid/status: missing or 'different'"
kill $pid
}
# Does trap support signal names?
# Old versions of ash did not.
require_trap_signame_()
{
(trap '' CHLD) || skip_ 'requires trap with signal name support'
}
# Does kill support sending signal to whole group?
# dash 0.5.8 at least does not.
require_kill_group_()
{
kill -0 -- -1 || skip_ 'requires kill with group signalling support'
}
# Return nonzero if the specified path is on a file system for
# which FIEMAP support exists. Note some file systems (like ext3 and btrfs)
# only support FIEMAP for files, not directories.
fiemap_capable_()
{
if ! python < /dev/null; then
warn_ 'fiemap_capable_: python missing: assuming not fiemap capable'
return 1
fi
python "$abs_srcdir"/tests/fiemap-capable "$@"
}
# Determine if find(1) emits warnings. This is not the case
# e.g. if stdin is not a tty.
find_emits_warnings_()
{
# Find usually emits a warning for the deprecated -d option.
find -maxdepth 0 -d -quit 2>&1 \
| grep 'warning:' >/dev/null
}
# Skip the current test if "." lacks d_type support.
require_dirent_d_type_()
{
python < /dev/null \
|| skip_ python missing: assuming no d_type support
python "$abs_srcdir"/tests/d_type-check \
|| skip_ requires d_type support
}
# Skip the current test if we lack Perl.
require_perl_()
{
: ${PERL=perl}
$PERL -e 'use warnings' > /dev/null 2>&1 \
|| skip_ 'configure did not find a usable version of Perl'
}
# Does the current (working-dir) file system support sparse files?
require_sparse_support_()
{
test $# = 0 || framework_failure_
# Test whether we can create a sparse file.
# For example, on Darwin6.5 with a file system of type hfs, it's not possible.
# NTFS requires 128K before a hole appears in a sparse file.
t=sparse.$$
dd bs=1 seek=128K of=$t < /dev/null 2> /dev/null
set x $(du -sk $t)
kb_size=$2
rm -f $t
if test $kb_size -ge 128; then
skip_ 'this file system does not support sparse files'
fi
}
# Compile a shared lib using the GCC options for doing so.
# Pass input and output file as parameters respectively.
# Any other optional parameters are passed to $CC.
gcc_shared_()
{
local in=$1
local out=$2
shift 2 || return 1
$CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" -ldl
}
# There are a myriad of ways to build shared libs,
# so we only consider running tests requiring shared libs,
# on platforms that support building them as follows.
require_gcc_shared_()
{
gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1 \
|| skip_ '$CC -shared ... failed to build a shared lib'
rm -f d.so
}
mkfifo_or_skip_()
{
test $# = 1 || framework_failure_
if ! mkfifo "$1"; then
# Make an exception of this case -- usually we interpret framework-creation
# failure as a test failure. However, in this case, when running on a SunOS
# system using a disk NFS mounted from OpenBSD, the above fails like this:
# mkfifo: cannot make fifo 'fifo-10558': Not owner
skip_ 'unable to create a fifo'
fi
}
# Disable the current test if the working directory seems to have
# the setgid bit set.
skip_if_setgid_()
{
setgid_tmpdir=setgid-$$
(umask 77; mkdir $setgid_tmpdir)
perms=$(stat --printf %A $setgid_tmpdir)
rmdir $setgid_tmpdir
case $perms in
drwx------);;
drwxr-xr-x);; # Windows98 + DJGPP 2.03
*) skip_ 'this directory has the setgid bit set';;
esac
}
# Skip if files are created with a different group to the current user
# This can happen due to a setgid dir, or by some other mechanism on OS X:
# https://unix.stackexchange.com/q/63865
# https://bugs.gnu.org/14024#41
skip_if_nondefault_group_()
{
touch grp.$$
gen_ug=$(stat -c '%u:%g' grp.$$)
rm grp.$$
test "$gen_ug" = "$(id -ru):$(id -rg)" ||
skip_ 'Files are created with a different gid'
}
skip_if_mcstransd_is_running_()
{
test $# = 0 || framework_failure_
# When mcstransd is running, you'll see only the 3-component
# version of file-system context strings. Detect that,
# and if it's running, skip this test.
__ctx=$(stat --printf='%C\n' .) || framework_failure_
case $__ctx in
*:*:*:*) __ctx_ok=1 ;; # four components is ok
*:*:*) # three components is ok too if there is no MLS
mls_enabled_ || __ctx_ok=1 ;;
esac
test "$__ctx_ok" ||
skip_ "unexpected context '$__ctx'; turn off mcstransd"
}
# Skip the current test if umask doesn't work as usual.
# This test should be run in the temporary directory that ends
# up being removed via the trap commands.
working_umask_or_skip_()
{
umask 022
touch file1 file2
chmod 644 file2
perms=$(ls -l file1 file2 | sed 's/ .*//' | uniq)
rm -f file1 file2
case $perms in
*'
'*) skip_ 'your build directory has unusual umask semantics'
esac
}
# Retry a function requiring a sufficient delay to _pass_
# using a truncated exponential backoff method.
# Example: retry_delay_ dd_reblock_1 .1 6
# This example will call the dd_reblock_1 function with
# an initial delay of .1 second and call it at most 6 times
# with a max delay of 3.2s (doubled each time), or a total of 6.3s
# Note ensure you do _not_ quote the parameter to GNU sleep in
# your function, as it may contain separate values that sleep
# needs to accumulate.
# Further function arguments will be forwarded to the test function.
retry_delay_()
{
local test_func=$1
local init_delay=$2
local max_n_tries=$3
shift 3 || return 1
local attempt=1
local num_sleeps=$attempt
local time_fail
while test $attempt -le $max_n_tries; do
local delay=$($AWK -v n=$num_sleeps -v s="$init_delay" \
'BEGIN { print s * n }')
"$test_func" "$delay" "$@" && { time_fail=0; break; } || time_fail=1
attempt=$(expr $attempt + 1)
num_sleeps=$(expr $num_sleeps '*' 2)
done
test "$time_fail" = 0
}
# Call this with a list of programs under test immediately after
# sourcing init.sh.
print_ver_()
{
require_built_ "$@"
if test "$VERBOSE" = yes; then
local i
for i in $*; do
env $i --version
done
fi
}
# Are we running on GNU/Hurd?
require_gnu_()
{
test "$(uname)" = GNU \
|| skip_ 'not running on GNU/Hurd'
}
# Prepend all our source directories to PATH.
fu_path_prepend_()
{
path_prepend_ "${srcdir=.}/find" "${srcdir=.}/locate" "${srcdir=.}/xargs"
}
sanitize_path_

View File

@ -1,21 +0,0 @@
.deps
Makefile
Makefile.in
regexprops
gnulib-version.c
buildcmd.o
dircallback.o
extendbuf.o
fdleak.o
findutils-version.o
forcefindlib.o
gnulib-version.o
libfind.a
listfile.o
nextelem.o
printquoted.o
qmark.o
regexprops.o
regextype.o
safe-atoi.o
savedirinfo.o

30
lib/.gitignore vendored
View File

@ -1,20 +1,10 @@
.deps
Makefile
Makefile.in
regexprops
buildcmd.o
dircallback.o
extendbuf.o
fdleak.o
findutils-version.o
forcefindlib.o
gnulib-version.o
listfile.o
nextelem.o
printquoted.o
qmark.o
regextype.o
safe-atoi.o
savedirinfo.o
libfind.a
regexprops.o
/*.log
/*.o
/*.trs
/Makefile
/Makefile.in
/check-regexprops
/libfind.a
/regexprops
/regexprops.texi.new
/test_splitstring

View File

@ -1,5 +1,20 @@
## Process this file with automake to produce Makefile.in.
## Copyright (C) 1996-2026 Free Software Foundation, Inc.
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = 1.5 gnits
# no-dependencies
AM_CFLAGS = $(WARN_CFLAGS)
@ -9,6 +24,7 @@ noinst_LIBRARIES = libfind.a
check_PROGRAMS = regexprops test_splitstring
check_SCRIPTS = check-regexprops
regexprops_SOURCES = regexprops.c regextype.c
regexprops_LDADD = $(LDADD) $(SETLOCALE_NULL_LIB) $(MBRTOWC_LIB)
TESTS =
if CROSS_COMPILING
@ -18,10 +34,33 @@ else
TESTS += check-regexprops test_splitstring
endif
libfind_a_SOURCES = findutils-version.c
EXTRA_DIST = extendbuf.h buildcmd.h \
libfind_a_SOURCES = \
buildcmd.c \
buildcmd.h \
dircallback.c \
dircallback.h \
extendbuf.c \
extendbuf.h \
fdleak.c \
fdleak.h \
findutils-version.c \
findutils-version.h \
fdleak.h unused-result.h check-regexprops.sh
listfile.c \
listfile.h \
printquoted.c \
printquoted.h \
qmark.c \
regextype.c \
regextype.h \
safe-atoi.c \
safe-atoi.h \
splitstring.c \
splitstring.h \
bugreports.c \
bugreports.h \
system.h
EXTRA_DIST = unused-result.h check-regexprops.sh
SUFFIXES =
MOSTLYCLEANFILES =
DISTCLEANFILES =
@ -31,25 +70,16 @@ MAINTAINERCLEANFILES =
AM_CPPFLAGS = -I../gl/lib -I$(top_srcdir)/gl/lib
LDADD = ../gl/lib/libgnulib.a $(LIBINTL)
libfind_a_SOURCES += printquoted.h listfile.h \
regextype.h dircallback.h safe-atoi.h splitstring.h
libfind_a_SOURCES += listfile.c extendbuf.c buildcmd.c \
forcefindlib.c qmark.c printquoted.c regextype.c dircallback.c fdleak.c \
safe-atoi.c splitstring.c
CLEANFILES = check-regexprops
# Clean coverage files generated by running binaries built with
# gcc -fprofile-arcs -ftest-coverage
coverage-clean:
$(RM) *.gcno *.gcda *.gcov *.lcov
rm -f *.gcno *.gcda *.gcov *.lcov
clean-local: coverage-clean
EXTRA_DIST += waitpid.c forcefindlib.c
TESTS_ENVIRONMENT = REGEXPROPS=regexprops$(EXEEXT)
libfind_a_LIBADD = $(FINDLIBOBJS)
libfind_a_DEPENDENCIES = $(FINDLIBOBJS)
check-regexprops: check-regexprops.sh
cp $(srcdir)/check-regexprops.sh check-regexprops

39
lib/bugreports.c Normal file
View File

@ -0,0 +1,39 @@
/* bugreports.h -- explain how to report bugs
Copyright (C) 2016-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* Written by James Youngman <jay@gnu.org>.
*/
#include <config.h>
#include <stdio.h>
#include "bugreports.h"
#include "system.h"
int
explain_how_to_report_bugs (FILE *f, const char *program_name)
{
return fprintf (f,_(""
"Please see also the documentation at %s.\n"
"You can report (and track progress on fixing) bugs in the \"%s\"\n"
"program via the %s bug-reporting page at\n"
"%s or, if\n"
"you have no web access, by sending email to <%s>.\n"),
PACKAGE_URL,
program_name,
PACKAGE_NAME,
PACKAGE_BUGREPORT_URL,
PACKAGE_BUGREPORT);
}

26
lib/bugreports.h Normal file
View File

@ -0,0 +1,26 @@
/* bugreports.h -- explain how to report bugs
Copyright (C) 2016-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* Written by James Youngman <jay@gnu.org>.
*/
#if !defined BUGREPORTS_H
# define BUGREPORTS_H
# include <stdio.h>
/* Interpreetation of the return code is as for fprintf. */
int explain_how_to_report_bugs (FILE *f, const char *program_name);
#endif

View File

@ -1,6 +1,5 @@
/* buildcmd.c -- build command lines from a list of arguments.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003, 2005, 2006,
2007, 2008, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1990-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* config.h must be included first. */
#include <config.h>
@ -21,10 +20,7 @@
/* system headers. */
#include <assert.h>
#include <errno.h>
#include <error.h>
#include <limits.h>
#include <locale.h>
#include <openat.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@ -36,33 +32,19 @@
#include <xalloc.h>
/* gnulib headers. */
#include "gettext.h"
#include "xstrtol.h"
/* find headers. */
#include "system.h"
#include "buildcmd.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#define textdomain(Domain)
#define bindtextdomain(Package, Directory)
#endif
#ifdef gettext_noop
# define N_(String) gettext_noop (String)
#else
/* See locate.c for explanation as to why not use (String) */
# define N_(String) String
#endif
/* COMPAT: SYSV version defaults size (and has a max value of) to 470.
We try to make it as large as possible. See bc_get_arg_max() below. */
#if defined NCARGS && !defined ARG_MAX
/* We include sys/param.h in order to detect this case. */
#error "You have an unusual system. Once you remove this error message from buildcmd.c, it should work, but please make sure that DejaGnu is installed on your system and that 'make check' passes before using the findutils programs. Please mail bug-findutils@gnu.org to tell us about your system."
#define ARG_MAX NCARGS
# error "You have an unusual system. Once you remove this error message from buildcmd.c, it should work, but please make sure that DejaGnu is installed on your system and that 'make check' passes before using the findutils programs. Please mail bug-findutils@gnu.org to tell us about your system."
# define ARG_MAX NCARGS
#endif
@ -73,7 +55,7 @@ static const char *special_terminating_arg = "do_not_care";
/* Add a terminator to the argument list. */
static void
bc_args_complete (struct buildcmd_control *ctl,
struct buildcmd_state *state)
struct buildcmd_state *state)
{
bc_push_arg (ctl, state, special_terminating_arg, 0, NULL, 0, 0);
}
@ -130,7 +112,7 @@ bc_do_insert (struct buildcmd_control *ctl,
if (bytes_left <= len)
break;
else
bytes_left -= len;
bytes_left -= len;
strncpy (p, arg, len);
p += len;
@ -139,16 +121,16 @@ bc_do_insert (struct buildcmd_control *ctl,
if (s)
{
if (bytes_left <= (lblen + pfxlen))
break;
else
bytes_left -= (lblen + pfxlen);
if (bytes_left <= (lblen + pfxlen))
break;
else
bytes_left -= (lblen + pfxlen);
if (prefix)
{
strcpy (p, prefix);
p += pfxlen;
}
if (prefix)
{
strcpy (p, prefix);
p += pfxlen;
}
strcpy (p, linebuf);
p += lblen;
@ -162,7 +144,7 @@ bc_do_insert (struct buildcmd_control *ctl,
*p++ = '\0';
bc_push_arg (ctl, state,
insertbuf, p - insertbuf,
insertbuf, p - insertbuf,
NULL, 0,
initial_args);
}
@ -173,55 +155,55 @@ bc_do_insert (struct buildcmd_control *ctl,
*/
static size_t
update_limit (struct buildcmd_control *ctl,
struct buildcmd_state *state,
bool success,
size_t limit)
struct buildcmd_state *state,
bool success,
size_t limit)
{
if (success)
{
if (limit > state->largest_successful_arg_count)
state->largest_successful_arg_count = limit;
state->largest_successful_arg_count = limit;
}
else
{
if (limit < state->smallest_failed_arg_count
|| (0 == state->smallest_failed_arg_count))
state->smallest_failed_arg_count = limit;
|| (0 == state->smallest_failed_arg_count))
state->smallest_failed_arg_count = limit;
}
if (0 == (state->largest_successful_arg_count)
|| (state->smallest_failed_arg_count <= state->largest_successful_arg_count))
{
/* No success yet, or running on a system which has
limits on total argv length, but not arg count. */
limits on total argv length, but not arg count. */
if (success)
{
if (limit < SIZE_MAX)
++limit;
}
{
if (limit < SIZE_MAX)
++limit;
}
else
{
limit /= 2;
}
{
limit /= 2;
}
}
else /* We can use bisection. */
{
const size_t shift = (state->smallest_failed_arg_count
- state->largest_successful_arg_count) / 2;
- state->largest_successful_arg_count) / 2;
if (success)
{
if (shift)
limit += shift;
else
++limit;
}
{
if (shift)
limit += shift;
else
++limit;
}
else
{
if (shift)
limit -= shift;
else
--limit;
}
{
if (shift)
limit -= shift;
else
--limit;
}
}
/* Make sure the returned value is such that progress is
@ -241,8 +223,8 @@ update_limit (struct buildcmd_control *ctl,
*/
static size_t
copy_args (struct buildcmd_control *ctl,
struct buildcmd_state *state,
char** working_args, size_t limit, size_t done)
struct buildcmd_state *state,
char** working_args, size_t limit, size_t done)
{
size_t dst_pos = 0;
size_t src_pos = 0;
@ -267,7 +249,7 @@ copy_args (struct buildcmd_control *ctl,
/* Execute the program with the currently-built list of arguments. */
void
bc_do_exec (struct buildcmd_control *ctl,
struct buildcmd_state *state)
struct buildcmd_state *state)
{
char** working_args;
size_t limit, done;
@ -284,28 +266,28 @@ bc_do_exec (struct buildcmd_control *ctl,
do
{
const size_t dst_pos = copy_args (ctl, state, working_args,
limit, done);
if (ctl->exec_callback (ctl, state->usercontext, dst_pos, working_args))
{
limit = update_limit (ctl, state, true, limit);
done += (dst_pos - ctl->initial_argc);
}
else /* got E2BIG, adjust arguments */
{
if (limit <= ctl->initial_argc + 1)
{
/* No room to reduce the length of the argument list.
Issue an error message and give up. */
error (EXIT_FAILURE, 0,
_("can't call exec() due to argument size restrictions"));
}
else
{
/* Try fewer arguments. */
limit = update_limit (ctl, state, false, limit);
}
}
const size_t dst_pos = copy_args (ctl, state, working_args,
limit, done);
if (ctl->exec_callback (ctl, state->usercontext, dst_pos, working_args))
{
limit = update_limit (ctl, state, true, limit);
done += (dst_pos - ctl->initial_argc);
}
else /* got E2BIG, adjust arguments */
{
if (limit <= ctl->initial_argc + 1)
{
/* No room to reduce the length of the argument list.
Issue an error message and give up. */
error (EXIT_FAILURE, 0,
_("can't call exec() due to argument size restrictions"));
}
else
{
/* Try fewer arguments. */
limit = update_limit (ctl, state, false, limit);
}
}
}
while ((done + 1) < (state->cmd_argc - ctl->initial_argc));
/* (state->cmd_argc - ctl->initial_argc) includes the terminating NULL,
@ -325,8 +307,8 @@ bc_do_exec (struct buildcmd_control *ctl,
*/
static int
bc_argc_limit_reached (int initial_args,
const struct buildcmd_control *ctl,
struct buildcmd_state *state)
const struct buildcmd_control *ctl,
struct buildcmd_state *state)
{
/* Check to see if we about to exceed a limit set by xargs' -n option */
if (!initial_args && ctl->args_per_exec &&
@ -357,30 +339,34 @@ bc_push_arg (struct buildcmd_control *ctl,
assert (arg != NULL);
if (!initial_args)
{
state->todo = 1;
}
if (!terminate)
{
if (state->cmd_argv_chars + len + pfxlen > ctl->arg_max)
{
if (initial_args || state->cmd_argc == ctl->initial_argc)
error (EXIT_FAILURE, 0,
_("cannot fit single argument within argument list size limit"));
{
error (EXIT_FAILURE, 0,
_("cannot fit single argument within argument list size limit"));
}
/* xargs option -i (replace_pat) implies -x (exit_if_size_exceeded) */
if (ctl->replace_pat
|| (ctl->exit_if_size_exceeded &&
(ctl->lines_per_exec || ctl->args_per_exec)))
error (EXIT_FAILURE, 0, _("argument list too long"));
bc_do_exec (ctl, state);
{
error (EXIT_FAILURE, 0, _("argument list too long"));
}
bc_do_exec (ctl, state);
}
if (bc_argc_limit_reached (initial_args, ctl, state))
bc_do_exec (ctl, state);
}
if (!initial_args)
{
state->todo = 1;
}
if (state->cmd_argc >= state->cmd_argv_alloc)
{
/* XXX: we could use extendbuf() here. */
@ -393,7 +379,7 @@ bc_push_arg (struct buildcmd_control *ctl,
{
state->cmd_argv_alloc *= 2;
state->cmd_argv = xrealloc (state->cmd_argv,
sizeof (char *) * state->cmd_argv_alloc);
sizeof (char *) * state->cmd_argv_alloc);
}
}
@ -415,9 +401,9 @@ bc_push_arg (struct buildcmd_control *ctl,
* do the exec immediately.
*/
if (bc_argc_limit_reached (initial_args, ctl, state))
{
bc_do_exec (ctl, state);
}
{
bc_do_exec (ctl, state);
}
}
/* If this is an initial argument, set the high-water mark. */
@ -467,9 +453,9 @@ bc_get_arg_max (void)
static int
cb_exec_noop (struct buildcmd_control * ctl,
void *usercontext,
int argc,
char **argv)
void *usercontext,
int argc,
char **argv)
{
/* does nothing. */
(void) ctl;
@ -497,13 +483,13 @@ bc_size_of_environment (void)
enum BC_INIT_STATUS
bc_init_controlinfo (struct buildcmd_control *ctl,
size_t headroom)
size_t headroom)
{
size_t size_of_environment = bc_size_of_environment ();
/* POSIX requires that _POSIX_ARG_MAX is 4096. That is the lowest
* possible value for ARG_MAX on a POSIX compliant system. See
* http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
* https://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
*/
ctl->posix_arg_size_min = _POSIX_ARG_MAX;
ctl->posix_arg_size_max = bc_get_arg_max ();
@ -571,8 +557,8 @@ bc_use_sensible_arg_max (struct buildcmd_control *ctl)
void
bc_init_state (const struct buildcmd_control *ctl,
struct buildcmd_state *state,
void *context)
struct buildcmd_state *state,
void *context)
{
state->cmd_argc = 0;
state->cmd_argv_chars = 0;
@ -597,7 +583,7 @@ bc_init_state (const struct buildcmd_control *ctl,
void
bc_clear_args (const struct buildcmd_control *ctl,
struct buildcmd_state *state)
struct buildcmd_state *state)
{
state->cmd_argc = ctl->initial_argc;
state->cmd_argv_chars = state->cmd_initial_argv_chars;
@ -619,18 +605,18 @@ exceeds (const char *env_var_name, size_t quantity)
unsigned long limit;
if (xstrtoul (val, &tmp, 10, &limit, NULL) == LONGINT_OK)
{
if (quantity > limit)
return 1;
}
{
if (quantity > limit)
return 1;
}
else
{
error (EXIT_FAILURE, errno,
_("Environment variable %s is not set to a "
"valid decimal number"),
env_var_name);
return 0;
}
{
error (EXIT_FAILURE, errno,
_("Environment variable %s is not set to a "
"valid decimal number"),
env_var_name);
return 0;
}
}
return 0;
}
@ -651,5 +637,5 @@ bc_args_exceed_testing_limit (char **argv)
}
return (exceeds ("__GNU_FINDUTILS_EXEC_ARG_COUNT_LIMIT", args) ||
exceeds ("__GNU_FINDUTILS_EXEC_ARG_LENGTH_LIMIT", chars));
exceeds ("__GNU_FINDUTILS_EXEC_ARG_LENGTH_LIMIT", chars));
}

View File

@ -1,5 +1,5 @@
/* buildcmd.[ch] -- build command lines from a stream of arguments
Copyright (C) 2005, 2008, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 2005-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -12,20 +12,20 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*
* Written by James Youngman.
*/
#ifndef INC_BUILDCMD_H
#define INC_BUILDCMD_H 1
# define INC_BUILDCMD_H 1
#include <stdbool.h>
# include <stdbool.h>
struct buildcmd_state
{
/* Number of valid elements in `cmd_argv', including terminating NULL. */
size_t cmd_argc; /* 0 */
size_t cmd_argc; /* 0 */
/* The list of args being built. */
char **cmd_argv; /* NULL */
@ -90,14 +90,14 @@ struct buildcmd_control
const char *replace_pat;
/* Number of initial arguments given on the command line. */
size_t initial_argc; /* 0 */
size_t initial_argc; /* 0 */
/* exec callback. */
int (*exec_callback)(struct buildcmd_control *, void *usercontext, int argc, char **argv);
/* If nonzero, the maximum number of nonblank lines from stdin to use
per command line. */
unsigned long lines_per_exec; /* 0 */
unsigned long lines_per_exec; /* 0 */
/* The maximum number of arguments to use per command line. */
size_t args_per_exec;
@ -114,30 +114,30 @@ extern size_t bc_size_of_environment (void);
extern void bc_do_insert (struct buildcmd_control *ctl,
struct buildcmd_state *state,
char *arg, size_t arglen,
const char *prefix, size_t pfxlen,
const char *linebuf, size_t lblen,
int initial_args);
struct buildcmd_state *state,
char *arg, size_t arglen,
const char *prefix, size_t pfxlen,
const char *linebuf, size_t lblen,
int initial_args);
extern void bc_do_exec (struct buildcmd_control *ctl,
struct buildcmd_state *state);
struct buildcmd_state *state);
extern void bc_push_arg (struct buildcmd_control *ctl,
struct buildcmd_state *state,
const char *arg, size_t len,
const char *prefix, size_t pfxlen,
int initial_args);
struct buildcmd_state *state,
const char *arg, size_t len,
const char *prefix, size_t pfxlen,
int initial_args);
extern void bc_init_state(const struct buildcmd_control *ctl,
struct buildcmd_state *state,
void *usercontext);
struct buildcmd_state *state,
void *usercontext);
extern enum BC_INIT_STATUS bc_init_controlinfo(struct buildcmd_control *ctl,
size_t arglen_headroom);
size_t arglen_headroom);
extern size_t bc_get_arg_max(void);
extern void bc_use_sensible_arg_max(struct buildcmd_control *ctl);
extern void bc_clear_args(const struct buildcmd_control *ctl,
struct buildcmd_state *state);
struct buildcmd_state *state);
bool bc_args_exceed_testing_limit(char **argv);

View File

@ -1,7 +1,7 @@
#! /bin/sh
# Generate regexprops.texi and compare it against the checked-in version.
#
# Copyright (C) 2009-2015 Free Software Foundation, Inc.
# Copyright (C) 2009-2026 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -14,7 +14,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
existing=${srcdir}/../doc/regexprops.texi
case ${REGEXPROPS} in

View File

@ -1,6 +1,5 @@
/* listfile.c -- run a function in a specific directory
Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
Inc.
Copyright (C) 2007-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* This file was written by James Youngman, based on gnulib'c at-func.c.
@ -24,7 +23,6 @@
/* system headers. */
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <sys/stat.h>
@ -38,7 +36,7 @@
int
run_in_dir (const struct saved_cwd *there,
int (*callback)(void*), void *usercontext)
int (*callback)(void*), void *usercontext)
{
int err = -1;
int saved_errno = 0;
@ -46,17 +44,17 @@ run_in_dir (const struct saved_cwd *there,
if (0 == save_cwd (&here))
{
if (0 == restore_cwd (there))
{
err = callback(usercontext);
saved_errno = (err < 0 ? errno : 0);
}
{
err = callback(usercontext);
saved_errno = (err < 0 ? errno : 0);
}
else
{
openat_restore_fail (errno);
}
{
openat_restore_fail (errno);
}
if (restore_cwd (&here) != 0)
openat_restore_fail (errno);
openat_restore_fail (errno);
free_cwd (&here);
}
@ -84,26 +82,26 @@ run_in_dirfd (int dir_fd, int (*callback)(void*), void *usercontext)
int err;
if (save_cwd (&saved_cwd) != 0)
openat_save_fail (errno);
openat_save_fail (errno);
if (fchdir (dir_fd) != 0)
{
saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return -1;
}
{
saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return -1;
}
err = (*callback)(usercontext);
saved_errno = (err < 0 ? errno : 0);
if (restore_cwd (&saved_cwd) != 0)
openat_restore_fail (errno);
openat_restore_fail (errno);
free_cwd (&saved_cwd);
if (saved_errno)
errno = saved_errno;
errno = saved_errno;
return err;
}
}

Some files were not shown because too many files have changed in this diff Show More