Fix license issue
This commit is contained in:
parent
dce18963e6
commit
73f64102bd
@ -3,140 +3,50 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1991, 1993
|
* Written by Alexander S. Aganichev.
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Kenneth Almquist.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
|
* Released to public domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define CTLESC '\\'
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if the pattern matches the string.
|
* Returns true if the pattern matches the string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int patmat(char *string, char *pattern)
|
int patmat (char *tag, char *mask)
|
||||||
{
|
{
|
||||||
register char *p, *q;
|
if (tag && mask) {
|
||||||
register char c;
|
while (*tag && *mask)
|
||||||
|
if ((*tag == *mask) || (*mask == '?')) {
|
||||||
p = pattern;
|
++ tag;
|
||||||
q = string;
|
++ mask;
|
||||||
for (;;) {
|
} else if (*mask == '*') {
|
||||||
switch (c = *p++) {
|
while ((*mask == '*') || (*mask == '?')) {
|
||||||
case '\0':
|
if (*mask == '?') {
|
||||||
goto breakloop;
|
if (*tag)
|
||||||
case CTLESC:
|
++ tag;
|
||||||
if (*q++ != *p++)
|
else
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
}
|
||||||
case '?':
|
++ mask;
|
||||||
if (*q++ == '\0')
|
}
|
||||||
return 0;
|
if (*mask) {
|
||||||
break;
|
while (*tag && !patmat (tag, mask))
|
||||||
case '*':
|
++ tag;
|
||||||
c = *p;
|
if (*tag)
|
||||||
if (c != CTLESC && c != '?' && c != '*' && c != '[') {
|
return 1;
|
||||||
while (*q != c) {
|
} else
|
||||||
if (*q == '\0')
|
return 1;
|
||||||
return 0;
|
} else
|
||||||
q++;
|
return 0;
|
||||||
}
|
while (*mask == '*')
|
||||||
}
|
++ mask;
|
||||||
do {
|
if (*mask)
|
||||||
if (patmat(q, p))
|
return 0;
|
||||||
return 1;
|
return (*tag) ? 0 : 1;
|
||||||
} while (*q++ != '\0');
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case '[': {
|
|
||||||
char *endp;
|
|
||||||
int invert, found;
|
|
||||||
char chr;
|
|
||||||
|
|
||||||
endp = p;
|
|
||||||
if (*endp == '!')
|
|
||||||
endp++;
|
|
||||||
for (;;) {
|
|
||||||
if (*endp == '\0')
|
|
||||||
goto dft; /* no matching ] */
|
|
||||||
if (*endp == CTLESC)
|
|
||||||
endp++;
|
|
||||||
if (*++endp == ']')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
invert = 0;
|
|
||||||
if (*p == '!') {
|
|
||||||
invert++;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
found = 0;
|
|
||||||
chr = *q++;
|
|
||||||
c = *p++;
|
|
||||||
do {
|
|
||||||
if (c == CTLESC)
|
|
||||||
c = *p++;
|
|
||||||
if (*p == '-' && p[1] != ']') {
|
|
||||||
p++;
|
|
||||||
if (*p == CTLESC)
|
|
||||||
p++;
|
|
||||||
if (chr >= c && chr <= *p)
|
|
||||||
found = 1;
|
|
||||||
p++;
|
|
||||||
} else {
|
|
||||||
if (chr == c)
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
} while ((c = *p++) != ']');
|
|
||||||
if (found == invert)
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dft: default:
|
|
||||||
if (*q++ != c)
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
breakloop:
|
|
||||||
if (*q != '\0')
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
Reference in New Issue
Block a user