Annotation of src/lib/libc/gen/fnmatch.3, Revision 1.22
1.22 ! jruoho 1: .\" $NetBSD: fnmatch.3,v 1.21 2003/08/07 16:42:48 agc Exp $
1.9 cgd 2: .\"
1.5 cgd 3: .\" Copyright (c) 1989, 1991, 1993
4: .\" The Regents of the University of California. All rights reserved.
1.1 cgd 5: .\"
6: .\" This code is derived from software contributed to Berkeley by
7: .\" Guido van Rossum.
8: .\" Redistribution and use in source and binary forms, with or without
9: .\" modification, are permitted provided that the following conditions
10: .\" are met:
11: .\" 1. Redistributions of source code must retain the above copyright
12: .\" notice, this list of conditions and the following disclaimer.
13: .\" 2. Redistributions in binary form must reproduce the above copyright
14: .\" notice, this list of conditions and the following disclaimer in the
15: .\" documentation and/or other materials provided with the distribution.
1.21 agc 16: .\" 3. Neither the name of the University nor the names of its contributors
1.1 cgd 17: .\" may be used to endorse or promote products derived from this software
18: .\" without specific prior written permission.
19: .\"
20: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: .\" SUCH DAMAGE.
31: .\"
1.12 perry 32: .\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95
1.1 cgd 33: .\"
1.22 ! jruoho 34: .Dd November 30, 2010
1.1 cgd 35: .Dt FNMATCH 3
36: .Os
37: .Sh NAME
38: .Nm fnmatch
1.11 cjs 39: .Nd match filename or pathname using shell glob rules
1.13 perry 40: .Sh LIBRARY
41: .Lb libc
1.1 cgd 42: .Sh SYNOPSIS
1.20 wiz 43: .In fnmatch.h
1.1 cgd 44: .Ft int
45: .Fn fnmatch "const char *pattern" "const char *string" "int flags"
46: .Sh DESCRIPTION
47: The
48: .Fn fnmatch
49: function
1.11 cjs 50: matches patterns according to the globbing rules used by the shell.
1.1 cgd 51: It checks the string specified by the
52: .Fa string
53: argument to see if it matches the pattern specified by the
54: .Fa pattern
55: argument.
56: .Pp
57: The
58: .Fa flags
59: argument modifies the interpretation of
60: .Fa pattern
61: and
62: .Fa string .
63: The value of
64: .Fa flags
65: is the bitwise inclusive
66: .Tn OR
67: of any of the following
68: constants, which are defined in the include file
1.2 jtc 69: .Pa fnmatch.h .
1.19 wiz 70: .Bl -tag -width FNM_LEADING_DIRXX
1.2 jtc 71: .It Dv FNM_NOESCAPE
72: Normally, every occurrence of a backslash
73: .Pq Ql \e
74: followed by a character in
75: .Fa pattern
76: is replaced by that character.
77: This is done to negate any special meaning for the character.
78: If the
79: .Dv FNM_NOESCAPE
80: flag is set, a backslash character is treated as an ordinary character.
1.1 cgd 81: .It Dv FNM_PATHNAME
82: Slash characters in
83: .Fa string
84: must be explicitly matched by slashes in
85: .Fa pattern .
86: If this flag is not set, then slashes are treated as regular characters.
1.2 jtc 87: .It Dv FNM_PERIOD
88: Leading periods in strings match periods in patterns.
89: The definition of ``leading'' is related to the specification of
1.16 wiz 90: .Dv FNM_PATHNAME .
1.2 jtc 91: A period is always ``leading'' if it is the first character in
92: .Ar string .
93: Additionally, if
94: .Dv FNM_PATHNAME
95: is set,
96: a period is ``leading'' if it immediately follows a slash.
1.18 provos 97: .It Dv FNM_LEADING_DIR
98: Ignore
1.19 wiz 99: .Dq /*
1.18 provos 100: rest after successful
101: .Fa pattern
102: matching.
1.14 thorpej 103: .It Dv FNM_CASEFOLD
104: The pattern is matched in a case-insensitive fashion.
1.1 cgd 105: .El
106: .Sh RETURN VALUES
1.2 jtc 107: The
108: .Fn fnmatch
109: function returns zero if
1.1 cgd 110: .Fa string
111: matches the pattern specified by
112: .Fa pattern ,
1.2 jtc 113: otherwise, it returns the value
114: .Dv FNM_NOMATCH .
1.1 cgd 115: .Sh SEE ALSO
116: .Xr sh 1 ,
117: .Xr glob 3 ,
1.22 ! jruoho 118: .Xr regex 3 ,
! 119: .Xr glob 7
1.6 jtc 120: .Sh STANDARDS
121: The
122: .Fn fnmatch
1.8 jtc 123: function conforms to
1.6 jtc 124: .St -p1003.2-92 .
1.14 thorpej 125: The
126: .Dv FNM_CASEFOLD
127: flag is a
128: .Nx
129: extension.
1.1 cgd 130: .Sh HISTORY
131: The
132: .Fn fnmatch
1.15 wiz 133: function first appeared in
1.8 jtc 134: .Bx 4.4 .
1.1 cgd 135: .Sh BUGS
136: The pattern
137: .Ql *
138: matches the empty string, even if
139: .Dv FNM_PATHNAME
140: is specified.
CVSweb <webmaster@jp.NetBSD.org>