MCPcopy Create free account
hub / github.com/WinMerge/winmerge / Compare

Function Compare

Src/stringdiffs.cpp:193–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193int Compare(const String& str1, const String& str2,
194 bool case_sensitive, EolCompareMode eol_mode, int whitespace, bool ignore_numbers)
195{
196 if (case_sensitive && eol_mode == EOL_STRICT && whitespace == WHITESPACE_COMPARE_ALL && !ignore_numbers)
197 return str2.compare(str1);
198 String s1 = str1, s2 = str2;
199 if (!case_sensitive)
200 {
201 s1 = strutils::makelower(s1);
202 s2 = strutils::makelower(s2);
203 }
204 if (eol_mode == EOL_IGNORE)
205 {
206 strutils::replace_chars(s1, _T("\r\n"), _T("\n"));
207 strutils::replace_chars(s2, _T("\r\n"), _T("\n"));
208 }
209 else if (eol_mode == EOL_AS_SPACE)
210 {
211 strutils::replace(s1, _T("\r\n"), _T(" "));
212 strutils::replace_chars(s1, _T("\r\n"), _T(" "));
213 strutils::replace(s2, _T("\r\n"), _T(" "));
214 strutils::replace_chars(s2, _T("\r\n"), _T(" "));
215 }
216 if (whitespace == WHITESPACE_IGNORE_CHANGE)
217 {
218 strutils::replace_chars(s1, _T(" \t"), _T(" "));
219 strutils::replace_chars(s2, _T(" \t"), _T(" "));
220 }
221 else if (whitespace == WHITESPACE_IGNORE_ALL)
222 {
223 strutils::replace_chars(s1, _T(" \t"), _T(""));
224 strutils::replace_chars(s2, _T(" \t"), _T(""));
225 }
226 if (ignore_numbers)
227 {
228 strutils::replace_chars(s1, _T("0123456789"), _T(""));
229 strutils::replace_chars(s2, _T("0123456789"), _T(""));
230 }
231 return s2.compare(s1);
232}
233
234/**
235 * @brief stringdiffs constructor simply loads all members from arguments

Callers 7

FlagTrivialLinesMethod · 0.85
ComputeOpType3wayMethod · 0.85
TEST_FFunction · 0.85
CompareBufferWithDiyFpFunction · 0.85
EqualMethod · 0.85
LessEqualMethod · 0.85
LessMethod · 0.85

Calls 4

replace_charsFunction · 0.85
makelowerFunction · 0.50
replaceFunction · 0.50
compareMethod · 0.45

Tested by 1

TEST_FFunction · 0.68