summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@libreoffice.org>2013-08-10 12:41:03 +0200
committerPetr Mladek <pmladek@suse.cz>2013-08-19 15:49:18 +0000
commitc8e39e66528affb66f1ae121fa36dd4ab31a9b0b (patch)
tree227691ebad802e87695bfffb96889a1ccfe147a4 /sal
parent2e45813b7e5757bc050e121acfe942763b9544ff (diff)
Introduce rtl::compareIgnoreCase and deprecate rtl/character.hxx equivalents.
Change-Id: Id90935fd2b0f904f89477792edc8140cfc31e91f Reviewed-on: https://gerrit.libreoffice.org/5412 Reviewed-by: Petr Mladek <pmladek@suse.cz> Tested-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/strtmpl.cxx32
-rw-r--r--sal/rtl/ustring.cxx16
2 files changed, 13 insertions, 35 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index dc54945ab6a9..8d759b4c7826 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -27,6 +27,8 @@
#include <limits>
#include <boost/static_assert.hpp>
+#include <rtl/character.hxx>
+
/*
inline void rtl_str_ImplCopy( IMPL_RTL_STRCODE* pDest,
const IMPL_RTL_STRCODE* pSrc,
@@ -170,25 +172,19 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase )( const IMPL_RTL_ST
SAL_THROW_EXTERN_C()
{
sal_Int32 nRet;
- sal_Int32 c1;
- sal_Int32 c2;
do
{
- /* If character between 'A' and 'Z', than convert it to lowercase */
- c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 );
- c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 );
- if ( (c1 >= 65) && (c1 <= 90) )
- c1 += 32;
- if ( (c2 >= 65) && (c2 <= 90) )
- c2 += 32;
- nRet = c1-c2;
+ nRet = rtl::compareAsciiIgnoreCase(
+ (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ),
+ (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ));
+
if ( nRet != 0 )
return nRet;
pStr1++;
pStr2++;
}
- while ( c2 );
+ while ( *pStr2 );
return 0;
}
@@ -204,18 +200,12 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase_WithLength )( const
const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len;
const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len;
sal_Int32 nRet;
- sal_Int32 c1;
- sal_Int32 c2;
while ( (pStr1 < pStr1End) && (pStr2 < pStr2End) )
{
- /* If character between 'A' and 'Z', than convert it to lowercase */
- c1 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 );
- c2 = (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 );
- if ( (c1 >= 65) && (c1 <= 90) )
- c1 += 32;
- if ( (c2 >= 65) && (c2 <= 90) )
- c2 += 32;
- nRet = c1-c2;
+ nRet = rtl::compareAsciiIgnoreCase(
+ (sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ),
+ (sal_Int32)IMPL_RTL_USTRCODE( *pStr2 ));
+
if ( nRet != 0 )
return nRet;
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index abf9db7b388b..3f54088c8573 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -41,6 +41,7 @@
#include "strimp.hxx"
#include "surrogates.hxx"
#include <rtl/ustring.h>
+#include <rtl/character.hxx>
#include "rtl/math.h"
#include "rtl/tencinfo.h"
@@ -404,23 +405,10 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( co
{
const sal_Unicode* pStr1End = pStr1 + nStr1Len;
sal_Int32 nRet;
- sal_Int32 c1;
- sal_Int32 c2;
while ( (nShortenedLength > 0) &&
(pStr1 < pStr1End) && *pStr2 )
{
- /* Check ASCII range */
- SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string",
- "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" );
-
- /* If character between 'A' and 'Z', than convert it to lowercase */
- c1 = (sal_Int32)*pStr1;
- c2 = (sal_Int32)((unsigned char)*pStr2);
- if ( (c1 >= 65) && (c1 <= 90) )
- c1 += 32;
- if ( (c2 >= 65) && (c2 <= 90) )
- c2 += 32;
- nRet = c1-c2;
+ nRet = rtl::compareAsciiIgnoreCase( *pStr1, (sal_Int32)((unsigned char)*pStr2));
if ( nRet != 0 )
return nRet;