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

Function findParenthesesGroups

src/mergeresultwindow.cpp:936–963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

934}
935
936bool findParenthesesGroups(const QString& s, QStringList& sl)
937{
938 sl.clear();
939 qsizetype i = 0;
940 std::list<qsizetype> startPosStack;
941 qsizetype length = s.length();
942 for(i = 0; i < length; ++i)
943 {
944 if(s[i] == '\\' && i + 1 < length && (s[i + 1] == '\\' || s[i + 1] == '(' || s[i + 1] == ')'))
945 {
946 ++i;
947 continue;
948 }
949 if(s[i] == '(')
950 {
951 startPosStack.push_back(i);
952 }
953 else if(s[i] == ')')
954 {
955 if(startPosStack.empty())
956 return false; // Parentheses don't match
957 qsizetype startPos = startPosStack.back();
958 startPosStack.pop_back();
959 sl.push_back(s.mid(startPos + 1, i - startPos - 1));
960 }
961 }
962 return startPosStack.empty(); // false if parentheses don't match
963}
964
965QString calcHistorySortKey(const QString& keyOrder, QRegularExpressionMatch& regExprMatch, const QStringList& parenthesesGroupList)
966{

Callers 2

slotRecalcMethod · 0.85

Calls 2

push_backMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected