diff options
Diffstat (limited to 'src/diff.cpp')
-rw-r--r-- | src/diff.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/src/diff.cpp b/src/diff.cpp index 7875bc6..9ead57f 100644 --- a/src/diff.cpp +++ b/src/diff.cpp @@ -25,9 +25,9 @@ #include <kmessagebox.h> #include <klocale.h> -#include <qfileinfo.h> -#include <qdir.h> -#include <qtextcodec.h> +#include <tqfileinfo.h> +#include <tqdir.h> +#include <tqtextcodec.h> #include <map> #include <assert.h> @@ -69,11 +69,11 @@ bool equal( const LineData& l1, const LineData& l2, bool bStrict ) return false; // Ignore white space diff - const QChar* p1 = l1.pLine; - const QChar* p1End = p1 + l1.size; + const TQChar* p1 = l1.pLine; + const TQChar* p1End = p1 + l1.size; - const QChar* p2 = l2.pLine; - const QChar* p2End = p2 + l2.size; + const TQChar* p2 = l2.pLine; + const TQChar* p2End = p2 + l2.size; if ( g_bIgnoreWhiteSpace ) { @@ -113,7 +113,7 @@ bool equal( const LineData& l1, const LineData& l2, bool bStrict ) } -static bool isLineOrBufEnd( const QChar* p, int i, int size ) +static bool isLineOrBufEnd( const TQChar* p, int i, int size ) { return i>=size // End of file @@ -173,7 +173,7 @@ void SourceData::reset() } } -void SourceData::setFilename( const QString& filename ) +void SourceData::setFilename( const TQString& filename ) { if (filename.isEmpty()) { @@ -206,17 +206,17 @@ void SourceData::setOptionDialog( OptionDialog* pOptionDialog ) m_pOptionDialog = pOptionDialog; } -QString SourceData::getFilename() +TQString SourceData::getFilename() { return m_fileAccess.absFilePath(); } -QString SourceData::getAliasName() +TQString SourceData::getAliasName() { return m_aliasName.isEmpty() ? m_fileAccess.prettyAbsPath() : m_aliasName; } -void SourceData::setAliasName( const QString& name ) +void SourceData::setAliasName( const TQString& name ) { m_aliasName = name; } @@ -224,7 +224,7 @@ void SourceData::setAliasName( const QString& name ) void SourceData::setFileAccess( const FileAccess& fileAccess ) { m_fileAccess = fileAccess; - m_aliasName = QString(); + m_aliasName = TQString(); if ( !m_tempInputFileName.isEmpty() ) { FileAccess::removeFile( m_tempInputFileName ); @@ -232,7 +232,7 @@ void SourceData::setFileAccess( const FileAccess& fileAccess ) } } -void SourceData::setData( const QString& data ) +void SourceData::setData( const TQString& data ) { // Create a temp file for preprocessing: if ( m_tempInputFileName.isEmpty() ) @@ -241,7 +241,7 @@ void SourceData::setData( const QString& data ) } FileAccess f( m_tempInputFileName ); - bool bSuccess = f.writeFile( QTextCodec::codecForName("UTF-8")->fromUnicode(data), data.length() ); + bool bSuccess = f.writeFile( TQTextCodec::codecForName("UTF-8")->fromUnicode(data), data.length() ); if ( !bSuccess ) { KMessageBox::error( m_pOptionDialog, i18n("Writing clipboard data to temp file failed.") ); @@ -308,7 +308,7 @@ void SourceData::FileData::reset() m_bIsText = true; } -bool SourceData::FileData::readFile( const QString& filename ) +bool SourceData::FileData::readFile( const TQString& filename ) { reset(); if ( filename.isEmpty() ) { return true; } @@ -329,12 +329,12 @@ bool SourceData::FileData::readFile( const QString& filename ) return bSuccess; } -bool SourceData::saveNormalDataAs( const QString& fileName ) +bool SourceData::saveNormalDataAs( const TQString& fileName ) { return m_normalData.writeFile( fileName ); } -bool SourceData::FileData::writeFile( const QString& filename ) +bool SourceData::FileData::writeFile( const TQString& filename ) { if ( filename.isEmpty() ) { return true; } @@ -353,71 +353,71 @@ void SourceData::FileData::copyBufFrom( const FileData& src ) } // 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 ) +static bool convertFileEncoding( const TQString& fileNameIn, TQTextCodec* pCodecIn, + const TQString& fileNameOut, TQTextCodec* pCodecOut ) { - QFile in( fileNameIn ); + TQFile in( fileNameIn ); if ( ! in.open(IO_ReadOnly ) ) return false; - QTextStream inStream( &in ); + TQTextStream inStream( &in ); inStream.setCodec( pCodecIn ); - //inStream.setAutoDetectUnicode( false ); //not available in Qt3, will always detect UCS2 + //inStream.setAutoDetectUnicode( false ); //not available in TQt3, will always detect UCS2 - QFile out( fileNameOut ); + TQFile out( fileNameOut ); if ( ! out.open( IO_WriteOnly ) ) return false; - QTextStream outStream( &out ); + TQTextStream outStream( &out ); outStream.setCodec( pCodecOut ); - QString data = inStream.read(); + TQString data = inStream.read(); outStream << data; return true; } -static QTextCodec* detectEncoding( const char* buf, long size, long& skipBytes ) +static TQTextCodec* detectEncoding( const char* buf, long size, long& skipBytes ) { if (size>=2) { - skipBytes = 0; // In Qt3 UTF-16LE can only be used if autodetected. + skipBytes = 0; // In TQt3 UTF-16LE can only be used if autodetected. if (buf[0]=='\xFF' && buf[1]=='\xFE' ) - return QTextCodec::codecForName( "ISO-10646-UCS2" );// "UTF-16LE" + return TQTextCodec::codecForName( "ISO-10646-UCS2" );// "UTF-16LE" if (buf[0]=='\xFE' && buf[1]=='\xFF' ) - return QTextCodec::codecForName( "ISO-10646-UCS2" );// "UTF-16BE". Qt3 autodetects the difference but has no name for it. + return TQTextCodec::codecForName( "ISO-10646-UCS2" );// "UTF-16BE". TQt3 autodetects the difference but has no name for it. } if (size>=3) { skipBytes = 3; if (buf[0]=='\xEF' && buf[1]=='\xBB' && buf[2]=='\xBF' ) - return QTextCodec::codecForName( "UTF-8-BOM" ); + return TQTextCodec::codecForName( "UTF-8-BOM" ); } skipBytes = 0; return 0; } -QTextCodec* SourceData::detectEncoding( const QString& fileName, QTextCodec* pFallbackCodec ) +TQTextCodec* SourceData::detectEncoding( const TQString& fileName, TQTextCodec* pFallbackCodec ) { - QFile f(fileName); + TQFile f(fileName); if ( f.open(IO_ReadOnly) ) { char buf[4]; long size = f.readBlock( buf, sizeof(buf) ); long skipBytes = 0; - QTextCodec* pCodec = ::detectEncoding( buf, size, skipBytes ); + TQTextCodec* pCodec = ::detectEncoding( buf, size, skipBytes ); if (pCodec) return pCodec; } return pFallbackCodec; } -void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnicode ) +void SourceData::readAndPreprocess( TQTextCodec* pEncoding, bool bAutoDetectUnicode ) { m_pEncoding = pEncoding; - QString fileNameIn1; - QString fileNameOut1; - QString fileNameIn2; - QString fileNameOut2; + TQString fileNameIn1; + TQString fileNameOut1; + TQString fileNameIn2; + TQString fileNameOut2; bool bTempFileFromClipboard = !m_fileAccess.isValid(); @@ -443,10 +443,10 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico else // The input was set via setData(), probably from clipboard. { fileNameIn1 = m_tempInputFileName; - m_pEncoding = QTextCodec::codecForName("UTF-8"); + m_pEncoding = TQTextCodec::codecForName("UTF-8"); } - QTextCodec* pEncoding1 = m_pEncoding; - QTextCodec* pEncoding2 = m_pEncoding; + TQTextCodec* pEncoding1 = m_pEncoding; + TQTextCodec* pEncoding2 = m_pEncoding; m_normalData.reset(); m_lmppData.reset(); @@ -458,10 +458,10 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico { #ifdef _WIN32 - QString catCmd = "type"; - fileNameIn1.replace( '/', "\\" ); + TQString catCmd = "type"; + fileNameIn1.tqreplace( '/', "\\" ); #else - QString catCmd = "cat"; + TQString catCmd = "cat"; #endif // Run the first preprocessor @@ -472,7 +472,7 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico } else { - QString fileNameInPP = fileNameIn1; + TQString fileNameInPP = fileNameIn1; if ( pEncoding1 != m_pOptionDialog->m_pEncodingPP ) { @@ -482,9 +482,9 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico convertFileEncoding( fileNameIn1, pEncoding, fileNameInPP, pEncoding1 ); } - QString ppCmd = m_pOptionDialog->m_PreProcessorCmd; + TQString ppCmd = m_pOptionDialog->m_PreProcessorCmd; fileNameOut1 = FileAccess::tempFileName(); - QString cmd = catCmd + " \"" + fileNameInPP + "\" | " + ppCmd + " >\"" + fileNameOut1+"\""; + TQString cmd = catCmd + " \"" + fileNameInPP + "\" | " + ppCmd + " >\"" + fileNameOut1+"\""; ::system( encodeString(cmd) ); bool bSuccess = m_normalData.readFile( fileNameOut1 ); if ( fileInSize >0 && ( !bSuccess || m_normalData.m_size==0 ) ) @@ -492,7 +492,7 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico KMessageBox::error(m_pOptionDialog, i18n("Preprocessing possibly failed. Check this command:\n\n %1" "\n\nThe preprocessing command will be disabled now." - ).arg(cmd) ); + ).tqarg(cmd) ); m_pOptionDialog->m_PreProcessorCmd = ""; m_normalData.readFile( fileNameIn1 ); pEncoding1 = m_pEncoding; @@ -507,7 +507,7 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico if ( ! m_pOptionDialog->m_LineMatchingPreProcessorCmd.isEmpty() ) { fileNameIn2 = fileNameOut1.isEmpty() ? fileNameIn1 : fileNameOut1; - QString fileNameInPP = fileNameIn2; + TQString fileNameInPP = fileNameIn2; pEncoding2 = pEncoding1; if ( pEncoding2 != m_pOptionDialog->m_pEncodingPP ) { @@ -517,9 +517,9 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico convertFileEncoding( fileNameIn2, pEncoding1, fileNameInPP, pEncoding2 ); } - QString ppCmd = m_pOptionDialog->m_LineMatchingPreProcessorCmd; + TQString ppCmd = m_pOptionDialog->m_LineMatchingPreProcessorCmd; fileNameOut2 = FileAccess::tempFileName(); - QString cmd = catCmd + " \"" + fileNameInPP + "\" | " + ppCmd + " >\"" + fileNameOut2 + "\""; + TQString 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 ) ) @@ -527,7 +527,7 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico KMessageBox::error(m_pOptionDialog, i18n("The line-matching-preprocessing possibly failed. Check this command:\n\n %1" "\n\nThe line-matching-preprocessing command will be disabled now." - ).arg(cmd) ); + ).tqarg(cmd) ); m_pOptionDialog->m_LineMatchingPreProcessorCmd = ""; m_lmppData.readFile( fileNameIn2 ); } @@ -557,7 +557,7 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico 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_unicodeBuf.unicode()+m_lmppData.m_unicodeBuf.length(); + m_lmppData.m_v[i].pLine = m_lmppData.m_tqunicodeBuf.tqunicode()+m_lmppData.m_tqunicodeBuf.length(); } m_lmppData.m_vSize = m_normalData.m_vSize; @@ -567,8 +567,8 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico if ( m_pOptionDialog->m_bIgnoreCase ) { int i; - QChar* pBuf = const_cast<QChar*>(m_lmppData.m_unicodeBuf.unicode()); - int ucSize = m_lmppData.m_unicodeBuf.length(); + TQChar* pBuf = const_cast<TQChar*>(m_lmppData.m_tqunicodeBuf.tqunicode()); + int ucSize = m_lmppData.m_tqunicodeBuf.length(); for(i=0; i<ucSize; ++i) { pBuf[i] = pBuf[i].upper(); @@ -602,25 +602,25 @@ void SourceData::readAndPreprocess( QTextCodec* pEncoding, bool bAutoDetectUnico /** Prepare the linedata vector for every input line.*/ -void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding ) +void SourceData::FileData::preprocess( bool bPreserveCR, TQTextCodec* pEncoding ) { - //m_unicodeBuf = decodeString( m_pBuf, m_size, eEncoding ); + //m_tqunicodeBuf = decodeString( m_pBuf, m_size, eEncoding ); long skipBytes = 0; - QTextCodec* pCodec = ::detectEncoding( m_pBuf, m_size, skipBytes ); + TQTextCodec* pCodec = ::detectEncoding( m_pBuf, m_size, skipBytes ); if ( pCodec != pEncoding ) skipBytes=0; - QByteArray ba; + TQByteArray ba; ba.setRawData( m_pBuf+skipBytes, m_size-skipBytes ); - QTextStream ts( ba, IO_ReadOnly ); + TQTextStream ts( ba, IO_ReadOnly ); ts.setCodec( pEncoding); //ts.setAutoDetectUnicode( false ); - m_unicodeBuf = ts.read(); + m_tqunicodeBuf = ts.read(); ba.resetRawData( m_pBuf+skipBytes, m_size-skipBytes ); - int ucSize = m_unicodeBuf.length(); - const QChar* p = m_unicodeBuf.unicode(); + int ucSize = m_tqunicodeBuf.length(); + const TQChar* p = m_tqunicodeBuf.tqunicode(); m_bIsText = true; int lines = 1; @@ -680,7 +680,7 @@ void SourceData::FileData::preprocess( bool bPreserveCR, QTextCodec* pEncoding ) // Comments in white lines must remain, while comments in // non-white lines are overwritten with spaces. static void checkLineForComments( - QChar* p, // pointer to start of buffer + TQChar* 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) @@ -770,9 +770,9 @@ static void checkLineForComments( void SourceData::FileData::removeComments() { int line=0; - QChar* p = const_cast<QChar*>(m_unicodeBuf.unicode()); + TQChar* p = const_cast<TQChar*>(m_tqunicodeBuf.tqunicode()); bool bWithinComment=false; - int size = m_unicodeBuf.length(); + int size = m_tqunicodeBuf.length(); for(int i=0; i<size; ++i ) { // std::cout << "2 " << std::string(&p[i], m_v[line].size) << std::endl; @@ -1190,7 +1190,7 @@ void correctManualDiffAlignment( Diff3LineList& d3ll, ManualDiffHelpList* pManua if ( pManualDiffHelpList->empty() ) return; - // If a line appears unaligned in comparison to the manual alignment, correct this. + // If a line appears unaligned in comparison to the manual tqalignment, correct this. ManualDiffHelpList::iterator iMDHL; for( iMDHL = pManualDiffHelpList->begin(); iMDHL != pManualDiffHelpList->end(); ++iMDHL ) @@ -1228,7 +1228,7 @@ void correctManualDiffAlignment( Diff3LineList& d3ll, ManualDiffHelpList* pManua if (wi>=1 && wi <= 3) { - // Found manual alignment for one source + // Found manual tqalignment for one source Diff3LineList::iterator iDest = i3; // Move lines up until the next firstLine is found. Omit wi from move and search. @@ -1653,7 +1653,7 @@ void debugLineCheck( Diff3LineList& d3ll, int size, int idx ) } } -inline bool equal( QChar c1, QChar c2, bool /*bStrict*/ ) +inline bool equal( TQChar c1, TQChar c2, bool /*bStrict*/ ) { // If bStrict then white space doesn't match |