[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/utils/kdiff3/src
From:       Joachim Eibl <joachim.eibl () gmx ! de>
Date:       2011-08-31 20:40:45
Message-ID: 20110831204045.BD6BBAC87A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1250629 by joachim:

KDiff3 0.9.96

 M  +82 -8     diff.cpp  
 M  +30 -16    directorymergewindow.cpp  
 M  +9 -4      fileaccess.cpp  
 M  +1 -1      gnudiff_system.h  
 M  +2 -2      kreplacements/ShellContextMenu.cpp  
 M  +1 -1      kreplacements/kreplacements.cpp  
 M  +3 -1      main.cpp  
 M  +6 -3      optiondialog.cpp  
 A             stable.cpp   [License: Trivial file.]
 A             stable.h   [License: UNKNOWN]


--- trunk/extragear/utils/kdiff3/src/diff.cpp #1250628:1250629
@@ -386,24 +386,90 @@
    return true;
 }
 
+static QTextCodec* getEncodingFromTag( const QByteArray& s, const QByteArray& \
encodingTag ) +{   
+   int encodingPos = s.indexOf( encodingTag );
+   if ( encodingPos>=0 )
+   {
+      int apostrophPos = s.indexOf( '"', encodingPos + encodingTag.length() );
+      int apostroph2Pos = s.indexOf( '\'', encodingPos + encodingTag.length() );
+      char apostroph = '"';
+      if ( apostroph2Pos>=0 && ( apostrophPos<0 || apostrophPos>=0 && apostroph2Pos \
< apostrophPos ) ) +      {
+         apostroph = '\'';
+         apostrophPos = apostroph2Pos;
+      }
+
+      int encodingEnd = s.indexOf( apostroph, apostrophPos+1 );
+      if ( encodingEnd>=0 ) // e.g.: <meta charset="utf-8"> or <?xml version="1.0" \
encoding="ISO-8859-1"?> +      {
+         QByteArray encoding = s.mid( apostrophPos+1, encodingEnd - (apostrophPos + \
1) ); +         return QTextCodec::codecForName( encoding );
+      }
+      else // e.g.: <meta http-equiv="Content-Type" content="text/html; \
charset=utf-8"> +      {
+         QByteArray encoding = s.mid( encodingPos+encodingTag.length(), apostrophPos \
- ( encodingPos+encodingTag.length() ) ); +         return QTextCodec::codecForName( \
encoding ); +      }
+   }
+   return 0;
+}
+
 static QTextCodec* detectEncoding( const char* buf, qint64 size, qint64& skipBytes )
 {
    if (size>=2)
    {
+      if (buf[0]=='\xFF' && buf[1]=='\xFE' )
+      {
       skipBytes = 2;
-      if (buf[0]=='\xFF' && buf[1]=='\xFE' )
          return QTextCodec::codecForName( "UTF-16LE" );
+      }
 
       if (buf[0]=='\xFE' && buf[1]=='\xFF' )
+      {
+         skipBytes = 2;
          return QTextCodec::codecForName( "UTF-16BE" );
    }
+   }
    if (size>=3)
    {
+      if (buf[0]=='\xEF' && buf[1]=='\xBB' && buf[2]=='\xBF' )
+      {
       skipBytes = 3;
-      if (buf[0]=='\xEF' && buf[1]=='\xBB' && buf[2]=='\xBF' )
          return QTextCodec::codecForName( "UTF-8-BOM" );
    }
+   }
    skipBytes = 0;
+   QByteArray s( buf, size );
+   int xmlHeaderPos = s.indexOf( "<?xml" );
+   if ( xmlHeaderPos >= 0 )
+   {
+      int xmlHeaderEnd = s.indexOf( "?>", xmlHeaderPos );
+      if ( xmlHeaderEnd>=0 )
+      {
+         QTextCodec* pCodec = getEncodingFromTag( s.mid( xmlHeaderPos, xmlHeaderEnd \
- xmlHeaderPos ), "encoding=" ); +         if (pCodec)
+            return pCodec;
+      }
+   }
+   else // HTML
+   {
+      int metaHeaderPos = s.indexOf( "<meta" );
+      while ( metaHeaderPos >= 0)
+      {
+         int metaHeaderEnd = s.indexOf( ">", metaHeaderPos );
+         if (metaHeaderEnd>=0)
+         {
+            QTextCodec* pCodec = getEncodingFromTag( s.mid( metaHeaderPos, \
metaHeaderEnd - metaHeaderPos ), "charset=" ); +            if (pCodec)
+               return pCodec;
+
+            metaHeaderPos = s.indexOf( "<meta", metaHeaderEnd );
+         }
+         else
+            break;
+      }
+   }
    return 0;
 }
 
