xref: /openbsd/gnu/lib/libiberty/src/fnmatch.txh (revision 9588ddcf)
1*9588ddcfSespie@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})
2*9588ddcfSespie
3*9588ddcfSespieMatches @var{string} against @var{pattern}, returning zero if it
4*9588ddcfSespiematches, @code{FNM_NOMATCH} if not.  @var{pattern} may contain the
5*9588ddcfSespiewildcards @code{?} to match any one character, @code{*} to match any
6*9588ddcfSespiezero or more characters, or a set of alternate characters in square
7*9588ddcfSespiebrackets, like @samp{[a-gt8]}, which match one character (@code{a}
8*9588ddcfSespiethrough @code{g}, or @code{t}, or @code{8}, in this example) if that one
9*9588ddcfSespiecharacter is in the set.  A set may be inverted (i.e., match anything
10*9588ddcfSespieexcept what's in the set) by giving @code{^} or @code{!} as the first
11*9588ddcfSespiecharacter in the set.  To include those characters in the set, list them
12*9588ddcfSespieas anything other than the first character of the set.  To include a
13*9588ddcfSespiedash in the set, list it last in the set.  A backslash character makes
14*9588ddcfSespiethe following character not special, so for example you could match
15*9588ddcfSespieagainst a literal asterisk with @samp{\*}.  To match a literal
16*9588ddcfSespiebackslash, use @samp{\\}.
17*9588ddcfSespie
18*9588ddcfSespie@code{flags} controls various aspects of the matching process, and is a
19*9588ddcfSespieboolean OR of zero or more of the following values (defined in
20*9588ddcfSespie@code{<fnmatch.h>}):
21*9588ddcfSespie
22*9588ddcfSespie@table @code
23*9588ddcfSespie
24*9588ddcfSespie@item FNM_PATHNAME
25*9588ddcfSespie@itemx FNM_FILE_NAME
26*9588ddcfSespie@var{string} is assumed to be a path name.  No wildcard will ever match
27*9588ddcfSespie@code{/}.
28*9588ddcfSespie
29*9588ddcfSespie@item FNM_NOESCAPE
30*9588ddcfSespieDo not interpret backslashes as quoting the following special character.
31*9588ddcfSespie
32*9588ddcfSespie@item FNM_PERIOD
33*9588ddcfSespieA leading period (at the beginning of @var{string}, or if
34*9588ddcfSespie@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
35*9588ddcfSespie@code{?} but must be matched explicitly.
36*9588ddcfSespie
37*9588ddcfSespie@item FNM_LEADING_DIR
38*9588ddcfSespieMeans that @var{string} also matches @var{pattern} if some initial part
39*9588ddcfSespieof @var{string} matches, and is followed by @code{/} and zero or more
40*9588ddcfSespiecharacters.  For example, @samp{foo*} would match either @samp{foobar}
41*9588ddcfSespieor @samp{foobar/grill}.
42*9588ddcfSespie
43*9588ddcfSespie@item FNM_CASEFOLD
44*9588ddcfSespieIgnores case when performing the comparison.
45*9588ddcfSespie
46*9588ddcfSespie@end table
47*9588ddcfSespie
48*9588ddcfSespie@end deftypefn
49