LCOV - code coverage report
Current view: top level - libreoffice/sal/qa/OStringBuffer - rtl_String_Utils.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2012-12-27 Functions: 0 8 0.0 %
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             : #include <math.h>
      21             : #include <stdlib.h>
      22             : 
      23             : #include <sal/types.h>
      24             : 
      25             : #include <rtl/ustring.h>
      26             : #include <rtl/string.hxx>
      27             : #include <rtl_String_Utils_Const.h>
      28             : 
      29             : using ::rtl::OString;
      30           0 : sal_uInt32 AStringLen( const sal_Char *pAStr )
      31             : {
      32           0 :     sal_uInt32  nStrLen = 0;
      33             : 
      34           0 :     if ( pAStr != NULL )
      35             :     {
      36           0 :         const sal_Char *pTempStr = pAStr;
      37             : 
      38           0 :         while( *pTempStr )
      39             :         {
      40           0 :             pTempStr++;
      41             :         } // while
      42             : 
      43           0 :         nStrLen = (sal_uInt32)( pTempStr - pAStr );
      44             :     } // if
      45             : 
      46           0 :     return nStrLen;
      47             : } // AStringLen
      48             : /* disable assignment within condition expression */
      49             : #if defined WNT && defined _MSC_VER
      50             : #pragma warning( disable : 4706 )
      51             : #endif
      52           0 : sal_Char* cpystr( sal_Char* dst, const sal_Char* src )
      53             : {
      54           0 :     const sal_Char* psrc = src;
      55           0 :     sal_Char* pdst = dst;
      56             : 
      57           0 :     while( (*pdst++ = *psrc++) ) {}
      58             : 
      59           0 :     return dst;
      60             : }
      61             : 
      62           0 : sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt )
      63             : {
      64             : 
      65           0 :     const sal_Char* psrc = src;
      66           0 :     sal_Char* pdst = dst;
      67           0 :     sal_uInt32 len = cnt;
      68             :     sal_uInt32 i;
      69             : 
      70           0 :     if ( len >= AStringLen(src) )
      71             :     {
      72           0 :         return( cpystr( dst, src ) );
      73             :     }
      74             : 
      75             :     // copy string by char
      76           0 :     for( i = 0; i < len; i++ )
      77           0 :         *pdst++ = *psrc++;
      78           0 :     *pdst = '\0';
      79             : 
      80           0 :     return ( dst );
      81             : }
      82             : 
      83             : //------------------------------------------------------------------------
      84           0 : sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len )
      85             : {
      86           0 :     const sal_Char* pBuf1 = str1;
      87           0 :     const sal_Char* pBuf2 = str2;
      88           0 :     sal_uInt32 i = 0;
      89             : 
      90           0 :     while ( (*pBuf1 == *pBuf2) && i < len )
      91             :     {
      92           0 :         (pBuf1)++;
      93           0 :         (pBuf2)++;
      94           0 :         i++;
      95             :     }
      96           0 :     return( i == len );
      97             : }
      98             : //-----------------------------------------------------------------------
      99           0 : sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2 )
     100             : {
     101           0 :     const sal_Char* pBuf1 = str1;
     102           0 :     const sal_Char* pBuf2 = str2;
     103           0 :     sal_Bool res = sal_True;
     104             : 
     105           0 :     while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0')
     106             :     {
     107           0 :         (pBuf1)++;
     108           0 :         (pBuf2)++;
     109             :     }
     110           0 :     if (*pBuf1 == '\0' && *pBuf2 == '\0')
     111           0 :         res = sal_True;
     112             :     else
     113           0 :         res = sal_False;
     114           0 :     return (res);
     115             : }
     116             : //------------------------------------------------------------------------
     117           0 : sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len )
     118             : {
     119           0 :     const sal_Unicode* pBuf1 = str1;
     120           0 :     const sal_Unicode* pBuf2 = str2;
     121           0 :     sal_uInt32 i = 0;
     122             : 
     123           0 :     while ( (*pBuf1 == *pBuf2) && i < len )
     124             :     {
     125           0 :         (pBuf1)++;
     126           0 :         (pBuf2)++;
     127           0 :         i++;
     128             :     }
     129           0 :     return( i == len );
     130             : }
     131             : 
     132             : //-----------------------------------------------------------------------
     133           0 : sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 )
     134             : {
     135           0 :     const sal_Unicode* pBuf1 = str1;
     136           0 :     const sal_Unicode* pBuf2 = str2;
     137           0 :     sal_Bool res = sal_True;
     138             : 
     139           0 :     while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0')
     140             :     {
     141           0 :         (pBuf1)++;
     142           0 :         (pBuf2)++;
     143             :     }
     144           0 :     if (*pBuf1 == '\0' && *pBuf2 == '\0')
     145           0 :         res = sal_True;
     146             :     else
     147           0 :         res = sal_False;
     148           0 :     return (res);
     149             : }
     150             : 
     151           0 : sal_Char* createName( sal_Char* dst, const sal_Char* meth, sal_uInt32 cnt )
     152             : {
     153           0 :     sal_Char* pdst = dst;
     154             :     sal_Char nstr[16];
     155           0 :     sal_Char* pstr = nstr;
     156           0 :     rtl_str_valueOfInt32( pstr, cnt, 10 );
     157             : 
     158           0 :     cpystr( pdst, meth );
     159           0 :     cpystr( pdst+ AStringLen(meth), "_" );
     160             : 
     161           0 :     if ( cnt < 100 )
     162             :     {
     163           0 :         cpystr(pdst + AStringLen(pdst), "0" );
     164             :     }
     165           0 :     if ( cnt < 10 )
     166             :     {
     167           0 :         cpystr(pdst + AStringLen(pdst), "0" );
     168             :     }
     169             : 
     170           0 :     cpystr( pdst + AStringLen(pdst), nstr );
     171           0 :     return( pdst );
     172             : }
     173             : 
     174             : //------------------------------------------------------------------------
     175             : 
     176             : static inline sal_Int32 ACharToUCharCompare( const sal_Unicode *pUStr,
     177             :                                              const sal_Char    *pAStr
     178             :                                            )
     179             : {
     180             :     sal_Int32  nCmp   = 0;
     181             :     sal_Int32  nUChar = (sal_Int32)*pUStr;
     182             :     sal_Int32  nChar  = (sal_Int32)((unsigned char)*pAStr);
     183             : 
     184             :     nCmp = nUChar - nChar;
     185             : 
     186             :     return  nCmp;
     187             : } // ACharToUCharCompare
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10