Commits

Anonymous committed 57bd96d

toolsfixes: #115441# replaced the empty string replacer while loop by the new replace helper

Comments (0)

Files changed (1)

l10ntools/source/export.cxx

 // set of global variables
 DECLARE_LIST( FileList, string* )
 FileList aInputFileList;
-BOOL bEnableExport;
-BOOL bMergeMode;
-BOOL bErrorLog;
-BOOL bBreakWhenHelpText;
-BOOL bUnmerge;
-BOOL bUTF8;
+bool bEnableExport;
+bool bMergeMode;
+bool bErrorLog;
+bool bBreakWhenHelpText;
+bool bUnmerge;
+bool bUTF8;
 string sPrj;
 string sPrjRoot;
 string sActFileName;
 	sTempFile = "";
 	pTempFile = NULL;
 	USHORT nState = STATE_NON;
-	BOOL bInput = FALSE;
+	bool bInput = FALSE;
 
 	// parse command line
 	for( int i = 1; i < argc; i++ ) {
 			SetError();
 		}
 
-		if ( sId.Len() > 255 ) {
+		if ( sId.size() > 255 ) {
 			string sWarning( "LocalId > 255 chars, truncating..." );
-			YYWarning( sWarning.GetBufferAccess());
-			sWarning.ReleaseBufferAccess();
-			sId.Erase( 255 );
-			sId.EraseTrailingChars( ' ' );
-			sId.EraseTrailingChars( '\t' );
+			YYWarning( const_cast<char*>(sWarning.c_str()) );
+
+			sId = sId.substr( 0, 255 );
+			sId = strip( sId );
+
+			//sId.Erase( 255 );
+			//sId.EraseTrailingChars( ' ' );
+			//sId.EraseTrailingChars( '\t' );
 		}
 
 		return TRUE;
 //
 
 /*****************************************************************************/
-Export::Export( const string &rOutput, BOOL bWrite,
+Export::Export( const string &rOutput, bool bWrite,
 				const string &rPrj, const string &rPrjRoot , const string& rFile )
 /*****************************************************************************/
 				:
 }
 
 /*****************************************************************************/
-Export::Export( const string &rOutput, BOOL bWrite,
+Export::Export( const string &rOutput, bool bWrite,
 				const string &rPrj, const string &rPrjRoot,
 				const string &rMergeSource , const string& rFile )
 /*****************************************************************************/
 	printf("sToken = %s\n",sToken.GetBuffer());
 	printf("nToken = %d\n",nToken);
 	printf("+---------------\n"); */
-    BOOL bWriteToMerged = bMergeMode;
+    bool bWriteToMerged = bMergeMode;
 
 	if ( nToken == CONDITION ) {
 		string sTestToken( pToken );
 		}
 	}
 
-	BOOL bExecuteDown = FALSE;
+	bool bExecuteDown = FALSE;
 	if ( nToken != LEVELDOWN ) {
 		USHORT nOpen = 0;
 		USHORT nClose = 0;
-		BOOL bReadOver1 = FALSE;
+		bool bReadOver1 = FALSE;
         USHORT i = 0; 
 		for ( i = 0; i < sToken.Len(); i++ ) {
 			if ( sToken.GetChar( i ) == '\"' )
 		string sWork( rText );
 		sWork.SearchAndReplaceAll( "\\\"", "XX" );
 		USHORT i = 0;
-		BOOL bInner = FALSE;
+		bool bInner = FALSE;
 
 		while ( i < sWork.Len() - 1 ) {
 			if ( sWork.GetChar( i ) == '\"' )
 }
 
 /*****************************************************************************/
-BOOL Export::ListExists( ResData *pResData, USHORT nLst )
+bool Export::ListExists( ResData *pResData, USHORT nLst )
 /*****************************************************************************/
 {
 	switch ( nLst ) {
 }
 
 /*****************************************************************************/
-BOOL Export::WriteData( ResData *pResData, BOOL bCreateNew )
+bool Export::WriteData( ResData *pResData, bool bCreateNew )
 /*****************************************************************************/
 {
 	if ( bMergeMode ) {
 }
 
 /*****************************************************************************/
-BOOL Export::WriteExportList( ResData *pResData, ExportList *pExportList,
-						const string &rTyp, BOOL bCreateNew )
+bool Export::WriteExportList( ResData *pResData, ExportList *pExportList,
+						const string &rTyp, bool bCreateNew )
 /*****************************************************************************/
 {
 	string sGID = pResData->sGId;
     #endif
 
     if ( !bDontWriteOutput || !bUnmerge ) {
-		string sText( rText );
-		while ( sText.SearchAndReplace( " \n", "\n" ) != STRING_NOTFOUND ) {};
-        if( pParseQueue->bNextIsM && bSDFContent && sText.Len() > 2 ){
+		string sText = replace( rText, " \n", "\n" );
+
+        if( pParseQueue->bNextIsM && bSDFContent && sText.size() > 2 ){
             for( USHORT n = 0 ; n < sText.Len() ; n++ ){
-                if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){    
-                    sText.Insert('\\' , n++ );
-                    
+                if( sText.at( n ) == '\n' && sText.at( n-1 ) != '\\'){    
+                    sText = sText.insert( n++, "\\" );
                 }
             }
         }
-        else if( pParseQueue->bLastWasM && sText.Len() > 2 ){ 
-            for( USHORT n = 0 ; n < sText.Len() ; n++ ){
-                if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){    
-                    sText.Insert('\\' , n++ );
+        else if( pParseQueue->bLastWasM && sText.size() > 2 ){ 
+            for( USHORT n = 0 ; n < sText.size() ; n++ ){
+                if( sText.at( n ) == '\n' && sText.at( n-1 ) != '\\'){    
+                    sText = sText.insert( n++, "\\" );
                 }
-                if( sText.GetChar( n ) == '\n' )pParseQueue->bMflag=true;
+                if( sText.at( n ) == '\n' )pParseQueue->bMflag=true;
             }
         }
-        else if( pParseQueue->bCurrentIsM && bSDFContent && sText.Len() > 2 ){ 
-            for( USHORT n = 0 ; n < sText.Len() ; n++ ){
-                if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){    
-                    sText.Insert('\\' , n++ );
+        else if( pParseQueue->bCurrentIsM && bSDFContent && sText.size() > 2 ){ 
+            for( USHORT n = 0 ; n < sText.size() ; n++ ){
+                if( sText.GetChar( n ) == '\n' && sText.at( n-1 ) != '\\'){    
+                    sText = sText.insert( n++, "\\" );
                     pParseQueue->bMflag=true;
                 }
             }
         }
         else if( pParseQueue->bMflag ){ 
-            for( USHORT n = 1 ; n < sText.Len() ; n++ ){
-                if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){    
-                    sText.Insert('\\' , n++ );
+            for( USHORT n = 1 ; n < sText.size() ; n++ ){
+                if( sText.at( n ) == '\n' && sText.at( n-1 ) != '\\'){    
+                    sText = sText.insert( n++, "\\" );
                 }
             }
         }
-        for ( USHORT i = 0; i < sText.Len(); i++ ) {
+        for ( USHORT i = 0; i < sText.size(); i++ ) {
 			if ( sText.GetChar( i ) != '\n' ){
-				aOutput.Write( string( sText.GetChar( i )).GetBuffer(), 1 );
+				aOutput << string( sText.at( i ) );
 				
 			}
             else{
-                aOutput.WriteLine( string());
+				aOutput << endl;
             }
 			
 		}
 void Export::ConvertMergeContent( string &rText )
 /*****************************************************************************/
 {
-	BOOL bNoOpen = ( rText.Search( "\\\"" ) != 0 );
+	bool bNoOpen = ( rText.Search( "\\\"" ) != 0 );
 	string sClose( rText.Copy( rText.Len() - 2 ));
-	BOOL bNoClose = ( sClose != "\\\"" );
+	bool bNoClose = ( sClose != "\\\"" );
 	string sNew;
 	for ( USHORT i = 0; i < rText.Len(); i++ ) {
 		string sChar( rText.GetChar( i ));
 }
 
 /*****************************************************************************/
-BOOL Export::PrepareTextToMerge( string &rText, USHORT nTyp,
+bool Export::PrepareTextToMerge( string &rText, USHORT nTyp,
                                 string &nLangIndex, ResData *pResData )
 /*****************************************************************************/
 {
 				return FALSE;
 			}
 
-			BOOL bFound = FALSE;
+			bool bFound = FALSE;
 			for ( nEnd = nStart + 1; nEnd < rText.Len() && !bFound; nEnd++ ) {
 				if ( rText.GetChar( nEnd ) == '\"' )
 					bFound = TRUE;
 			}
 
 			nStart++;
-			BOOL bFound = FALSE;
+			bool bFound = FALSE;
 			while(( nStart < rText.Len()) && !bFound ) {
 				if (( rText.GetChar( nStart ) != ' ' ) && ( rText.GetChar( nStart ) != '\t' ))
 					bFound = TRUE;
             bool bWriteNoSlash = false;
 			if ( pEntry && pResData->bText ) {
                 
-				BOOL bAddSemikolon = FALSE;
-				BOOL bFirst = TRUE;
+				bool bAddSemikolon = FALSE;
+				bool bFirst = TRUE;
                 string sCur;
                 string sTmp = Export::sLanguages;
 
                     sCur = aLanguages[ n ];
 
                     string sText;
-                    BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , TRUE );
+                    bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , TRUE );
 					if ( bText && sText.Len() && sText != "-" ) {
 						string sOutput;
 						if ( bNextMustBeDefineEOL)  {
 			}
 
 			if ( pEntry && pResData->bQuickHelpText ) {
-				BOOL bAddSemikolon = FALSE;
-				BOOL bFirst = TRUE;
+				bool bAddSemikolon = FALSE;
+				bool bFirst = TRUE;
                 string sCur;
 
                 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
                     sCur = aLanguages[ n ];
 
 					string sText;
-                    BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, TRUE );
+                    bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, TRUE );
 					if ( bText && sText.Len() && sText != "-" ) {
 						string sOutput;
 						if ( bNextMustBeDefineEOL)  {
 			}
 
 			if ( pEntry && pResData->bTitle ) {
-				BOOL bAddSemikolon = FALSE;
-				BOOL bFirst = TRUE;
+				bool bAddSemikolon = FALSE;
+				bool bFirst = TRUE;
                 string sCur;
 
                 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
                     sCur = aLanguages[ n ];
 
                 string sText;
-                    BOOL bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, TRUE );
+                    bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, TRUE );
 					if ( bText && sText.Len() && sText != "-" ) {
 						string sOutput;
 						if ( bNextMustBeDefineEOL)  {
                         while( pEntrys  && ( nLIndex < nMaxIndex )) {
 						    //printf("Lang %s, List Index %d\n",sCur.GetBuffer(),(int)nLIndex);
 							string sText;
-                            BOOL bText;
+                            bool bText;
 							bText = pEntrys->GetTransex3Text( sText, STRING_TYP_TEXT, sCur, TRUE );
 							if( !bText )
 								bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , FALSE );
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.