@@ -412,7 +478,7 @@
    QFile f(fileName);
    if ( f.open(QIODevice::ReadOnly) )
    {
-      char buf[4];
+      char buf[200];
       qint64 size = f.read( buf, sizeof(buf) );
       qint64 skipBytes = 0;
       QTextCodec* pCodec = ::detectEncoding( buf, size, skipBytes );
@@ -468,10 +534,10 @@
          {
             args << cmd.mid( argStart, i-argStart );
             if ( i+1<cmd.length() && !cmd[i+1].isSpace() )
-               return i18n("Expecting space after closing quotation mark.");
+               return i18n("Expecting space after closing apostroph.");
          }
          else
-            return i18n("Not matching quotation marks.");
+            return i18n("Not matching apostrophs.");
          continue;
       }
       else
@@ -493,7 +559,7 @@
                bSkip = true;
             else */
             if ( cmd[i]=='"' || cmd[i]=='\'' )
-               return i18n("Unexpected quotation mark within argument.");
+               return i18n("Unexpected apostroph within argument.");
             ++i;
          }
          args << cmd.mid( argStart, i-argStart );
@@ -739,7 +805,7 @@
       if ( m_pBuf[i]=='\n' )
       {
          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 +              (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;
@@ -752,6 +818,14 @@
       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 );
    ts.setCodec( pEncoding);
    ts.setAutoDetectUnicode( false );
@@ -834,7 +908,7 @@
    bStartsOpenComment = false;
    for(; i<size; ++i )
    {
-      // A single quotation mark ' has prio over a double quotation mark " (e.g. \
'"') +      // A single apostroph ' has prio over a double apostroph " (e.g. '"')
       // (if not in a string)
       if ( p[i]=='\'' )
       {
--- trunk/extragear/utils/kdiff3/src/directorymergewindow.cpp #1250628:1250629
@@ -34,6 +34,7 @@
 #include <QSplitter>
 #include <QTextEdit>
 #include <QItemDelegate>
+#include <QPushButton>
 
 
 #include <kmenu.h>
@@ -52,37 +53,50 @@
 
 static bool conflictingFileTypes(MergeFileInfos& mfi);
 
-class StatusInfo : public QTextEdit
+class StatusInfo : public QDialog
 {
+   QTextEdit* m_pTextEdit;
 public:
-   StatusInfo(QWidget* pParent) : QTextEdit( pParent )
+   StatusInfo(QWidget* pParent) : QDialog( pParent )
    {
+      QVBoxLayout* pVLayout = new QVBoxLayout( this );     
+      m_pTextEdit = new QTextEdit(this);
+      pVLayout->addWidget( m_pTextEdit );
       setObjectName("StatusInfo");
       setWindowFlags(Qt::Dialog);
-      setWordWrapMode(QTextOption::NoWrap);
-      setReadOnly(true);
-      setWindowModality( Qt::ApplicationModal );
-      //showMaximized();
+      m_pTextEdit->setWordWrapMode(QTextOption::NoWrap);
+      m_pTextEdit->setReadOnly(true);
+      QPushButton* pClose = new QPushButton(tr("Close"));
+      connect( pClose, SIGNAL(clicked()), this, SLOT(accept()));
+      pVLayout->addWidget(pClose);
    }
 
    bool isEmpty(){ 
-      return toPlainText().isEmpty(); }
+      return m_pTextEdit->toPlainText().isEmpty(); 
+   }
 
    void addText(const QString& s )
    {
-      append(s);
+      m_pTextEdit->append(s);
    }
 
+   void clear()
+   {
+      m_pTextEdit->clear();
+   }
+
    void setVisible(bool bVisible)
    {
       if (bVisible)
       {
-         moveCursor ( QTextCursor::End );
-         moveCursor ( QTextCursor::StartOfLine );
-         ensureCursorVisible();
+         m_pTextEdit->moveCursor ( QTextCursor::End );
+         m_pTextEdit->moveCursor ( QTextCursor::StartOfLine );
+         m_pTextEdit->ensureCursorVisible();
       }
 
-      QTextEdit::setVisible(bVisible);
+      QDialog::setVisible(bVisible);
+      if ( bVisible )
+         setWindowState( windowState() | Qt::WindowMaximized );
    }
 };
 
@@ -346,7 +360,7 @@
    m_bRealMergeStarted=false;
    m_bError = false;
    m_bSyncMode = false;
-   m_pStatusInfo = new StatusInfo(0);
+   m_pStatusInfo = new StatusInfo(this);
    m_pStatusInfo->hide();
    m_bScanning = false;
    m_pSelection1Item = 0;
@@ -1955,7 +1969,7 @@
          {
             KMessageBox::error(this, i18n("An error occurred while copying.\n"), \
i18n("Error") );  m_pStatusInfo->setWindowTitle(i18n("Merge Error"));
-            m_pStatusInfo->showMaximized();
+            m_pStatusInfo->exec();
             //if ( m_pStatusInfo->firstChild()!=0 )
             //   m_pStatusInfo->ensureItemVisible( m_pStatusInfo->last() );
             m_bError = true;
@@ -2338,7 +2352,7 @@
                static_cast<DirMergeItem*>(p)->m_pMFI->m_bSimOpComplete = false;
             }
             m_pStatusInfo->setWindowTitle(i18n("Simulated merge complete: Check if \
                you agree with the proposed operations."));
-            m_pStatusInfo->showMaximized();
+            m_pStatusInfo->exec();
          }
          m_mergeItemList.clear();
          m_bRealMergeStarted=false;
