Lines Matching refs:S

21 static bool hasWildcard(StringRef S) {  in hasWildcard()  argument
22 return S.find_first_of("?*[\\") != StringRef::npos; in hasWildcard()
27 static Expected<BitVector> expand(StringRef S, StringRef Original) { in expand() argument
32 if (S.size() < 3) in expand()
35 uint8_t Start = S[0]; in expand()
36 uint8_t End = S[2]; in expand()
40 if (S[1] != '-') { in expand()
42 S = S.substr(1); in expand()
54 S = S.substr(3); in expand()
57 for (char C : S) in expand()
67 static Expected<BitVector> scan(StringRef &S, StringRef Original) { in scan() argument
68 switch (S[0]) { in scan()
70 S = S.substr(1); in scan()
75 S = S.substr(1); in scan()
80 size_t End = S.find(']', 2); in scan()
85 StringRef Chars = S.substr(1, End - 1); in scan()
86 S = S.substr(End + 1); in scan()
98 S = S.substr(1); in scan()
102 BV[(uint8_t)S[0]] = true; in scan()
103 S = S.substr(1); in scan()
108 Expected<GlobPattern> GlobPattern::create(StringRef S) { in create() argument
113 if (!hasWildcard(S)) { in create()
114 Pat.Exact = S; in create()
120 if (S.endswith("*") && !S.endswith("\\*") && !hasWildcard(S.drop_back())) { in create()
121 Pat.Prefix = S.drop_back(); in create()
126 if (S.startswith("*") && !hasWildcard(S.drop_front())) { in create()
127 Pat.Suffix = S.drop_front(); in create()
133 StringRef Original = S; in create()
134 while (!S.empty()) { in create()
135 Expected<BitVector> BV = scan(S, Original); in create()
143 bool GlobPattern::match(StringRef S) const { in match()
145 return S == *Exact; in match()
147 return S.startswith(*Prefix); in match()
149 return S.endswith(*Suffix); in match()
150 return matchOne(Tokens, S); in match()
154 bool GlobPattern::matchOne(ArrayRef<BitVector> Pats, StringRef S) const { in matchOne()
157 return S.empty(); in matchOne()
166 for (size_t I = 0, E = S.size(); I < E; ++I) in matchOne()
167 if (matchOne(Pats, S.substr(I))) in matchOne()
173 if (S.empty() || !Pats[0][(uint8_t)S[0]]) in matchOne()
176 S = S.substr(1); in matchOne()