Commit 80c9636a authored by Michael Reeves's avatar Michael Reeves

fix formatting.

parent 80bc904b
......@@ -22,20 +22,38 @@
enum e_MergeOperation
{
eTitleId,
eNoOperation,
// Operations in sync mode (with only two directories):
eCopyAToB, eCopyBToA, eDeleteA, eDeleteB, eDeleteAB, eMergeToA, eMergeToB, eMergeToAB,
// Operations in merge mode (with two or three directories)
eCopyAToDest, eCopyBToDest, eCopyCToDest, eDeleteFromDest, eMergeABCToDest,
eMergeABToDest,
eConflictingFileTypes, // Error
eChangedAndDeleted, // Error
eConflictingAges // Equal age but files are not!
eTitleId,
eNoOperation,
// Operations in sync mode (with only two directories):
eCopyAToB,
eCopyBToA,
eDeleteA,
eDeleteB,
eDeleteAB,
eMergeToA,
eMergeToB,
eMergeToAB,
// Operations in merge mode (with two or three directories)
eCopyAToDest,
eCopyBToDest,
eCopyCToDest,
eDeleteFromDest,
eMergeABCToDest,
eMergeABToDest,
eConflictingFileTypes, // Error
eChangedAndDeleted, // Error
eConflictingAges // Equal age but files are not!
};
enum e_Age { eNew, eMiddle, eOld, eNotThere, eAgeEnd };
enum e_Age
{
eNew,
eMiddle,
eOld,
eNotThere,
eAgeEnd
};
enum e_OperationStatus
{
......@@ -124,10 +142,10 @@ class MergeFileInfos
FileAccess* m_pFileInfoC;
QSharedPointer<DirectoryInfo> m_dirInfo;
TotalDiffStatus m_totalDiffStatus;
public:
public:
e_MergeOperation m_eMergeOperation;
e_OperationStatus m_eOpStatus;
e_Age m_ageA;
......
......@@ -228,7 +228,8 @@ void SourceData::FileData::reset()
bool SourceData::FileData::readFile(FileAccess& file)
{
reset();
if(file.fileName().isEmpty()) {
if(file.fileName().isEmpty())
{
return true;
}
......@@ -255,7 +256,8 @@ bool SourceData::FileData::readFile(FileAccess& file)
bool SourceData::FileData::readFile(const QString& filename)
{
reset();
if(filename.isEmpty()) {
if(filename.isEmpty())
{
return true;
}
......@@ -286,7 +288,8 @@ bool SourceData::saveNormalDataAs(const QString& fileName)
bool SourceData::FileData::writeFile(const QString& filename)
{
if(filename.isEmpty()) {
if(filename.isEmpty())
{
return true;
}
......@@ -675,7 +678,7 @@ void SourceData::FileData::checkLineForComments(
bool& bWhite, // false if this line contains nonwhite characters (in, out)
bool& bCommentInLine, // true if any comment is within this line (in, out)
bool& bStartsOpenComment // true if the line ends within an comment (out)
)
)
{
bStartsOpenComment = false;
for(; i < size; ++i)
......@@ -734,7 +737,8 @@ void SourceData::FileData::checkLineForComments(
if(!bWhite)
{
size = i - commentStart;
m_unicodeBuf.replace(commentStart, size, QString(" ").repeated(size)); }
m_unicodeBuf.replace(commentStart, size, QString(" ").repeated(size));
}
return;
}
}
......@@ -809,7 +813,7 @@ void SourceData::FileData::removeComments()
bool SourceData::isLineOrBufEnd(const QChar* p, int i, int size)
{
return i >= size // End of file
return i >= size // End of file
|| Utils::isEndOfLine(p[i]) // Normal end of line
// No support for Mac-end of line yet, because incompatible with GNU-diff-routines.
......@@ -820,7 +824,7 @@ bool SourceData::isLineOrBufEnd(const QChar* p, int i, int size)
// Convert the input file from input encoding to output encoding and write it to the output file.
bool SourceData::convertFileEncoding(const QString& fileNameIn, QTextCodec* pCodecIn,
const QString& fileNameOut, QTextCodec* pCodecOut)
const QString& fileNameOut, QTextCodec* pCodecOut)
{
QFile in(fileNameIn);
if(!in.open(QIODevice::ReadOnly))
......@@ -900,9 +904,9 @@ QTextCodec* SourceData::detectEncoding(const char* buf, qint64 size, qint64& ski
We don't need the whole file here just the header.
] */
if(size <= 5000)
s=QByteArray(buf, (int)size);
s = QByteArray(buf, (int)size);
else
s=QByteArray(buf, 5000);
s = QByteArray(buf, 5000);
int xmlHeaderPos = s.indexOf("<?xml");
if(xmlHeaderPos >= 0)
......
......@@ -21,9 +21,9 @@
#include <ctype.h>
#include <map>
#include <qglobal.h>
#include <KLocalizedString>
#include <KMessageBox>
#include <qglobal.h>
int LineData::width(int tabSize) const
{
......@@ -560,9 +560,9 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
GnuDiff::comparison comparisonInput;
memset(&comparisonInput, 0, sizeof(comparisonInput));
comparisonInput.parent = nullptr;
comparisonInput.file[0].buffer = p1[0].getLine(); //ptr to buffer
comparisonInput.file[0].buffer = p1[0].getLine(); //ptr to buffer
comparisonInput.file[0].buffered = (p1[size1 - 1].getLine() - p1[0].getLine() + p1[size1 - 1].size()); // size of buffer
comparisonInput.file[1].buffer = p2[0].getLine(); //ptr to buffer
comparisonInput.file[1].buffer = p2[0].getLine(); //ptr to buffer
comparisonInput.file[1].buffered = (p2[size2 - 1].getLine() - p2[0].getLine() + p2[size2 - 1].size()); // size of buffer
gnuDiff.ignore_white_space = GnuDiff::IGNORE_ALL_SPACE; // I think nobody needs anything else ...
......@@ -639,8 +639,8 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
}
bool ManualDiffHelpList::runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineRef size2, DiffList& diffList,
e_SrcSelector winIdx1, e_SrcSelector winIdx2,
Options* pOptions)
e_SrcSelector winIdx1, e_SrcSelector winIdx2,
Options* pOptions)
{
diffList.clear();
DiffList diffList2;
......@@ -934,7 +934,8 @@ void calcDiff3LineListTrim(
if(line > lineA && i3->getLineA().isValid() && !i3->isEqualAB() && !i3->isEqualAC() &&
pManualDiffHelpList->isValidMove(i3->getLineA(), (*i3A).getLineB(), A, B) &&
pManualDiffHelpList->isValidMove(i3->getLineA(), (*i3A).getLineC(), A, C)) {
pManualDiffHelpList->isValidMove(i3->getLineA(), (*i3A).getLineC(), A, C))
{
// Empty space for A. A doesn't match B or C. Move it up.
(*i3A).setLineA(i3->getLineA());
i3->getLineA().invalidate();
......@@ -976,8 +977,8 @@ void calcDiff3LineListTrim(
}
if(line > lineC && i3->getLineC().isValid() && !i3->isEqualAC() && !i3->isEqualBC() &&
pManualDiffHelpList->isValidMove( i3->getLineC(), (*i3C).getLineA(), C, A) &&
pManualDiffHelpList->isValidMove( i3->getLineC(), (*i3C).getLineB(), C, B))
pManualDiffHelpList->isValidMove(i3->getLineC(), (*i3C).getLineA(), C, A) &&
pManualDiffHelpList->isValidMove(i3->getLineC(), (*i3C).getLineB(), C, B))
{
// Empty space for C. C matches neither A nor B. Move C up.
(*i3C).setLineC(i3->getLineC());
......@@ -1003,8 +1004,8 @@ void calcDiff3LineListTrim(
Diff3LineList::iterator i = lineA > lineB ? i3A : i3B;
int l = lineA > lineB ? lineA : lineB;
if(pManualDiffHelpList->isValidMove( i->getLineC(), i3->getLineA(), C, A) &&
pManualDiffHelpList->isValidMove( i->getLineC(), i3->getLineB(), C, B))
if(pManualDiffHelpList->isValidMove(i->getLineC(), i3->getLineA(), C, A) &&
pManualDiffHelpList->isValidMove(i->getLineC(), i3->getLineB(), C, B))
{
(*i).setLineA(i3->getLineA());
(*i).setLineB(i3->getLineB());
......@@ -1063,8 +1064,8 @@ void calcDiff3LineListTrim(
Diff3LineList::iterator i = lineB > lineC ? i3B : i3C;
int l = lineB > lineC ? lineB : lineC;
if(pManualDiffHelpList->isValidMove( i->getLineA(), i3->getLineB(), A, B) &&
pManualDiffHelpList->isValidMove( i->getLineA(), i3->getLineC(), A, C))
if(pManualDiffHelpList->isValidMove(i->getLineA(), i3->getLineB(), A, B) &&
pManualDiffHelpList->isValidMove(i->getLineA(), i3->getLineC(), A, C))
{
(*i).setLineB(i3->getLineB());
(*i).setLineC(i3->getLineC());
......@@ -1147,7 +1148,7 @@ void Diff3LineList::calcWhiteDiff3Lines(
{
Diff3LineList::iterator i3;
for(i3=begin(); i3 != end(); ++i3)
for(i3 = begin(); i3 != end(); ++i3)
{
i3->bWhiteLineA = (!i3->getLineA().isValid() || pldA == nullptr || pldA[i3->getLineA()].whiteLine() || pldA[i3->getLineA()].isPureComment());
i3->bWhiteLineB = (!i3->getLineA().isValid() || pldB == nullptr || pldB[i3->getLineB()].whiteLine() || pldB[i3->getLineB()].isPureComment());
......@@ -1391,8 +1392,8 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector,
}
void Diff3Line::getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int& lineIdx,
DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
int& changed, int& changed2) const
DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
int& changed, int& changed2) const
{
changed = 0;
changed2 = 0;
......@@ -1401,7 +1402,8 @@ void Diff3Line::getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int
bool bBEqualC = this->isEqualBC() || (bWhiteLineB && bWhiteLineC);
Q_ASSERT(winIdx >= A && winIdx <= C);
if(winIdx == A) {
if(winIdx == A)
{
lineIdx = getLineA();
pFineDiff1 = pFineAB;
pFineDiff2 = pFineCA;
......
......@@ -56,9 +56,9 @@ static GNULineRef too_expensive; /* Edit scripts longer than this are too
#define SNAKE_LIMIT 20 /* Snakes bigger than this are considered `big'. */
struct partition {
GNULineRef xmid, ymid; /* Midpoints of this partition. */
bool lo_minimal; /* Nonzero if low half will be analyzed minimally. */
bool hi_minimal; /* Likewise for high half. */
GNULineRef xmid, ymid; /* Midpoints of this partition. */
bool lo_minimal; /* Nonzero if low half will be analyzed minimally. */
bool hi_minimal; /* Likewise for high half. */
};
/* Find the midpoint of the shortest edit script for a specified
......@@ -93,7 +93,7 @@ struct partition {
It cannot cause incorrect diff output. */
GNULineRef GnuDiff::diag(GNULineRef xoff, GNULineRef xlim, GNULineRef yoff, GNULineRef ylim, bool find_minimal,
partition *part)
partition *part)
{
GNULineRef *const fd = fdiag; /* Give the compiler a chance. */
GNULineRef *const bd = bdiag; /* Additional help for the compiler. */
......@@ -106,7 +106,7 @@ GNULineRef GnuDiff::diag(GNULineRef xoff, GNULineRef xlim, GNULineRef yoff, GNUL
GNULineRef fmin = fmid, fmax = fmid; /* Limits of top-down search. */
GNULineRef bmin = bmid, bmax = bmid; /* Limits of bottom-up search. */
GNULineRef c; /* Cost. */
bool odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd
bool odd = (fmid - bmid) & 1; /* True if southeast corner is on an odd
diagonal with respect to the northwest. */
fd[fmid] = xoff;
......
......@@ -40,7 +40,7 @@ static_assert(std::is_unsigned<hash_value>::value, "hash_value must be signed.")
but only while the classes are being computed.
Afterward, each class is represented by a number. */
struct equivclass {
GNULineRef next; /* Next item in this bucket. */
GNULineRef next; /* Next item in this bucket. */
hash_value hash; /* Hash of lines in this class. */
const QChar *line; /* A line that fits this class. */
size_t length; /* That line's length, not counting its newline. */
......@@ -163,42 +163,42 @@ void GnuDiff::find_and_hash_each_line(file_data *current)
if(ignore_case)
switch(ignore_white_space)
{
case IGNORE_ALL_SPACE:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.toLower().unicode());
++p;
}
break;
case IGNORE_ALL_SPACE:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.toLower().unicode());
++p;
}
break;
default:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.toLower().unicode());
++p;
}
break;
default:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.toLower().unicode());
++p;
}
break;
}
else
switch(ignore_white_space)
{
case IGNORE_ALL_SPACE:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.unicode());
++p;
}
break;
case IGNORE_ALL_SPACE:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.unicode());
++p;
}
break;
default:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.unicode());
++p;
}
break;
default:
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.unicode());
++p;
}
break;
}
bucket = &buckets[h % nbuckets];
......
......@@ -38,7 +38,7 @@ bool Merger::MergeData::eq()
bool Merger::MergeData::isEnd()
{
return (pDiffList == nullptr || (it == pDiffList->end() && d.nofEquals == 0 &&
(idx == 0 ? d.diff1 == 0 : d.diff2 == 0)));
(idx == 0 ? d.diff1 == 0 : d.diff2 == 0)));
}
void Merger::MergeData::update()
......
......@@ -14,42 +14,40 @@
#include "diff.h"
class Merger
{
public:
Merger( const DiffList* pDiffList1, const DiffList* pDiffList2 );
public:
Merger(const DiffList* pDiffList1, const DiffList* pDiffList2);
/** Go one step. */
void next();
/** Go one step. */
void next();
/** Information about what changed. Can be used for coloring.
/** Information about what changed. Can be used for coloring.
The return value is 0 if nothing changed here,
bit 1 is set if a difference from pDiffList1 was detected,
bit 2 is set if a difference from pDiffList2 was detected.
*/
int whatChanged();
/** End of both diff lists reached. */
bool isEndReached();
private:
struct MergeData
{
DiffList::const_iterator it;
const DiffList* pDiffList;
Diff d;
int idx;
MergeData( const DiffList* p, int i );
bool eq();
void update();
bool isEnd();
};
MergeData md1;
MergeData md2;
int whatChanged();
/** End of both diff lists reached. */
bool isEndReached();
private:
struct MergeData
{
DiffList::const_iterator it;
const DiffList* pDiffList;
Diff d;
int idx;
MergeData(const DiffList* p, int i);
bool eq();
void update();
bool isEnd();
};
MergeData md1;
MergeData md2;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment