LCOV - code coverage report
Current view: top level - sal/qa/OStringBuffer - rtl_String_Utils.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 75 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 50 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            : #
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            : #*************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <math.h>
      31                 :            : #include <stdlib.h>
      32                 :            : 
      33                 :            : #include <sal/types.h>
      34                 :            : 
      35                 :            : #include <rtl/ustring.h>
      36                 :            : #include <rtl/string.hxx>
      37                 :            : #include <rtl_String_Utils_Const.h>
      38                 :            : 
      39                 :            : using ::rtl::OString;
      40                 :          0 : sal_uInt32 AStringLen( const sal_Char *pAStr )
      41                 :            : {
      42                 :          0 :     sal_uInt32  nStrLen = 0;
      43                 :            : 
      44         [ #  # ]:          0 :     if ( pAStr != NULL )
      45                 :            :     {
      46                 :          0 :         const sal_Char *pTempStr = pAStr;
      47                 :            : 
      48         [ #  # ]:          0 :         while( *pTempStr )
      49                 :            :         {
      50                 :          0 :             pTempStr++;
      51                 :            :         } // while
      52                 :            : 
      53                 :          0 :         nStrLen = (sal_uInt32)( pTempStr - pAStr );
      54                 :            :     } // if
      55                 :            : 
      56                 :          0 :     return nStrLen;
      57                 :            : } // AStringLen
      58                 :            : /* disable assignment within condition expression */
      59                 :            : #if defined WNT && defined _MSC_VER
      60                 :            : #pragma warning( disable : 4706 )
      61                 :            : #endif
      62                 :          0 : sal_Char* cpystr( sal_Char* dst, const sal_Char* src )
      63                 :            : {
      64                 :          0 :     const sal_Char* psrc = src;
      65                 :          0 :     sal_Char* pdst = dst;
      66                 :            : 
      67         [ #  # ]:          0 :     while( (*pdst++ = *psrc++) ) {}
      68                 :            : 
      69                 :          0 :     return dst;
      70                 :            : }
      71                 :            : 
      72                 :          0 : sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt )
      73                 :            : {
      74                 :            : 
      75                 :          0 :     const sal_Char* psrc = src;
      76                 :          0 :     sal_Char* pdst = dst;
      77                 :          0 :     sal_uInt32 len = cnt;
      78                 :            :     sal_uInt32 i;
      79                 :            : 
      80         [ #  # ]:          0 :     if ( len >= AStringLen(src) )
      81                 :            :     {
      82                 :          0 :         return( cpystr( dst, src ) );
      83                 :            :     }
      84                 :            : 
      85                 :            :     // copy string by char
      86         [ #  # ]:          0 :     for( i = 0; i < len; i++ )
      87                 :          0 :         *pdst++ = *psrc++;
      88                 :          0 :     *pdst = '\0';
      89                 :            : 
      90                 :          0 :     return ( dst );
      91                 :            : }
      92                 :            : 
      93                 :            : //------------------------------------------------------------------------
      94                 :          0 : sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len )
      95                 :            : {
      96                 :          0 :     const sal_Char* pBuf1 = str1;
      97                 :          0 :     const sal_Char* pBuf2 = str2;
      98                 :          0 :     sal_uInt32 i = 0;
      99                 :            : 
     100 [ #  # ][ #  # ]:          0 :     while ( (*pBuf1 == *pBuf2) && i < len )
                 [ #  # ]
     101                 :            :     {
     102                 :          0 :         (pBuf1)++;
     103                 :          0 :         (pBuf2)++;
     104                 :          0 :         i++;
     105                 :            :     }
     106                 :          0 :     return( i == len );
     107                 :            : }
     108                 :            : //-----------------------------------------------------------------------
     109                 :          0 : sal_Bool cmpstr( const sal_Char* str1, const sal_Char* str2 )
     110                 :            : {
     111                 :          0 :     const sal_Char* pBuf1 = str1;
     112                 :          0 :     const sal_Char* pBuf2 = str2;
     113                 :          0 :     sal_Bool res = sal_True;
     114                 :            : 
     115 [ #  # ][ #  # ]:          0 :     while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0')
         [ #  # ][ #  # ]
     116                 :            :     {
     117                 :          0 :         (pBuf1)++;
     118                 :          0 :         (pBuf2)++;
     119                 :            :     }
     120 [ #  # ][ #  # ]:          0 :     if (*pBuf1 == '\0' && *pBuf2 == '\0')
     121                 :          0 :         res = sal_True;
     122                 :            :     else
     123                 :          0 :         res = sal_False;
     124                 :          0 :     return (res);
     125                 :            : }
     126                 :            : //------------------------------------------------------------------------
     127                 :          0 : sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len )
     128                 :            : {
     129                 :          0 :     const sal_Unicode* pBuf1 = str1;
     130                 :          0 :     const sal_Unicode* pBuf2 = str2;
     131                 :          0 :     sal_uInt32 i = 0;
     132                 :            : 
     133 [ #  # ][ #  # ]:          0 :     while ( (*pBuf1 == *pBuf2) && i < len )
                 [ #  # ]
     134                 :            :     {
     135                 :          0 :         (pBuf1)++;
     136                 :          0 :         (pBuf2)++;
     137                 :          0 :         i++;
     138                 :            :     }
     139                 :          0 :     return( i == len );
     140                 :            : }
     141                 :            : 
     142                 :            : //-----------------------------------------------------------------------
     143                 :          0 : sal_Bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 )
     144                 :            : {
     145                 :          0 :     const sal_Unicode* pBuf1 = str1;
     146                 :          0 :     const sal_Unicode* pBuf2 = str2;
     147                 :          0 :     sal_Bool res = sal_True;
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 :     while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0')
         [ #  # ][ #  # ]
     150                 :            :     {
     151                 :          0 :         (pBuf1)++;
     152                 :          0 :         (pBuf2)++;
     153                 :            :     }
     154 [ #  # ][ #  # ]:          0 :     if (*pBuf1 == '\0' && *pBuf2 == '\0')
     155                 :          0 :         res = sal_True;
     156                 :            :     else
     157                 :          0 :         res = sal_False;
     158                 :          0 :     return (res);
     159                 :            : }
     160                 :            : 
     161                 :          0 : sal_Char* createName( sal_Char* dst, const sal_Char* meth, sal_uInt32 cnt )
     162                 :            : {
     163                 :          0 :     sal_Char* pdst = dst;
     164                 :            :     sal_Char nstr[16];
     165                 :          0 :     sal_Char* pstr = nstr;
     166                 :          0 :     rtl_str_valueOfInt32( pstr, cnt, 10 );
     167                 :            : 
     168                 :          0 :     cpystr( pdst, meth );
     169                 :          0 :     cpystr( pdst+ AStringLen(meth), "_" );
     170                 :            : 
     171         [ #  # ]:          0 :     if ( cnt < 100 )
     172                 :            :     {
     173                 :          0 :         cpystr(pdst + AStringLen(pdst), "0" );
     174                 :            :     }
     175         [ #  # ]:          0 :     if ( cnt < 10 )
     176                 :            :     {
     177                 :          0 :         cpystr(pdst + AStringLen(pdst), "0" );
     178                 :            :     }
     179                 :            : 
     180                 :          0 :     cpystr( pdst + AStringLen(pdst), nstr );
     181                 :          0 :     return( pdst );
     182                 :            : }
     183                 :            : 
     184                 :            : //------------------------------------------------------------------------
     185                 :            : 
     186                 :            : static inline sal_Int32 ACharToUCharCompare( const sal_Unicode *pUStr,
     187                 :            :                                              const sal_Char    *pAStr
     188                 :            :                                            )
     189                 :            : {
     190                 :            :     sal_Int32  nCmp   = 0;
     191                 :            :     sal_Int32  nUChar = (sal_Int32)*pUStr;
     192                 :            :     sal_Int32  nChar  = (sal_Int32)((unsigned char)*pAStr);
     193                 :            : 
     194                 :            :     nCmp = nUChar - nChar;
     195                 :            : 
     196                 :            :     return  nCmp;
     197                 :            : } // ACharToUCharCompare
     198                 :            : 
     199                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10