diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-27 16:05:12 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-27 16:05:12 +0000 |
commit | fd2cf3dc7cd9c73070fa4d70c8ca99c9fc1ce135 (patch) | |
tree | 9569a564e06fba817528ea414129b4074d83cb61 /tools/source/communi | |
parent | ff09f8d6ef2c613037f039dbcafcad6b76243a48 (diff) |
MWS_SRX644: migrate branch mws_srx644 -> HEAD
Diffstat (limited to 'tools/source/communi')
-rw-r--r-- | tools/source/communi/geninfo.cxx | 25 | ||||
-rw-r--r-- | tools/source/communi/makefile.mk | 8 | ||||
-rw-r--r-- | tools/source/communi/parser.cxx | 107 |
3 files changed, 47 insertions, 93 deletions
diff --git a/tools/source/communi/geninfo.cxx b/tools/source/communi/geninfo.cxx index b4616e0bdf26..09abae555a2a 100644 --- a/tools/source/communi/geninfo.cxx +++ b/tools/source/communi/geninfo.cxx @@ -2,9 +2,9 @@ * * $RCSfile: geninfo.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: gh $ $Date: 2002-01-09 17:34:58 $ + * last change: $Author: hr $ $Date: 2003-03-27 17:03:45 $ * * Copyright according the GNU Public License. * @@ -254,24 +254,11 @@ ULONG GenericInformationList::InsertSorted( GenericInformation *pInfo, return 0; } - ByteString sKey( pInfo->GetBuffer()); - sKey.ToUpperAscii(); - - // Check to sppeed up reading a (partially) sorted list - if ( nStart == 0 && Count()-1 == nEnd ) - { - ByteString sCandidate( *GetObject( nEnd )); - if ( sCandidate.ToUpperAscii() < sKey ) - { - Insert( pInfo, LIST_APPEND ); - return nEnd+1; - } - } - // ### GH: dieser Block schein überflüssig zu sein + ByteString sKey( pInfo->GetBuffer()); if ( Count() == 1 ) { ByteString sCandidate( *GetObject( 0 )); - if ( sCandidate.ToUpperAscii() == sKey ) { + if ( sCandidate.ToUpperAscii() == sKey.ToUpperAscii()) { // key allready exists in list if ( bOverwrite ) Replace( pInfo, ULONG(0)); // ### Laut NF scheint hier ein Memory Leak zu sein @@ -291,7 +278,7 @@ ULONG GenericInformationList::InsertSorted( GenericInformation *pInfo, ULONG nActPos = nStart + (( nEnd - nStart ) / 2 ); ByteString sCandidate = ByteString( *GetObject( nActPos )); - if ( sCandidate.ToUpperAscii() == sKey ) { + if ( sCandidate.ToUpperAscii() == sKey.ToUpperAscii()) { // key allready exists in list if ( bOverwrite ) Replace( pInfo, nActPos ); // ### Laut NF scheint hier ein Memory Leak zu sein @@ -306,7 +293,7 @@ ULONG GenericInformationList::InsertSorted( GenericInformation *pInfo, } else { Insert( pInfo, nStart + 1 ); - return ( nStart + 1 ); + return ( nStart + 1 ); } } diff --git a/tools/source/communi/makefile.mk b/tools/source/communi/makefile.mk index 9f660bb450da..52f0ea6ced82 100644 --- a/tools/source/communi/makefile.mk +++ b/tools/source/communi/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: gh $ $Date: 2002-04-19 07:59:27 $ +# last change: $Author: hr $ $Date: 2003-03-27 17:03:47 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -76,7 +76,6 @@ TARGET=communi CXXFILES= simplecm.cxx bcst.cxx OBJFILES= \ - $(OBJ)$/SafePureVirtual.obj \ $(OBJ)$/tcpio.obj \ $(OBJ)$/packethandler.obj \ $(OBJ)$/simplecm.obj \ @@ -89,10 +88,8 @@ OBJFILES= \ $(OBJ)$/ssockcon.obj \ $(OBJ)$/parser.obj \ $(OBJ)$/geninfo.obj \ - $(OBJ)$/abthread.obj SLOFILES= \ - $(SLO)$/SafePureVirtual.obj \ $(SLO)$/tcpio.obj \ $(SLO)$/packethandler.obj \ $(SLO)$/simplecm.obj \ @@ -105,7 +102,6 @@ SLOFILES= \ $(SLO)$/ssockcon.obj \ $(SLO)$/parser.obj \ $(SLO)$/geninfo.obj \ - $(SLO)$/abthread.obj # --- Targets ------------------------------------------------------ diff --git a/tools/source/communi/parser.cxx b/tools/source/communi/parser.cxx index 6ace9aa612dd..890106083a16 100644 --- a/tools/source/communi/parser.cxx +++ b/tools/source/communi/parser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: parser.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: gh $ $Date: 2002-05-27 14:42:42 $ + * last change: $Author: hr $ $Date: 2003-03-27 17:03:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,7 +72,7 @@ // class InformationParser // -#define cKeyLevelChar '\t' +const char InformationParser::cKeyLevelChars = '\t'; /*****************************************************************************/ InformationParser::InformationParser( BOOL bReplace ) @@ -109,25 +109,20 @@ ByteString &InformationParser::ReadLine() else { if ( !pActStream->IsEof()) { pActStream->ReadLine( sLine ); - ULONG nStart = 0; - ULONG nEnd = sLine.Len(); - BOOL bCopy = FALSE; - while ( nStart < nEnd && ( sLine.GetChar( nStart ) == ' ' || sLine.GetChar( nStart ) == 0x09 ) ) - { - nStart++; - bCopy = TRUE; - } - - while ( nStart < nEnd && ( sLine.GetChar( nEnd-1 ) == ' ' || sLine.GetChar( nEnd-1 ) == 0x09 ) ) - { - nEnd--; - bCopy = TRUE; - } - - if ( bCopy ) - sLine = sLine.Copy( nStart, nEnd - nStart ); - - if (( sLine.GetChar( 0 ) == '#' ) || ( !sLine.Len())) { + ULONG nLen; + do { + nLen = sLine.Len(); + sLine.EraseLeadingChars( 0x09 ); + sLine.EraseLeadingChars( ' ' ); + } while ( nLen != sLine.Len()); + + do { + nLen = sLine.Len(); + sLine.EraseTrailingChars( 0x09 ); + sLine.EraseTrailingChars( ' ' ); + } while ( nLen != sLine.Len()); + + if (( sLine.Search( "#" ) == 0 ) || ( !sLine.Len())) { if ( sCurrentComment.Len()) sCurrentComment += "\n"; sCurrentComment += sLine; @@ -135,21 +130,11 @@ ByteString &InformationParser::ReadLine() } else { if ( bReplaceVariables ) { - sLine.SearchAndReplaceAll( "%UPD", sUPD ); - sLine.SearchAndReplaceAll( "%VERSION", sVersion ); + while( sLine.SearchAndReplace( "%UPD", sUPD ) != (USHORT)-1 ); + while( sLine.SearchAndReplace( "%VERSION", sVersion ) != (USHORT)-1 ); } } } - else { - if ( nLevel ) { - sLine = "}"; - fprintf( stdout, "Reached EOF parsing %s. Suplying extra '}'\n",ByteString( sStreamName, gsl_getSystemTextEncoding()).GetBuffer() ); - // nErrorCode = IP_UNEXPECTED_EOF; - // nErrorLine = nActLine; - } - else - sLine = ""; - } sOldLine = sLine; nActLine++; @@ -230,11 +215,8 @@ GenericInformation *InformationParser::ReadKey( } else { Recover(); - if ( !sKey.Equals( "}" ) && !sKey.Equals( "{" ) ) - { - pInfo = new GenericInformation( sKey, sValue, pExistingList ); - pInfo->SetComment( sComment ); - } + pInfo = new GenericInformation( sKey, sValue, pExistingList ); + pInfo->SetComment( sComment ); } return pInfo; @@ -250,7 +232,7 @@ void InformationParser::Recover() /*****************************************************************************/ BOOL InformationParser::Save( SvStream &rOutStream, const GenericInformationList *pSaveList, - USHORT nLevel, BOOL bStripped ) + USHORT nLevel ) /*****************************************************************************/ { USHORT i; @@ -259,23 +241,19 @@ BOOL InformationParser::Save( SvStream &rOutStream, GenericInformation *pGenericInfo; GenericInformationList *pGenericInfoList; - static ByteString aKeyLevel; - aKeyLevel.Expand( nLevel, cKeyLevelChar ); - for ( nInfoListCount = 0; nInfoListCount < pSaveList->Count(); nInfoListCount++) { // Key-Value Paare schreiben pGenericInfo = pSaveList->GetObject( nInfoListCount ); sTmpStr = ""; - if ( !bStripped && nLevel ) - sTmpStr.Append( aKeyLevel.GetBuffer(), nLevel ); - - if ( !bStripped ) - for ( i = 0; i < pGenericInfo->GetComment().GetTokenCount( '\n' ); i++ ) { - sTmpStr += pGenericInfo->GetComment().GetToken( i, '\n' ); - sTmpStr += "\n"; - if ( nLevel ) - sTmpStr.Append( aKeyLevel.GetBuffer(), nLevel ); - } + for( ULONG j=0; j<nLevel; j++) + sTmpStr += cKeyLevelChars; + + for ( i = 0; i < pGenericInfo->GetComment().GetTokenCount( '\n' ); i++ ) { + sTmpStr += pGenericInfo->GetComment().GetToken( i, '\n' ); + sTmpStr += "\n"; + for( ULONG j=0; j<nLevel; j++) + sTmpStr += cKeyLevelChars; + } sTmpStr += pGenericInfo->GetBuffer(); sTmpStr += ' '; @@ -284,21 +262,21 @@ BOOL InformationParser::Save( SvStream &rOutStream, return FALSE; // wenn vorhanden, bearbeite recursive die Sublisten - if (( pGenericInfoList = pGenericInfo->GetSubList() ) != NULL ) { + if (( pGenericInfoList = pGenericInfo->GetSubList() ) != 0) { // oeffnende Klammer sTmpStr = ""; - if ( !bStripped && nLevel ) - sTmpStr.Append( aKeyLevel.GetBuffer(), nLevel ); + for( i=0; i<nLevel; i++) + sTmpStr += cKeyLevelChars; sTmpStr += '{'; if ( !rOutStream.WriteLine( sTmpStr ) ) return FALSE; // recursiv die sublist abarbeiten - if ( !Save( rOutStream, pGenericInfoList, nLevel+1, bStripped ) ) + if ( !Save( rOutStream, pGenericInfoList, nLevel+1 ) ) return FALSE; // schliessende Klammer sTmpStr = ""; - if ( !bStripped && nLevel ) - sTmpStr.Append( aKeyLevel.GetBuffer(), nLevel ); + for( i=0; i<nLevel; i++) + sTmpStr += cKeyLevelChars; sTmpStr += '}'; if ( !rOutStream.WriteLine( sTmpStr ) ) return FALSE; @@ -432,11 +410,8 @@ BOOL InformationParser::Save( SvFileStream &rSourceStream, const GenericInformationList *pSaveList ) /*****************************************************************************/ { - if ( !rSourceStream.IsOpen() || !Save( (SvStream &)rSourceStream, pSaveList, 0, FALSE )) - { - printf( "ERROR saving file \"%s\"\n",ByteString( rSourceStream.GetFileName(), gsl_getSystemTextEncoding()).GetBuffer() ); + if ( !rSourceStream.IsOpen() || !Save( (SvStream &)rSourceStream, pSaveList, 0 )) return FALSE; - } return TRUE; } @@ -446,11 +421,7 @@ BOOL InformationParser::Save( SvMemoryStream &rSourceStream, const GenericInformationList *pSaveList ) /*****************************************************************************/ { - Time a; - BOOL bRet = Save( (SvStream &)rSourceStream, pSaveList, 0, TRUE ); - Time b; - b = b - a; - return bRet; + return Save( (SvStream &)rSourceStream, pSaveList, 0 ); } /*****************************************************************************/ |