MCPcopy Create free account
hub / github.com/KDE/kdiff3 / equal

Method equal

src/diff.cpp:96–134  ·  view source on GitHub ↗

Implement support for g_bIgnoreWhiteSpace */

Source from the content-addressed store, hash-verified

94 Implement support for g_bIgnoreWhiteSpace
95*/
96bool LineData::equal(const LineData& l1, const LineData& l2)
97{
98 if(l1.getLine() == nullptr || l2.getLine() == nullptr) return false;
99
100 if(g_bIgnoreWhiteSpace)
101 {
102 // Ignore white space diff
103 const QString line1 = l1.getLine(), line2 = l2.getLine();
104 StringIter p1{line1};
105 StringIter p2{line2};
106
107 for(; ; p1.next(), p2.next())
108 {
109 // Advance to the next non-whitespace character or EOL.
110 while (p1.hasPeek() && isspace(p1.tryPeek()->toLatin1())) {
111 p1.next();
112 }
113 while (p2.hasPeek() && isspace(p2.tryPeek()->toLatin1())) {
114 p2.next();
115 }
116
117 // If the two strings differ outside of whitespace, or either ends earlier, return false.
118 if(p1.tryPeek() != p2.tryPeek())
119 return false;
120
121 // If both strings end together, return true.
122 if (!p1.hasPeek() && !p2.hasPeek()) {
123 return true;
124 }
125
126 // Test remaining characters.
127 }
128 }
129 else
130 {
131 const QString line1 = l1.getLine(), line2 = l2.getLine();
132 return (l1.size() == l2.size() && QString::compare(line1, line2) == 0);
133 }
134}
135
136// First step
137void Diff3LineList::calcDiff3LineListUsingAB(const DiffList* pDiffListAB)

Callers

nothing calls this directly

Calls 5

getLineMethod · 0.80
hasPeekMethod · 0.80
tryPeekMethod · 0.80
nextMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected