llvm.org GIT mirror llvm / 7dd6107
Remove unused string functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93183 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 10 years ago
2 changed file(s) with 0 addition(s) and 83 deletion(s). Raw diff Collapse all Expand all
136136 return result;
137137 }
138138
139 /// StringsEqualNoCase - Return true if the two strings are equal, ignoring
140 /// case.
141 static inline bool StringsEqualNoCase(const std::string &LHS,
142 const std::string &RHS) {
143 if (LHS.size() != RHS.size()) return false;
144 for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i)
145 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
146 return true;
147 }
148
149 /// StringsEqualNoCase - Return true if the two strings are equal, ignoring
150 /// case.
151 static inline bool StringsEqualNoCase(const std::string &LHS,
152 const char *RHS) {
153 for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) {
154 if (RHS[i] == 0) return false; // RHS too short.
155 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
156 }
157 return RHS[LHS.size()] == 0; // Not too long?
158 }
159
160 /// StringsEqualNoCase - Return true if the two null-terminated C strings are
161 /// equal, ignoring
162
163 static inline bool StringsEqualNoCase(const char *LHS, const char *RHS,
164 unsigned len) {
165
166 for (unsigned i = 0; i < len; ++i) {
167 if (tolower(LHS[i]) != tolower(RHS[i]))
168 return false;
169
170 // If RHS[i] == 0 then LHS[i] == 0 or otherwise we would have returned
171 // at the previous branch as tolower('\0') == '\0'.
172 if (RHS[i] == 0)
173 return true;
174 }
175
176 return true;
177 }
178
179 /// CStrInCStrNoCase - Portable version of strcasestr. Locates the first
180 /// occurance of c-string 's2' in string 's1', ignoring case. Returns
181 /// NULL if 's2' cannot be found.
182 static inline const char* CStrInCStrNoCase(const char *s1, const char *s2) {
183
184 // Are either strings NULL or empty?
185 if (!s1 || !s2 || s1[0] == '\0' || s2[0] == '\0')
186 return 0;
187
188 if (s1 == s2)
189 return s1;
190
191 const char *I1=s1, *I2=s2;
192
193 while (*I1 != '\0' && *I2 != '\0' )
194 if (tolower(*I1) != tolower(*I2)) { // No match. Start over.
195 ++s1; I1 = s1; I2 = s2;
196 }
197 else { // Character match. Advance to the next character.
198 ++I1; ++I2;
199 }
200
201 // If we exhausted all of the characters in 's2', then 's2' appears in 's1'.
202 return *I2 == '\0' ? s1 : 0;
203 }
204
205139 /// StrInStrNoCase - Portable version of strcasestr. Locates the first
206140 /// occurrence of string 's1' in string 's2', ignoring case. Returns
207141 /// the offset of s2 in s1 or npos if s2 cannot be found.
222156 SmallVectorImpl &OutFragments,
223157 StringRef Delimiters = " \t\n\v\f\r");
224158
225 // FIXME: remove when llvm-gcc doesn't use this anymore
226 void SplitString(StringRef Source,
227 std::vector &OutFragments,
228 StringRef Delimiters = " \t\n\v\f\r");
229
230159 /// HashString - Hash funtion for strings.
231160 ///
232161 /// This is the Bernstein hash function.
6060 }
6161 }
6262
63 // FIXME: remove when llvm-gcc doesn't use this anymore
64 void llvm::SplitString(StringRef Source,
65 std::vector &OutFragments,
66 StringRef Delimiters) {
67 StringRef S2, S;
68 tie(S2, S) = getToken(Source, Delimiters);
69 while (!S2.empty()) {
70 OutFragments.push_back(S2);
71 tie(S2, S) = getToken(S, Delimiters);
72 }
73 }
74
7563 void llvm::StringRef::split(SmallVectorImpl &A,
7664 StringRef Separators, int MaxSplit,
7765 bool KeepEmpty) const {