[Libreoffice-commits] .: 2 commits - tools/bootstrp
Joseph Powers
jpowers at kemper.freedesktop.org
Sat Feb 12 01:00:16 PST 2011
tools/bootstrp/addexes2/mkfilt.cxx | 36 ++++++++++++++++++-----------
tools/bootstrp/cppdep.cxx | 45 ++++++++++++++++++++++---------------
tools/bootstrp/cppdep.hxx | 6 ++--
tools/bootstrp/rscdep.cxx | 30 ++++--------------------
4 files changed, 59 insertions(+), 58 deletions(-)
New commits:
commit 78bd97554160bf2c676794878d7965e8016ba618
Author: Joseph Powers <jpowers27 at cox.net>
Date: Fri Feb 11 20:30:42 2011 -0800
Remove DECLARE_LIST( ByteStringList, ByteString * )
Alsp fixed some memory leeks.
diff --git a/tools/bootstrp/cppdep.cxx b/tools/bootstrp/cppdep.cxx
index 6d45965..7ad18a4 100644
--- a/tools/bootstrp/cppdep.cxx
+++ b/tools/bootstrp/cppdep.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
@@ -31,15 +31,13 @@
#include <stdio.h>
#include <string.h>
-
+
#include <unistd.h>
#include <sys/stat.h>
#include <tools/stream.hxx>
#include "cppdep.hxx"
-//#define TEST
-
CppDep::CppDep( ByteString aFileName )
{
aSourceFile = aFileName;
@@ -57,17 +55,28 @@ CppDep::CppDep()
CppDep::~CppDep()
{
+ for ( size_t i = 0, n = pSources->size(); i < n; ++i ) {
+ delete (*pSources)[ i ];
+ }
delete pSources;
+
+ for ( size_t i = 0, n = pSearchPath->size(); i < n; ++i ) {
+ delete (*pSearchPath)[ i ];
+ }
delete pSearchPath;
+
+ for ( size_t i = 0, n = pFileList->size(); i < n; ++i ) {
+ delete (*pFileList)[ i ];
+ }
delete pFileList;
}
void CppDep::Execute()
{
- ULONG nCount = pSources->Count();
- for ( ULONG n=0; n<nCount;n++)
+ size_t nCount = pSources->size();
+ for ( size_t n = 0; n < nCount; n++ )
{
- ByteString *pStr = pSources->GetObject(n);
+ ByteString *pStr = (*pSources)[ n ];
Search( *pStr );
}
}
@@ -75,14 +84,14 @@ void CppDep::Execute()
BOOL CppDep::AddSearchPath( const char* aPath )
{
ByteString *pStr = new ByteString( aPath );
- pSearchPath->Insert( pStr, LIST_APPEND );
+ pSearchPath->push_back( pStr );
return FALSE;
}
BOOL CppDep::AddSource( const char* aSource )
{
ByteString *pStr = new ByteString( aSource );
- pSources->Insert( pStr, LIST_APPEND );
+ pSources->push_back( pStr );
return FALSE;
}
@@ -117,10 +126,10 @@ BOOL CppDep::Search( ByteString aFileName )
if ( (aNewFile = Exists( aResult )) != "" )
{
BOOL bFound = FALSE;
- ULONG nCount = pFileList->Count();
- for ( ULONG i=0; i<nCount; i++ )
+ size_t nCount = pFileList->size();
+ for ( size_t i = 0; i < nCount; i++ )
{
- ByteString *pStr = pFileList->GetObject(i);
+ ByteString *pStr = (*pFileList)[ i ];
if ( *pStr == aNewFile )
bFound = TRUE;
}
@@ -129,7 +138,7 @@ BOOL CppDep::Search( ByteString aFileName )
#endif
if ( !bFound )
{
- pFileList->Insert( new ByteString( aNewFile ), LIST_APPEND );
+ pFileList->push_back( new ByteString( aNewFile ) );
#ifdef DEBUG_VERBOSE
fprintf( stderr, " CppDep %s\\\n", aNewFile.GetBuffer() );
#endif
@@ -152,11 +161,11 @@ ByteString CppDep::Exists( ByteString aFileName )
fprintf( stderr, "Searching %s \n", aFileName.GetBuffer() );
#endif
- ULONG nCount = pSearchPath->Count();
- for ( ULONG n=0; n<nCount; n++)
+ size_t nCount = pSearchPath->size();
+ for ( size_t n = 0; n < nCount; n++ )
{
struct stat aBuf;
- ByteString *pPathName = pSearchPath->GetObject(n);
+ ByteString *pPathName = (*pSearchPath)[ n ];
strcpy( pFullName, pPathName->GetBuffer());
strcat( pFullName, DIR_SEP );
@@ -188,7 +197,7 @@ ByteString CppDep::IsIncludeStatement( ByteString aLine )
#ifdef DEBUG_VERBOSE
fprintf( stderr, "found starting C comment : %s\n", aLine.GetBuffer() );
#endif
- aLine.Erase(aLine.Search("/*",0), aLine.Len() - 1);
+ aLine.Erase(aLine.Search("/*",0), aLine.Len() - 1);
#ifdef DEBUG_VERBOSE
fprintf( stderr, "cleaned string : %s\n", aLine.GetBuffer() );
#endif
@@ -198,7 +207,7 @@ ByteString CppDep::IsIncludeStatement( ByteString aLine )
#ifdef DEBUG_VERBOSE
fprintf( stderr, "found C++ comment : %s\n", aLine.GetBuffer() );
#endif
- aLine.Erase(aLine.Search("//",0), aLine.Len() - 1);
+ aLine.Erase(aLine.Search("//",0), aLine.Len() - 1);
#ifdef DEBUG_VERBOSE
fprintf( stderr, "cleaned string : %s\n", aLine.GetBuffer() );
#endif
diff --git a/tools/bootstrp/cppdep.hxx b/tools/bootstrp/cppdep.hxx
index 46d401f..2b50f78 100644
--- a/tools/bootstrp/cppdep.hxx
+++ b/tools/bootstrp/cppdep.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
@@ -26,12 +26,12 @@
*
************************************************************************/
-#include <tools/list.hxx>
#include <tools/string.hxx>
+#include <vector>
#define PATH_SEP ":"
#define DIR_SEP "/"
-DECLARE_LIST( ByteStringList, ByteString * )
+typedef ::std::vector< ByteString* > ByteStringList;
class CppDep
{
diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx
index b7cc7b2..8363875 100644
--- a/tools/bootstrp/rscdep.cxx
+++ b/tools/bootstrp/rscdep.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
@@ -46,7 +46,7 @@
#include "cppdep.hxx"
-#if defined WNT
+#if defined WNT
#if !defined HAVE_GETOPT
#define __STDC__ 1
#define __GNU_LIBRARY__
@@ -79,8 +79,6 @@ void RscHrcDep::Execute()
CppDep::Execute();
}
-//static String aDelim;
-
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
{
int c;
@@ -96,7 +94,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
String aDelim = '/';
RscHrcDep *pDep = new RscHrcDep;
-
+
pOutputFileName[0] = 0;
pSrsFileName[0] = 0;
@@ -123,12 +121,10 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
}
if (aBuf[0] == '-' && aBuf[1] == 'i' )
{
- //printf("Include : %s\n", &aBuf[2] );
pDep->AddSearchPath( &aBuf[2] );
}
if (aBuf[0] == '-' && aBuf[1] == 'I' )
{
- //printf("Include : %s\n", &aBuf[2] );
pDep->AddSearchPath( &aBuf[2] );
}
if (aBuf[0] == '@' )
@@ -160,12 +156,10 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
}
if (aBuf2[0] == '-' && aBuf2[1] == 'i' )
{
- //printf("Include : %s\n", &aBuf[2] );
pDep->AddSearchPath( &aBuf2[2] );
}
if (aBuf2[0] == '-' && aBuf2[1] == 'I' )
{
- //printf("Include : %s\n", &aBuf[2] );
pDep->AddSearchPath( &aBuf2[2] );
}
if (( aBuf2[0] != '-' ) && ( aBuf2[0] != '@' ))
@@ -220,18 +214,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
DirEntry aEntry(".");
aEntry.ToAbs();
-// String aCwd = aEntry.GetName();
String aCwd(pFileNamePrefix, gsl_getSystemTextEncoding());
-/* USHORT nPos;
-#ifndef UNX
- while ( (nPos = aCwd.Search('\\') != STRING_NOTFOUND ))
-#else
- while ( (nPos = aCwd.Search('/') != STRING_NOTFOUND ))
-#endif
- {
- String attt = aCwd.Copy( 0, nPos );
- aCwd.Erase( 0, nPos );
- } */
SvFileStream aOutStream;
String aOutputFileName( pOutputFileName, gsl_getSystemTextEncoding());
DirEntry aOutEntry( aOutputFileName );
@@ -243,7 +226,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
aFileName += String(".", gsl_getSystemTextEncoding());
aFileName += aSrsBaseName;
aFileName += String(".dprr", gsl_getSystemTextEncoding());
- //fprintf( stderr, "OutFileName : %s \n",aFileName.GetStr());
aOutStream.Open( aFileName, STREAM_WRITE );
ByteString aString;
@@ -273,7 +255,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
aString += aRespArg;
pDep->Execute();
ByteStringList *pLst = pDep->GetDepList();
- ULONG nCount = pLst->Count();
+ size_t nCount = pLst->size();
if ( nCount == 0 )
{
aOutStream.WriteLine( aString );
@@ -284,9 +266,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
aOutStream.WriteLine( aString );
}
- for ( ULONG j=0; j<nCount; j++ )
+ for ( size_t j = 0; j < nCount; j++ )
{
- ByteString *pStr = pLst->GetObject(j);
+ ByteString *pStr = (*pLst)[ j ];
pStr->SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US ));
if ( j != (nCount-1) )
*pStr += ByteString( "\\" );
commit 2cc2e5b9a45887a53f01ad2fd324b6ed43f018ef
Author: Joseph Powers <jpowers27 at cox.net>
Date: Fri Feb 11 19:34:44 2011 -0800
Remove DECLARE_LIST( ByteStringList, MkLine * )
Also fix some memory leeks.
diff --git a/tools/bootstrp/addexes2/mkfilt.cxx b/tools/bootstrp/addexes2/mkfilt.cxx
index 6f42f53..36b3140 100644
--- a/tools/bootstrp/addexes2/mkfilt.cxx
+++ b/tools/bootstrp/addexes2/mkfilt.cxx
@@ -32,7 +32,7 @@
#include <stdio.h>
#include <../../inc/tools/string.hxx>
-#include <../../inc/tools/list.hxx>
+#include <vector>
class TextFilter
{
@@ -82,7 +82,8 @@ void TextFilter::Filter()
#define LINE_LEN 2048
-class ByteStringList;
+class MkLine;
+typedef ::std::vector< MkLine* > ByteStringList;
class MkLine
{
@@ -102,7 +103,6 @@ MkLine::MkLine()
pPrivateTnrLst = NULL;
}
-DECLARE_LIST( ByteStringList, MkLine * )
class MkFilter : public TextFilter
{
@@ -125,7 +125,13 @@ MkFilter::MkFilter( ByteString aInFile, ByteString aOutFile ) :
MkFilter::~MkFilter()
{
+ for ( size_t i = 0, n = pLst->size(); i < n; ++i ) {
+ delete (*pTnrLst)[ i ];
+ }
delete pTnrLst;
+ for ( size_t i = 0, n = pLst->size(); i < n; ++i ) {
+ delete (*pLst)[ i ];
+ }
delete pLst;
}
@@ -162,7 +168,7 @@ void MkFilter::Filter()
pMkLine->aLine = *pStr;
pMkLine->bOut = FALSE;
- pLst->Insert( pMkLine, LIST_APPEND );
+ pLst->push_back( pMkLine );
}
else if ( nState == 1 )
{
@@ -179,7 +185,7 @@ void MkFilter::Filter()
p_MkLine->bOut = FALSE;
p_MkLine->pPrivateTnrLst = pTnrLst;
pTnrLst = new ByteStringList();
- pLst->Insert( p_MkLine, LIST_APPEND );
+ pLst->push_back( p_MkLine );
nState = 0;
bInTnrList = FALSE;
}
@@ -188,7 +194,7 @@ void MkFilter::Filter()
pMkLine->bOut = FALSE;
if ( bInTnrList )
- pTnrLst->Insert( pMkLine, LIST_APPEND );
+ pTnrLst->push_back( pMkLine );
}
else {
/* Zeilen ignorieren */;
@@ -197,27 +203,31 @@ void MkFilter::Filter()
fprintf( stderr, "\n" );
// das File wieder ausgegeben
- ULONG nLines = pLst->Count();
- for ( ULONG j=0; j<nLines; j++ )
+ size_t nLines = pLst->size();
+ for ( size_t j=0; j<nLines; j++ )
{
- MkLine *pLine = pLst->GetObject( j );
+ MkLine *pLine = (*pLst)[ j ];
if ( pLine->bHier )
{
// die List n - Mal abarbeiten
for ( USHORT n=1; n<11; n++)
{
- ULONG nCount = pLine->pPrivateTnrLst->Count();
- for ( ULONG i=0; i<nCount; i++ )
+ size_t nCount = pLine->pPrivateTnrLst->size();
+ for ( size_t i=0; i<nCount; i++ )
{
- MkLine *pMkLine = pLine->pPrivateTnrLst->GetObject(i);
+ MkLine *pMkLine = (*pLine->pPrivateTnrLst)[ i ];
ByteString aLine = pMkLine->aLine;
while( aLine.SearchAndReplace( aTnr, ByteString::CreateFromInt32( n )) != (USHORT)-1 ) ;
fputs( aLine.GetBuffer(), pOut );
fprintf( stderr, "o" );
}
}
- if ( pLine->pPrivateTnrLst != NULL )
+ if ( pLine->pPrivateTnrLst != NULL ) {
+ for ( size_t i = 0, n = pLine->pPrivateTnrLst->size(); i < n; ++i ) {
+ delete (*pLine->pPrivateTnrLst)[ i ];
+ }
delete pLine->pPrivateTnrLst;
+ }
pLine->pPrivateTnrLst = NULL;
}
if ( pLine->bOut )
More information about the Libreoffice-commits
mailing list