summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-10-23 16:40:20 +0000
committerache <ache@FreeBSD.org>1996-10-23 16:40:20 +0000
commit392b773de0d2e240c8b31e37463505fff384909c (patch)
treec05ddbdeb156c25f3d69669dc44146c5c1d4feeb /sys
parentb7a42c0562a14602ef003def609b976789ca6967 (diff)
downloadFreeBSD-src-392b773de0d2e240c8b31e37463505fff384909c.zip
FreeBSD-src-392b773de0d2e240c8b31e37463505fff384909c.tar.gz
GNU-style changes:
1) Rename FNM_ICASE to FNM_CASEFOLD 2) Add FNM_LEADING_DIR Add proper (unsigned char) casts to tolower(). Use 'char' function argument for proper sign extension
Diffstat (limited to 'sys')
-rw-r--r--sys/libkern/fnmatch.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c
index 1fa1db5..3bf9e17 100644
--- a/sys/libkern/fnmatch.c
+++ b/sys/libkern/fnmatch.c
@@ -51,7 +51,7 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#define EOS '\0'
-static const char *rangematch __P((const char *, int, int));
+static const char *rangematch __P((const char *, char, int));
int
fnmatch(pattern, string, flags)
@@ -64,6 +64,8 @@ fnmatch(pattern, string, flags)
for (stringstart = string;;)
switch (c = *pattern++) {
case EOS:
+ if ((flags & FNM_LEADING_DIR) && *string == '/')
+ return (0);
return (*string == EOS ? 0 : FNM_NOMATCH);
case '?':
if (*string == EOS)
@@ -130,8 +132,9 @@ fnmatch(pattern, string, flags)
default:
if (c == *string)
;
- else if ((flags & FNM_ICASE) &&
- (tolower(c) == tolower(*string)))
+ else if ((flags & FNM_CASEFOLD) &&
+ (tolower((unsigned char)c) ==
+ tolower((unsigned char)*string)))
;
else
return (FNM_NOMATCH);
@@ -144,7 +147,8 @@ fnmatch(pattern, string, flags)
static const char *
rangematch(pattern, test, flags)
const char *pattern;
- int test, flags;
+ char test;
+ int flags;
{
int negate, ok;
char c, c2;
@@ -159,8 +163,8 @@ rangematch(pattern, test, flags)
if ( (negate = (*pattern == '!' || *pattern == '^')) )
++pattern;
- if (flags & FNM_ICASE)
- test = tolower(test);
+ if (flags & FNM_CASEFOLD)
+ test = tolower((unsigned char)test);
for (ok = 0; (c = *pattern++) != ']';) {
if (c == '\\' && !(flags & FNM_NOESCAPE))
@@ -168,8 +172,8 @@ rangematch(pattern, test, flags)
if (c == EOS)
return (NULL);
- if (flags & FNM_ICASE)
- c = tolower(c);
+ if (flags & FNM_CASEFOLD)
+ c = tolower((unsigned char)c);
if (*pattern == '-'
&& (c2 = *(pattern+1)) != EOS && c2 != ']') {
@@ -179,8 +183,8 @@ rangematch(pattern, test, flags)
if (c2 == EOS)
return (NULL);
- if (flags & FNM_ICASE)
- c2 = tolower(c2);
+ if (flags & FNM_CASEFOLD)
+ c2 = tolower((unsigned char)c2);
if ( collate_range_cmp(c, test) <= 0
&& collate_range_cmp(test, c2) <= 0
OpenPOWER on IntegriCloud