Lines Matching refs:S
21 static Expected<BitVector> expand(StringRef S, StringRef Original) {
26 if (S.size() < 3)
29 uint8_t Start = S[0];
30 uint8_t End = S[2];
34 if (S[1] != '-') {
36 S = S.substr(1);
48 S = S.substr(3);
51 for (char C : S)
56 // Identify brace expansions in S and return the list of patterns they expand
59 parseBraceExpansions(StringRef S, std::optional<size_t> MaxSubPatterns) {
60 SmallVector<std::string> SubPatterns = {S.str()};
61 if (!MaxSubPatterns || !S.contains('{'))
73 for (size_t I = 0, E = S.size(); I != E; ++I) {
74 if (S[I] == '[') {
75 I = S.find(']', I + 2);
79 } else if (S[I] == '{') {
87 } else if (S[I] == ',') {
90 CurrentBE->Terms.push_back(S.substr(TermBegin, I - TermBegin));
92 } else if (S[I] == '}') {
99 CurrentBE->Terms.push_back(S.substr(TermBegin, I - TermBegin));
102 } else if (S[I] == '\\') {
136 GlobPattern::create(StringRef S, std::optional<size_t> MaxSubPatterns) {
140 size_t PrefixSize = S.find_first_of("?*[{\\");
141 Pat.Prefix = S.substr(0, PrefixSize);
144 S = S.substr(PrefixSize);
147 if (auto Err = parseBraceExpansions(S, MaxSubPatterns).moveInto(SubPats))
160 GlobPattern::SubGlobPattern::create(StringRef S) {
164 Pat.Pat.assign(S.begin(), S.end());
165 for (size_t I = 0, E = S.size(); I != E; ++I) {
166 if (S[I] == '[') {
170 size_t J = S.find(']', I + 1);
174 StringRef Chars = S.substr(I, J - I);
175 bool Invert = S[I] == '^' || S[I] == '!';
177 Invert ? expand(Chars.substr(1), S) : expand(Chars, S);
184 } else if (S[I] == '\\') {
193 bool GlobPattern::match(StringRef S) const {
194 if (!S.consume_front(Prefix))
196 if (SubGlobs.empty() && S.empty())
199 if (Glob.match(S))
208 const char *P = Pat.data(), *SegmentBegin = nullptr, *S = Str.data(),
209 *SavedS = S;
210 const char *const PEnd = P + Pat.size(), *const End = S + Str.size();
212 while (S != End) {
216 // The non-* substring on the left of '*' matches the tail of S. Save the
219 SavedS = S;
223 if (Brackets[B].Bytes[uint8_t(*S)]) {
225 ++S;
229 if (*++P == *S) {
231 ++S;
234 } else if (*P == *S || *P == '?') {
236 ++S;
241 // We have seen a '*'. Backtrack to the saved positions. Shift the S
244 S = ++SavedS;