llvm.org GIT mirror llvm / 1fd2e6d
Make the interface of CStrInCStrNoCase be the same as strcasestr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50828 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 11 years ago
1 changed file(s) with 5 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
142142 }
143143
144144 /// CStrInCStrNoCase - Portable version of strcasestr. Locates the first
145 /// occurance of c-string 's1' in string 's2', ignoring case. Returns
146 /// NULL if 's1' cannot be found. NOTE: the arguments are provided
147 /// in a different order than strcasestr.
145 /// occurance of c-string 's2' in string 's1', ignoring case. Returns
146 /// NULL if 's2' cannot be found.
148147 static inline const char* CStrInCStrNoCase(const char *s1, const char *s2) {
149148
150149 // Are either strings NULL or empty?
158157
159158 while (*I1 != '\0' || *I2 != '\0' )
160159 if (tolower(*I1) != tolower(*I2)) { // No match. Start over.
161 ++s2; I1 = s1; I2 = s2;
160 ++s1; I1 = s1; I2 = s2;
162161 }
163162 else { // Character match. Advance to the next character.
164163 ++I1; ++I2;
165164 }
166165
167 // If we exhausted all of the characters in 's1', then 's1' appears in 's2'.
168 return *I1 == '\0' ? s2 : 0;
166 // If we exhausted all of the characters in 's2', then 's2' appears in 's1'.
167 return *I2 == '\0' ? s1 : 0;
169168 }
170169
171170 /// getToken - This function extracts one token from source, ignoring any