Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SDK
libkomparediff2
Commits
992708b1
Commit
992708b1
authored
Oct 30, 2022
by
Volker Krause
Browse files
Port diff header parsing to QRegularExpression
parent
9faf8b56
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cvsdiffparser.cpp
View file @
992708b1
...
...
@@ -17,10 +17,10 @@ CVSDiffParser::CVSDiffParser(const KompareModelList* list, const QStringList& di
{
// The regexps needed for context cvs diff parsing, the rest is the same as in parserbase.cpp
// third capture in header1 is non optional for cvs diff, it is the revision
m_contextDiffHeader1
.
setPattern
(
QStringLiteral
(
"
\\
*
\\
*
\\
* ([^
\\
t]+)
\\
t([^
\\
t]+)
\\
t(.*)
\\
n"
));
m_contextDiffHeader2
.
setPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)
\\
t([^
\\
t]+)(|
\\
t(.*))
\\
n"
));
m_contextDiffHeader1
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"
\\
*
\\
*
\\
* ([^
\\
t]+)
\\
t([^
\\
t]+)
\\
t(.*)
\\
n"
))
)
;
m_contextDiffHeader2
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)
\\
t([^
\\
t]+)(|
\\
t(.*))
\\
n"
))
)
;
m_normalDiffHeader
.
setPattern
(
QStringLiteral
(
"Index: (.*)
\\
n"
));
m_normalDiffHeader
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"Index: (.*)
\\
n"
))
)
;
}
CVSDiffParser
::~
CVSDiffParser
()
...
...
@@ -81,14 +81,15 @@ bool CVSDiffParser::parseNormalDiffHeader()
while
(
m_diffIterator
!=
diffEnd
)
{
if
(
m_normalDiffHeader
.
exactMatch
(
*
m_diffIterator
))
const
auto
normalDiffHeaderMatch
=
m_normalDiffHeader
.
match
(
*
m_diffIterator
);
if
(
normalDiffHeaderMatch
.
hasMatch
())
{
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length Header = "
<<
m_
normalDiffHeader
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched string Header = "
<<
m_
normalDiffHeader
.
cap
(
0
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length Header = "
<<
normalDiffHeader
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched string Header = "
<<
normalDiffHeader
Match
.
captured
(
0
);
m_currentModel
=
new
DiffModel
();
m_currentModel
->
setSourceFile
(
m_
normalDiffHeader
.
cap
(
1
));
m_currentModel
->
setDestinationFile
(
m_
normalDiffHeader
.
cap
(
1
));
m_currentModel
->
setSourceFile
(
normalDiffHeader
Match
.
captured
(
1
));
m_currentModel
->
setDestinationFile
(
normalDiffHeader
Match
.
captured
(
1
));
result
=
true
;
...
...
src/diffparser.cpp
View file @
992708b1
...
...
@@ -15,8 +15,8 @@ using namespace Diff2;
DiffParser
::
DiffParser
(
const
KompareModelList
*
list
,
const
QStringList
&
diff
)
:
ParserBase
(
list
,
diff
)
{
// The regexps needed for context diff parsing, the rest is the same as in parserbase.cpp
m_contextDiffHeader1
.
setPattern
(
QStringLiteral
(
"
\\
*
\\
*
\\
* ([^
\\
t]+)(
\\
t([^
\\
t]+))?
\\
n"
));
m_contextDiffHeader2
.
setPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)(
\\
t([^
\\
t]+))?
\\
n"
));
m_contextDiffHeader1
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"
\\
*
\\
*
\\
* ([^
\\
t]+)(
\\
t([^
\\
t]+))?
\\
n"
))
)
;
m_contextDiffHeader2
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)(
\\
t([^
\\
t]+))?
\\
n"
))
)
;
}
DiffParser
::~
DiffParser
()
...
...
src/parserbase.cpp
View file @
992708b1
...
...
@@ -80,7 +80,7 @@ ParserBase::ParserBase(const KompareModelList* list, const QStringList& diff) :
m_contextHunkBodyLine
.
setPattern
(
QStringLiteral
(
"[-
\\
+! ] (.*)"
));
// This regexp sucks... i'll see what happens
m_normalDiffHeader
.
setPattern
(
QStringLiteral
(
"diff (?:(?:-|--)[a-zA-Z0-9=
\\\"
]+ )*(?:|-- +)(.*) +(.*)
\\
n"
));
m_normalDiffHeader
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"diff (?:(?:-|--)[a-zA-Z0-9=
\\\"
]+ )*(?:|-- +)(.*) +(.*)
\\
n"
))
)
;
m_normalHunkHeaderAdded
.
setPattern
(
QStringLiteral
(
"([0-9]+)a([0-9]+)(|,[0-9]+)(.*)
\\
n"
));
m_normalHunkHeaderRemoved
.
setPattern
(
QStringLiteral
(
"([0-9]+)(|,[0-9]+)d([0-9]+)(.*)
\\
n"
));
...
...
@@ -90,8 +90,8 @@ ParserBase::ParserBase(const KompareModelList* list, const QStringList& diff) :
m_normalHunkBodyAdded
.
setPattern
(
QStringLiteral
(
"> (.*)"
));
m_normalHunkBodyDivider
.
setPattern
(
QStringLiteral
(
"---
\\
n"
));
m_unifiedDiffHeader1
.
setPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)(?:
\\
t([^
\\
t]+)(?:
\\
t?)(.*))?
\\
n"
));
m_unifiedDiffHeader2
.
setPattern
(
QStringLiteral
(
"
\\
+
\\
+
\\
+ ([^
\\
t]+)(?:
\\
t([^
\\
t]+)(?:
\\
t?)(.*))?
\\
n"
));
m_unifiedDiffHeader1
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"--- ([^
\\
t]+)(?:
\\
t([^
\\
t]+)(?:
\\
t?)(.*))?
\\
n"
))
)
;
m_unifiedDiffHeader2
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"
\\
+
\\
+
\\
+ ([^
\\
t]+)(?:
\\
t([^
\\
t]+)(?:
\\
t?)(.*))?
\\
n"
))
)
;
m_unifiedHunkHeader
.
setPattern
(
QStringLiteral
(
"@@ -([0-9]+)(|,([0-9]+))
\\
+([0-9]+)(|,([0-9]+)) @@(?: ?)(.*)
\\
n"
));
m_unifiedHunkBodyAdded
.
setPattern
(
QStringLiteral
(
"
\\
+(.*)"
));
m_unifiedHunkBodyRemoved
.
setPattern
(
QStringLiteral
(
"-(.*)"
));
...
...
@@ -151,22 +151,24 @@ bool ParserBase::parseContextDiffHeader()
while
(
m_diffIterator
!=
m_diffLines
.
end
())
{
if
(
!
m_contextDiffHeader1
.
exactMatch
(
*
(
m_diffIterator
)
++
))
const
auto
contextDiffHeader1Match
=
m_contextDiffHeader1
.
match
(
*
(
m_diffIterator
)
++
);
if
(
!
contextDiffHeader1Match
.
hasMatch
())
{
continue
;
}
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " << m_contextDiffHeader1.matchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " << m_contextDiffHeader1.cap( 0 );
if
(
m_diffIterator
!=
m_diffLines
.
end
()
&&
m_contextDiffHeader2
.
exactMatch
(
*
m_diffIterator
))
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " << contextDiffHeader1Match.capturedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " << contextDiffHeader1Match.captured( 0 );
const
auto
contextDiffHeader2Match
=
m_contextDiffHeader2
.
match
(
*
m_diffIterator
);
if
(
m_diffIterator
!=
m_diffLines
.
end
()
&&
contextDiffHeader2Match
.
hasMatch
())
{
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header2 = " <<
m_
contextDiffHeader2
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header2 = " <<
m_
contextDiffHeader2
.cap
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header2 = " << contextDiffHeader2
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header2 = " << contextDiffHeader2
Match.captured
( 0 );
m_currentModel
=
new
DiffModel
(
unescapePath
(
m_
contextDiffHeader1
.
cap
(
1
)),
unescapePath
(
m_
contextDiffHeader2
.
cap
(
1
)));
m_currentModel
->
setSourceTimestamp
(
m_
contextDiffHeader1
.
cap
(
3
));
m_currentModel
->
setSourceRevision
(
m_
contextDiffHeader1
.
cap
(
5
));
m_currentModel
->
setDestinationTimestamp
(
m_
contextDiffHeader2
.
cap
(
3
));
m_currentModel
->
setDestinationRevision
(
m_
contextDiffHeader2
.
cap
(
5
));
m_currentModel
=
new
DiffModel
(
unescapePath
(
contextDiffHeader1
Match
.
captured
(
1
)),
unescapePath
(
contextDiffHeader2
Match
.
captured
(
1
)));
m_currentModel
->
setSourceTimestamp
(
contextDiffHeader1
Match
.
captured
(
3
));
m_currentModel
->
setSourceRevision
(
contextDiffHeader1
Match
.
captured
(
5
));
m_currentModel
->
setDestinationTimestamp
(
contextDiffHeader2
Match
.
captured
(
3
));
m_currentModel
->
setDestinationRevision
(
contextDiffHeader2
Match
.
captured
(
5
));
++
m_diffIterator
;
result
=
true
;
...
...
@@ -198,14 +200,15 @@ bool ParserBase::parseNormalDiffHeader()
while
(
m_diffIterator
!=
m_diffLines
.
end
())
{
if
(
m_normalDiffHeader
.
exactMatch
(
*
m_diffIterator
))
const
auto
normalDiffHeaderMatch
=
m_normalDiffHeader
.
match
(
*
m_diffIterator
);
if
(
normalDiffHeaderMatch
.
hasMatch
())
{
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header = " <<
m_
normalDiffHeader
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header = " <<
m_
normalDiffHeader
.cap
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header = " << normalDiffHeader
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header = " << normalDiffHeader
Match.captured
( 0 );
m_currentModel
=
new
DiffModel
();
m_currentModel
->
setSourceFile
(
unescapePath
(
m_
normalDiffHeader
.
cap
(
1
)));
m_currentModel
->
setDestinationFile
(
unescapePath
(
m_
normalDiffHeader
.
cap
(
2
)));
m_currentModel
->
setSourceFile
(
unescapePath
(
normalDiffHeader
Match
.
captured
(
1
)));
m_currentModel
->
setDestinationFile
(
unescapePath
(
normalDiffHeader
Match
.
captured
(
2
)));
result
=
true
;
...
...
@@ -242,21 +245,23 @@ bool ParserBase::parseUnifiedDiffHeader()
while
(
m_diffIterator
!=
m_diffLines
.
end
())
// do not assume we start with the diffheader1 line
{
if
(
!
m_unifiedDiffHeader1
.
exactMatch
(
*
m_diffIterator
))
const
auto
unifiedDiffHeader1Match
=
m_unifiedDiffHeader1
.
match
(
*
m_diffIterator
);
if
(
!
unifiedDiffHeader1Match
.
hasMatch
())
{
++
m_diffIterator
;
continue
;
}
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " <<
m_
unifiedDiffHeader1
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " <<
m_
unifiedDiffHeader1
.cap
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " << unifiedDiffHeader1
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " << unifiedDiffHeader1
Match.captured
( 0 );
++
m_diffIterator
;
if
(
m_diffIterator
!=
m_diffLines
.
end
()
&&
m_unifiedDiffHeader2
.
exactMatch
(
*
m_diffIterator
))
const
auto
unifiedDiffHeader2Match
=
m_unifiedDiffHeader2
.
match
(
*
m_diffIterator
);
if
(
m_diffIterator
!=
m_diffLines
.
end
()
&&
unifiedDiffHeader2Match
.
hasMatch
())
{
m_currentModel
=
new
DiffModel
(
unescapePath
(
m_
unifiedDiffHeader1
.
cap
(
1
)),
unescapePath
(
m_
unifiedDiffHeader2
.
cap
(
1
)));
m_currentModel
->
setSourceTimestamp
(
m_
unifiedDiffHeader1
.
cap
(
2
));
m_currentModel
->
setSourceRevision
(
m_
unifiedDiffHeader1
.
cap
(
4
));
m_currentModel
->
setDestinationTimestamp
(
m_
unifiedDiffHeader2
.
cap
(
2
));
m_currentModel
->
setDestinationRevision
(
m_
unifiedDiffHeader2
.
cap
(
4
));
m_currentModel
=
new
DiffModel
(
unescapePath
(
unifiedDiffHeader1
Match
.
captured
(
1
)),
unescapePath
(
unifiedDiffHeader2
Match
.
captured
(
1
)));
m_currentModel
->
setSourceTimestamp
(
unifiedDiffHeader1
Match
.
captured
(
2
));
m_currentModel
->
setSourceRevision
(
unifiedDiffHeader1
Match
.
captured
(
4
));
m_currentModel
->
setDestinationTimestamp
(
unifiedDiffHeader2
Match
.
captured
(
2
));
m_currentModel
->
setDestinationRevision
(
unifiedDiffHeader2
Match
.
captured
(
4
));
++
m_diffIterator
;
result
=
true
;
...
...
@@ -660,10 +665,10 @@ bool ParserBase::parseUnifiedHunkBody()
return
true
;
}
void
ParserBase
::
checkHeader
(
const
QReg
Exp
&
header
)
void
ParserBase
::
checkHeader
(
const
QReg
ularExpression
&
header
)
{
if
(
m_diffIterator
!=
m_diffLines
.
end
()
&&
!
header
.
exactM
atch
(
*
m_diffIterator
)
&&
!
header
.
m
atch
(
*
m_diffIterator
)
.
hasMatch
()
&&
!
m_diffIterator
->
startsWith
(
QLatin1String
(
"Index: "
))
/* SVN diff */
&&
!
m_diffIterator
->
startsWith
(
QLatin1String
(
"diff "
))
/* concatenated diff */
&&
!
m_diffIterator
->
startsWith
(
QLatin1String
(
"-- "
))
/* git format-patch */
)
...
...
src/parserbase.h
View file @
992708b1
...
...
@@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#ifndef DIFF2_PARSERBASE_H
#define DIFF2_PARSERBASE_H
#include
<QRegularExpression>
#include
<QRegExp>
#include
<QStringList>
...
...
@@ -63,7 +64,7 @@ protected:
protected:
// Helper methods to speed things up
bool
matchesUnifiedHunkLine
(
const
QString
&
line
)
const
;
void
checkHeader
(
const
QReg
Exp
&
header
);
void
checkHeader
(
const
QReg
ularExpression
&
header
);
protected:
/** What is format of the diff */
...
...
@@ -71,8 +72,8 @@ protected:
protected:
// Regexps for context parsing
QReg
Exp
m_contextDiffHeader1
;
QReg
Exp
m_contextDiffHeader2
;
QReg
ularExpression
m_contextDiffHeader1
;
QReg
ularExpression
m_contextDiffHeader2
;
QRegExp
m_contextHunkHeader1
;
QRegExp
m_contextHunkHeader2
;
...
...
@@ -85,7 +86,7 @@ protected:
QRegExp
m_contextHunkBodyLine
;
// Added for convenience
// Regexps for normal parsing
QReg
Exp
m_normalDiffHeader
;
QReg
ularExpression
m_normalDiffHeader
;
QRegExp
m_normalHunkHeaderAdded
;
QRegExp
m_normalHunkHeaderRemoved
;
...
...
@@ -98,11 +99,11 @@ protected:
enum
Difference
::
Type
m_normalDiffType
;
// RegExps for rcs parsing
QReg
Exp
m_rcsDiffHeader
;
QReg
ularExpression
m_rcsDiffHeader
;
// Regexps for unified parsing
QReg
Exp
m_unifiedDiffHeader1
;
QReg
Exp
m_unifiedDiffHeader2
;
QReg
ularExpression
m_unifiedDiffHeader1
;
QReg
ularExpression
m_unifiedDiffHeader2
;
QRegExp
m_unifiedHunkHeader
;
...
...
src/perforceparser.cpp
View file @
992708b1
...
...
@@ -15,14 +15,14 @@ using namespace Diff2;
PerforceParser
::
PerforceParser
(
const
KompareModelList
*
list
,
const
QStringList
&
diff
)
:
ParserBase
(
list
,
diff
)
{
m_contextDiffHeader1
.
setPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
));
m_contextDiffHeader1
.
set
Minimal
(
true
);
m_normalDiffHeader
.
setPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
));
m_normalDiffHeader
.
set
Minimal
(
true
);
m_rcsDiffHeader
.
setPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
));
m_rcsDiffHeader
.
set
Minimal
(
true
);
m_unifiedDiffHeader1
.
setPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
));
m_unifiedDiffHeader1
.
set
Minimal
(
true
);
m_contextDiffHeader1
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
))
)
;
m_contextDiffHeader1
.
set
PatternOptions
(
QRegularExpression
::
InvertedGreedinessOption
);
m_normalDiffHeader
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
))
)
;
m_normalDiffHeader
.
set
PatternOptions
(
QRegularExpression
::
InvertedGreedinessOption
);
m_rcsDiffHeader
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
))
)
;
m_rcsDiffHeader
.
set
PatternOptions
(
QRegularExpression
::
InvertedGreedinessOption
);
m_unifiedDiffHeader1
.
setPattern
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"==== (.*) - (.*) ====
\\
n"
))
)
;
m_unifiedDiffHeader1
.
set
PatternOptions
(
QRegularExpression
::
InvertedGreedinessOption
);
}
PerforceParser
::~
PerforceParser
()
...
...
@@ -81,16 +81,17 @@ bool PerforceParser::parseContextDiffHeader()
while
(
m_diffIterator
!=
itEnd
)
{
if
(
m_contextDiffHeader1
.
exactMatch
(
*
(
m_diffIterator
)
++
))
const
auto
contextDiffHeader1Match
=
m_contextDiffHeader1
.
match
(
*
(
m_diffIterator
)
++
);
if
(
contextDiffHeader1Match
.
hasMatch
())
{
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " <<
m_
contextDiffHeader1
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " <<
m_
contextDiffHeader1
.cap
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "First capture Header1 = " <<
m_
contextDiffHeader1
.cap
( 1 );
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = " <<
m_
contextDiffHeader1
.cap
( 2 );
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " << contextDiffHeader1
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " << contextDiffHeader1
Match.captured
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "First capture Header1 = " << contextDiffHeader1
Match.captured
( 1 );
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = " << contextDiffHeader1
Match.captured
( 2 );
m_currentModel
=
new
DiffModel
();
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
m_
contextDiffHeader1
.
cap
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
m_
contextDiffHeader1
.
cap
(
2
));
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
contextDiffHeader1
Match
.
captured
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
contextDiffHeader1
Match
.
captured
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileREMatch
.
capturedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileREMatch
.
capturedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileREMatch
.
capturedTexts
();
...
...
@@ -106,8 +107,8 @@ bool PerforceParser::parseContextDiffHeader()
}
else
{
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
m_
contextDiffHeader1
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
m_
contextDiffHeader1
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
contextDiffHeader1
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
contextDiffHeader1
Match
.
capturedTexts
();
}
}
...
...
@@ -127,16 +128,17 @@ bool PerforceParser::parseNormalDiffHeader()
{
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Line = "
<<
*
m_diffIterator
;
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"String length = "
<<
(
*
m_diffIterator
).
length
();
if
(
m_normalDiffHeader
.
exactMatch
(
*
(
m_diffIterator
)
++
))
const
auto
normalDiffHeaderMatch
=
m_normalDiffHeader
.
match
(
*
(
m_diffIterator
)
++
);
if
(
normalDiffHeaderMatch
.
hasMatch
())
{
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length Header1 = "
<<
m_
normalDiffHeader
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched string Header1 = "
<<
m_
normalDiffHeader
.
cap
(
0
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"First capture Header1 =
\"
"
<<
m_
normalDiffHeader
.
cap
(
1
)
<<
"
\"
"
;
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Second capture Header1 =
\"
"
<<
m_
normalDiffHeader
.
cap
(
2
)
<<
"
\"
"
;
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length Header1 = "
<<
normalDiffHeader
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched string Header1 = "
<<
normalDiffHeader
Match
.
captured
(
0
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"First capture Header1 =
\"
"
<<
normalDiffHeader
Match
.
captured
(
1
)
<<
"
\"
"
;
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Second capture Header1 =
\"
"
<<
normalDiffHeader
Match
.
captured
(
2
)
<<
"
\"
"
;
m_currentModel
=
new
DiffModel
();
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
m_
normalDiffHeader
.
cap
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
m_
normalDiffHeader
.
cap
(
2
));
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
normalDiffHeader
Match
.
captured
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
normalDiffHeader
Match
.
captured
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileREMatch
.
capturedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileREMatch
.
capturedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileREMatch
.
capturedTexts
();
...
...
@@ -152,8 +154,8 @@ bool PerforceParser::parseNormalDiffHeader()
}
else
{
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
m_
normalDiffHeader
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
m_
normalDiffHeader
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
normalDiffHeader
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
normalDiffHeader
Match
.
capturedTexts
();
}
}
...
...
@@ -178,16 +180,17 @@ bool PerforceParser::parseUnifiedDiffHeader()
{
// qCDebug(LIBKOMPAREDIFF2) << "Line = " << *m_diffIterator;
// qCDebug(LIBKOMPAREDIFF2) << "String length = " << (*m_diffIterator).length();
if
(
m_unifiedDiffHeader1
.
exactMatch
(
*
(
m_diffIterator
)
++
))
const
auto
unifiedDiffHeader1Match
=
m_unifiedDiffHeader1
.
match
(
*
(
m_diffIterator
)
++
);
if
(
unifiedDiffHeader1Match
.
hasMatch
())
{
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " <<
m_
unifiedDiffHeader1
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " <<
m_
unifiedDiffHeader1
.cap
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "First capture Header1 = \"" <<
m_
unifiedDiffHeader1
.cap
( 1 ) << "\"";
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = \"" <<
m_
unifiedDiffHeader1
.cap
( 2 ) << "\"";
// qCDebug(LIBKOMPAREDIFF2) << "Matched length Header1 = " << unifiedDiffHeader1
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched string Header1 = " << unifiedDiffHeader1
Match.captured
( 0 );
// qCDebug(LIBKOMPAREDIFF2) << "First capture Header1 = \"" << unifiedDiffHeader1
Match.captured
( 1 ) << "\"";
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = \"" << unifiedDiffHeader1
Match.captured
( 2 ) << "\"";
m_currentModel
=
new
DiffModel
();
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
m_
unifiedDiffHeader1
.
cap
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
m_
unifiedDiffHeader1
.
cap
(
2
));
const
auto
sourceFileREMatch
=
sourceFileRE
.
match
(
unifiedDiffHeader1
Match
.
captured
(
1
));
const
auto
destinationFileREMatch
=
destinationFileRE
.
match
(
unifiedDiffHeader1
Match
.
captured
(
2
));
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << sourceFileREMatch.capturedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << destinationFileREMatch.capturedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << sourceFileREMatch.capturedTexts();
...
...
@@ -203,8 +206,8 @@ bool PerforceParser::parseUnifiedDiffHeader()
}
else
{
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " <<
m_
unifiedDiffHeader1
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " <<
m_
unifiedDiffHeader1.capturedTexts();
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << unifiedDiffHeader1
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << unifiedDiffHeader1
Match
.capturedTexts();
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment