# # # patch "src/util/DiffParser.cpp" # from [4a0256295820e64a621bee2c82c34357ac711b91] # to [32f4fa2ef30289c8834b08a70bfb69ab242b6e04] # ============================================================ --- src/util/DiffParser.cpp 4a0256295820e64a621bee2c82c34357ac711b91 +++ src/util/DiffParser.cpp 32f4fa2ef30289c8834b08a70bfb69ab242b6e04 @@ -31,7 +31,7 @@ DiffParser::~DiffParser() DiffParser::~DiffParser() { - qDeleteAll(fileDiffs); + qDeleteAll(fileDiffs); fileDiffs.clear(); } @@ -42,38 +42,38 @@ void DiffParser::parse(const QString & i W("Nothing to parse"); return; } - + // remove last newline character QString in(input); in.chop(1); - + // split the output into lines QStringList lines = in.split(QChar('\n')); - + QString curFile; - + Diff * curDiff = 0; DiffHunk * curHunk = 0; - + for (int i=0, s=lines.size(); i 0); QChar curChar = line.at(0); - + // // parse file diff separators, setup new DiffFile object // if (curChar == '=') { I(i < (s-1)); - + // straightly go to the next line QString nextGroup(lines.at(++i)); - + // create a new diff curDiff = new Diff(); - + // check if this is a binary QRegExp rx = QRegExp("^#\\s(.+)\\sis binary"); if (rx.indexIn(nextGroup) != -1) @@ -93,34 +93,34 @@ void DiffParser::parse(const QString & i // the cset i++; } - + fileDiffs.insert(curFile, curDiff); continue; } - + I(curDiff); - + // // parse hunk lines, setup new hunk object // if (curChar == '@') { - QRegExp rx = QRegExp("^@@\\s+\\-(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))\\s+@@"); + QRegExp rx = QRegExp("^@@\\s+\\-(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@"); I(rx.indexIn(line) > -1); QStringList list = rx.capturedTexts(); I(list.size() >= 2); - + // create a new Hunk curHunk = new DiffHunk(); curDiff->hunks.push_back(curHunk); - + // extract line numbers and positions curHunk->leftStart = list.at(1).toInt(); if (list.at(2).length() > 0) curHunk->leftCount = list.at(3).toInt(); else curHunk->leftCount = 1; - + curHunk->rightStart = list.at(4).toInt(); if (list.at(5).length() > 0) curHunk->rightCount = list.at(6).toInt(); @@ -129,13 +129,13 @@ void DiffParser::parse(const QString & i continue; } - + I(curHunk); - + DiffLine * diffLine = new DiffLine(); curHunk->lines.push_back(diffLine); diffLine->content = line.mid(1); - + if (curChar == '+') diffLine->state = DiffLine::Added; else if (curChar == '-') diffLine->state = DiffLine::Removed; else if (curChar == ' ') diffLine->state = DiffLine::Unchanged;