diff options
author | dd <dd@FreeBSD.org> | 2002-10-08 04:15:55 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2002-10-08 04:15:55 +0000 |
commit | ad775810328c27239d98ff30a2094979615da054 (patch) | |
tree | b4cc92ca4e8e38d896ee5d8b07b785e538d94644 /sys/libkern | |
parent | 2af88da4a811029879c8a1c6e91242798f884bd2 (diff) | |
download | FreeBSD-src-ad775810328c27239d98ff30a2094979615da054.zip FreeBSD-src-ad775810328c27239d98ff30a2094979615da054.tar.gz |
Import the libc fnmatch() into the kernel. This will be used by,
among other things, the DEVFS rule subsystem to match nodes against a
path pattern supplied by the user.
fnmatch.c was repo-copied from src/lib/libc/gen/fnmatch.c, and the
only changes to it are those necessary to make it compile in the
kernel. The relevant parts of fnmatch.h were imported into libkern.h.
Approved by: -arch
Diffstat (limited to 'sys/libkern')
-rw-r--r-- | sys/libkern/fnmatch.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c index a07a2d0..9376b22 100644 --- a/sys/libkern/fnmatch.c +++ b/sys/libkern/fnmatch.c @@ -32,25 +32,18 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. * Compares a filename or pathname to a pattern. */ -#include <ctype.h> -#include <fnmatch.h> -#include <string.h> -#include <stdio.h> - -#include "collate.h" +#include <sys/param.h> +#include <sys/ctype.h> +#include <sys/libkern.h> #define EOS '\0' @@ -101,12 +94,12 @@ fnmatch(pattern, string, flags) if (c == EOS) if (flags & FNM_PATHNAME) return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? + index(string, '/') == NULL ? 0 : FNM_NOMATCH); else return (0); else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = strchr(string, '/')) == NULL) + if ((string = index(string, '/')) == NULL) return (FNM_NOMATCH); break; } @@ -218,16 +211,12 @@ rangematch(pattern, test, flags, newp) if (flags & FNM_CASEFOLD) c2 = tolower((unsigned char)c2); - if (__collate_load_error ? - c <= test && test <= c2 : - __collate_range_cmp(c, test) <= 0 - && __collate_range_cmp(test, c2) <= 0 - ) + if (c <= test && test <= c2) ok = 1; } else if (c == test) ok = 1; } while ((c = *pattern++) != ']'); - *newp = (char *)pattern; + *newp = (char *)(uintptr_t)pattern; return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); } |