[Libreoffice-commits] .: 2 commits - tools/inc tools/source

Joseph Powers jpowers at kemper.freedesktop.org
Tue Feb 15 06:37:08 PST 2011


 tools/inc/tools/fsys.hxx     |   14 ++++----
 tools/source/fsys/os2.cxx    |   10 +-----
 tools/source/fsys/tdir.cxx   |   71 ++++++++++++++++++-------------------------
 tools/source/fsys/unx.cxx    |   16 +++------
 tools/source/fsys/wntmsc.cxx |   14 +++-----
 5 files changed, 52 insertions(+), 73 deletions(-)

New commits:
commit 36522f65f9cf5cb39695ef54c0c8a82c77c87e25
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Tue Feb 15 06:36:28 2011 -0800

    Remove DECLARE_LIST( DirEntryList, DirEntry* )

diff --git a/tools/inc/tools/fsys.hxx b/tools/inc/tools/fsys.hxx
index 2f25221..43e9819 100644
--- a/tools/inc/tools/fsys.hxx
+++ b/tools/inc/tools/fsys.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -37,6 +37,7 @@
 #include "tools/toolsdllapi.h"
 
 #include <cstdarg>
+#include <vector>
 
 #define FEAT_FSYS_DOUBLESPEED
 
@@ -45,13 +46,14 @@
 // --------------
 
 class DirEntry;
-class DirEntryList;
 class FSysSortList;
 class FileStatList;
 struct FileCopier_Impl;
 class SvFileStream;
 class BigInt;
 
+typedef ::std::vector< DirEntry* > DirEntryList;
+
 #define FSYS_BUFSIZE				1024
 #define FSYS_SHORTNAME_DELIMITER	'@'
 
@@ -472,8 +474,8 @@ private:
 protected:
     BOOL			ImpInsertPointReached( const DirEntry& rIsSmaller,
                                            const FileStat& rNewStat,
-                                           ULONG nCurPos,
-                                           ULONG nSortIndex ) const;
+                                           size_t nCurPos,
+                                           size_t nSortIndex ) const;
     void			ImpSortedInsert( const DirEntry *pNewEntry,
                                      const FileStat *pNewStat );
 #endif
@@ -493,11 +495,11 @@ public:
 
     void			Reset();
     USHORT			Scan( USHORT nCount = 5 );
-    USHORT			Count( BOOL bUpdated = TRUE ) const;
+    size_t          Count( BOOL bUpdated = TRUE ) const;
     BOOL			Update();
 
     Dir&			operator +=( const Dir& rDir );
-    DirEntry&		operator []( USHORT nIndex ) const;
+    DirEntry&       operator []( size_t nIndex ) const;
 };
 
 // we don't need this stuff for bootstraping
diff --git a/tools/source/fsys/tdir.cxx b/tools/source/fsys/tdir.cxx
index a6cd710..ebde24b 100644
--- a/tools/source/fsys/tdir.cxx
+++ b/tools/source/fsys/tdir.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -40,10 +40,8 @@
 #include "comdep.hxx"
 #include <tools/fsys.hxx>
 
-
 DBG_NAME( Dir )
 
-DECLARE_LIST( DirEntryList, DirEntry* )
 DECLARE_LIST( FSysSortList, FSysSort* )
 DECLARE_LIST( FileStatList, FileStat* )
 
