Lines Matching defs:Pattern
22 // Check whether `FilePath` matches `Pattern` based on POSIX 2.13.1, 2.13.2, and
24 bool matchFilePath(StringRef Pattern, StringRef FilePath) {
25 assert(!Pattern.empty());
30 // No match if `Pattern` ends with a non-meta character not equal to the last
32 if (const auto C = Pattern.back(); !strchr("?*]", C) && C != FilePathBack)
36 const auto EOP = Pattern.size(); // End of `Pattern`.
38 unsigned I = 0; // Index to `Pattern`.
44 switch (const auto F = FilePath[J]; Pattern[I]) {
46 if (++I == EOP || F != Pattern[I])
54 bool Globstar = I == 0 || Pattern[I - 1] == Separator;
56 for (; ++I < EOP && Pattern[I] == '*'; ++StarCount) {
63 if (I == EOP) // `Pattern` ends with a star.
65 if (Pattern[I] != Separator) {
66 // `Pattern` ends with a lone backslash.
67 if (Pattern[I] == '\\' && ++I == EOP)
72 if (Pattern[I] == Separator) {
83 for (auto Pat = Pattern.substr(I);
92 if (I + 3 < EOP || (I + 3 == EOP && Pattern[I + 1] != '!')) {
94 if (const auto K = Pattern.find_first_of("]/", I + 1);
95 K != StringRef::npos && Pattern[K] == ']' && K > I + 1) {
100 if (Pattern[I] == '!') {
106 if (I + 2 < K && Pattern[I + 1] == '-') {
107 Match = Pattern[I] <= F && F <= Pattern[I + 2];
110 Match = F == Pattern[I++];
121 if (F != Pattern[I])
129 while (I < EOP && Pattern[I] == '*')