]> git.ipfire.org Git - thirdparty/bash.git/blame - lib/glob/strmatch.c
Imported from ../bash-2.05b.tar.gz.
[thirdparty/bash.git] / lib / glob / strmatch.c
CommitLineData
f73dda09 1/* strmatch.c -- ksh-like extended pattern matching for the shell and filename
cce855bc
JA
2 globbing. */
3
7117c2d2 4/* Copyright (C) 1991-2002 Free Software Foundation, Inc.
cce855bc
JA
5
6 This file is part of GNU Bash, the Bourne Again SHell.
7
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
28ef6c31 12
cce855bc
JA
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
28ef6c31 17
cce855bc
JA
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING. If not, write to the Free Software
bb70624e 20 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
cce855bc
JA
21
22#include <config.h>
bb70624e 23
7117c2d2 24#include "stdc.h"
f73dda09 25#include "strmatch.h"
726f6388 26
7117c2d2
JA
27/* Structured this way so that if HAVE_LIBC_FNM_EXTMATCH is defined, the
28 matching portion of the library (smatch.c) is not linked into the shell. */
cce855bc 29
7117c2d2
JA
30#ifndef HAVE_LIBC_FNM_EXTMATCH
31extern int xstrmatch __P((char *, char *, int));
cce855bc 32#else
7117c2d2 33# define xstrmatch fnmatch
cce855bc
JA
34#endif
35
726f6388 36int
f73dda09 37strmatch (pattern, string, flags)
726f6388
JA
38 char *pattern;
39 char *string;
40 int flags;
41{
cce855bc
JA
42 if (string == 0 || pattern == 0)
43 return FNM_NOMATCH;
44
7117c2d2 45 return (xstrmatch (pattern, string, flags));
726f6388 46}
cce855bc
JA
47
48#ifdef TEST
49main (c, v)
50 int c;
51 char **v;
52{
53 char *string, *pat;
54
55 string = v[1];
56 pat = v[2];
57
f73dda09 58 if (strmatch (pat, string, 0) == 0)
cce855bc
JA
59 {
60 printf ("%s matches %s\n", string, pat);
61 exit (0);
62 }
63 else
64 {
65 printf ("%s does not match %s\n", string, pat);
66 exit (1);
67 }
68}
69#endif