@@ -59,19 +57,19 @@ DECLARE_LIST( FileStatList, FileStat* )
 
 BOOL Dir::ImpInsertPointReached( const DirEntry& rNewEntry,
                                  const FileStat& rNewStat,
-                                 ULONG nCurPos, ULONG nSortIndex ) const
+                                 size_t nCurPos, size_t nSortIndex ) const
 {
 #define VALUE( nKindFlags ) \
     ( ( FSYS_KIND_FILE | FSYS_KIND_DIR | FSYS_KIND_DEV | \
         FSYS_KIND_CHAR | FSYS_KIND_BLOCK ) & nKindFlags )
 
     // einfache Dinge erfordern einfache Loesungen
-    if ( !pLst->Count() )
+    if ( pLst->empty() )
         return TRUE;
 
     FSysSort  nSort      = *( pSortLst->GetObject( nSortIndex ) );
     FileStat *pOldStat   = NULL;
-    DirEntry *pCurLstObj = pLst->GetObject( nCurPos );
+    DirEntry *pCurLstObj = (*pLst)[ nCurPos ];
     if ( pStatLst )
         pOldStat = pStatLst->GetObject( nCurPos );
 
@@ -214,25 +212,26 @@ void Dir::ImpSortedInsert( const DirEntry *pNewEntry, const FileStat *pNewStat )
 {
     //Sonderfall, keine Sortierung gewuenscht.
     if ( !pSortLst ) {
-        pLst->Insert( (DirEntry*)pNewEntry, APPEND );
+        pLst->push_back( (DirEntry*)pNewEntry );
         return;
     }
 
-    pLst->First();
-    do {
-        if ( ImpInsertPointReached( *pNewEntry, *pNewStat, pLst->GetCurPos(),
-                                    (ULONG)0  ) )
+    for ( size_t i = 0, n = pLst->size(); i < n; ++i )
+    {
+        if ( ImpInsertPointReached( *pNewEntry, *pNewStat, i, 0  ) )
         {
             if ( pStatLst )
-                pStatLst->Insert( (FileStat*)pNewStat, pLst->GetCurPos() );
-            pLst->Insert( (DirEntry*)pNewEntry );
+                pStatLst->Insert( (FileStat*)pNewStat, i );
+            DirEntryList::iterator it = pLst->begin();
+            ::std::advance( it, i );
+            pLst->insert( it, (DirEntry*)pNewEntry );
             return;
         }
-    } while( pLst->Next() );
+    }
 
     if ( pStatLst )
         pStatLst->Insert( (FileStat*)pNewStat, APPEND );
-    pLst->Insert( (DirEntry*)pNewEntry, APPEND );
+    pLst->push_back( (DirEntry*)pNewEntry );
 }
 
 /*************************************************************************
@@ -295,14 +294,10 @@ void Dir::Reset()
     // alle DirEntries aus der Liste entfernen und deren Speicher freigeben
     if ( pLst )
     {
-        DirEntry* pEntry = pLst->First();
-        while (pEntry)
-        {
-            DirEntry* pNext = pLst->Next();
-            delete pEntry;
-            pEntry = pNext;
+        for ( size_t i = 0, n = pLst->size(); i < n; ++i ) {
+            delete (*pLst)[ i ];
         }
-        pLst->Clear();
+        pLst->clear();
     }
     else
         pLst = new DirEntryList();
@@ -368,7 +363,7 @@ USHORT Dir::Scan( USHORT nCount )
     if ( pReader )
     {
         // frischer Reader?
-        if ( !pLst->Count() )
+        if ( pLst->empty() )
         {
             // dann ggf. Laufwerke scannen
             pReader->bInUse = TRUE;
@@ -456,15 +451,10 @@ Dir::~Dir()
     // alle DirEntries aus der Liste entfernen und deren Speicher freigeben
     if ( pLst )
     {
-        DirEntry* pEntry = pLst->First();
-        while (pEntry)
-        {
-            DirEntry* pNext = pLst->Next();
-            delete pEntry;
-            pEntry = pNext;
+        for ( size_t i = 0, n = pLst->size(); i < n; ++i ) {
+            delete (*pLst)[ i ];
         }
-        pLst->Clear();
-
+        pLst->clear();
         delete pLst;
     }
 
@@ -607,17 +597,16 @@ FSysError Dir::ImpSetSort( std::va_list pArgs, int nFirstSort )
             pOldStatLst = pStatLst;
             pStatLst = new FileStatList(); //neue StatListe (zu Sortieren)
         }
-        pOldLst->First();
-        do
+
+        for ( size_t i = 0, n = pOldLst->size(); i < n; ++i )
         {
             //Sortiertes Einfuegen der Elemente aus den gemerkten Listen
             //in die 'richtigen' Listen
             if ( pOldStatLst )
-                ImpSortedInsert( pOldLst->GetCurObject(),
-                                 pOldStatLst->GetObject( pOldLst->GetCurPos() ) );
+                ImpSortedInsert( (*pOldLst)[ i ], pOldStatLst->GetObject( i ) );
             else
-                ImpSortedInsert( pOldLst->GetCurObject(), NULL );
-        } while( pOldLst->Next() );
+                ImpSortedInsert( (*pOldLst)[ i ], NULL );
+        }
 
         delete pOldLst;
         if ( pOldStatLst )
@@ -645,11 +634,11 @@ FSysError Dir::SetSort( FSysSort nSort, ... )
 |*
 *************************************************************************/
 
-DirEntry& Dir::operator[] ( USHORT nIndex ) const
+DirEntry& Dir::operator[] ( size_t nIndex ) const
 {
     DBG_ASSERT( nIndex < Count(), "Dir::operator[] : nIndex > Count()" );
 
-    DirEntry *pEntry = pLst->GetObject( nIndex );
+    DirEntry *pEntry = (*pLst)[ nIndex ];
     return *pEntry;
 }
 
@@ -703,13 +692,13 @@ Dir& Dir::operator+=( const Dir& rDir )
 *************************************************************************/
 
 
-USHORT Dir::Count( BOOL bUpdated ) const
+size_t Dir::Count( BOOL bUpdated ) const
 {
     // ggf. erst den Rest lesen
     if ( bUpdated && pReader )
         ((Dir*)this)->Scan( USHRT_MAX );
 
-    return pLst == NULL ? 0 : (USHORT) pLst->Count();
+    return pLst == NULL ? 0 : pLst->size();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 732f667114e8947954e68efc969fbf09d656bffa
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Tue Feb 15 06:34:47 2011 -0800

    Remove some extra DECLARE_LIST() items

diff --git a/tools/source/fsys/os2.cxx b/tools/source/fsys/os2.cxx
index d7281d6..0bcf7d9 100644
--- a/tools/source/fsys/os2.cxx
+++ b/tools/source/fsys/os2.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -47,10 +47,6 @@
 
 int Sys2SolarError_Impl( int nSysErr );
 
-DECLARE_LIST( DirEntryList, DirEntry* );
-DECLARE_LIST( FSysSortList, FSysSort* );
-DECLARE_LIST( FileStatList, FileStat* );
-
 static char sCaseMap[256];
 static BOOL bCaseMap = FALSE;
 static BOOL bDriveMap = FALSE;
@@ -173,7 +169,7 @@ BOOL DirEntry::ToAbs()
 String DirEntry::GetVolume() const
 {
     DBG_CHKTHIS( DirEntry, ImpCheckDirEntry );
-    
+
     String aRet;
     const DirEntry *pTop = ImpGetTopPtr();
     ByteString aName = ByteString( pTop->aName ).ToLowerAscii();
@@ -250,7 +246,7 @@ USHORT DirReader_Impl::Init()
             sDrive[0] = c;
             sRoot[0] = c;
             DirEntry* pDrive = new DirEntry( sDrive, FSYS_FLAG_VOLUME, FSYS_STYLE_HOST );
-            if ( pDir->aNameMask.Matches( String( ByteString(sDrive), osl_getThreadTextEncoding())) 
+            if ( pDir->aNameMask.Matches( String( ByteString(sDrive), osl_getThreadTextEncoding()))
                 && aDriveMap[c-'a'].nKind != FSYS_KIND_UNKNOWN )
             {
                 if ( pDir->pStatLst ) //Status fuer Sort gewuenscht?
diff --git a/tools/source/fsys/unx.cxx b/tools/source/fsys/unx.cxx
index 7d93c4d..989fe24 100644
--- a/tools/source/fsys/unx.cxx
+++ b/tools/source/fsys/unx.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -43,7 +43,7 @@
 #include <sys/mntctl.h>
 #include <sys/vmount.h>
 extern "C" int mntctl( int cmd, size_t size, char* buf );
-#elif defined(NETBSD) 
+#elif defined(NETBSD)
 #include <sys/mount.h>
 #elif defined(FREEBSD) || defined(MACOSX) || defined(OPENBSD)
 #elif defined DECUNIX
@@ -66,10 +66,6 @@ struct mnttab
 #include "comdep.hxx"
 #include <rtl/instance.hxx>
 
-DECLARE_LIST( DirEntryList, DirEntry* )
-DECLARE_LIST( FSysSortList, FSysSort* )
-DECLARE_LIST( FileStatList, FileStat* )
-
 #if defined SOLARIS || defined SINIX
 #define MOUNTSPECIAL mnt_special
 #define MOUNTPOINT 	 mnt_mountp
@@ -333,8 +329,8 @@ String DirEntry::GetVolume() const
     }
     mymnttab &rMnt = mymnt::get();
     return ((buf.st_dev == rMnt.mountdevice ||
-                GetMountEntry(buf.st_dev, &rMnt)) ? 
-                    String(rMnt.mountspecial, osl_getThreadTextEncoding()) : 
+                GetMountEntry(buf.st_dev, &rMnt)) ?
+                    String(rMnt.mountspecial, osl_getThreadTextEncoding()) :
                     String());
 }
 
@@ -354,8 +350,8 @@ DirEntry DirEntry::GetDevice() const
     }
     mymnttab &rMnt = mymnt::get();
     return ((buf.st_dev == rMnt.mountdevice ||
-                GetMountEntry(buf.st_dev, &rMnt)) ? 
-                    String( rMnt.mountpoint, osl_getThreadTextEncoding()) : 
+                GetMountEntry(buf.st_dev, &rMnt)) ?
+                    String( rMnt.mountpoint, osl_getThreadTextEncoding()) :
                     String());
 }
 
