Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
SDK
KDiff3
Commits
5ac57037
Commit
5ac57037
authored
Mar 26, 2019
by
Michael Reeves
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish LineRef
parent
b9e3890a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
29 deletions
+36
-29
src/LineRef.h
src/LineRef.h
+20
-11
src/SourceData.cpp
src/SourceData.cpp
+1
-1
src/diff.cpp
src/diff.cpp
+12
-12
src/gnudiff_diff.h
src/gnudiff_diff.h
+1
-3
src/kdiff3.cpp
src/kdiff3.cpp
+2
-2
No files found.
src/LineRef.h
View file @
5ac57037
...
...
@@ -25,13 +25,21 @@
#include <type_traits>
#include <QtGlobal>
#define TYPE_MAX(x) std::numeric_limits<x>::max()
class
LineRef
{
public:
typedef
qint32
LineType
;
LineRef
()
=
default
;
LineRef
(
const
LineType
i
)
{
mLineNumber
=
i
;
}
operator
LineType
()
const
{
return
mLineNumber
;
}
inline
LineRef
()
=
default
;
inline
LineRef
(
const
LineType
i
)
{
mLineNumber
=
i
;
}
inline
LineRef
(
const
qint64
i
)
{
if
(
i
<=
TYPE_MAX
(
LineType
))
mLineNumber
=
(
LineType
)
i
;
else
mLineNumber
=
-
1
;
}
inline
operator
LineType
()
const
{
return
mLineNumber
;
}
inline
void
operator
=
(
const
LineType
lineIn
)
{
mLineNumber
=
lineIn
;
}
inline
LineRef
&
operator
+=
(
const
LineType
&
inLine
)
{
...
...
@@ -39,22 +47,23 @@ class LineRef
return
*
this
;
};
void
invalidate
()
{
mLineNumber
=
-
1
;
}
bool
isValid
()
const
{
return
mLineNumber
!=
-
1
;
}
inline
void
invalidate
()
{
mLineNumber
=
-
1
;
}
inline
bool
isValid
()
const
{
return
mLineNumber
!=
-
1
;
}
private:
LineType
mLineNumber
=
-
1
;
};
static_assert
(
std
::
is_copy_constructible
<
LineRef
>::
value
,
""
);
static_assert
(
std
::
is_copy_assignable
<
LineRef
>::
value
,
""
);
static_assert
(
std
::
is_move_constructible
<
LineRef
>::
value
,
""
);
static_assert
(
std
::
is_move_assignable
<
LineRef
>::
value
,
""
);
static_assert
(
std
::
is_convertible
<
LineRef
,
int
>::
value
,
""
);
static_assert
(
std
::
is_convertible
<
int
,
LineRef
>::
value
,
""
);
static_assert
(
std
::
is_copy_constructible
<
LineRef
>::
value
,
"
LineRef must be copt constuctible.
"
);
static_assert
(
std
::
is_copy_assignable
<
LineRef
>::
value
,
"
LineRef must copy assignable.
"
);
static_assert
(
std
::
is_move_constructible
<
LineRef
>::
value
,
"
LineRef must be move constructible.
"
);
static_assert
(
std
::
is_move_assignable
<
LineRef
>::
value
,
"
LineRef not must be move assignable.
"
);
static_assert
(
std
::
is_convertible
<
LineRef
,
int
>::
value
,
"
Can not convert LineRef to int.
"
);
static_assert
(
std
::
is_convertible
<
int
,
LineRef
>::
value
,
"
Can not convert int to LineRef.
"
);
typedef
LineRef
::
LineType
LineCount
;
typedef
size_t
PtrDiffRef
;
typedef
LineRef
::
LineType
LineIndex
;
#endif
src/SourceData.cpp
View file @
5ac57037
...
...
@@ -173,7 +173,7 @@ const LineData* SourceData::getLineDataForDisplay() const
LineRef
SourceData
::
getSizeLines
()
const
{
return
(
LineRef
::
LineType
)(
m_normalData
.
m_vSize
);
return
(
LineRef
)(
m_normalData
.
m_vSize
);
}
qint64
SourceData
::
getSizeBytes
()
const
...
...
src/diff.cpp
View file @
5ac57037
...
...
@@ -105,8 +105,8 @@ void calcDiff3LineListUsingAB(
// First make d3ll for AB (from pDiffListAB)
DiffList
::
const_iterator
i
=
pDiffListAB
->
begin
();
in
t
lineA
=
0
;
in
t
lineB
=
0
;
L
in
eRef
::
LineType
lineA
=
0
;
L
in
eRef
::
LineType
lineB
=
0
;
Diff
d
(
0
,
0
,
0
);
for
(;;)
...
...
@@ -170,8 +170,8 @@ void calcDiff3LineListUsingAC(
DiffList
::
const_iterator
i
=
pDiffListAC
->
begin
();
Diff3LineList
::
iterator
i3
=
d3ll
.
begin
();
in
t
lineA
=
0
;
in
t
lineC
=
0
;
L
in
eRef
::
LineType
lineA
=
0
;
L
in
eRef
::
LineType
lineC
=
0
;
Diff
d
(
0
,
0
,
0
);
for
(;;)
...
...
@@ -242,8 +242,8 @@ void calcDiff3LineListUsingBC(
DiffList
::
const_iterator
i
=
pDiffListBC
->
begin
();
Diff3LineList
::
iterator
i3b
=
d3ll
.
begin
();
Diff3LineList
::
iterator
i3c
=
d3ll
.
begin
();
in
t
lineB
=
0
;
in
t
lineC
=
0
;
L
in
eRef
::
LineType
lineB
=
0
;
L
in
eRef
::
LineType
lineC
=
0
;
Diff
d
(
0
,
0
,
0
);
for
(;;)
...
...
@@ -572,19 +572,19 @@ static bool runDiff(const LineData* p1, LineRef size1, const LineData* p2, LineR
gnuDiff
.
ignore_case
=
false
;
GnuDiff
::
change
*
script
=
gnuDiff
.
diff_2_files
(
&
comparisonInput
);
LineRef
equalLinesAtStart
=
(
LineRef
::
LineType
)
comparisonInput
.
file
[
0
].
prefix_lines
;
LineRef
equalLinesAtStart
=
(
LineRef
)
comparisonInput
.
file
[
0
].
prefix_lines
;
LineRef
currentLine1
=
0
;
LineRef
currentLine2
=
0
;
GnuDiff
::
change
*
p
=
nullptr
;
for
(
GnuDiff
::
change
*
e
=
script
;
e
;
e
=
p
)
{
Diff
d
(
0
,
0
,
0
);
d
.
nofEquals
=
(
LineRef
::
LineType
)(
e
->
line0
-
currentLine1
);
d
.
nofEquals
=
(
LineRef
)(
e
->
line0
-
currentLine1
);
Q_ASSERT
(
d
.
nofEquals
==
e
->
line1
-
currentLine2
);
d
.
diff1
=
e
->
deleted
;
d
.
diff2
=
e
->
inserted
;
currentLine1
+=
(
LineRef
::
LineType
)(
d
.
nofEquals
+
d
.
diff1
);
currentLine2
+=
(
LineRef
::
LineType
)(
d
.
nofEquals
+
d
.
diff2
);
currentLine1
+=
(
LineRef
)(
d
.
nofEquals
+
d
.
diff1
);
currentLine2
+=
(
LineRef
)(
d
.
nofEquals
+
d
.
diff2
);
diffList
.
push_back
(
d
);
p
=
e
->
link
;
...
...
@@ -1303,8 +1303,8 @@ void calcDiff(const QChar* p1, LineRef size1, const QChar* p2, LineRef size2, Di
DiffList
::
iterator
i
;
for
(
i
=
diffList
.
begin
();
i
!=
diffList
.
end
();
++
i
)
{
l1
+=
(
LineRef
::
LineType
)(
i
->
nofEquals
+
i
->
diff1
);
l2
+=
(
LineRef
::
LineType
)(
i
->
nofEquals
+
i
->
diff2
);
l1
+=
(
LineRef
)(
i
->
nofEquals
+
i
->
diff1
);
l2
+=
(
LineRef
)(
i
->
nofEquals
+
i
->
diff2
);
}
Q_ASSERT
(
l1
==
size1
&&
l2
==
size2
);
...
...
src/gnudiff_diff.h
View file @
5ac57037
...
...
@@ -43,12 +43,10 @@
#include "LineRef.h"
/* The integer type of a line number. */
typedef
qint64
GNULineRef
;
#define LINEREF_MAX std::numeric_limits<LineRef>::max()
#define GNULINEREF_MAX std::numeric_limits<GNULineRef>::max()
static_assert
(
sizeof
(
int
)
>=
sizeof
(
qint32
),
"Legacy LP32 systems/compilers not supported"
);
// e.g. Windows 16-bit
static_assert
(
std
::
is_signed
<
GNULineRef
>::
value
,
"GNULineRef must be signed."
);
static_assert
(
sizeof
(
GNULineRef
)
>=
sizeof
(
size_t
),
"GNULineRef must be able to rec
i
eve size_t values."
);
static_assert
(
sizeof
(
GNULineRef
)
>=
sizeof
(
size_t
),
"GNULineRef must be able to rece
i
ve size_t values."
);
inline
bool
isEndOfLine
(
QChar
c
)
{
...
...
src/kdiff3.cpp
View file @
5ac57037
...
...
@@ -820,8 +820,8 @@ void KDiff3App::slotFilePrint()
QPrinter
printer
;
QPointer
<
QPrintDialog
>
printDialog
=
QPointer
<
QPrintDialog
>
(
new
QPrintDialog
(
&
printer
,
this
));
LineRef
firstSelectionD3LIdx
=
-
1
;
LineRef
lastSelectionD3LIdx
=
-
1
;
LineRef
firstSelectionD3LIdx
;
LineRef
lastSelectionD3LIdx
;
m_pDiffTextWindow1
->
getSelectionRange
(
&
firstSelectionD3LIdx
,
&
lastSelectionD3LIdx
,
eD3LLineCoords
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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