diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-02 10:55:27 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-05 09:18:19 +0000 |
commit | bacfd2dc4cea1a5d87658ed8592116acd931e000 (patch) | |
tree | d22172a33fdd13a440b6882a28c23ea2d639bbad /l10ntools/source | |
parent | 6281eb0e0792da0194c07da18296e94dd944b8e5 (diff) |
add a comphelper::string::getTokenCount
suitable for conversion from [Byte]String::GetTokenCount
converted low-hanging variants to rtl::O[UString]::getToken loops
added unit test
Diffstat (limited to 'l10ntools/source')
-rw-r--r-- | l10ntools/source/export.cxx | 18 | ||||
-rw-r--r-- | l10ntools/source/gsicheck.cxx | 9 | ||||
-rw-r--r-- | l10ntools/source/helpmerge.cxx | 2 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 3 | ||||
-rw-r--r-- | l10ntools/source/localize.cxx | 5 | ||||
-rw-r--r-- | l10ntools/source/merge.cxx | 3 |
6 files changed, 23 insertions, 17 deletions
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index bd1fbfb55509..041b57d34b7a 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -37,6 +37,7 @@ #include <comphelper/string.hxx> using comphelper::string::getToken; +using comphelper::string::getTokenCount; extern "C" { int yyerror( const char * ); } extern "C" { int YYWarning( const char * ); } @@ -791,8 +792,8 @@ int Export::Execute( int nToken, const char * pToken ) nListIndex = 0; nListLevel = 0; } - if (( sToken.Search( "{" ) != STRING_NOTFOUND ) && - ( sToken.GetTokenCount( '{' ) > sToken.GetTokenCount( '}' ))) + if ( (sToken.Search( "{" ) != STRING_NOTFOUND) && + ( getTokenCount(sToken, '{') > getTokenCount(sToken, '}') )) { Parse( LEVELUP, "" ); } @@ -888,7 +889,7 @@ int Export::Execute( int nToken, const char * pToken ) if ( nList ) { SetChildWithText(); ByteString sEntry(getToken(sToken, 1, '\"')); - if ( sToken.GetTokenCount( '\"' ) > 3 ) + if ( getTokenCount(sToken, '\"') > 3 ) sEntry += "\""; if ( sEntry == "\\\"" ) sEntry = "\""; @@ -1527,13 +1528,13 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) sTmp = comphelper::string::remove(sTmp, '\r'); while ( sTmp.SearchAndReplace( "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"" ) - != STRING_NOTFOUND ) {}; + != STRING_NOTFOUND ) {} while ( sTmp.SearchAndReplace( "\\\"", "-=<[Hochkomma]>=-" ) - != STRING_NOTFOUND ) {}; + != STRING_NOTFOUND ) {} while ( sTmp.SearchAndReplace( "\\", "-=<[0x7F]>=-" ) - != STRING_NOTFOUND ) {}; + != STRING_NOTFOUND ) {} while ( sTmp.SearchAndReplace( "\\0x7F", "-=<[0x7F]>=-" ) - != STRING_NOTFOUND ) {}; + != STRING_NOTFOUND ) {} sal_uInt16 nStart = 0; sal_uInt16 nState = TXT_STATE_MACRO; @@ -1542,7 +1543,8 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) nStart = 1; - for ( sal_uInt16 i = nStart; i < sTmp.GetTokenCount( '\"' ); i++ ) { + for ( sal_uInt16 i = nStart; i < getTokenCount(sTmp, '\"'); ++i ) + { ByteString sToken = getToken(sTmp, i, '\"'); if ( sToken.Len()) { if ( nState == TXT_STATE_TEXT ) { diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx index 56708290d9ad..f8ee2e0a1726 100644 --- a/l10ntools/source/gsicheck.cxx +++ b/l10ntools/source/gsicheck.cxx @@ -36,6 +36,7 @@ #include "gsicheck.hxx" using comphelper::string::getToken; +using comphelper::string::getTokenCount; #define MAX_GID_LID_LEN 250 @@ -74,9 +75,9 @@ sal_Bool LanguageOK( ByteString aLang ) if (isdigitAsciiString(aLang)) return sal_True; - if ( aLang.GetTokenCount( '-' ) == 1 ) + if ( getTokenCount(aLang, '-') == 1 ) return islowerAsciiString(aLang); - else if ( aLang.GetTokenCount( '-' ) == 2 ) + else if ( getTokenCount(aLang, '-') == 2 ) { ByteString aTok0( getToken(aLang, 0, '-') ); ByteString aTok1( getToken(aLang, 1, '-') ); @@ -145,7 +146,7 @@ GSILine::GSILine( const ByteString &rLine, sal_uLong nLine ) , bOK( sal_True ) , bFixed ( sal_False ) { - if ( rLine.GetTokenCount( '\t' ) == 15 ) + if ( getTokenCount(rLine, '\t') == 15 ) { aFormat = FORMAT_SDF; aUniqId = getToken(rLine, 0, '\t'); @@ -465,7 +466,7 @@ sal_Bool GSIBlock::IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uIn nAfterID += 7; nAfterID = nAfterID + aDelimiter.getLength(); } - else if ( aID.GetTokenCount( '.' ) > 1 ) + else if ( getTokenCount(aID, '.') > 1 ) { // test for old KeyIDs 5 to 6 digits followed by a dot '44373.' bNewId = sal_False; nErrorPos = 1; diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index f08310c26d28..6ff89316772e 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -523,7 +523,7 @@ void HelpParser::MakeDir( const ByteString& sPath ) ByteString sTPath( sPath ); rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US)); sTPath.SearchAndReplaceAll( sDelimiter , rtl::OString('/') ); - sal_uInt16 cnt = sTPath.GetTokenCount( '/' ); + sal_uInt16 cnt = comphelper::string::getTokenCount(sTPath, '/'); rtl::OStringBuffer sCreateDir; for (sal_uInt16 i = 0; i < cnt; ++i) { diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index e61b36db73aa..eaa0b39588d3 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -34,6 +34,7 @@ using namespace std; using comphelper::string::getToken; +using comphelper::string::getTokenCount; // // class LngParser @@ -256,7 +257,7 @@ sal_Bool LngParser::Merge( nPos ++; sLanguagesDone = ""; } - else if ( sLine.GetTokenCount( '=' ) > 1 ) + else if ( getTokenCount(sLine, '=') > 1 ) { ByteString sLang = getToken(sLine, 0, '='); sLang = comphelper::string::stripStart(sLang, ' '); diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index a857a65c0b85..b29d08e00fec 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -276,10 +276,11 @@ const ByteString SourceTreeLocalizer::GetProjectRootRel() sCur.SearchAndReplaceAll( sDelimiter, "/" ); sCur = comphelper::string::stripStart(sCur, '/'); - sal_uLong nCount = sCur.GetTokenCount( '/' ); + sal_Int32 nCount = comphelper::string::getTokenCount(sCur, '/'); ByteString sProjectRootRel; - for ( sal_uLong i = 0; i < nCount; i++ ) { + for (sal_Int32 i = 0; i < nCount; ++i) + { if ( sProjectRootRel.Len()) sProjectRootRel += sDelimiter; sProjectRootRel += ".."; diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx index 5141b9bdd259..fb397582a9a7 100644 --- a/l10ntools/source/merge.cxx +++ b/l10ntools/source/merge.cxx @@ -34,6 +34,7 @@ using namespace std; using comphelper::string::getToken; +using comphelper::string::getTokenCount; namespace { @@ -200,7 +201,7 @@ MergeDataFile::MergeDataFile( { xub_StrLen nToks; aInputStream.ReadLine( sLine ); - nToks = sLine.GetTokenCount( '\t' ); + nToks = getTokenCount(sLine, '\t'); if ( nToks == 15 ) { // Skip all wrong filenames |