1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <sal/types.h>
25 #include <rtl/ustring.h>
26 #include <rtl/string.hxx>
27 #include <rtl_String_Utils_Const.h>
30 sal_uInt32
AStringLen( const sal_Char
*pAStr
)
32 sal_uInt32 nStrLen
= 0;
36 const sal_Char
*pTempStr
= pAStr
;
43 nStrLen
= (sal_uInt32
)( pTempStr
- pAStr
);
48 /* disable assignment within condition expression */
49 #if defined WNT && defined _MSC_VER
50 #pragma warning( disable : 4706 )
52 sal_Char
* cpystr( sal_Char
* dst
, const sal_Char
* src
)
54 const sal_Char
* psrc
= src
;
57 while( (*pdst
++ = *psrc
++) ) {}
62 sal_Char
* cpynstr( sal_Char
* dst
, const sal_Char
* src
, sal_uInt32 cnt
)
65 const sal_Char
* psrc
= src
;
70 if ( len
>= AStringLen(src
) )
72 return( cpystr( dst
, src
) );
75 // copy string by char
76 for( i
= 0; i
< len
; i
++ )
83 //------------------------------------------------------------------------
84 sal_Bool
cmpstr( const sal_Char
* str1
, const sal_Char
* str2
, sal_uInt32 len
)
86 const sal_Char
* pBuf1
= str1
;
87 const sal_Char
* pBuf2
= str2
;
90 while ( (*pBuf1
== *pBuf2
) && i
< len
)
98 //-----------------------------------------------------------------------
99 sal_Bool
cmpstr( const sal_Char
* str1
, const sal_Char
* str2
)
101 const sal_Char
* pBuf1
= str1
;
102 const sal_Char
* pBuf2
= str2
;
103 sal_Bool res
= sal_True
;
105 while ( (*pBuf1
== *pBuf2
) && *pBuf1
!='\0' && *pBuf2
!= '\0')
110 if (*pBuf1
== '\0' && *pBuf2
== '\0')
116 //------------------------------------------------------------------------
117 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
, sal_uInt32 len
)
119 const sal_Unicode
* pBuf1
= str1
;
120 const sal_Unicode
* pBuf2
= str2
;
123 while ( (*pBuf1
== *pBuf2
) && i
< len
)
132 //-----------------------------------------------------------------------
133 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
)
135 const sal_Unicode
* pBuf1
= str1
;
136 const sal_Unicode
* pBuf2
= str2
;
137 sal_Bool res
= sal_True
;
139 while ( (*pBuf1
== *pBuf2
) && *pBuf1
!='\0' && *pBuf2
!= '\0')
144 if (*pBuf1
== '\0' && *pBuf2
== '\0')
151 sal_Char
* createName( sal_Char
* dst
, const sal_Char
* meth
, sal_uInt32 cnt
)
153 sal_Char
* pdst
= dst
;
155 sal_Char
* pstr
= nstr
;
156 rtl_str_valueOfInt32( pstr
, cnt
, 10 );
158 cpystr( pdst
, meth
);
159 cpystr( pdst
+ AStringLen(meth
), "_" );
163 cpystr(pdst
+ AStringLen(pdst
), "0" );
167 cpystr(pdst
+ AStringLen(pdst
), "0" );
170 cpystr( pdst
+ AStringLen(pdst
), nstr
);
174 //------------------------------------------------------------------------
176 static inline sal_Int32
ACharToUCharCompare( const sal_Unicode
*pUStr
,
177 const sal_Char
*pAStr
181 sal_Int32 nUChar
= (sal_Int32
)*pUStr
;
182 sal_Int32 nChar
= (sal_Int32
)((unsigned char)*pAStr
);
184 nCmp
= nUChar
- nChar
;
187 } // ACharToUCharCompare
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */