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
185f19e6
Commit
185f19e6
authored
Oct 30, 2022
by
Volker Krause
Browse files
Port Perforce file name matching to QRegularExpression
parent
ca931c8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/perforceparser.cpp
View file @
185f19e6
...
...
@@ -76,8 +76,8 @@ bool PerforceParser::parseContextDiffHeader()
QStringList
::
ConstIterator
itEnd
=
m_diffLines
.
end
();
QRegExp
sourceFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
));
QRegExp
destinationFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
));
const
QRegularExpression
sourceFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
))
)
;
const
QRegularExpression
destinationFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
))
)
;
while
(
m_diffIterator
!=
itEnd
)
{
...
...
@@ -89,16 +89,16 @@ bool PerforceParser::parseContextDiffHeader()
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = " << m_contextDiffHeader1.cap( 2 );
m_currentModel
=
new
DiffModel
();
sourceFileRE
.
exactM
atch
(
m_contextDiffHeader1
.
cap
(
1
));
destinationFileRE
.
exactM
atch
(
m_contextDiffHeader1
.
cap
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileRE
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileRE
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileRE
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
destinationFileRE
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Source File : "
<<
sourceFileRE
.
cap
(
1
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Destination File : "
<<
destinationFileRE
.
cap
(
1
);
m_currentModel
->
setSourceFile
(
sourceFileRE
.
cap
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
.
cap
(
1
));
const
auto
sourceFileRE
Match
=
sourceFileRE
.
m
atch
(
m_contextDiffHeader1
.
cap
(
1
));
const
auto
destinationFileRE
Match
=
destinationFileRE
.
m
atch
(
m_contextDiffHeader1
.
cap
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileRE
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileRE
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileRE
Match
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
destinationFileRE
Match
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Source File : "
<<
sourceFileRE
Match
.
captured
(
1
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Destination File : "
<<
destinationFileRE
Match
.
captured
(
1
);
m_currentModel
->
setSourceFile
(
sourceFileRE
Match
.
captured
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
Match
.
captured
(
1
));
result
=
true
;
...
...
@@ -120,8 +120,8 @@ bool PerforceParser::parseNormalDiffHeader()
QStringList
::
ConstIterator
itEnd
=
m_diffLines
.
end
();
QReg
Exp
sourceFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
));
QReg
Exp
destinationFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
));
QReg
ularExpression
sourceFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
))
)
;
QReg
ularExpression
destinationFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
))
)
;
while
(
m_diffIterator
!=
itEnd
)
{
...
...
@@ -135,16 +135,16 @@ bool PerforceParser::parseNormalDiffHeader()
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Second capture Header1 =
\"
"
<<
m_normalDiffHeader
.
cap
(
2
)
<<
"
\"
"
;
m_currentModel
=
new
DiffModel
();
sourceFileRE
.
exactM
atch
(
m_normalDiffHeader
.
cap
(
1
));
destinationFileRE
.
exactM
atch
(
m_normalDiffHeader
.
cap
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileRE
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileRE
.
m
atchedLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileRE
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
destinationFileRE
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Source File : "
<<
sourceFileRE
.
cap
(
1
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Destination File : "
<<
destinationFileRE
.
cap
(
1
);
m_currentModel
->
setSourceFile
(
sourceFileRE
.
cap
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
.
cap
(
1
));
const
auto
sourceFileRE
Match
=
sourceFileRE
.
m
atch
(
m_normalDiffHeader
.
cap
(
1
));
const
auto
destinationFileRE
Match
=
destinationFileRE
.
m
atch
(
m_normalDiffHeader
.
cap
(
2
));
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
sourceFileRE
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Matched length = "
<<
destinationFileRE
M
atch
.
captur
edLength
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
sourceFileRE
Match
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Captured texts = "
<<
destinationFileRE
Match
.
capturedTexts
();
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Source File : "
<<
sourceFileRE
Match
.
captured
(
1
);
qCDebug
(
LIBKOMPAREDIFF2
)
<<
"Destination File : "
<<
destinationFileRE
Match
.
captured
(
1
);
m_currentModel
->
setSourceFile
(
sourceFileRE
Match
.
captured
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
Match
.
captured
(
1
));
result
=
true
;
...
...
@@ -171,8 +171,8 @@ bool PerforceParser::parseUnifiedDiffHeader()
QStringList
::
ConstIterator
itEnd
=
m_diffLines
.
end
();
QReg
Exp
sourceFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
));
QReg
Exp
destinationFileRE
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
));
QReg
ularExpression
sourceFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(
\\
d+)"
))
)
;
QReg
ularExpression
destinationFileRE
(
QRegularExpression
::
anchoredPattern
(
QStringLiteral
(
"([^
\\
#]+)#(|
\\
d+)"
))
)
;
while
(
m_diffIterator
!=
itEnd
)
{
...
...
@@ -186,16 +186,16 @@ bool PerforceParser::parseUnifiedDiffHeader()
// qCDebug(LIBKOMPAREDIFF2) << "Second capture Header1 = \"" << m_unifiedDiffHeader1.cap( 2 ) << "\"";
m_currentModel
=
new
DiffModel
();
sourceFileRE
.
exactM
atch
(
m_unifiedDiffHeader1
.
cap
(
1
));
destinationFileRE
.
exactM
atch
(
m_unifiedDiffHeader1
.
cap
(
2
));
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << sourceFileRE
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << destinationFileRE
.m
atchedLength();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << sourceFileRE.capturedTexts();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << destinationFileRE.capturedTexts();
// qCDebug(LIBKOMPAREDIFF2) << "Source File : " << sourceFileRE
.cap
( 1 );
// qCDebug(LIBKOMPAREDIFF2) << "Destination File : " << destinationFileRE
.cap
( 1 );
m_currentModel
->
setSourceFile
(
sourceFileRE
.
cap
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
.
cap
(
1
));
const
auto
sourceFileRE
Match
=
sourceFileRE
.
m
atch
(
m_unifiedDiffHeader1
.
cap
(
1
));
const
auto
destinationFileRE
Match
=
destinationFileRE
.
m
atch
(
m_unifiedDiffHeader1
.
cap
(
2
));
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << sourceFileRE
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Matched length = " << destinationFileRE
M
atch
.captur
edLength();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << sourceFileRE
Match
.capturedTexts();
// qCDebug(LIBKOMPAREDIFF2) << "Captured texts = " << destinationFileRE
Match
.capturedTexts();
// qCDebug(LIBKOMPAREDIFF2) << "Source File : " << sourceFileRE
Match.captured
( 1 );
// qCDebug(LIBKOMPAREDIFF2) << "Destination File : " << destinationFileRE
Match.captured
( 1 );
m_currentModel
->
setSourceFile
(
sourceFileRE
Match
.
captured
(
1
));
m_currentModel
->
setDestinationFile
(
destinationFileRE
Match
.
captured
(
1
));
result
=
true
;
...
...
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