2021-02-11 01:51:11 +00:00
|
|
|
/* $NetBSD: str.c,v 1.81 2021/02/01 22:36:28 rillig Exp $ */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
/*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Copyright (c) 1988, 1989, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* 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. 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.
|
|
|
|
*/
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
/*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Copyright (c) 1989 by Berkeley Softworks
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "make.h"
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
|
2021-02-11 01:51:11 +00:00
|
|
|
MAKE_RCSID("$NetBSD: str.c,v 1.81 2021/02/01 22:36:28 rillig Exp $");
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
/* Return the concatenation of s1 and s2, freshly allocated. */
|
1996-10-06 15:57:15 +00:00
|
|
|
char *
|
2020-09-05 16:11:04 +00:00
|
|
|
str_concat2(const char *s1, const char *s2)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2020-09-05 16:11:04 +00:00
|
|
|
size_t len1 = strlen(s1);
|
|
|
|
size_t len2 = strlen(s2);
|
|
|
|
char *result = bmake_malloc(len1 + len2 + 1);
|
1996-10-06 15:57:15 +00:00
|
|
|
memcpy(result, s1, len1);
|
|
|
|
memcpy(result + len1, s2, len2 + 1);
|
2020-09-05 16:11:04 +00:00
|
|
|
return result;
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
/* Return the concatenation of s1, s2 and s3, freshly allocated. */
|
|
|
|
char *
|
|
|
|
str_concat3(const char *s1, const char *s2, const char *s3)
|
|
|
|
{
|
|
|
|
size_t len1 = strlen(s1);
|
|
|
|
size_t len2 = strlen(s2);
|
|
|
|
size_t len3 = strlen(s3);
|
|
|
|
char *result = bmake_malloc(len1 + len2 + len3 + 1);
|
|
|
|
memcpy(result, s1, len1);
|
|
|
|
memcpy(result + len1, s2, len2);
|
|
|
|
memcpy(result + len1 + len2, s3, len3 + 1);
|
2020-07-01 02:13:04 +00:00
|
|
|
return result;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
/* Return the concatenation of s1, s2, s3 and s4, freshly allocated. */
|
|
|
|
char *
|
|
|
|
str_concat4(const char *s1, const char *s2, const char *s3, const char *s4)
|
|
|
|
{
|
|
|
|
size_t len1 = strlen(s1);
|
|
|
|
size_t len2 = strlen(s2);
|
|
|
|
size_t len3 = strlen(s3);
|
|
|
|
size_t len4 = strlen(s4);
|
|
|
|
char *result = bmake_malloc(len1 + len2 + len3 + len4 + 1);
|
|
|
|
memcpy(result, s1, len1);
|
|
|
|
memcpy(result + len1, s2, len2);
|
|
|
|
memcpy(result + len1 + len2, s3, len3);
|
|
|
|
memcpy(result + len1 + len2 + len3, s4, len4 + 1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Fracture a string into an array of words (as delineated by tabs or spaces)
|
2020-11-20 03:54:37 +00:00
|
|
|
* taking quotation marks into account.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-09-05 16:11:04 +00:00
|
|
|
* If expand is TRUE, quotes are removed and escape sequences such as \r, \t,
|
2020-11-20 03:54:37 +00:00
|
|
|
* etc... are expanded. In this case, return NULL on parse errors.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Returns the fractured words, which must be freed later using Words_Free,
|
|
|
|
* unless the returned Words.words was NULL.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-09-05 16:11:04 +00:00
|
|
|
Words
|
|
|
|
Str_Words(const char *str, Boolean expand)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2020-09-05 16:11:04 +00:00
|
|
|
size_t str_len;
|
|
|
|
char *words_buf;
|
|
|
|
size_t words_cap;
|
|
|
|
char **words;
|
|
|
|
size_t words_len;
|
2020-05-20 19:34:48 +00:00
|
|
|
char inquote;
|
2020-09-05 16:11:04 +00:00
|
|
|
char *word_start;
|
|
|
|
char *word_end;
|
2020-05-20 19:34:48 +00:00
|
|
|
const char *str_p;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/* XXX: why only hspace, not whitespace? */
|
|
|
|
cpp_skip_hspace(&str); /* skip leading space chars. */
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-05-20 19:34:48 +00:00
|
|
|
/* words_buf holds the words, separated by '\0'. */
|
|
|
|
str_len = strlen(str);
|
2021-01-14 01:24:34 +00:00
|
|
|
words_buf = bmake_malloc(str_len + 1);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
words_cap = str_len / 5 > 50 ? str_len / 5 : 50;
|
2020-05-20 19:34:48 +00:00
|
|
|
words = bmake_malloc((words_cap + 1) * sizeof(char *));
|
2014-07-02 21:24:54 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
|
|
|
* copy the string; at the same time, parse backslashes,
|
2020-05-20 19:34:48 +00:00
|
|
|
* quotes and build the word list.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-05-20 19:34:48 +00:00
|
|
|
words_len = 0;
|
1996-10-06 15:57:15 +00:00
|
|
|
inquote = '\0';
|
2020-09-05 16:11:04 +00:00
|
|
|
word_start = words_buf;
|
|
|
|
word_end = words_buf;
|
2021-02-11 01:51:11 +00:00
|
|
|
for (str_p = str;; str_p++) {
|
2020-05-20 19:34:48 +00:00
|
|
|
char ch = *str_p;
|
2020-09-05 16:11:04 +00:00
|
|
|
switch (ch) {
|
1996-10-06 15:57:15 +00:00
|
|
|
case '"':
|
|
|
|
case '\'':
|
2021-01-14 01:24:34 +00:00
|
|
|
if (inquote != '\0') {
|
1996-10-06 15:57:15 +00:00
|
|
|
if (inquote == ch)
|
|
|
|
inquote = '\0';
|
|
|
|
else
|
|
|
|
break;
|
2020-09-05 16:11:04 +00:00
|
|
|
} else {
|
2020-11-07 19:39:21 +00:00
|
|
|
inquote = ch;
|
1996-10-06 15:57:15 +00:00
|
|
|
/* Don't miss "" or '' */
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL && str_p[1] == inquote) {
|
2012-06-08 21:57:36 +00:00
|
|
|
if (!expand) {
|
2020-05-20 19:34:48 +00:00
|
|
|
word_start = word_end;
|
|
|
|
*word_end++ = ch;
|
2012-06-08 21:57:36 +00:00
|
|
|
} else
|
2020-05-20 19:34:48 +00:00
|
|
|
word_start = word_end + 1;
|
|
|
|
str_p++;
|
2012-06-08 21:57:36 +00:00
|
|
|
inquote = '\0';
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!expand) {
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL)
|
|
|
|
word_start = word_end;
|
|
|
|
*word_end++ = ch;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
case '\n':
|
2021-01-14 01:24:34 +00:00
|
|
|
if (inquote != '\0')
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL)
|
1996-10-06 15:57:15 +00:00
|
|
|
continue;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case '\0':
|
|
|
|
/*
|
2020-05-20 19:34:48 +00:00
|
|
|
* end of a token -- make sure there's enough words
|
1996-10-06 15:57:15 +00:00
|
|
|
* space and save off a pointer.
|
|
|
|
*/
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL)
|
2020-09-05 16:11:04 +00:00
|
|
|
goto done;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2020-05-20 19:34:48 +00:00
|
|
|
*word_end++ = '\0';
|
|
|
|
if (words_len == words_cap) {
|
2020-09-05 16:11:04 +00:00
|
|
|
size_t new_size;
|
2020-05-20 19:34:48 +00:00
|
|
|
words_cap *= 2; /* ramp up fast */
|
2020-09-05 16:11:04 +00:00
|
|
|
new_size = (words_cap + 1) * sizeof(char *);
|
|
|
|
words = bmake_realloc(words, new_size);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-05-20 19:34:48 +00:00
|
|
|
words[words_len++] = word_start;
|
|
|
|
word_start = NULL;
|
2012-06-08 21:57:36 +00:00
|
|
|
if (ch == '\n' || ch == '\0') {
|
2021-01-14 01:24:34 +00:00
|
|
|
if (expand && inquote != '\0') {
|
2020-05-20 19:34:48 +00:00
|
|
|
free(words);
|
|
|
|
free(words_buf);
|
2020-09-05 16:11:04 +00:00
|
|
|
return (Words){ NULL, 0, NULL };
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
goto done;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
continue;
|
|
|
|
case '\\':
|
|
|
|
if (!expand) {
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL)
|
|
|
|
word_start = word_end;
|
|
|
|
*word_end++ = '\\';
|
|
|
|
/* catch '\' at end of line */
|
|
|
|
if (str_p[1] == '\0')
|
2012-06-08 21:57:36 +00:00
|
|
|
continue;
|
2020-05-20 19:34:48 +00:00
|
|
|
ch = *++str_p;
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-05-20 19:34:48 +00:00
|
|
|
switch (ch = *++str_p) {
|
1996-10-06 15:57:15 +00:00
|
|
|
case '\0':
|
|
|
|
case '\n':
|
|
|
|
/* hmmm; fix it up as best we can */
|
|
|
|
ch = '\\';
|
2020-11-20 03:54:37 +00:00
|
|
|
str_p--;
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
ch = '\b';
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
ch = '\f';
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
ch = '\n';
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
ch = '\r';
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
ch = '\t';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-05-20 19:34:48 +00:00
|
|
|
if (word_start == NULL)
|
|
|
|
word_start = word_end;
|
|
|
|
*word_end++ = ch;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
done:
|
2020-11-20 03:54:37 +00:00
|
|
|
words[words_len] = NULL; /* useful for argv */
|
2020-09-05 16:11:04 +00:00
|
|
|
return (Words){ words, words_len, words_buf };
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2020-07-08 18:32:15 +00:00
|
|
|
* Str_Match -- Test if a string matches a pattern like "*.[ch]".
|
2020-11-20 03:54:37 +00:00
|
|
|
* The following special characters are known *?\[] (as in fnmatch(3)).
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* XXX: this function does not detect or report malformed patterns.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-07-08 18:32:15 +00:00
|
|
|
Boolean
|
|
|
|
Str_Match(const char *str, const char *pat)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
|
|
|
for (;;) {
|
|
|
|
/*
|
|
|
|
* See if we're at the end of both the pattern and the
|
2020-11-20 03:54:37 +00:00
|
|
|
* string. If so, we succeeded. If we're at the end of the
|
1996-10-06 15:57:15 +00:00
|
|
|
* pattern but not at the end of the string, we failed.
|
|
|
|
*/
|
2020-11-20 03:54:37 +00:00
|
|
|
if (*pat == '\0')
|
|
|
|
return *str == '\0';
|
|
|
|
if (*str == '\0' && *pat != '*')
|
2020-07-08 18:32:15 +00:00
|
|
|
return FALSE;
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2020-07-08 18:32:15 +00:00
|
|
|
* A '*' in the pattern matches any substring. We handle this
|
|
|
|
* by calling ourselves for each suffix of the string.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-07-08 18:32:15 +00:00
|
|
|
if (*pat == '*') {
|
|
|
|
pat++;
|
|
|
|
while (*pat == '*')
|
|
|
|
pat++;
|
2020-11-20 03:54:37 +00:00
|
|
|
if (*pat == '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
return TRUE;
|
2020-11-20 03:54:37 +00:00
|
|
|
while (*str != '\0') {
|
2020-07-08 18:32:15 +00:00
|
|
|
if (Str_Match(str, pat))
|
|
|
|
return TRUE;
|
|
|
|
str++;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
return FALSE;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
|
|
|
|
/* A '?' in the pattern matches any single character. */
|
|
|
|
if (*pat == '?')
|
1996-10-06 15:57:15 +00:00
|
|
|
goto thisCharOK;
|
2020-07-08 18:32:15 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2020-07-08 18:32:15 +00:00
|
|
|
* A '[' in the pattern matches a character from a list.
|
|
|
|
* The '[' is followed by the list of acceptable characters,
|
|
|
|
* or by ranges (two characters separated by '-'). In these
|
|
|
|
* character lists, the backslash is an ordinary character.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-07-08 18:32:15 +00:00
|
|
|
if (*pat == '[') {
|
|
|
|
Boolean neg = pat[1] == '^';
|
2020-09-05 16:11:04 +00:00
|
|
|
pat += neg ? 2 : 1;
|
2017-04-15 00:51:18 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
for (;;) {
|
2020-11-20 03:54:37 +00:00
|
|
|
if (*pat == ']' || *pat == '\0') {
|
2020-07-08 18:32:15 +00:00
|
|
|
if (neg)
|
2017-05-10 22:40:27 +00:00
|
|
|
break;
|
2020-07-08 18:32:15 +00:00
|
|
|
return FALSE;
|
2017-05-10 22:40:27 +00:00
|
|
|
}
|
2021-02-11 01:51:11 +00:00
|
|
|
/*
|
|
|
|
* XXX: This naive comparison makes the
|
|
|
|
* control flow of the pattern parser
|
|
|
|
* dependent on the actual value of the
|
|
|
|
* string. This is unpredictable. It may be
|
|
|
|
* though that the code only looks wrong but
|
|
|
|
* actually all code paths result in the same
|
|
|
|
* behavior. This needs further tests.
|
|
|
|
*/
|
2020-07-08 18:32:15 +00:00
|
|
|
if (*pat == *str)
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2020-07-08 18:32:15 +00:00
|
|
|
if (pat[1] == '-') {
|
2020-11-20 03:54:37 +00:00
|
|
|
if (pat[2] == '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
return neg;
|
|
|
|
if (*pat <= *str && pat[2] >= *str)
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2020-07-08 18:32:15 +00:00
|
|
|
if (*pat >= *str && pat[2] <= *str)
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2020-07-08 18:32:15 +00:00
|
|
|
pat += 2;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
pat++;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-11-20 03:54:37 +00:00
|
|
|
if (neg && *pat != ']' && *pat != '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
return FALSE;
|
2020-11-20 03:54:37 +00:00
|
|
|
while (*pat != ']' && *pat != '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
pat++;
|
2020-11-20 03:54:37 +00:00
|
|
|
if (*pat == '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
pat--;
|
1996-10-06 15:57:15 +00:00
|
|
|
goto thisCharOK;
|
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2020-07-08 18:32:15 +00:00
|
|
|
* A backslash in the pattern matches the character following
|
|
|
|
* it exactly.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-07-08 18:32:15 +00:00
|
|
|
if (*pat == '\\') {
|
|
|
|
pat++;
|
2020-11-20 03:54:37 +00:00
|
|
|
if (*pat == '\0')
|
2020-07-08 18:32:15 +00:00
|
|
|
return FALSE;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
|
|
|
|
if (*pat != *str)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
thisCharOK:
|
|
|
|
pat++;
|
|
|
|
str++;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
}
|