@@ -2373,7 +2387,7 @@
    {
       KMessageBox::error(this, i18n("An error occurred. Press OK to see detailed \
information.\n"), i18n("Error") );  m_pStatusInfo->setWindowTitle(i18n("Merge \
                Error"));
-      m_pStatusInfo->showMaximized();
+      m_pStatusInfo->exec();
       //if ( m_pStatusInfo->firstChild()!=0 )
       //   m_pStatusInfo->ensureItemVisible( m_pStatusInfo->last() );
       m_bError = true;
--- trunk/extragear/utils/kdiff3/src/fileaccess.cpp #1250628:1250629
@@ -135,9 +135,9 @@
          m_bWritable    = fi.isWritable();
          m_bExecutable  = fi.isExecutable();
 #endif
-         m_creationTime = fi.created();
+         //m_creationTime = fi.created();
          m_bHidden    = fi.isHidden();
-         m_modificationTime = fi.lastModified();
+         //m_modificationTime = fi.lastModified();
          m_accessTime = fi.lastRead();
          m_size       = fi.size();
          m_bSymLink   = fi.isSymLink();
@@ -164,6 +164,7 @@
             process.start( cmd );
             process.waitForFinished(-1);
             //::system( cmd.local8Bit() );
+            QFile::setPermissions( m_localCopy, QFile::ReadUser | QFile::WriteUser \
); // Clearcase creates a write protected file, allow delete.  
             QFileInfo fi( m_localCopy );
 #if defined(Q_WS_WIN)
@@ -329,11 +330,15 @@
 
 QDateTime FileAccess::created() const
 {
-   return ( m_creationTime.isValid() ?  m_creationTime : m_modificationTime );
+   if ( m_bLocal && m_creationTime.isNull() )
+      const_cast<FileAccess*>(this)->m_creationTime = QFileInfo( m_absoluteFilePath \
).created(); +   return ( m_creationTime.isValid() ?  m_creationTime : lastModified() \
);  }
 
 QDateTime FileAccess::lastModified() const
 {
+   if ( m_bLocal && m_modificationTime.isNull() )
+      const_cast<FileAccess*>(this)->m_modificationTime = QFileInfo( \
m_absoluteFilePath ).lastModified();  return m_modificationTime;
 }
 
@@ -996,7 +1001,7 @@
 // class CvsIgnoreList from Cervisia cvsdir.cpp
 //    Copyright (C) 1999-2002 Bernd Gehrmann <bernd at mail.berlios.de>
 // with elements from class StringMatcher
-//    Copyright (c) 2003 Andr�Woebeking <Woebbeking at web.de>
+//    Copyright (c) 2003 Andre Woebbeking <Woebbeking at web.de>
 // Modifications for KDiff3 by Joachim Eibl
 class CvsIgnoreList
 {
--- trunk/extragear/utils/kdiff3/src/gnudiff_system.h #1250628:1250629
@@ -116,6 +116,6 @@
 #define LIN_MAX PTRDIFF_MAX
 verify (lin_is_signed, TYPE_SIGNED (lin));
 verify (lin_is_wide_enough, sizeof (ptrdiff_t) <= sizeof (lin));
-verify (lin_is_printable_as_long, sizeof (lin) <= sizeof (long));
+//verify (lin_is_printable_as_long, sizeof (lin) <= sizeof (long));
 
 #endif
--- trunk/extragear/utils/kdiff3/src/kreplacements/ShellContextMenu.cpp \
#1250628:1250629 @@ -178,7 +178,7 @@
 	WNDPROC OldWndProc;
 	if (iMenuType > 1)	// only subclass if its version 2 or 3
 	{
-		OldWndProc = (WNDPROC) SetWindowLong (hWnd, GWL_WNDPROC, (DWORD) HookWndProc);
+		OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) \
HookWndProc);  if (iMenuType == 2)
 			g_IContext2 = (LPCONTEXTMENU2) pContextMenu;
 		else	// version 3
@@ -190,7 +190,7 @@
 	UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), \
