diff options
author | ache <ache@FreeBSD.org> | 1996-10-23 16:53:26 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-10-23 16:53:26 +0000 |
commit | 6744ae81292c9b555a5a5ce7e3f7e07d1d7aca6e (patch) | |
tree | 67412370b1f1957094c1a415f09f6cee1f644466 /gnu/usr.bin | |
parent | 6042dbe6e1cb576e2169e694e05971eb51f6941f (diff) | |
download | FreeBSD-src-6744ae81292c9b555a5a5ce7e3f7e07d1d7aca6e.zip FreeBSD-src-6744ae81292c9b555a5a5ce7e3f7e07d1d7aca6e.tar.gz |
Remove local fnmatch() copy, we now compatible with GNU fnmatch
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/tar/Makefile | 2 | ||||
-rw-r--r-- | gnu/usr.bin/tar/fnmatch.c | 181 | ||||
-rw-r--r-- | gnu/usr.bin/tar/fnmatch.h | 66 | ||||
-rw-r--r-- | gnu/usr.bin/tar/tar.c | 2 |
4 files changed, 2 insertions, 249 deletions
diff --git a/gnu/usr.bin/tar/Makefile b/gnu/usr.bin/tar/Makefile index c9c76bf..0fea3db 100644 --- a/gnu/usr.bin/tar/Makefile +++ b/gnu/usr.bin/tar/Makefile @@ -1,5 +1,5 @@ PROG= tar -SRCS= buffer.c create.c diffarch.c extract.c fnmatch.c getdate.y \ +SRCS= buffer.c create.c diffarch.c extract.c getdate.y \ getoldopt.c getopt.c getopt1.c gnu.c list.c mangle.c names.c port.c \ rtapelib.c tar.c update.c version.c CFLAGS+= -DRETSIGTYPE=void -DDIRENT=1 -DHAVE_SYS_MTIO_H=1 -DHAVE_UNISTD_H=1 diff --git a/gnu/usr.bin/tar/fnmatch.c b/gnu/usr.bin/tar/fnmatch.c deleted file mode 100644 index 0acac5f..0000000 --- a/gnu/usr.bin/tar/fnmatch.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -This library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include <errno.h> -#include "fnmatch.h" -#ifdef __FreeBSD__ -#include <locale.h> -#endif - -#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) -extern int errno; -#endif - -/* Match STRING against the filename pattern PATTERN, returning zero if - it matches, nonzero if not. */ -int -fnmatch (pattern, string, flags) - const char *pattern; - const char *string; - int flags; -{ - register const char *p = pattern, *n = string; - register char c; - - if ((flags & ~__FNM_FLAGS) != 0) - { - errno = EINVAL; - return -1; - } - - while ((c = *p++) != '\0') - { - switch (c) - { - case '?': - if (*n == '\0') - return FNM_NOMATCH; - else if ((flags & FNM_PATHNAME) && *n == '/') - return FNM_NOMATCH; - else if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - break; - - case '\\': - if (!(flags & FNM_NOESCAPE)) - c = *p++; - if (*n != c) - return FNM_NOMATCH; - break; - - case '*': - if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - - for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) - if (((flags & FNM_PATHNAME) && *n == '/') || - (c == '?' && *n == '\0')) - return FNM_NOMATCH; - - if (c == '\0') - return 0; - - { - char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; - for (--p; *n != '\0'; ++n) - if ((c == '[' || *n == c1) && - fnmatch (p, n, flags & ~FNM_PERIOD) == 0) - return 0; - return FNM_NOMATCH; - } - - case '[': - { - /* Nonzero if the sense of the character class is inverted. */ - register int not; - - if (*n == '\0') - return FNM_NOMATCH; - - if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - - not = (*p == '!' || *p == '^'); - if (not) - ++p; - - c = *p++; - for (;;) - { - register char cstart = c, cend = c; - - if (!(flags & FNM_NOESCAPE) && c == '\\') - cstart = cend = *p++; - - if (c == '\0') - /* [ (unterminated) loses. */ - return FNM_NOMATCH; - - c = *p++; - - if ((flags & FNM_PATHNAME) && c == '/') - /* [/] can never match. */ - return FNM_NOMATCH; - - if (c == '-' && *p != ']') - { - cend = *p++; - if (!(flags & FNM_NOESCAPE) && cend == '\\') - cend = *p++; - if (cend == '\0') - return FNM_NOMATCH; - c = *p++; - } -#ifdef __FreeBSD__ - if ( collate_range_cmp (*n, cstart) >= 0 - && collate_range_cmp (*n, cend) <= 0 - ) - goto matched; -#else - if (*n >= cstart && *n <= cend) - goto matched; -#endif - if (c == ']') - break; - } - if (!not) - return FNM_NOMATCH; - break; - - matched:; - /* Skip the rest of the [...] that already matched. */ - while (c != ']') - { - if (c == '\0') - /* [... (unterminated) loses. */ - return FNM_NOMATCH; - - c = *p++; - if (!(flags & FNM_NOESCAPE) && c == '\\') - /* 1003.2d11 is unclear if this is right. %%% */ - ++p; - } - if (not) - return FNM_NOMATCH; - } - break; - - default: - if (c != *n) - return FNM_NOMATCH; - } - - ++n; - } - - if (*n == '\0') - return 0; - - if ((flags & FNM_LEADING_DIR) && *n == '/') - /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ - return 0; - - return FNM_NOMATCH; -} diff --git a/gnu/usr.bin/tar/fnmatch.h b/gnu/usr.bin/tar/fnmatch.h deleted file mode 100644 index ffb2188..0000000 --- a/gnu/usr.bin/tar/fnmatch.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -This library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with this library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef _FNMATCH_H - -#define _FNMATCH_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __FreeBSD__ -#include <sys/cdefs.h> -#else -#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) -#undef __P -#define __P(args) args -#else /* Not C++ or ANSI C. */ -#undef __P -#define __P(args) () -#undef const -#define const -#endif /* C++ or ANSI C. */ -#endif - -/* Bits set in the FLAGS argument to `fnmatch'. */ -#ifdef FNM_PATHNAME /* Because it is already defined in <unistd.h> */ -#undef FNM_PATHNAME -#endif -#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */ -#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD|FNM_LEADING_DIR) - -#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE) -#define FNM_LEADING_DIR (1 << 3)/* Ignore `/...' after a match. */ -#define FNM_FILE_NAME FNM_PATHNAME -#endif - -/* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 - -/* Match STRING against the filename pattern PATTERN, - returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch __P ((const char *__pattern, const char *__string, - int __flags)); - -#ifdef __cplusplus -} -#endif - -#endif /* fnmatch.h */ diff --git a/gnu/usr.bin/tar/tar.c b/gnu/usr.bin/tar/tar.c index 8fb8f81..73aba24 100644 --- a/gnu/usr.bin/tar/tar.c +++ b/gnu/usr.bin/tar/tar.c @@ -39,7 +39,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "port.h" #include "gnuregex.h" -#include "fnmatch.h" +#include <fnmatch.h> /* * We should use a conversion routine that does reasonable error |