diff --git a/tools/source/fsys/wntmsc.cxx b/tools/source/fsys/wntmsc.cxx
index 12da4c9..2c9eae2 100644
--- a/tools/source/fsys/wntmsc.cxx
+++ b/tools/source/fsys/wntmsc.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -47,10 +47,6 @@
 #include <tools/fsys.hxx>
 #include <tools/bigint.hxx>
 
-DECLARE_LIST( DirEntryList, DirEntry* );
-DECLARE_LIST( FSysSortList, FSysSort* );
-DECLARE_LIST( FileStatList, FileStat* );
-
 int Sys2SolarError_Impl( int nSysErr );
 
 static BOOL   bLastCaseSensitive    = FALSE;
@@ -506,21 +502,21 @@ void FileStat::ImpInit( void* p )
     FILETIME aLocTime;
 
     // use the last write date / time when the creation date / time isn't set
-    if ( ( pDirEnt->ftCreationTime.dwLowDateTime == 0 ) && 
+    if ( ( pDirEnt->ftCreationTime.dwLowDateTime == 0 ) &&
          ( pDirEnt->ftCreationTime.dwHighDateTime == 0 ) )
     {
         pDirEnt->ftCreationTime.dwLowDateTime = pDirEnt->ftLastWriteTime.dwLowDateTime;
         pDirEnt->ftCreationTime.dwHighDateTime = pDirEnt->ftLastWriteTime.dwHighDateTime;
     }
-    
+
     // use the last write date / time when the last accessed date / time isn't set
-    if ( ( pDirEnt->ftLastAccessTime.dwLowDateTime == 0 ) && 
+    if ( ( pDirEnt->ftLastAccessTime.dwLowDateTime == 0 ) &&
          ( pDirEnt->ftLastAccessTime.dwHighDateTime == 0 ) )
     {
         pDirEnt->ftLastAccessTime.dwLowDateTime = pDirEnt->ftLastWriteTime.dwLowDateTime;
         pDirEnt->ftLastAccessTime.dwHighDateTime = pDirEnt->ftLastWriteTime.dwHighDateTime;
     }
-    
+
     FileTimeToLocalFileTime( &pDirEnt->ftCreationTime, &aLocTime );
     FileTimeToSystemTime( &aLocTime, &aSysTime );
     aDateCreated  = Date( aSysTime.wDay, aSysTime.wMonth, aSysTime.wYear );


More information about the Libreoffice-commits mailing list