fnmatch: pattern syntax can no longer fail

Whenever an expected pattern syntax rule cannot be matched, the
character starting the rule loses its special meaning and the parsing
is resumed:
- backslash at the end of pattern string matches itself.
- Error in [:keyword:] results in set containing :\[dekorwy.

Unit test 1307 updated for this new situation.

Closes #2273
This commit is contained in:
Patrick Monnerat 2018-01-30 20:22:17 +01:00
parent fcaa1826bd
commit da5f4b1d84
2 changed files with 84 additions and 116 deletions

View file

@ -25,7 +25,6 @@
#define MATCH CURL_FNMATCH_MATCH
#define NOMATCH CURL_FNMATCH_NOMATCH
#define RE_ERR CURL_FNMATCH_FAIL
struct testcase {
const char *pattern;
@ -135,6 +134,8 @@ static const struct testcase tests[] = {
{ "[^[:blank:]]", "\t", NOMATCH },
{ "[^[:print:]]", "\10", MATCH },
{ "[[:lower:]][[:lower:]]", "ll", MATCH },
{ "[[:foo:]]", "bar", NOMATCH },
{ "[[:foo:]]", "f]", MATCH },
{ "Curl[[:blank:]];-)", "Curl ;-)", MATCH },
{ "*[[:blank:]]*", " ", MATCH },
@ -172,7 +173,7 @@ static const struct testcase tests[] = {
{ "x", "", NOMATCH },
/* backslash */
{ "\\", "\\", RE_ERR },
{ "\\", "\\", MATCH },
{ "\\\\", "\\", MATCH },
{ "\\\\", "\\\\", NOMATCH },
{ "\\?", "?", MATCH },