delorie.com/djgpp/doc/libc/libc_334.html | search |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <fnmatch.h> int fnmatch(const char *pattern, const char *string, int flags); |
This function indicates if string matches the pattern. The pattern may include the following special characters:
*
Matches zero of more characters.
?
Matches exactly one character.
[...]
Matches one character if it's in a range of characters. If the first character is `!', matches if the character is not in the range. Between the brackets, the range is specified by listing the characters that are in the range, or two characters separated by `-' to indicate all characters in that range. For example, `[a-d]' matches `a', `b', `c', or `d'. If you want to include the literal `-' in the range, make it the first character, like in `[-afz]'.
\
Causes the next character to not be treated as a wildcard. For example,
`\*' matches an asterisk. This feature is not available if
flags includes FNM_NOESCAPE
, in which case `\' is
treated as a directory separator.
The value of flags is a combination of zero of more of the following:
FNM_PATHNAME
This means that the string should be treated as a pathname, in that the slash characters `/' and `\' in string never match any of the wildcards in pattern.
FNM_NOESCAPE
If this flag is not set, the backslash `\' may be used in pattern for quoting special characters. If this flag is set, `\' is treated as a directory separator.
FNM_NOCASE
If this flag is set, fnmatch
matches characters
case-insensitively, including in character ranges like [a-f]
.
Note that the case-folding is done by calling toupper
(see section toupper), and thus might be sensitive to the current locale.
FNM_PERIOD
This flag is accepted and ignored in the current implementation. (This is the right thing to do on non-LFN platforms, where leading dots in file names are forbidden.)
In the Posix specification, if this flag is set, leading dots in file
names will not match any wildcards. If FNM_PATHNAME
is set, a
dot after a slash also doesn't match any wildcards.
The DJGPP implementation treats forward slashes and backslashes as equal
when FNM_NOESCAPE
is set, since on DOS/Windows these two
characters are both used as directory separators in file names.
Zero if the string matches, FNM_NOMATCH
if it does not. Posix
defines an additional FNM_ERROR
code that's returned in case of
an error, but the current implementation never returns it.
ANSI/ISO C | No |
POSIX | 1003.2-1992; 1003.1-2001 (see note 1) |
Notes:
if (fnmatch("*.[ch]", filename, FNM_PATHNAME|FNM_NOCASE)) do_source_file(filename); |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2004 | Updated Apr 2004 |