pt.y(), 0, pParentWidget->winId(), 0);  
 	if (OldWndProc) // unsubclass
-		SetWindowLong (hWnd, GWL_WNDPROC, (DWORD) OldWndProc);
+		SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc);
 
 	if (idCommand >= MIN_ID && idCommand <= MAX_ID)	// see if returned idCommand \
belongs to shell menu entries  {
--- trunk/extragear/utils/kdiff3/src/kreplacements/kreplacements.cpp #1250628:1250629
@@ -81,7 +81,7 @@
 #ifndef Q_OS_OS2
       char buf[256];
       HINSTANCE hi = FindExecutableA( helpFile.fileName().toAscii(), \
                helpFile.absolutePath().toAscii(), buf );
-      if ( int(hi)<=32 )
+      if ( (quintptr)hi<=32 )
       {
 #endif
          static QTextBrowser* pBrowser = 0;
--- trunk/extragear/utils/kdiff3/src/main.cpp #1250628:1250629
@@ -160,7 +160,9 @@
    const QByteArray& appName = QByteArray("kdiff3");
    const QByteArray& appCatalog = appName;
    const KLocalizedString i18nName = ki18n("kdiff3");
-   const QByteArray& appVersion = QByteArray( VERSION );
+   QByteArray appVersion = QByteArray( VERSION );
+   if ( sizeof(void*)==8 )
+      appVersion += " (64 bit)";
    const KLocalizedString description = ki18n("Tool for Comparison and Merge of \
Files and Directories");  const KLocalizedString copyright = ki18n("(c) 2002-2011 \
Joachim Eibl");  const QByteArray& homePage = "http://kdiff3.sourceforge.net/";
--- trunk/extragear/utils/kdiff3/src/optiondialog.cpp #1250628:1250629
@@ -764,9 +764,9 @@
 
    OptionComboBox* pLineEndStyle = new OptionComboBox( eLineEndStyleAutoDetect, \
"LineEndStyle", &m_lineEndStyle, page, this );  gbox->addWidget( pLineEndStyle, line, \
                1 );
-   pLineEndStyle->insertItem( eLineEndStyleUnix, i18n("Unix") );
-   pLineEndStyle->insertItem( eLineEndStyleDos, i18n("Dos/Windows") );
-   pLineEndStyle->insertItem( eLineEndStyleAutoDetect, i18n("Autodetect") );
+   pLineEndStyle->insertItem( eLineEndStyleUnix, "Unix" );
+   pLineEndStyle->insertItem( eLineEndStyleDos, "Dos/Windows" );
+   pLineEndStyle->insertItem( eLineEndStyleAutoDetect, "Autodetect" );
 
    label->setToolTip( i18n(
       "Sets the line endings for when an edited file is saved.\n"
@@ -1327,6 +1327,7 @@
 "br Breton",
 "bs Bosnian",
 "ca Catalan",
+"ca@valencia Catalan (Valencian)",
 "cs Czech",
 "cy Welsh",
 "da Danish",
@@ -1346,6 +1347,7 @@
 "gu Gujarati",
 "he Hebrew",
 "hi Hindi",
+"hne Chhattisgarhi",
 "hr Croatian",
 "hsb Upper Sorbian",
 "hu Hungarian",
@@ -1361,6 +1363,7 @@
 "lv Latvian",
 "mi Maori",
 "mk Macedonian",
+"ml Malayalam"
 "mn Mongolian",
 "ms Malay",
 "mt Maltese",


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic