Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KDiff3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SDK
KDiff3
Commits
88ed3eb5
Commit
88ed3eb5
authored
Oct 09, 2013
by
Joachim Eibl
Committed by
Michael Reeves
Jan 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Word wrap multithreaded. - Preserve carriage return reintroduced.
Signed-off-by:
joachim99
<
joachim.eibl@gmx.de
>
parent
d8d48199
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
314 additions
and
135 deletions
+314
-135
src/diff.cpp
src/diff.cpp
+46
-21
src/diff.h
src/diff.h
+2
-1
src/difftextwindow.cpp
src/difftextwindow.cpp
+100
-23
src/difftextwindow.h
src/difftextwindow.h
+2
-1
src/directorymergewindow.cpp
src/directorymergewindow.cpp
+7
-2
src/fileaccess.cpp
src/fileaccess.cpp
+9
-5
src/fileaccess.h
src/fileaccess.h
+2
-1
src/gnudiff_diff.h
src/gnudiff_diff.h
+5
-0
src/gnudiff_io.cpp
src/gnudiff_io.cpp
+8
-9
src/optiondialog.cpp
src/optiondialog.cpp
+7
-7
src/pdiff.cpp
src/pdiff.cpp
+29
-13
src/progress.cpp
src/progress.cpp
+81
-42
src/progress.h
src/progress.h
+15
-9
src/version.h
src/version.h
+1
-1
No files found.
src/diff.cpp
View file @
88ed3eb5
...
...
@@ -121,7 +121,7 @@ static bool isLineOrBufEnd( const QChar* p, int i, int size )
{
return
i
>=
size
// End of file
||
p
[
i
]
==
'\n'
// Normal end of line
||
isEndOfLine
(
p
[
i
])
// Normal end of line
// No support for Mac-end of line yet, because incompatible with GNU-diff-routines.
// || ( p[i]=='\r' && (i>=size-1 || p[i+1]!='\n')
...
...
@@ -836,34 +836,44 @@ void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding )
qint64
i
;
// detect line end style
QVector
<
e_LineEndStyle
>
vOrigDataLineEndStyle
;
m_eLineEndStyle
=
eLineEndStyleUndefined
;
for
(
i
=
0
;
i
<
m_size
;
++
i
)
{
if
(
m_pBuf
[
i
]
==
'\
n
'
)
if
(
m_pBuf
[
i
]
==
'\
r
'
)
{
if
(
(
i
>
0
&&
m_pBuf
[
i
-
1
]
==
'\r'
)
||
// normal file
(
i
>
3
&&
m_pBuf
[
i
-
1
]
==
'\0'
&&
m_pBuf
[
i
-
2
]
==
'\r'
&&
m_pBuf
[
i
-
3
]
==
'\0'
))
// 16-bit unicode: TODO only little endian covered here
m_eLineEndStyle
=
eLineEndStyleDos
;
else
m_eLineEndStyle
=
eLineEndStyleUnix
;
break
;
// Only analyze first line
if
(
i
+
1
<
m_size
&&
m_pBuf
[
i
+
1
]
==
'\n'
)
// not 16-bit unicode
{
vOrigDataLineEndStyle
.
push_back
(
eLineEndStyleDos
);
++
i
;
}
else
if
(
i
>
0
&&
i
+
2
<
m_size
&&
m_pBuf
[
i
-
1
]
==
'\0'
&&
m_pBuf
[
i
+
1
]
==
'\0'
&&
m_pBuf
[
i
+
2
]
==
'\n'
)
// 16-bit unicode
{
vOrigDataLineEndStyle
.
push_back
(
eLineEndStyleDos
);
i
+=
2
;
}
else
// old mac line end style ?
{
vOrigDataLineEndStyle
.
push_back
(
eLineEndStyleUndefined
);
const_cast
<
char
*>
(
m_pBuf
)[
i
]
=
'\n'
;
// fix it in original data
}
}
else
if
(
m_pBuf
[
i
]
==
'\n'
)
{
vOrigDataLineEndStyle
.
push_back
(
eLineEndStyleUnix
);
}
}
if
(
!
vOrigDataLineEndStyle
.
isEmpty
()
)
m_eLineEndStyle
=
vOrigDataLineEndStyle
[
0
];
qint64
skipBytes
=
0
;
QTextCodec
*
pCodec
=
::
detectEncoding
(
m_pBuf
,
m_size
,
skipBytes
);
if
(
pCodec
!=
pEncoding
)
skipBytes
=
0
;
QByteArray
ba
=
QByteArray
::
fromRawData
(
m_pBuf
+
skipBytes
,
m_size
-
skipBytes
);
if
(
m_eLineEndStyle
==
eLineEndStyleUndefined
)
// normally only for one liners except when old mac line end style is used
{
for
(
int
j
=
0
;
j
<
ba
.
size
();
++
j
)
// int because QByteArray does not support operator[](qint64)
{
if
(
ba
[
j
]
==
'\r'
)
ba
[
j
]
=
'\n'
;
// We only fix the old mac line end style, but leave it as "undefined"
}
}
QTextStream
ts
(
ba
,
QIODevice
::
ReadOnly
);
QTextStream
ts
(
ba
,
QIODevice
::
ReadOnly
|
QIODevice
::
Text
);
ts
.
setCodec
(
pEncoding
);
ts
.
setAutoDetectUnicode
(
false
);
m_unicodeBuf
=
ts
.
readAll
();
...
...
@@ -877,7 +887,7 @@ void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding )
m_bIncompleteConversion
=
false
;
for
(
i
=
0
;
i
<
ucSize
;
++
i
)
{
if
(
i
sLineOrBufEnd
(
p
,
i
,
ucSize
)
)
if
(
i
>=
ucSize
||
p
[
i
]
==
'\n'
)
{
++
lines
;
}
...
...
@@ -898,15 +908,25 @@ void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding )
int
whiteLength
=
0
;
for
(
i
=
0
;
i
<=
ucSize
;
++
i
)
{
if
(
i
sLineOrBufEnd
(
p
,
i
,
ucSize
)
)
if
(
i
>=
ucSize
||
p
[
i
]
==
'\n'
)
{
m_v
[
lineIdx
].
pLine
=
&
p
[
i
-
lineLength
];
while
(
!
bPreserveCR
&&
lineLength
>
0
&&
m_v
[
lineIdx
].
pLine
[
lineLength
-
1
]
==
'\r'
)
while
(
/*!bPreserveCR &&*/
lineLength
>
0
&&
m_v
[
lineIdx
].
pLine
[
lineLength
-
1
]
==
'\r'
)
{
--
lineLength
;
}
m_v
[
lineIdx
].
pFirstNonWhiteChar
=
m_v
[
lineIdx
].
pLine
+
min2
(
whiteLength
,
lineLength
);
m_v
[
lineIdx
].
size
=
lineLength
;
if
(
lineIdx
<
vOrigDataLineEndStyle
.
count
()
&&
bPreserveCR
&&
i
<
ucSize
)
{
++
m_v
[
lineIdx
].
size
;
switch
(
vOrigDataLineEndStyle
[
lineIdx
]
)
{
case
eLineEndStyleUnix
:
const_cast
<
QChar
*>
(
m_v
[
lineIdx
].
pLine
)[
lineLength
]
=
'\n'
;
break
;
case
eLineEndStyleDos
:
const_cast
<
QChar
*>
(
m_v
[
lineIdx
].
pLine
)[
lineLength
]
=
'\r'
;
break
;
case
eLineEndStyleUndefined
:
const_cast
<
QChar
*>
(
m_v
[
lineIdx
].
pLine
)[
lineLength
]
=
'\x0b'
;
break
;
}
}
lineLength
=
0
;
bNonWhiteFound
=
false
;
whiteLength
=
0
;
...
...
@@ -1130,6 +1150,10 @@ void calcDiff3LineListUsingAB(
--
d
.
diff2
;
++
lineB
;
}
else
if
(
d
.
nofEquals
<
0
)
{
assert
(
false
);
}
d3ll
.
push_back
(
d3l
);
}
...
...
@@ -2232,6 +2256,7 @@ bool fineDiff(
int
k2
=
0
;
bool
bTextsTotalEqual
=
true
;
int
listSize
=
diff3LineList
.
size
();
pp
.
setMaxNofSteps
(
listSize
);
int
listIdx
=
0
;
for
(
i
=
diff3LineList
.
begin
();
i
!=
diff3LineList
.
end
();
++
i
)
{
...
...
@@ -2287,7 +2312,7 @@ bool fineDiff(
}
}
++
listIdx
;
pp
.
s
etCurrent
(
double
(
listIdx
)
/
listSize
);
pp
.
s
tep
(
);
}
return
bTextsTotalEqual
;
}
...
...
src/diff.h
View file @
88ed3eb5
...
...
@@ -47,7 +47,8 @@ struct LineData
const
QChar
*
pFirstNonWhiteChar
;
int
size
;
LineData
(){
pLine
=
0
;
pFirstNonWhiteChar
=
0
;
size
=
0
;
/*occurances=0;*/
bContainsPureComment
=
false
;
}
LineData
(){
pLine
=
0
;
pFirstNonWhiteChar
=
0
;
size
=
0
;
/*occurances=0;*/
bContainsPureComment
=
false
;
}
int
width
(
int
tabSize
)
const
;
// Calcs width considering tabs.
//int occurances;
bool
whiteLine
()
const
{
return
pFirstNonWhiteChar
-
pLine
==
size
;
}
...
...
src/difftextwindow.cpp
View file @
88ed3eb5
...
...
@@ -41,6 +41,8 @@
#include <cstdlib>
#include <assert.h>
#include <QFileDialog>
#include <QRunnable>
#include <QThreadPool>
class
DiffTextWindowData
...
...
@@ -102,7 +104,7 @@ public:
:
m_d3LineIdx
(
d3LineIdx
),
m_textStart
(
textStart
),
m_textLength
(
textLength
)
{}
int
m_d3LineIdx
;
int
m_textStart
;
int
m_textLength
;
};
Q
Vector
<
WrapLineCacheData
>
m_wrapLineCache
;
Q
List
<
QVector
<
WrapLineCacheData
>
>
m_wrapLineCacheList
;
Options
*
m_pOptions
;
QColor
m_cThis
;
...
...
@@ -936,6 +938,15 @@ void DiffTextWindowData::writeLine(
// First calculate the "changed" information for each character.
int
i
=
0
;
QString
lineString
(
pld
->
pLine
,
pld
->
size
);
if
(
!
lineString
.
isEmpty
()
)
{
switch
(
lineString
[
lineString
.
length
()
-
1
].
unicode
()
)
{
case
'\n'
:
lineString
[
lineString
.
length
()
-
1
]
=
0x00B6
;
break
;
// "Pilcrow", "paragraph mark"
case
'\r'
:
lineString
[
lineString
.
length
()
-
1
]
=
0x00A4
;
break
;
// Currency sign ;0x2761 "curved stem paragraph sign ornament"
case
'\
0
b
'
:
lineString
[
lineString
.
length
()
-
1
]
=
0x2756
;
break
;
// some other nice looking character
}
}
QVector
<
UINT8
>
charChanged
(
pld
->
size
);
Merger
merger
(
pLineDiff1
,
pLineDiff2
);
while
(
!
merger
.
isEndReached
()
&&
i
<
pld
->
size
)
...
...
@@ -1525,7 +1536,25 @@ void DiffTextWindow::convertSelectionToD3LCoords()
d
->
m_selection
.
end
(
lastD3LIdx
,
lastD3LPos
);
}
void
DiffTextWindow
::
recalcWordWrap
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
visibleTextWidth
)
class
RecalcWordWrapRunnable
:
public
QRunnable
{
DiffTextWindow
*
m_pDTW
;
int
m_nofVisibleColumns
;
int
m_cacheIdx
;
ProgressProxy
*
m_pProgressProxy
;
public:
RecalcWordWrapRunnable
(
DiffTextWindow
*
p
,
int
nofVisibleColumns
,
int
cacheIdx
,
ProgressProxy
*
pPP
)
:
m_pDTW
(
p
),
m_nofVisibleColumns
(
nofVisibleColumns
),
m_cacheIdx
(
cacheIdx
),
m_pProgressProxy
(
pPP
)
{
setAutoDelete
(
true
);
}
void
run
()
{
m_pDTW
->
recalcWordWrapHelper
(
true
,
0
,
m_nofVisibleColumns
,
m_cacheIdx
,
m_pProgressProxy
);
}
};
void
DiffTextWindow
::
recalcWordWrap
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
visibleTextWidth
,
ProgressProxy
*
pPP
)
{
if
(
d
->
m_pDiff3LineVector
==
0
||
!
d
->
m_bPaintingAllowed
||
!
isVisible
()
)
{
...
...
@@ -1536,16 +1565,40 @@ void DiffTextWindow::recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int
d
->
m_bWordWrap
=
bWordWrap
;
if
(
!
bWordWrap
||
wrapLineVectorSize
==
0
)
d
->
m_wrapLineCache
.
clear
();
if
(
bWordWrap
)
{
ProgressProxy
pp
;
//
ProgressProxy pp;
d
->
m_lineNumberWidth
=
d
->
m_pOptions
->
m_bShowLineNumbers
?
(
int
)
log10
((
double
)
qMax
(
d
->
m_size
,
1
))
+
1
:
0
;
d
->
m_diff3WrapLineVector
.
resize
(
wrapLineVectorSize
);
}
if
(
!
bWordWrap
||
wrapLineVectorSize
==
0
)
d
->
m_wrapLineCacheList
.
clear
();
if
(
wrapLineVectorSize
==
0
)
{
pPP
->
addNofSteps
(
d
->
m_pDiff3LineVector
->
size
()
/
2000
);
for
(
int
i
=
0
,
j
=
0
;
i
<
d
->
m_pDiff3LineVector
->
size
();
i
+=
2000
,
++
j
)
//int i=0;
{
d
->
m_wrapLineCacheList
.
append
(
QVector
<
DiffTextWindowData
::
WrapLineCacheData
>
());
QThreadPool
::
globalInstance
()
->
start
(
new
RecalcWordWrapRunnable
(
this
,
visibleTextWidth
,
j
,
pPP
)
);
}
//recalcWordWrap( bWordWrap, wrapLineVectorSize, visibleTextWidth, 0 );
}
else
{
recalcWordWrapHelper
(
bWordWrap
,
wrapLineVectorSize
,
visibleTextWidth
,
0
,
pPP
);
}
}
void
DiffTextWindow
::
recalcWordWrapHelper
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
visibleTextWidth
,
int
cacheListIdx
,
ProgressProxy
*
pPP
)
{
if
(
bWordWrap
)
{
if
(
pPP
->
wasCancelled
()
)
return
;
if
(
visibleTextWidth
<
0
)
visibleTextWidth
=
getVisibleTextAreaWidth
();
else
...
...
@@ -1554,41 +1607,64 @@ void DiffTextWindow::recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int
int
wrapLineIdx
=
0
;
int
wrapLineCacheIdx
=
0
;
int
size
=
d
->
m_pDiff3LineVector
->
size
();
pp
.
setMaxNofSteps
(
size
);
for
(
i
=
0
;
i
<
size
;
++
i
)
//pp.setMaxNofSteps(size);
int
firstD3LineIdx
=
wrapLineVectorSize
>
0
?
0
:
cacheListIdx
*
2000
;
int
endIdx
=
wrapLineVectorSize
>
0
?
size
:
qMin
(
firstD3LineIdx
+
2000
,
size
);
QVector
<
DiffTextWindowData
::
WrapLineCacheData
>&
wrapLineCache
=
d
->
m_wrapLineCacheList
[
cacheListIdx
];
int
cacheListIdx2
=
0
;
QTextLayout
textLayout
(
QString
(),
font
(),
this
);
for
(
i
=
firstD3LineIdx
;
i
<
endIdx
;
++
i
)
{
pp
.
setInformation
(
i18n
(
"Word wrap"
),
double
(
i
)
/
size
,
false
);
if
(
pp
.
wasCancelled
()
)
return
;
//pp.setInformation( i18n("Word wrap"), double(i)/size, false );
int
linesNeeded
=
0
;
if
(
wrapLineVectorSize
==
0
)
{
QString
s
=
d
->
getString
(
i
);
QTextLayout
textLayout
(
s
,
font
(),
this
);
textLayout
.
clearLayout
();
textLayout
.
setText
(
s
);
d
->
prepareTextLayout
(
textLayout
,
true
,
visibleTextWidth
);
linesNeeded
=
textLayout
.
lineCount
();
for
(
int
l
=
0
;
l
<
linesNeeded
;
++
l
)
{
//Diff3WrapLine* pDiff3WrapLine = &d->m_diff3WrapLineVector[ wrapLineIdx + l ];
QTextLine
line
=
textLayout
.
lineAt
(
l
);
d
->
m_
wrapLineCache
.
push_back
(
DiffTextWindowData
::
WrapLineCacheData
(
i
,
line
.
textStart
(),
line
.
textLength
())
);
wrapLineCache
.
push_back
(
DiffTextWindowData
::
WrapLineCacheData
(
i
,
line
.
textStart
(),
line
.
textLength
())
);
}
}
else
if
(
wrapLineVectorSize
>
0
)
{
while
(
wrapLineCacheIdx
<
d
->
m_wrapLineCache
.
count
()
&&
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_d3LineIdx
<
i
)
++
wrapLineCacheIdx
;
DiffTextWindowData
::
WrapLineCacheData
*
pWrapLineCache
=
d
->
m_wrapLineCacheList
[
cacheListIdx2
].
data
();
int
cacheIdx
=
0
;
int
clc
=
d
->
m_wrapLineCacheList
.
count
()
-
1
;
int
cllc
=
d
->
m_wrapLineCacheList
.
last
().
count
()
;
int
curCount
=
d
->
m_wrapLineCacheList
[
0
].
count
()
-
1
;
int
l
=
0
;
while
(
wrapLineCacheIdx
<
d
->
m_wrapLineCache
.
count
()
&&
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_d3LineIdx
==
i
)
while
(
(
cacheListIdx2
<
clc
||
cacheListIdx2
==
clc
&&
cacheIdx
<
cllc
)
&&
pWrapLineCache
->
m_d3LineIdx
<=
i
)
{
Diff3WrapLine
*
pDiff3WrapLine
=
&
d
->
m_diff3WrapLineVector
[
wrapLineIdx
+
l
];
pDiff3WrapLine
->
wrapLineOffset
=
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_textStart
;
pDiff3WrapLine
->
wrapLineLength
=
d
->
m_wrapLineCache
[
wrapLineCacheIdx
].
m_textLength
;
++
l
;
++
wrapLineCacheIdx
;
if
(
pWrapLineCache
->
m_d3LineIdx
==
i
)
{
Diff3WrapLine
*
pDiff3WrapLine
=
&
d
->
m_diff3WrapLineVector
[
wrapLineIdx
+
l
];
pDiff3WrapLine
->
wrapLineOffset
=
pWrapLineCache
->
m_textStart
;
pDiff3WrapLine
->
wrapLineLength
=
pWrapLineCache
->
m_textLength
;
++
l
;
}
if
(
cacheIdx
<
curCount
)
{
++
cacheIdx
;
++
pWrapLineCache
;
}
else
{
++
cacheListIdx2
;
if
(
cacheListIdx2
>=
d
->
m_wrapLineCacheList
.
count
())
break
;
pWrapLineCache
=
d
->
m_wrapLineCacheList
[
cacheListIdx2
].
data
();
curCount
=
d
->
m_wrapLineCacheList
[
cacheListIdx2
].
count
();
cacheIdx
=
0
;
}
}
linesNeeded
=
l
;
}
...
...
@@ -1615,6 +1691,7 @@ void DiffTextWindow::recalcWordWrap( bool bWordWrap, int wrapLineVectorSize, int
}
}
}
pPP
->
step
(
false
);
if
(
wrapLineVectorSize
>
0
)
{
...
...
src/difftextwindow.h
View file @
88ed3eb5
...
...
@@ -76,7 +76,8 @@ public:
void
getSelectionRange
(
int
*
firstLine
,
int
*
lastLine
,
e_CoordType
coordType
);
void
setPaintingAllowed
(
bool
bAllowPainting
);
void
recalcWordWrap
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
nofVisibleColumns
);
void
recalcWordWrap
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
nofVisibleColumns
,
ProgressProxy
*
);
void
recalcWordWrapHelper
(
bool
bWordWrap
,
int
wrapLineVectorSize
,
int
visibleTextWidth
,
int
cacheListIdx
,
ProgressProxy
*
);
void
print
(
MyPainter
&
painter
,
const
QRect
&
r
,
int
firstLine
,
int
nofLinesPerPage
);
Q_SIGNALS:
void
resizeSignal
(
int
nofVisibleColumns
,
int
nofVisibleLines
);
...
...
src/directorymergewindow.cpp
View file @
88ed3eb5
...
...
@@ -806,6 +806,8 @@ bool DirectoryMergeWindow::Data::fastFileComparison(
t_FileSize
fullSize
=
file1
.
size
();
t_FileSize
sizeLeft
=
fullSize
;
pp
.
setMaxNofSteps
(
fullSize
/
buf1
.
size
()
);
while
(
sizeLeft
>
0
&&
!
pp
.
wasCancelled
()
)
{
int
len
=
min2
(
sizeLeft
,
(
t_FileSize
)
buf1
.
size
()
);
...
...
@@ -827,7 +829,8 @@ bool DirectoryMergeWindow::Data::fastFileComparison(
return
bEqual
;
}
sizeLeft
-=
len
;
pp
.
setCurrent
(
double
(
fullSize
-
sizeLeft
)
/
fullSize
,
false
);
//pp.setCurrent(double(fullSize-sizeLeft)/fullSize, false );
pp
.
step
();
}
// If the program really arrives here, then the files are really equal.
...
...
@@ -2647,6 +2650,8 @@ void DirectoryMergeWindow::Data::mergeContinue(bool bStart, bool bVerbose)
m_bError
=
false
;
}
pp
.
setMaxNofSteps
(
nrOfItems
);
bool
bSuccess
=
true
;
bool
bSingleFileMerge
=
false
;
bool
bSim
=
m_bSimulatedMergeStarted
;
...
...
@@ -2755,7 +2760,7 @@ void DirectoryMergeWindow::Data::mergeContinue(bool bStart, bool bVerbose)
MergeFileInfos
&
mfi
=
*
getMFI
(
miCurrent
);
pp
.
setInformation
(
mfi
.
subPath
(),
bSim
?
double
(
nrOfCompletedSimItems
)
/
nrOfItems
:
double
(
nrOfCompletedItems
)
/
nrOf
Items
,
bSim
?
nrOfCompletedSimItems
:
nrOfCompleted
Items
,
false
// bRedrawUpdate
);
...
...
src/fileaccess.cpp
View file @
88ed3eb5
...
...
@@ -692,6 +692,7 @@ static bool interruptableReadFile( QFile& f, void* pDestBuffer, unsigned long ma
ProgressProxy
pp
;
const
unsigned
long
maxChunkSize
=
100000
;
unsigned
long
i
=
0
;
pp
.
setMaxNofSteps
(
maxLength
/
maxChunkSize
+
1
);
while
(
i
<
maxLength
)
{
unsigned
long
nextLength
=
min2
(
maxLength
-
i
,
maxChunkSize
);
...
...
@@ -703,7 +704,8 @@ static bool interruptableReadFile( QFile& f, void* pDestBuffer, unsigned long ma
i
+=
reallyRead
;
pp
.
setCurrent
(
double
(
i
)
/
maxLength
);
if
(
pp
.
wasCancelled
()
)
return
false
;
if
(
pp
.
wasCancelled
()
)
return
false
;
}
return
true
;
}
...
...
@@ -740,6 +742,7 @@ bool FileAccess::writeFile( const void* pSrcBuffer, unsigned long length )
if
(
f
.
open
(
QIODevice
::
WriteOnly
)
)
{
const
unsigned
long
maxChunkSize
=
100000
;
pp
.
setMaxNofSteps
(
length
/
maxChunkSize
+
1
);
unsigned
long
i
=
0
;
while
(
i
<
length
)
{
...
...
@@ -751,8 +754,9 @@ bool FileAccess::writeFile( const void* pSrcBuffer, unsigned long length )
}
i
+=
reallyWritten
;
pp
.
setCurrent
(
double
(
i
)
/
length
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
if
(
pp
.
wasCancelled
()
)
return
false
;
}
f
.
close
();
#ifndef _WIN32
...
...
@@ -1774,12 +1778,12 @@ void FileAccessJobHandler::slotListDirProcessNewEntries( KIO::Job*, const KIO::U
void
ProgressProxyExtender
::
slotListDirInfoMessage
(
KJob
*
,
const
QString
&
msg
)
{
setInformation
(
msg
,
0
.0
);
setInformation
(
msg
,
0
);
}
void
ProgressProxyExtender
::
slotPercent
(
KJob
*
,
unsigned
long
percent
)
{
setCurrent
(
percent
/
100.0
);
setCurrent
(
percent
);
}
...
...
src/fileaccess.h
View file @
88ed3eb5
...
...
@@ -29,7 +29,8 @@ class QFileInfo;
class
ProgressProxyExtender
:
public
ProgressProxy
{
Q_OBJECT
public:
ProgressProxyExtender
()
{
setMaxNofSteps
(
100
);
}
public
Q_SLOTS
:
void
slotListDirInfoMessage
(
KJob
*
,
const
QString
&
msg
);
void
slotPercent
(
KJob
*
,
unsigned
long
percent
);
...
...
src/gnudiff_diff.h
View file @
88ed3eb5
...
...
@@ -29,6 +29,11 @@
#include <stdio.h>
#include <QString>
inline
bool
isEndOfLine
(
QChar
c
)
{
return
c
==
'\n'
||
c
==
'\r'
||
c
==
'\x0b'
;
}
#define TAB_WIDTH 8
class
GnuDiff
...
...
src/gnudiff_io.cpp
View file @
88ed3eb5
...
...
@@ -64,7 +64,6 @@ static lin equivs_index;
/* Number of elements allocated in the array `equivs'. */
static
lin
equivs_alloc
;
/* Check for binary files and compare them for exact identity. */
/* Return 1 if BUF contains a non text character.
...
...
@@ -166,7 +165,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
switch
(
ignore_white_space
)
{
case
IGNORE_ALL_SPACE
:
while
(
p
<
bufend
&&
(
c
=
*
p
)
!=
'\n'
)
while
(
p
<
bufend
&&
!
isEndOfLine
(
c
=
*
p
)
)
{
if
(
!
(
isWhite
(
c
)
||
(
bIgnoreNumbers
&&
(
c
.
isDigit
()
||
c
==
'-'
||
c
==
'.'
))
))
h
=
HASH
(
h
,
c
.
toLower
().
unicode
());
...
...
@@ -175,7 +174,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
break
;
default:
while
(
p
<
bufend
&&
(
c
=
*
p
)
!=
'\n'
)
while
(
p
<
bufend
&&
!
isEndOfLine
(
c
=
*
p
)
)
{
h
=
HASH
(
h
,
c
.
toLower
().
unicode
());
++
p
;
...
...
@@ -186,7 +185,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
switch
(
ignore_white_space
)
{
case
IGNORE_ALL_SPACE
:
while
(
p
<
bufend
&&
(
c
=
*
p
)
!=
'\n'
)
while
(
p
<
bufend
&&
!
isEndOfLine
(
c
=
*
p
)
)
{
if
(
!
(
isWhite
(
c
)
||
(
bIgnoreNumbers
&&
(
c
.
isDigit
()
||
c
==
'-'
||
c
==
'.'
))
))
h
=
HASH
(
h
,
c
.
unicode
());
...
...
@@ -195,7 +194,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
break
;
default:
while
(
p
<
bufend
&&
(
c
=
*
p
)
!=
'\n'
)
while
(
p
<
bufend
&&
!
isEndOfLine
(
c
=
*
p
)
)
{
h
=
HASH
(
h
,
c
.
unicode
());
++
p
;
...
...
@@ -299,7 +298,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
line
++
;
while
(
p
<
bufend
&&
*
p
++
!=
'\n'
)
while
(
p
<
bufend
&&
!
isEndOfLine
(
*
p
++
)
)
continue
;
}
...
...
@@ -356,7 +355,7 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
/* Now P0 and P1 point at the first nonmatching characters. */
/* Skip back to last line-beginning in the prefix. */
while
(
p0
!=
buffer0
&&
(
p0
[
-
1
]
!=
'\n'
)
)
while
(
p0
!=
buffer0
&&
!
isEndOfLine
(
p0
[
-
1
])
)
p0
--
,
p1
--
;
/* Record the prefix. */
...
...
@@ -393,7 +392,7 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
{
if
(
*
p0
!=
*
p1
)
++
p0
;
while
(
p0
<
pEnd0
&&
*
p0
++
!=
'\n'
)
while
(
p0
<
pEnd0
&&
!
isEndOfLine
(
*
p0
++
)
)
continue
;
}
...
...
@@ -459,7 +458,7 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
linbuf0
=
(
const
QChar
**
)
xrealloc
(
linbuf0
,
alloc_lines0
*
sizeof
(
*
linbuf0
));
}
linbuf0
[
l
]
=
p0
;
while
(
p0
<
pEnd0
&&
*
p0
++
!=
'\n'
)
while
(
p0
<
pEnd0
&&
!
isEndOfLine
(
*
p0
++
)
)
continue
;
}
}
...
...
src/optiondialog.cpp
View file @
88ed3eb5
...
...
@@ -863,13 +863,13 @@ void OptionDialog::setupDiffPage( void ) {
QLabel
*
label
=
0
;
m_options
.
m_bPreserveCarriageReturn
=
false
;
//OptionCheckBox* pPreserveCarriageReturn = new OptionCheckBox( i18n("Preserve carriage return"), false, "PreserveCarriageReturn", &
m_bPreserveCarriageReturn, page, this );
//
gbox->addWidget( pPreserveCarriageReturn, line, 0, 1, 2 );
//
pPreserveCarriageReturn->setToolTip( i18n(
//
"Show carriage return characters '\\r' if they exist.\n"
//
"Helps to compare files that were modified under different operating systems.")
//
);
//
++line;
OptionCheckBox
*
pPreserveCarriageReturn
=
new
OptionCheckBox
(
i18n
(
"Preserve carriage return"
),
false
,
"PreserveCarriageReturn"
,
&
m_options
.
m_bPreserveCarriageReturn
,
page
,
this
);
gbox
->
addWidget
(
pPreserveCarriageReturn
,
line
,
0
,
1
,
2
);
pPreserveCarriageReturn
->
setToolTip
(
i18n
(
"Show carriage return characters '
\\
r' if they exist.
\n
"
"Helps to compare files that were modified under different operating systems."
)
);
++
line
;
QString
treatAsWhiteSpace
=
" ("
+
i18n
(
"Treat as white space."
)
+
")"
;
OptionCheckBox
*
pIgnoreNumbers
=
new
OptionCheckBox
(
i18n
(
"Ignore numbers"
)
+
treatAsWhiteSpace
,
false
,
"IgnoreNumbers"
,
&
m_options
.
m_bIgnoreNumbers
,
page
,
this
);
...
...
src/pdiff.cpp
View file @
88ed3eb5
...
...
@@ -1554,6 +1554,9 @@ void KDiff3App::slotRecalcWordWrap()
bool
KDiff3App
::
recalcWordWrap
(
int
nofVisibleColumns
)
// nofVisibleColumns is >=0 only for printing, otherwise the really visible width is used
{
QElapsedTimer
et
;
et
.
start
();
int
tel1
=
0
;
bool
bPrinting
=
nofVisibleColumns
>=
0
;
int
firstD3LIdx
=
0
;
if
(
m_pDiffTextWindow1
)
...
...
@@ -1581,31 +1584,41 @@ bool KDiff3App::recalcWordWrap(int nofVisibleColumns) // nofVisibleColumns is >=
}
ProgressProxy
pp
;
pp
.
setMaxNofSteps
(
(
m_bTripleDiff
?
4
:
3
)
);
//
pp.setMaxNofSteps( (m_bTripleDiff ? 4 : 3 ) );
pp
.
setInformation
(
i18n
(
"Word wrap (Cancel disables word wrap)"
),
false
);
// Let every window calc how many lines will be needed.
if
(
m_pDiffTextWindow1
)
{
m_pDiffTextWindow1
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
m_pDiffTextWindow1
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
,
&
pp
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
//
pp.step();
}
if
(
m_pDiffTextWindow2
)
{
m_pDiffTextWindow2
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
m_pDiffTextWindow2
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
,
&
pp
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
//
pp.step();
}
if
(
m_pDiffTextWindow3
)
{
m_pDiffTextWindow3
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
);
m_pDiffTextWindow3
->
recalcWordWrap
(
true
,
0
,
nofVisibleColumns
,
&
pp
);
if
(
pp
.
wasCancelled
()
)
return
false
;
pp
.
step
();
//pp.step();
}
while
(
!
QThreadPool
::
globalInstance
()
->
waitForDone
(
100
)
)
{
pp
.
recalc
();
// implicit process events and redraw
}