LCOV - code coverage report
Current view: top level - libreoffice/tools/source/string - strascii.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 152 188 80.9 %
Date: 2012-12-27 Functions: 20 21 95.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifdef DBG_UTIL
      21             : static sal_Bool ImplDbgCheckAsciiStr( const sal_Char* pAsciiStr, sal_Int32 nLen )
      22             : {
      23             :     while ( nLen && *pAsciiStr )
      24             :     {
      25             :         if ( ((unsigned char)*pAsciiStr) > 127 )
      26             :             return sal_False;
      27             :         ++pAsciiStr,
      28             :         --nLen;
      29             :     }
      30             : 
      31             :     return sal_True;
      32             : }
      33             : #endif
      34             : 
      35       10621 : static void ImplCopyAsciiStr( sal_Unicode* pDest, const sal_Char* pSrc,
      36             :                               sal_Int32 nLen )
      37             : {
      38             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pSrc, nLen ),
      39             :                 "UniString::CopyAsciiStr() - pAsciiStr include characters > 127" );
      40             : 
      41      131344 :     while ( nLen )
      42             :     {
      43      110102 :         *pDest = (unsigned char)*pSrc;
      44             :         ++pDest,
      45             :         ++pSrc,
      46      110102 :         --nLen;
      47             :     }
      48       10621 : }
      49             : 
      50      292464 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2 )
      51             : {
      52             :     sal_Int32 nRet;
      53     3670275 :     while ( ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
      54             :             *pStr2 )
      55             :     {
      56             :         ++pStr1,
      57     3085347 :         ++pStr2;
      58             :     }
      59             : 
      60      292464 :     return nRet;
      61             : }
      62             : 
      63      202416 : static sal_Int32 ImplStringCompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
      64             :                                          xub_StrLen nCount )
      65             : {
      66      202416 :     sal_Int32 nRet = 0;
      67      490535 :     while ( nCount &&
      68             :             ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) &&
      69             :             *pStr2 )
      70             :     {
      71             :         ++pStr1,
      72             :         ++pStr2,
      73       85703 :         --nCount;
      74             :     }
      75             : 
      76      202416 :     return nRet;
      77             : }
      78             : 
      79     3313651 : static sal_Int32 ImplStringCompareWithoutZeroAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
      80             :                                                     xub_StrLen nCount )
      81             : {
      82     3313651 :     sal_Int32 nRet = 0;
      83     6919598 :     while ( nCount &&
      84             :             ((nRet = ((sal_Int32)*pStr1)-((sal_Int32)((unsigned char)*pStr2))) == 0) )
      85             :     {
      86             :         ++pStr1,
      87             :         ++pStr2,
      88      292296 :         --nCount;
      89             :     }
      90             : 
      91     3313651 :     return nRet;
      92             : }
      93             : 
      94     1147622 : static sal_Int32 ImplStringICompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2 )
      95             : {
      96             :     sal_Int32   nRet;
      97             :     sal_Unicode c1;
      98             :     sal_Char    c2;
      99      279894 :     do
     100             :     {
     101             :         // Convert if char is between 'A' and 'Z'
     102     1147622 :         c1 = *pStr1;
     103     1147622 :         c2 = *pStr2;
     104     1147622 :         if ( (c1 >= 65) && (c1 <= 90) )
     105      272448 :             c1 += 32;
     106     1147622 :         if ( (c2 >= 65) && (c2 <= 90) )
     107      164834 :             c2 += 32;
     108     1147622 :         nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
     109     1147622 :         if ( nRet != 0 )
     110      867728 :             break;
     111             : 
     112             :         ++pStr1,
     113      279894 :         ++pStr2;
     114             :     }
     115             :     while ( c2 );
     116             : 
     117      887159 :     return nRet;
     118             : }
     119             : 
     120      596906 : static sal_Int32 ImplStringICompareAscii( const sal_Unicode* pStr1, const sal_Char* pStr2,
     121             :                                           xub_StrLen nCount )
     122             : {
     123      596906 :     sal_Int32   nRet = 0;
     124             :     sal_Unicode c1;
     125             :     sal_Char    c2;
     126      199087 :     do
     127             :     {
     128      794211 :         if ( !nCount )
     129       12008 :             break;
     130             : 
     131             :         // Convert if char is between 'A' and 'Z'
     132      782203 :         c1 = *pStr1;
     133      782203 :         c2 = *pStr2;
     134      782203 :         if ( (c1 >= 65) && (c1 <= 90) )
     135      512569 :             c1 += 32;
     136      782203 :         if ( (c2 >= 65) && (c2 <= 90) )
     137      505293 :             c2 += 32;
     138      782203 :         nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2));
     139      782203 :         if ( nRet != 0 )
     140      583116 :             break;
     141             : 
     142             :         ++pStr1,
     143             :         ++pStr2,
     144      199087 :         --nCount;
     145             :     }
     146             :     while ( c2 );
     147             : 
     148      596906 :     return nRet;
     149             : }
     150             : 
     151        8047 : UniString& UniString::AssignAscii( const sal_Char* pAsciiStr )
     152             : {
     153             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     154             :     DBG_ASSERT( pAsciiStr, "UniString::AssignAscii() - pAsciiStr is NULL" );
     155             : 
     156             :     // Determine string length
     157        8047 :     xub_StrLen nLen = ImplStringLen( pAsciiStr );
     158             : 
     159        8047 :     if ( !nLen )
     160             :     {
     161           0 :         STRING_NEW((STRING_TYPE **)&mpData);
     162             :     }
     163             :     else
     164             :     {
     165             :         // Replace string in-place if new size is equal
     166        8047 :         if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
     167           0 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     168             :         else
     169             :         {
     170             :             // release old string
     171        8047 :             STRING_RELEASE((STRING_TYPE *)mpData);
     172             : 
     173             :             // copy new string
     174        8047 :             mpData = ImplAllocData( nLen );
     175        8047 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     176             :         }
     177             :     }
     178             : 
     179        8047 :     return *this;
     180             : }
     181             : 
     182        2288 : UniString& UniString::AssignAscii( const sal_Char* pAsciiStr, xub_StrLen nLen )
     183             : {
     184             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     185             :     DBG_ASSERT( pAsciiStr, "UniString::AssignAscii() - pAsciiStr is NULL" );
     186             : 
     187        2288 :     if ( nLen == STRING_LEN )
     188           0 :         nLen = ImplStringLen( pAsciiStr );
     189             : 
     190             : #ifdef DBG_UTIL
     191             :     if ( DbgIsAssert() )
     192             :     {
     193             :         for ( xub_StrLen i = 0; i < nLen; ++i )
     194             :         {
     195             :             if ( !pAsciiStr[i] )
     196             :             {
     197             :                 OSL_FAIL( "UniString::AssignAscii() : nLen is wrong" );
     198             :             }
     199             :         }
     200             :     }
     201             : #endif
     202             : 
     203        2288 :     if ( !nLen )
     204             :     {
     205           0 :         STRING_NEW((STRING_TYPE **)&mpData);
     206             :     }
     207             :     else
     208             :     {
     209             :         // Replace string in-place if new size is equal
     210        2288 :         if ( (nLen == mpData->mnLen) && (mpData->mnRefCount == 1) )
     211           0 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     212             :         else
     213             :         {
     214             :             // release old string
     215        2288 :             STRING_RELEASE((STRING_TYPE *)mpData);
     216             : 
     217             :             // copy new string
     218        2288 :             mpData = ImplAllocData( nLen );
     219        2288 :             ImplCopyAsciiStr( mpData->maStr, pAsciiStr, nLen );
     220             :         }
     221             :     }
     222             : 
     223        2288 :     return *this;
     224             : }
     225             : 
     226          67 : UniString& UniString::AppendAscii( const sal_Char* pAsciiStr )
     227             : {
     228             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     229             :     DBG_ASSERT( pAsciiStr, "UniString::AppendAscii() - pAsciiStr is NULL" );
     230             : 
     231             :     // determine string length
     232          67 :     sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
     233             : 
     234             :     // detect overflow
     235          67 :     nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
     236             : 
     237             :     // If appended string is not empty
     238          67 :     if ( nCopyLen )
     239             :     {
     240             :         // Allocate new string
     241          66 :         UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     242             : 
     243             :         // copy string data
     244          66 :         memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
     245          66 :         ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
     246             : 
     247             :         // release old string
     248          66 :         STRING_RELEASE((STRING_TYPE *)mpData);
     249          66 :         mpData = pNewData;
     250             :     }
     251             : 
     252          67 :     return *this;
     253             : }
     254             : 
     255         218 : UniString& UniString::AppendAscii( const sal_Char* pAsciiStr, xub_StrLen nLen )
     256             : {
     257             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     258             :     DBG_ASSERT( pAsciiStr, "UniString::AppendAscii() - pAsciiStr is NULL" );
     259             : 
     260         218 :     if ( nLen == STRING_LEN )
     261           0 :         nLen = ImplStringLen( pAsciiStr );
     262             : 
     263             : #ifdef DBG_UTIL
     264             :     if ( DbgIsAssert() )
     265             :     {
     266             :         for ( xub_StrLen i = 0; i < nLen; ++i )
     267             :         {
     268             :             if ( !pAsciiStr[i] )
     269             :             {
     270             :                 OSL_FAIL( "UniString::AppendAscii() : nLen is wrong" );
     271             :             }
     272             :         }
     273             :     }
     274             : #endif
     275             : 
     276             :     // detect overflow
     277         218 :     sal_Int32 nCopyLen = ImplGetCopyLen( mpData->mnLen, nLen );
     278             : 
     279             :     // If appended string is not empty
     280         218 :     if ( nCopyLen )
     281             :     {
     282             :         // Allocate new string
     283         218 :         UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     284             : 
     285             :         // copy string data
     286         218 :         memcpy( pNewData->maStr, mpData->maStr, mpData->mnLen*sizeof( sal_Unicode ) );
     287         218 :         ImplCopyAsciiStr( pNewData->maStr+mpData->mnLen, pAsciiStr, nCopyLen );
     288             : 
     289             :         // release old string
     290         218 :         STRING_RELEASE((STRING_TYPE *)mpData);
     291         218 :         mpData = pNewData;
     292             :     }
     293             : 
     294         218 :     return *this;
     295             : }
     296             : 
     297           2 : UniString& UniString::InsertAscii( const char* pAsciiStr, xub_StrLen nIndex )
     298             : {
     299             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     300             :     DBG_ASSERT( pAsciiStr, "UniString::InsertAscii() - pAsciiStr is NULL" );
     301             : 
     302             :     // Determine string length
     303           2 :     sal_Int32 nCopyLen = ImplStringLen( pAsciiStr );
     304             : 
     305             :     // detect overflow
     306           2 :     nCopyLen = ImplGetCopyLen( mpData->mnLen, nCopyLen );
     307             : 
     308             :     // If appended string is not empty
     309           2 :     if ( !nCopyLen )
     310           0 :         return *this;
     311             : 
     312             :     // Adjust index if exceeds length
     313           2 :     if ( nIndex > mpData->mnLen )
     314           0 :         nIndex = static_cast< xub_StrLen >(mpData->mnLen);
     315             : 
     316             :     // Allocate new string
     317           2 :     UniStringData* pNewData = ImplAllocData( mpData->mnLen+nCopyLen );
     318             : 
     319             :     // copy string data
     320           2 :     memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( sal_Unicode ) );
     321           2 :     ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, nCopyLen );
     322           2 :     memcpy( pNewData->maStr+nIndex+nCopyLen, mpData->maStr+nIndex,
     323           4 :             (mpData->mnLen-nIndex)*sizeof( sal_Unicode ) );
     324             : 
     325             :     // release old string
     326           2 :     STRING_RELEASE((STRING_TYPE *)mpData);
     327           2 :     mpData = pNewData;
     328             : 
     329           2 :     return *this;
     330             : }
     331             : 
     332           0 : UniString& UniString::ReplaceAscii( xub_StrLen nIndex, xub_StrLen nCount,
     333             :                                     const sal_Char* pAsciiStr, xub_StrLen nStrLen )
     334             : {
     335             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     336             :     DBG_ASSERT( pAsciiStr, "UniString::ReplaceAscii() - pAsciiStr is NULL" );
     337             : 
     338             :     // Use append if index >= length
     339           0 :     if ( nIndex >= mpData->mnLen )
     340             :     {
     341           0 :         AppendAscii( pAsciiStr, nStrLen );
     342           0 :         return *this;
     343             :     }
     344             : 
     345             :     // Use assign if index = 0 and count >= length
     346           0 :     if ( (nIndex == 0) && (nCount >= mpData->mnLen) )
     347             :     {
     348           0 :         AssignAscii( pAsciiStr, nStrLen );
     349           0 :         return *this;
     350             :     }
     351             : 
     352             :     // Use erase if length is equal
     353           0 :     if ( nStrLen == STRING_LEN )
     354           0 :         nStrLen = ImplStringLen( pAsciiStr );
     355           0 :     if ( !nStrLen )
     356           0 :         return Erase( nIndex, nCount );
     357             : 
     358             :     // nCount must not exceed string length
     359           0 :     if ( nCount > mpData->mnLen - nIndex )
     360           0 :         nCount = static_cast< xub_StrLen >(mpData->mnLen-nIndex);
     361             : 
     362             :     // Use assign if length matches
     363           0 :     if ( nCount == nStrLen )
     364             :     {
     365           0 :         ImplCopyData();
     366           0 :         ImplCopyAsciiStr( mpData->maStr+nIndex, pAsciiStr, nStrLen );
     367           0 :         return *this;
     368             :     }
     369             : 
     370             :     // detect overflow
     371           0 :     sal_Int32 n = ImplGetCopyLen( mpData->mnLen-nCount, nStrLen );
     372             : 
     373             :     // allocate new string
     374           0 :     STRINGDATA* pNewData = ImplAllocData( mpData->mnLen-nCount+n );
     375             : 
     376             :     // copy string data
     377           0 :     memcpy( pNewData->maStr, mpData->maStr, nIndex*sizeof( STRCODE ) );
     378           0 :     ImplCopyAsciiStr( pNewData->maStr+nIndex, pAsciiStr, n );
     379           0 :     memcpy( pNewData->maStr+nIndex+n, mpData->maStr+nIndex+nCount,
     380           0 :             (mpData->mnLen-nIndex-nCount+1)*sizeof( STRCODE ) );
     381             : 
     382             :     // release old string
     383           0 :     STRING_RELEASE((STRING_TYPE *)mpData);
     384           0 :     mpData = pNewData;
     385             : 
     386           0 :     return *this;
     387             : }
     388             : 
     389      190038 : StringCompare UniString::CompareToAscii( const sal_Char* pAsciiStr,
     390             :                                          xub_StrLen nLen ) const
     391             : {
     392             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     393             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
     394             :                 "UniString::CompareToAscii() - pAsciiStr include characters > 127" );
     395             : 
     396             :     // String vergleichen
     397      190038 :     sal_Int32 nCompare = ImplStringCompareAscii( mpData->maStr, pAsciiStr, nLen );
     398             : 
     399             :     // Rueckgabewert anpassen
     400      190038 :     if ( nCompare == 0 )
     401        2190 :         return COMPARE_EQUAL;
     402      187848 :     else if ( nCompare < 0 )
     403      130661 :         return COMPARE_LESS;
     404             :     else
     405       57187 :         return COMPARE_GREATER;
     406             : }
     407             : 
     408      564412 : StringCompare UniString::CompareIgnoreCaseToAscii( const sal_Char* pAsciiStr,
     409             :                                                    xub_StrLen nLen ) const
     410             : {
     411             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     412             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
     413             :                 "UniString::CompareIgnoreCaseToAscii() - pAsciiStr include characters > 127" );
     414             : 
     415             :     // compare strings
     416      564412 :     sal_Int32 nCompare = ImplStringICompareAscii( mpData->maStr, pAsciiStr, nLen );
     417             : 
     418      564412 :     if ( nCompare == 0 )
     419       13123 :         return COMPARE_EQUAL;
     420      551289 :     else if ( nCompare < 0 )
     421      190230 :         return COMPARE_LESS;
     422             :     else
     423      361059 :         return COMPARE_GREATER;
     424             : }
     425             : 
     426      292464 : sal_Bool UniString::EqualsAscii( const sal_Char* pAsciiStr ) const
     427             : {
     428             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     429             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
     430             :                 "UniString::EqualsAscii() - pAsciiStr include characters > 127" );
     431             : 
     432      292464 :     return (ImplStringCompareAscii( mpData->maStr, pAsciiStr ) == 0);
     433             : }
     434             : 
     435      887159 : sal_Bool UniString::EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr ) const
     436             : {
     437             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     438             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
     439             :                 "UniString::EqualsIgnoreCaseAscii() - pAsciiStr include characters > 127" );
     440             : 
     441      887159 :     return (ImplStringICompareAscii( mpData->maStr, pAsciiStr ) == 0);
     442             : }
     443             : 
     444       12384 : sal_Bool UniString::EqualsAscii( const sal_Char* pAsciiStr,
     445             :                              xub_StrLen nIndex, xub_StrLen nLen ) const
     446             : {
     447             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     448             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
     449             :                 "UniString::EqualsAscii() - pAsciiStr include characters > 127" );
     450             : 
     451             :     // Are there enough codes for comparing?
     452       12384 :     if ( nIndex > mpData->mnLen )
     453           6 :         return (*pAsciiStr == 0);
     454             : 
     455       12378 :     return (ImplStringCompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
     456             : }
     457             : 
     458       32494 : sal_Bool UniString::EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr,
     459             :                                        xub_StrLen nIndex, xub_StrLen nLen ) const
     460             : {
     461             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     462             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, nLen ),
     463             :                 "UniString::EqualsIgnoreCaseAscii() - pAsciiStr include characters > 127" );
     464             : 
     465             :     // Are there enough codes for comparing?
     466       32494 :     if ( nIndex > mpData->mnLen )
     467           0 :         return (*pAsciiStr == 0);
     468             : 
     469       32494 :     return (ImplStringICompareAscii( mpData->maStr+nIndex, pAsciiStr, nLen ) == 0);
     470             : }
     471             : 
     472      957038 : xub_StrLen UniString::SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex ) const
     473             : {
     474             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     475             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
     476             :                 "UniString::SearchAscii() - pAsciiStr include characters > 127" );
     477             : 
     478      957038 :     sal_Int32 nLen = mpData->mnLen;
     479      957038 :     xub_StrLen nStrLen  = ImplStringLen( pAsciiStr );
     480             : 
     481             :     // If length of pAsciiStr is 0 or index exceeds length, it was not found
     482      957038 :     if ( !nStrLen || (nIndex >= nLen) )
     483        4264 :         return STRING_NOTFOUND;
     484             : 
     485      952774 :     const sal_Unicode* pStr = mpData->maStr;
     486      952774 :     pStr += nIndex;
     487             : 
     488      952774 :     if ( nStrLen == 1 )
     489             :     {
     490           3 :         sal_Unicode cSearch = (unsigned char)*pAsciiStr;
     491          63 :         while ( nIndex < nLen )
     492             :         {
     493          57 :             if ( *pStr == cSearch )
     494           0 :                 return nIndex;
     495             :             ++pStr,
     496          57 :             ++nIndex;
     497             :         }
     498             :     }
     499             :     else
     500             :     {
     501             :         // Only search within string
     502     5201269 :         while ( nLen - nIndex >= nStrLen )
     503             :         {
     504             :             // Check if string matches
     505     3313651 :             if ( ImplStringCompareWithoutZeroAscii( pStr, pAsciiStr, nStrLen ) == 0 )
     506       17924 :                 return nIndex;
     507             :             ++pStr,
     508     3295727 :             ++nIndex;
     509             :         }
     510             :     }
     511             : 
     512      934850 :     return STRING_NOTFOUND;
     513             : }
     514             : 
     515         243 : xub_StrLen UniString::SearchAndReplaceAscii( const sal_Char* pAsciiStr, const UniString& rRepStr,
     516             :                                              xub_StrLen nIndex )
     517             : {
     518             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     519             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
     520             :                 "UniString::SearchAndReplaceAscii() - pAsciiStr include characters > 127" );
     521             : 
     522         243 :     xub_StrLen nSPos = SearchAscii( pAsciiStr, nIndex );
     523         243 :     if ( nSPos != STRING_NOTFOUND )
     524         243 :         Replace( nSPos, ImplStringLen( pAsciiStr ), rRepStr );
     525             : 
     526         243 :     return nSPos;
     527             : }
     528             : 
     529          29 : void UniString::SearchAndReplaceAllAscii( const sal_Char* pAsciiStr, const UniString& rRepStr )
     530             : {
     531             :     DBG_CHKTHIS( UniString, DbgCheckUniString );
     532             :     DBG_ASSERT( ImplDbgCheckAsciiStr( pAsciiStr, STRING_LEN ),
     533             :                 "UniString::SearchAndReplaceAllAscii() - pAsciiStr include characters > 127" );
     534             : 
     535          29 :     xub_StrLen nCharLen = ImplStringLen( pAsciiStr );
     536          29 :     xub_StrLen nSPos = SearchAscii( pAsciiStr, 0 );
     537          69 :     while ( nSPos != STRING_NOTFOUND )
     538             :     {
     539          11 :         Replace( nSPos, nCharLen, rRepStr );
     540          11 :         nSPos = nSPos + rRepStr.Len();
     541          11 :         nSPos = SearchAscii( pAsciiStr, nSPos );
     542             :     }
     543          29 : }
     544             : 
     545             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10