i-bash/lib/glob/strmatch.c

80 lines
1.8 KiB
C
Raw Normal View History

2001-11-13 17:56:06 +00:00
/* strmatch.c -- ksh-like extended pattern matching for the shell and filename
1998-04-17 19:52:44 +00:00
globbing. */
2002-07-17 14:10:11 +00:00
/* Copyright (C) 1991-2002 Free Software Foundation, Inc.
1998-04-17 19:52:44 +00:00
This file is part of GNU Bash, the Bourne Again SHell.
2009-01-12 13:36:28 +00:00
Bash 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.
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
*/
1998-04-17 19:52:44 +00:00
#include <config.h>
2000-03-17 21:46:59 +00:00
2002-07-17 14:10:11 +00:00
#include "stdc.h"
2001-11-13 17:56:06 +00:00
#include "strmatch.h"
1996-08-26 18:22:31 +00:00
2002-07-17 14:10:11 +00:00
extern int xstrmatch __P((char *, char *, int));
2009-01-12 13:36:28 +00:00
#if defined (HANDLE_MULTIBYTE)
2004-07-27 13:29:18 +00:00
extern int internal_wstrmatch __P((wchar_t *, wchar_t *, int));
1998-04-17 19:52:44 +00:00
#endif
1996-08-26 18:22:31 +00:00
int
2001-11-13 17:56:06 +00:00
strmatch (pattern, string, flags)
1996-08-26 18:22:31 +00:00
char *pattern;
char *string;
int flags;
{
1998-04-17 19:52:44 +00:00
if (string == 0 || pattern == 0)
return FNM_NOMATCH;
2002-07-17 14:10:11 +00:00
return (xstrmatch (pattern, string, flags));
1996-08-26 18:22:31 +00:00
}
1998-04-17 19:52:44 +00:00
2004-07-27 13:29:18 +00:00
#if defined (HANDLE_MULTIBYTE)
int
wcsmatch (wpattern, wstring, flags)
wchar_t *wpattern;
wchar_t *wstring;
int flags;
{
if (wstring == 0 || wpattern == 0)
return (FNM_NOMATCH);
return (internal_wstrmatch (wpattern, wstring, flags));
}
#endif
1998-04-17 19:52:44 +00:00
#ifdef TEST
main (c, v)
int c;
char **v;
{
char *string, *pat;
string = v[1];
pat = v[2];
2001-11-13 17:56:06 +00:00
if (strmatch (pat, string, 0) == 0)
1998-04-17 19:52:44 +00:00
{
printf ("%s matches %s\n", string, pat);
exit (0);
}
else
{
printf ("%s does not match %s\n", string, pat);
exit (1);
}
}
#endif