Commit 0e7602b9 authored by Joachim Eibl's avatar Joachim Eibl
Browse files

KDiff3 0.9.87


git-svn-id: https://kdiff3.svn.sourceforge.net/svnroot/kdiff3/trunk@71 c8aa9fed-2811-0410-8543-893ada326672
parent 6227f725
Version 0.9.87 - 2005/30/01
===========================
- Unicode16 and UTF8 support (Internal data format is now QString (Unicode16). Conversion during save and load.)
- Directory "Full Analysis": Equality-Coloring for files with only whitespace differences. (Michael Denio)
- Support for right to left languages.
- In MergeResultWindow show "<Merge Conflict (Whitespace only)>" for whitespace-only conflicts
- Statusbar shows the number of remaining conflicts and whitespace conflicts.
- Go Next/Prev Difference/Conflict now have improved tooltips informing about "Show White Space"-disabled-behaviour.
Version 0.9.86 - 2004/06/14
===========================
- Double click on any file in directory merge would close the directory merge window. (Regression in 0.9.85)
......
......@@ -12,7 +12,7 @@ $(top_srcdir)/acinclude.m4: $(top_srcdir)/admin/acinclude.m4.in $(top_srcdir)/ad
MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files
package-messages:
$(MAKE) -f admin/Makefile.common package-messages
cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common package-messages
$(MAKE) -C po merge
EXTRA_DIST = admin COPYING configure.in.in
......
......@@ -2,8 +2,8 @@ KDiff3-Readme
=============
Author: Joachim Eibl (joachim.eibl@gmx.de)
Copyright: (C) 2002-2004 by Joachim Eibl
KDiff3-Version: 0.9.86
Copyright: (C) 2002-2005 by Joachim Eibl
KDiff3-Version: 0.9.87
KDiff3 is a program that
......@@ -45,12 +45,12 @@ Exception from the GPL:
Requirements & Installation:
Version 0.9.86 provides special support for KDE3, but it can also be
Version 0.9.87 provides special support for KDE3, but it can also be
built without KDE3 if the Qt-libraries are available.
(I also test and use the program under Windows.)
You always need
- kdiff3-0.9.86.tar.gz
- kdiff3-0.9.87.tar.gz
For building the KDE3-version
- KDE>=3.1 and QT>=3.1-libraries. (QT>=3.2 is recommended)
......@@ -67,7 +67,7 @@ Installation for KDE3:
- Make sure your shell-variable QTDIR is correct. (echo $QTDIR).
If it doesn't contain the correct path, type
export QTDIR=your_path_to_qt (e.g. /usr/lib/qt3)
- cd into the directory kdiff3-0.9.86 and type
- cd into the directory kdiff3-0.9.87 and type
- ./configure --prefix=/opt/kde3 (your KDE3 directory here)
- (make clean) (Required if you already compiled once.)
- make (Run compilation)
......@@ -108,7 +108,7 @@ Installation for the Qt-only-platforms for Un*x:
- Make sure your shell-variable QTDIR is correct. (echo $QTDIR).
If it doesn't contain the correct path, type
export QTDIR=your_path_to_qt (e.g. /usr/lib/qt)
- cd into the directory kdiff3-0.9.86/src and type
- cd into the directory kdiff3-0.9.87/src and type
- make -f Makefile.qt
- make -f Makefile.qt install (You must have root-rights for this step.)
(copies the files into /usr/local/bin and /usr/local/share/doc/kdiff3)
......
......@@ -3,6 +3,41 @@ This file contains some feature-wishes for future KDiff3-versions.
TODO
====
- ftp: Abbruch beim Einlesen von Verzeichnis stoppt nicht vollständig
- Projekt-Verwaltung: Die ganze Config-Datei (=Projektdatei) an einen benutzerdefinierten Ort zu legen. (Keine Angabe->Default)
- Bei Combobox-History alle Elemente von (A/B/C/Out) anzeigen.
- Test on empty floppy drive.
-I suppose this has been asked before, but are there any plans to use
colors for change/insert/delete (i.e. blue = change, green = insert, red
= delete)?
> I want to compare two revisions of a file (eventually I wanna do this on
> two directory hierarchies of files) and have an output of how many lines
> of code were added, modified, and deleted for each file and overall.
> Also, for "Send To" from Windows, it would be nice if I could pick one
> file via Send To, find the second file (if it's in a different
> directory), and click "Send To" again to compare. I.e., when user does
> "Send To", if one instance is already open and waiting for a second
> file, the first instance is used.
- kdiff3 does not preserve the permissions of files it overwrites during a 'save' operation.
- Insbesondere Ausführbarkeit "x" und Schreibschutz "w" sollten erhalten bleiben.
- Edit Select All, Ctrl-A
- Under Windows: Shortcut Ctrl-Shift-2 (for select B everywhere doesn't work.)
- Paste from Clipboard doesn't work.
- Improve message about WinCVS in the Installer.
- Bug: Comment section isn't recognized as nonwhite difference if several lines are between /* and */ on one side.
- Overview-option to show only remaining conflicts.
- Colors for disabled and enabled arrow are very similar
- ??? The gutters (kdiff3 have 2 "gutters") fonts and background-foreground colors sholud be configured other
......
......@@ -30,7 +30,7 @@ as Authors, publish date, the abstract, and Keywords -->
<!-- TRANS:ROLES_OF_TRANSLATORS -->
<copyright>
<year>2002-2004</year>
<year>2002-2005</year>
<holder>Joachim Eibl</holder>
</copyright>
<!-- Translators: put here the copyright notice of the translation -->
......@@ -45,8 +45,8 @@ Please respect the format of the date (YYYY-MM-DD) and of the version
(V.MM.LL), it could be used by automation scripts.
Do NOT change these in the translation. -->
<date>2004-05-29</date>
<releaseinfo>0.9.84</releaseinfo>
<date>2005-01-30</date>
<releaseinfo>0.9.87</releaseinfo>
<abstract>
......@@ -59,10 +59,11 @@ Do NOT change these in the translation. -->
<listitem><para>provides an automatic merge-facility,</para></listitem>
<listitem><para>has an editor for comfortable solving of merge-conflicts,</para></listitem>
<listitem><para>provides networktransparency via KIO,</para></listitem>
<listitem><para>has options to highlight or hide changes in white-space or comments.</para></listitem>
<listitem><para>has options to highlight or hide changes in white-space or comments,</para></listitem>
<listitem><para>supports Unicode, UTF-8 and other file encodings.</para></listitem>
</itemizedlist>
</para><para>
This document describes KDiff3-version 0.9.84.
This document describes KDiff3-version 0.9.87.
</para>
</abstract>
......@@ -221,6 +222,8 @@ This screenshot shows KDiff3 during a directory merge:
<listitem><para>Networktransparency via KIO.</para></listitem>
<listitem><para>Can be used as diff-viewer in KDevelop 3.</para></listitem>
<listitem><para>Word-wrap for long lines.</para></listitem>
<listitem><para>Support for Unicode, UTF-8 and other codecs.</para></listitem>
<listitem><para>Support for right to left languages.</para></listitem>
<listitem><para>...</para></listitem>
</itemizedlist>
</sect2>
......@@ -693,6 +696,26 @@ Yet there is one option here that is also relevant for saving single files:
</variablelist>
</sect2>
<sect2><title>Regional and Language Options</title>
<variablelist>
<varlistentry><term><emphasis>Language:</emphasis></term><listitem><para>Adjust the language of the user interface. Changing this option doesn't affect the running program. You have to exit and restart KDiff3 so that the language is changed. (This option is not available in the KDE version of KDiff3 because the language is adjustable in the global KDE settings.)
</para></listitem></varlistentry>
<varlistentry><term><emphasis>Use the same encoding for everything:</emphasis></term><listitem><para> The following encoding options can be adjusted separately for each item or if this option is true, all values will take the first value.
</para></listitem></varlistentry>
<varlistentry><term><emphasis>Local Encoding:</emphasis></term><listitem><para>Above the codec-selectors appears a note that tells you what the local encoding is. (This is not adjustable but for your information just in case you don't know your local encoding, but need to select it.)
</para></listitem></varlistentry>
<varlistentry><term><emphasis>File Encoding for A/B/C:</emphasis></term><listitem><para> Adjust the file encoding for input files. This has an effect on how the special characters are interpreted. Since you can adjust each codec separately you can even compare and merge files that were saved using different codecs.
</para></listitem></varlistentry>
<varlistentry><term><emphasis>File Encoding for Merge Output and Saving:</emphasis></term><listitem><para> When you have edited a file, then you can adjust which encoding will be used when saving to disk.
</para></listitem></varlistentry>
<varlistentry><term><emphasis>File Encoding for Preprocessor Files:</emphasis></term><listitem><para>When you define preprocessors then they might not be able to operate on your codec. (e.g.: Your files are 16-bit-unicode and your preprocessor can only take 8-bit-ascii.) With this option you can define the encoding of preprocessor output.
</para></listitem></varlistentry>
<varlistentry><term><emphasis>Right To Left Language:</emphasis></term><listitem><para>Some languages are written right to left. When this option is enabled, KDiff3 draws the text from right to left in the diff input windows and in the merge output window. Note that if you start KDiff3 with the command line option "--reverse" then all layouting will be done right to left too. (This is a feature provided by Qt.) This documentation was written assuming that "Right To Left Language" or reverse layout are disabled. So some references to "left" or "right" must be replaced by their respective counterpart if you use these options.
</para></listitem></varlistentry>
</variablelist>
</sect2>
<sect2><title>Miscellaneous</title>
<para>(These options and actions are available in menus or the buttonbar.)</para>
<variablelist>
......@@ -1511,7 +1534,7 @@ Other things that are possible, but probably less useful are:
</para></listitem><listitem><para>
No possibility to modify permissions or modification time, so permissions or time
of a copy will differ from the original. (See the option "Trust the size".)
(Modifying permissions or modification time is only possible for local files.)
(To modify permissions or modification time is only possible for local files.)
</para></listitem>
</itemizedlist>
</sect2>
......@@ -1642,14 +1665,14 @@ and menu. Merging or directory-comparison are not supported then.
&kdiff3; - File and Directory Comparison and Merge Tool
</para>
<para>
Program copyright 2002-2004 Joachim Eibl <email>joachim.eibl at gmx.de</email>
Program copyright 2002-2005 Joachim Eibl <email>joachim.eibl at gmx.de</email>
</para>
<para>
Several cool ideas and bugreports came from colleagues and many people out in the Wild Wild Web. Thank you!
</para>
<para>
Documentation Copyright &copy; 2002-2004 Joachim Eibl <email>joachim.eibl at gmx.de</email>
Documentation Copyright &copy; 2002-2005 Joachim Eibl <email>joachim.eibl at gmx.de</email>
</para>
<!-- TRANS:CREDIT_FOR_TRANSLATORS -->
......
......@@ -3,7 +3,7 @@
<general>
<author>Joachim Eibl</author>
<email>joachim@gmx.de</email>
<version>0.9.85</version>
<version>0.9.87</version>
<projectmanagement>KDevKDEAutoProject</projectmanagement>
<primarylanguage>C++</primarylanguage>
<keywords>
......@@ -106,7 +106,7 @@
<kdevdebugger>
<general>
<dbgshell>libtool</dbgshell>
<programargs/>
<programargs>/windows/C/qt/kdiff3-0.9.87/src/ /home/joachim/kdiff3-0.9.87/src</programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
......@@ -153,7 +153,10 @@
<automaticHeaderCompletion>true</automaticHeaderCompletion>
<headerCompletionDelay>250</headerCompletionDelay>
</codecompletion>
<references/>
<references>
<pcs>KDElibs</pcs>
<pcs>Qt</pcs>
</references>
</kdevcppsupport>
<cppsupportpart>
<filetemplates>
......
......@@ -12,8 +12,8 @@ CC = gcc
CXX = g++
LEX = flex
YACC = yacc
CFLAGS = -pipe -O2 -march=i586 -Wall -W -fmessage-length=0 -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -D__USE_STD_IOSTREAM
CXXFLAGS = -pipe -O2 -march=i586 -Wall -W -fmessage-length=0 -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -D__USE_STD_IOSTREAM
CFLAGS = -pipe -O2 -Wall -W -fmessage-length=0 -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -D__USE_STD_IOSTREAM
CXXFLAGS = -pipe -O2 -Wall -W -fmessage-length=0 -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -D__USE_STD_IOSTREAM
LEXFLAGS =
YACCFLAGS= -d
INCPATH = -I$(QTDIR)/mkspecs/default -I. -Ikreplacements -I/usr/include -I$(QTDIR)/include
......
......@@ -26,6 +26,7 @@
#include <klocale.h>
#include <qfileinfo.h>
#include <qdir.h>
#include <qtextcodec.h>
#include <map>
#include <assert.h>
......@@ -67,11 +68,11 @@ bool equal( const LineData& l1, const LineData& l2, bool bStrict )
return false;
// Ignore white space diff
const char* p1 = l1.pLine;
const char* p1End = p1 + l1.size;
const QChar* p1 = l1.pLine;
const QChar* p1End = p1 + l1.size;
const char* p2 = l2.pLine;
const char* p2End = p2 + l2.size;
const QChar* p2 = l2.pLine;
const QChar* p2End = p2 + l2.size;
if ( g_bIgnoreWhiteSpace )
{
......@@ -111,9 +112,7 @@ bool equal( const LineData& l1, const LineData& l2, bool bStrict )
}
static bool isLineOrBufEnd( const char* p, int i, int size )
static bool isLineOrBufEnd( const QChar* p, int i, int size )
{
return
i>=size // End of file
......@@ -131,7 +130,7 @@ static bool isLineOrBufEnd( const char* p, int i, int size )
- Allocate and free buffers as necessary.
- Run a preprocessor, when specified.
- Run the line-matching preprocessor, when specified.
- Run other preprocessing steps: Uppercase, ignore comments,
- Run other preprocessing steps: Uppercase, ignore comments,
remove carriage return, ignore numbers.
Order of operation:
......@@ -150,7 +149,7 @@ Optimizations: Skip unneeded steps.
*/
SourceData::SourceData()
{
{
m_pOptionDialog = 0;
reset();
}
......@@ -238,20 +237,20 @@ void SourceData::setData( const QString& data )
{
m_tempInputFileName = FileAccess::tempFileName();
}
FileAccess f( m_tempInputFileName );
bool bSuccess = f.writeFile( encodeString(data, m_pOptionDialog), data.length() );
bool bSuccess = f.writeFile( QTextCodec::codecForName("UTF-8")->fromUnicode(data), data.length() );
if ( !bSuccess )
{
KMessageBox::error( m_pOptionDialog, i18n("Writing clipboard data to temp file failed.") );
return;
}
m_aliasName = i18n("From Clipboard");
m_fileAccess = FileAccess(""); // Effect: m_fileAccess.isValid() is false
}
const LineData* SourceData::getLineDataForDiff() const
const LineData* SourceData::getLineDataForDiff() const
{
return m_lmppData.m_pBuf==0 ? &m_normalData.m_v[0] : &m_lmppData.m_v[0];
}
......@@ -312,6 +311,8 @@ bool SourceData::FileData::readFile( const QString& filename )
m_size = fa.sizeForReading();
char* pBuf;
m_pBuf = pBuf = new char[m_size+100]; // Alloc 100 byte extra: Savety hack, not nice but does no harm.
// Some extra bytes at the end of the buffer are needed by
// the diff algorithm. See also GnuDiff::diff_2_files().
bool bSuccess = fa.readFile( pBuf, m_size );
if ( !bSuccess )
{
......@@ -339,21 +340,46 @@ bool SourceData::FileData::writeFile( const QString& filename )
void SourceData::FileData::copyBufFrom( const FileData& src )
{
reset();
char* pBuf;
char* pBuf;
m_size = src.m_size;
m_pBuf = pBuf = new char[m_size+100];
memcpy( pBuf, src.m_pBuf, m_size );
}
void SourceData::readAndPreprocess()
// Convert the input file from input encoding to output encoding and write it to the output file.
static bool convertFileEncoding( const QString& fileNameIn, QTextCodec* pCodecIn,
const QString& fileNameOut, QTextCodec* pCodecOut )
{
QFile in( fileNameIn );
if ( ! in.open(IO_ReadOnly ) )
return false;
QTextStream inStream( &in );
inStream.setCodec( pCodecIn );
QFile out( fileNameOut );
if ( ! out.open( IO_WriteOnly ) )
return false;
QTextStream outStream( &out );
outStream.setCodec( pCodecOut );
QString data = inStream.read();
outStream << data;
return true;
}
void SourceData::readAndPreprocess(QTextCodec* pEncoding)
{
m_pEncoding = pEncoding;
QString fileNameIn1;
QString fileNameOut1;
QString fileNameIn2;
QString fileNameOut2;
QTextCodec* pEncoding1 = pEncoding;
QTextCodec* pEncoding2 = pEncoding;
bool bTempFileFromClipboard = !m_fileAccess.isValid();
// Detect the input for the preprocessing operations
if ( !bTempFileFromClipboard )
{
......@@ -364,7 +390,7 @@ void SourceData::readAndPreprocess()
else // File is not local: create a temporary local copy:
{
if ( m_tempInputFileName.isEmpty() ) { m_tempInputFileName = FileAccess::tempFileName(); }
m_fileAccess.copyFile(m_tempInputFileName);
fileNameIn1 = m_tempInputFileName;
}
......@@ -372,16 +398,19 @@ void SourceData::readAndPreprocess()
else // The input was set via setData(), probably from clipboard.
{
fileNameIn1 = m_tempInputFileName;
m_pEncoding = QTextCodec::codecForName("UTF-8");
pEncoding1 = m_pEncoding;
pEncoding2 = m_pEncoding;
}
m_normalData.reset();
m_lmppData.reset();
FileAccess faIn(fileNameIn1);
int fileInSize = faIn.size();
if ( faIn.exists() ) // fileInSize > 0 )
{
{
#ifdef _WIN32
QString catCmd = "type";
......@@ -389,7 +418,7 @@ void SourceData::readAndPreprocess()
#else
QString catCmd = "cat";
#endif
// Run the first preprocessor
if ( m_pOptionDialog->m_PreProcessorCmd.isEmpty() )
{
......@@ -398,10 +427,20 @@ void SourceData::readAndPreprocess()
}
else
{
QString fileNameInPP = fileNameIn1;
if ( pEncoding1 != m_pOptionDialog->m_pEncodingPP )
{
// Before running the preprocessor convert to the format that the preprocessor expects.
fileNameInPP = FileAccess::tempFileName();
pEncoding1 = m_pOptionDialog->m_pEncodingPP;
convertFileEncoding( fileNameIn1, pEncoding, fileNameInPP, pEncoding1 );
}
QString ppCmd = m_pOptionDialog->m_PreProcessorCmd;
fileNameOut1 = FileAccess::tempFileName();
QString cmd = catCmd + " \"" + fileNameIn1 + "\" | " + ppCmd + " >\"" + fileNameOut1+"\"";
::system( encodeString(cmd, m_pOptionDialog) );
QString cmd = catCmd + " \"" + fileNameInPP + "\" | " + ppCmd + " >\"" + fileNameOut1+"\"";
::system( encodeString(cmd) );
bool bSuccess = m_normalData.readFile( fileNameOut1 );
if ( fileInSize >0 && ( !bSuccess || m_normalData.m_size==0 ) )
{
......@@ -411,18 +450,32 @@ void SourceData::readAndPreprocess()
).arg(cmd) );
m_pOptionDialog->m_PreProcessorCmd = "";
m_normalData.readFile( fileNameIn1 );
pEncoding1 = m_pEncoding;
}
if (fileNameInPP != fileNameIn1)
{
FileAccess::removeFile( fileNameInPP );
}
}
// LineMatching Preprocessor
if ( ! m_pOptionDialog->m_LineMatchingPreProcessorCmd.isEmpty() )
{
fileNameIn2 = fileNameOut1.isEmpty() ? fileNameIn1 : fileNameOut1;
QString fileNameInPP = fileNameIn2;
pEncoding2 = pEncoding1;
if ( pEncoding2 != m_pOptionDialog->m_pEncodingPP )
{
// Before running the preprocessor convert to the format that the preprocesor expects.
fileNameInPP = FileAccess::tempFileName();
pEncoding2 = m_pOptionDialog->m_pEncodingPP;
convertFileEncoding( fileNameIn2, pEncoding1, fileNameInPP, pEncoding2 );
}
QString ppCmd = m_pOptionDialog->m_LineMatchingPreProcessorCmd;
fileNameOut2 = FileAccess::tempFileName();
QString cmd = catCmd + " \"" + fileNameIn2 + "\" | " + ppCmd + " >\"" + fileNameOut2 + "\"";
::system( encodeString(cmd, m_pOptionDialog) );
QString cmd = catCmd + " \"" + fileNameInPP + "\" | " + ppCmd + " >\"" + fileNameOut2 + "\"";
::system( encodeString(cmd) );
bool bSuccess = m_lmppData.readFile( fileNameOut2 );
if ( FileAccess(fileNameIn2).size()>0 && ( !bSuccess || m_lmppData.m_size==0 ) )
{
......@@ -434,6 +487,10 @@ void SourceData::readAndPreprocess()
m_lmppData.readFile( fileNameIn2 );
}
FileAccess::removeFile( fileNameOut2 );
if (fileNameInPP != fileNameIn2)
{
FileAccess::removeFile( fileNameInPP );
}
}
else if ( m_pOptionDialog->m_bIgnoreComments || m_pOptionDialog->m_bIgnoreCase )
{
......@@ -444,20 +501,20 @@ void SourceData::readAndPreprocess()
{ // We don't need any lmpp data at all.
m_lmppData.reset();
}
}
m_normalData.preprocess( m_pOptionDialog->m_bPreserveCarriageReturn );
m_lmppData.preprocess( false );
}
m_normalData.preprocess( m_pOptionDialog->m_bPreserveCarriageReturn, pEncoding1 );
m_lmppData.preprocess( false, pEncoding2 );
if ( m_lmppData.m_vSize < m_normalData.m_vSize )
{
// This probably is the fault of the LMPP-Command, but not worth reporting.
m_lmppData.m_v.resize( m_normalData.m_vSize );
for(int i=m_lmppData.m_vSize; i<m_normalData.m_vSize; ++i )
{ // Set all empty lines to point to the end of the buffer.
m_lmppData.m_v[i].pLine = m_lmppData.m_pBuf+m_lmppData.m_size;
m_lmppData.m_v[i].pLine = m_lmppData.m_unicodeBuf.unicode()+m_lmppData.m_unicodeBuf.length();
}
m_lmppData.m_vSize = m_normalData.m_vSize;
}
......@@ -465,13 +522,14 @@ void SourceData::readAndPreprocess()
if ( m_pOptionDialog->m_bIgnoreCase )
{
int i;
char* pBuf = const_cast<char*>(m_lmppData.m_pBuf);
for(i=0; i<m_lmppData.m_size; ++i)
QChar* pBuf = const_cast<QChar*>(m_lmppData.m_unicodeBuf.unicode());
int ucSize = m_lmppData.m_unicodeBuf.length();
for(i=0; i<ucSize; ++i)
{
pBuf[i] = toupper(pBuf[i]);
pBuf[i] = pBuf[i].upper();
}
}
}
// Ignore comments
if ( m_pOptionDialog->m_bIgnoreComments )
{
......@@ -482,14 +540,14 @@ void SourceData::readAndPreprocess()
m_normalData.m_v[i].bContainsPureComment = m_lmppData.m_v[i].bContainsPureComment;
}
}
// Remove unneeded temporary files. (A temp file from clipboard must not be deleted.)
if ( !bTempFileFromClipboard && !m_tempInputFileName.isEmpty() )
{
FileAccess::removeFile( m_tempInputFileName );
m_tempInputFileName = "";
}
if ( !fileNameOut1.isEmpty() )
{
FileAccess::removeFile( fileNameOut1 );
......@@ -499,15 +557,28 @@ void SourceData::readAndPreprocess()
/** Prepare the linedata vector for every input line.*/
void SourceData::FileData::preprocess( bool bPreserveCR )
void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding )
{
const char* p = m_pBuf;
//m_unicodeBuf = decodeString( m_pBuf, m_size, eEncoding );
QByteArray ba;
ba.setRawData( m_pBuf, m_size );
QTextStream ts( ba, IO_ReadOnly );
ts.setCodec( pEncoding);
m_unicodeBuf = ts.read();
ba.resetRawData( m_pBuf, m_size );
int ucSize = m_unicodeBuf.length();
m_unicodeBuf += " "; // Some extra bytes at the end of the buffer are needed by
// the diff algorithm. See also GnuDiff::diff_2_files().
const QChar* p = m_unicodeBuf.unicode();
m_bIsText = true;
int lines = 1;
int i;
for( i=0; i<m_size; ++i )
for( i=0; i<ucSize; ++i )
{
if ( isLineOrBufEnd(p,i,m_size) )
if ( isLineOrBufEnd(p,i,ucSize) )
{
++lines;
}
......@@ -522,9 +593,9 @@ void SourceData::FileData::preprocess( bool bPreserveCR )
int lineLength=0;
bool bNonWhiteFound = false;
int whiteLength = 0;
for( i=0; i<=m_size; ++i )
for( i=0; i<=ucSize; ++i )
{
if ( isLineOrBufEnd( p, i, m_size ) )
if ( isLineOrBufEnd( p, i, ucSize ) )
{
m_v[lineIdx].pLine = &p[ i-lineLength ];
while ( !bPreserveCR && lineLength>0 && m_v[lineIdx].pLine[lineLength-1]=='\r' )
......@@ -560,7 +631,7 @@ void SourceData::FileData::preprocess( bool bPreserveCR )
// Comments in white lines must remain, while comments in
// non-white lines are overwritten with spaces.
static void checkLineForComments(
char* p, // pointer to start of buffer
QChar* p, // pointer to start of buffer
int& i, // index of current position (in, out)
int size, // size of buffer
bool& bWhite, // false if this line contains nonwhite characters (in, out)
......@@ -650,9 +721,9 @@ static void checkLineForComments(
void SourceData::FileData::removeComments()
{
int line=0;
char* p = (char*)m_pBuf;
QChar* p = const_cast<QChar*>(m_unicodeBuf.unicode());
bool bWithinComment=false;
int size = m_size;
int size = m_unicodeBuf.length();
for(int i=0; i<size; ++i )
{
// std::cout << "2 " << std::string(&p[i], m_v[line].size) << std::endl;
......@@ -1293,7 +1364,7 @@ void debugLineCheck( Diff3LineList& d3ll, int size, int idx )
}
}
inline bool equal( char c1, char c2, bool /*bStrict*/ )
inline bool equal( QChar c1, QChar c2, bool /*bStrict*/ )
{
// If bStrict then white space doesn't match
......@@ -1494,11 +1565,10 @@ void fineDiff(
if( k1==-1 && k2!=-1 || k1!=-1 && k2==-1 ) bTextsTotalEqual=false;
if( k1!=-1 && k2!=-1 )
{
if ( v1[k1].size != v2[k2].size || memcmp( v1[k1].pLine, v2[k2].pLine, v1[k1].size)!=0 )
if ( v1[k1].size != v2[k2].size || memcmp( v1[k1].pLine, v2[k2].pLine, v1[k1].size<<1)!=0 )