FIXES 4623
Pattern matching was broken. '?' should match zero characters if it
appears before a '.' or at the end of the file name.
(cherry picked from commit
41fe908bead6b30e41fd9e4f5084cd5e1dc3ca4a)
while (*name) {
switch (*pattern) {
case '?':
- if (*name == '.')
- return FALSE;
- ++pattern, ++name;
+ ++pattern;
+ if (*name == '.')
+ continue;
+ ++name;
break;
case '*':
++pattern;
} /* endswitch */
} /* endwhile */
- if (*pattern == '\0' || *pattern == '*' && *(pattern+1) == '\0')
- return TRUE;
- else
- return FALSE;
+ /* if all we have left are wildcards, then we match */
+ for (;*pattern; pattern++) {
+ if (*pattern != '*' && *pattern != '?')
+ return FALSE;
+ }
+ return TRUE;
}
/* do a case-folding search of the star name mask with the name in namep.