diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-09-30 11:37:54 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-09-30 11:49:22 +0200 |
commit | edecc4e9af189ff8f4c95d4b89a713facb368d71 (patch) | |
tree | 2776121237ee2d6541b6a55fddc96dc6cedd64be /sal | |
parent | 89de6ba4c65c8709e32fe636ff743d914cf56225 (diff) |
Clean up rtl/character.hxx
It is probably best to base the functions on Unicode code points instead of
scalar values, now that they are also used from sal/rtl/strtmpl.cxx with UTF-16
code units and with arbitrary bytes (with values assumed to be a superset of
ASCII, though). Rename compareAsciiIgnoreCase to compareIgnoreAsciiCase. Also,
the corresponding tools::INetMIME functions can be removed completely; no need
to keep them around as deprecated.
Change-Id: I8d322177f4909e70a946e8186e3e0f7fa6d9a43e
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/strtmpl.cxx | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 48bf05e65e15..61103fed7b10 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -172,24 +172,19 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compareIgnoreAsciiCase )( const IMPL_RTL_ST const IMPL_RTL_STRCODE* pStr2 ) SAL_THROW_EXTERN_C() { - sal_Int32 nRet; - sal_Int32 c1; - sal_Int32 c2; + sal_uInt32 c1; 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 ); - c1 = rtl::toAsciiLowerCase( c1 ); - c2 = rtl::toAsciiLowerCase( c2 ); - nRet = c1-c2; + c1 = IMPL_RTL_USTRCODE(*pStr1); + sal_Int32 nRet = rtl::compareIgnoreAsciiCase( + c1, IMPL_RTL_USTRCODE(*pStr2)); if ( nRet != 0 ) return nRet; pStr1++; pStr2++; } - while ( c2 ); + while (c1); return 0; } @@ -204,12 +199,10 @@ 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; while ( (pStr1 < pStr1End) && (pStr2 < pStr2End) ) { - sal_uInt32 c1 = IMPL_RTL_USTRCODE( *pStr1 ); - sal_uInt32 c2 = IMPL_RTL_USTRCODE( *pStr2 ); - nRet = rtl::compareAsciiIgnoreCase(c1, c2); + sal_Int32 nRet = rtl::compareIgnoreAsciiCase( + IMPL_RTL_USTRCODE(*pStr1), IMPL_RTL_USTRCODE(*pStr2)); if ( nRet != 0 ) return nRet; @@ -231,13 +224,11 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompareIgnoreAsciiCase_WithLength { const IMPL_RTL_STRCODE* pStr1End = pStr1 + nStr1Len; const IMPL_RTL_STRCODE* pStr2End = pStr2 + nStr2Len; - sal_Int32 nRet; while ( (nShortenedLength > 0) && (pStr1 < pStr1End) && (pStr2 < pStr2End) ) { - sal_uInt32 c1 = IMPL_RTL_USTRCODE( *pStr1 ); - sal_uInt32 c2 = IMPL_RTL_USTRCODE( *pStr2 ); - nRet = rtl::compareAsciiIgnoreCase(c1, c2); + sal_Int32 nRet = rtl::compareIgnoreAsciiCase( + IMPL_RTL_USTRCODE(*pStr1), IMPL_RTL_USTRCODE(*pStr2)); if ( nRet != 0 ) return nRet; @@ -562,7 +553,7 @@ void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase )( IMPL_RTL_STRCODE* pStr ) { while ( *pStr ) { - *pStr = rtl::toAsciiLowerCase( *pStr ); + *pStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pStr)); pStr++; } @@ -576,7 +567,7 @@ void SAL_CALL IMPL_RTL_STRNAME( toAsciiLowerCase_WithLength )( IMPL_RTL_STRCODE* { while ( nLen > 0 ) { - *pStr = rtl::toAsciiLowerCase( *pStr ); + *pStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pStr)); pStr++; nLen--; @@ -590,7 +581,7 @@ void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase )( IMPL_RTL_STRCODE* pStr ) { while ( *pStr ) { - *pStr = rtl::toAsciiUpperCase( *pStr ); + *pStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pStr)); pStr++; } @@ -604,7 +595,7 @@ void SAL_CALL IMPL_RTL_STRNAME( toAsciiUpperCase_WithLength )( IMPL_RTL_STRCODE* { while ( nLen > 0 ) { - *pStr = rtl::toAsciiUpperCase( *pStr ); + *pStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pStr)); pStr++; nLen--; @@ -1568,8 +1559,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiLowerCase )( IMPL_RTL_STRINGDATA** while ( nLen > 0 ) { - /* Between A-Z (65-90), than to lowercase (+32) */ - if ( rtl::isAsciiUpperCase(*pCharStr) ) + if ( rtl::isAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)) ) { /* Copy String */ IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); @@ -1577,15 +1567,14 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiLowerCase )( IMPL_RTL_STRINGDATA** /* replace/copy rest of the string */ if ( pNewCharStr ) { - /* to lowercase (+32) */ - *pNewCharStr = *pCharStr+32; + *pNewCharStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)); pNewCharStr++; pCharStr++; nLen--; while ( nLen > 0 ) { - *pNewCharStr = rtl::toAsciiLowerCase( *pCharStr ); + *pNewCharStr = rtl::toAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)); pNewCharStr++; pCharStr++; @@ -1626,8 +1615,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiUpperCase )( IMPL_RTL_STRINGDATA** while ( nLen > 0 ) { - /* Between a-z (97-122), than to uppercase (-32) */ - if ( rtl::isAsciiLowerCase(*pCharStr) ) + if ( rtl::isAsciiLowerCase(IMPL_RTL_USTRCODE(*pCharStr)) ) { /* Copy String */ IMPL_RTL_STRCODE* pNewCharStr = IMPL_RTL_STRINGNAME( ImplNewCopy )( ppThis, pStr, pCharStr-pStr->buffer ); @@ -1635,15 +1623,14 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newToAsciiUpperCase )( IMPL_RTL_STRINGDATA** /* replace/copy rest of the string */ if ( pNewCharStr ) { - /* to uppercase (-32) */ - *pNewCharStr = *pCharStr-32; + *pNewCharStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)); pNewCharStr++; pCharStr++; nLen--; while ( nLen > 0 ) { - *pNewCharStr = rtl::toAsciiUpperCase( *pCharStr ); + *pNewCharStr = rtl::toAsciiUpperCase(IMPL_RTL_USTRCODE(*pCharStr)); pNewCharStr++; pCharStr++; |