summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-07-01 23:21:17 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-07-01 23:21:17 +0200
commit4f90623dba6a211e7b4c9e98def91605627c5072 (patch)
treedfd149b4a968abe9a9c30fb59910387d0e8a30f3 /sal
parenta402fd0d520108ec62b170415b6bc7b04716e3b4 (diff)
Clean up surrogates.hxx
Change-Id: I0eae089be1bde9db822a77bea482c10650c8a137
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/string.cxx6
-rw-r--r--sal/rtl/surrogates.hxx25
-rw-r--r--sal/rtl/uri.cxx15
-rw-r--r--sal/rtl/ustring.cxx14
4 files changed, 25 insertions, 35 deletions
diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx
index 9a651b65617a..28039720d1ec 100644
--- a/sal/rtl/string.cxx
+++ b/sal/rtl/string.cxx
@@ -138,7 +138,7 @@ static int rtl_ImplGetFastUTF8ByteLen( const sal_Unicode* pStr, sal_Int32 nLen )
n += 2;
else
{
- if ( !SAL_RTL_IS_HIGH_SURROGATE(c) )
+ if ( !isHighSurrogate(c) )
n += 3;
else
{
@@ -147,9 +147,9 @@ static int rtl_ImplGetFastUTF8ByteLen( const sal_Unicode* pStr, sal_Int32 nLen )
if ( pStr+1 < pEndStr )
{
c = *(pStr+1);
- if ( SAL_RTL_IS_LOW_SURROGATE(c) )
+ if ( isLowSurrogate(c) )
{
- nUCS4Char = SAL_RTL_COMBINE_SURROGATES(nUCS4Char, c);
+ nUCS4Char = combineSurrogates(nUCS4Char, c);
pStr++;
}
}
diff --git a/sal/rtl/surrogates.hxx b/sal/rtl/surrogates.hxx
index ac47050dc594..b100597d5da0 100644
--- a/sal/rtl/surrogates.hxx
+++ b/sal/rtl/surrogates.hxx
@@ -20,24 +20,29 @@
#ifndef INCLUDED_SAL_RTL_SURROGATES_HXX
#define INCLUDED_SAL_RTL_SURROGATES_HXX
-#include "sal/config.h"
+#include <sal/config.h>
+
+#include <sal/types.h>
#define SAL_RTL_FIRST_HIGH_SURROGATE 0xD800
#define SAL_RTL_LAST_HIGH_SURROGATE 0xDBFF
#define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00
#define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF
-#define SAL_RTL_IS_HIGH_SURROGATE(utf16) \
- ((utf16) >= SAL_RTL_FIRST_HIGH_SURROGATE && \
- (utf16) <= SAL_RTL_LAST_HIGH_SURROGATE)
+inline bool isHighSurrogate(sal_uInt32 utf16) {
+ return utf16 >= SAL_RTL_FIRST_HIGH_SURROGATE
+ && utf16 <= SAL_RTL_LAST_HIGH_SURROGATE;
+}
-#define SAL_RTL_IS_LOW_SURROGATE(utf16) \
- ((utf16) >= SAL_RTL_FIRST_LOW_SURROGATE && \
- (utf16) <= SAL_RTL_LAST_LOW_SURROGATE)
+inline bool isLowSurrogate(sal_uInt32 utf16) {
+ return utf16 >= SAL_RTL_FIRST_LOW_SURROGATE
+ && utf16 <= SAL_RTL_LAST_LOW_SURROGATE;
+}
-#define SAL_RTL_COMBINE_SURROGATES(high, low) \
- ((((high) - SAL_RTL_FIRST_HIGH_SURROGATE) << 10) + \
- ((low) - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000)
+inline sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low) {
+ return ((high - SAL_RTL_FIRST_HIGH_SURROGATE) << 10)
+ + (low - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000;
+}
#endif
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index 20daac36024c..e51039888ba9 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -41,21 +41,6 @@ std::size_t const nCharClassSize = 128;
sal_Unicode const cEscapePrefix = 0x25; // '%'
-inline bool isHighSurrogate(sal_uInt32 nUtf16)
-{
- return SAL_RTL_IS_HIGH_SURROGATE(nUtf16);
-}
-
-inline bool isLowSurrogate(sal_uInt32 nUtf16)
-{
- return SAL_RTL_IS_LOW_SURROGATE(nUtf16);
-}
-
-inline sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low)
-{
- return SAL_RTL_COMBINE_SURROGATES(high, low);
-}
-
inline int getHexWeight(sal_uInt32 nUtf32)
{
return nUtf32 >= 0x30 && nUtf32 <= 0x39 ? // '0'--'9'
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index a79c9177a3ee..c7622bd246be 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -1010,8 +1010,8 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
while (incrementCodePoints < 0) {
assert(n > 0);
cu = string->buffer[--n];
- if (SAL_RTL_IS_LOW_SURROGATE(cu) && n != 0 &&
- SAL_RTL_IS_HIGH_SURROGATE(string->buffer[n - 1]))
+ if (isLowSurrogate(cu) && n != 0 &&
+ isHighSurrogate(string->buffer[n - 1]))
{
--n;
}
@@ -1019,18 +1019,18 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints(
}
assert(n >= 0 && n < string->length);
cu = string->buffer[n];
- if (SAL_RTL_IS_HIGH_SURROGATE(cu) && string->length - n >= 2 &&
- SAL_RTL_IS_LOW_SURROGATE(string->buffer[n + 1]))
+ if (isHighSurrogate(cu) && string->length - n >= 2 &&
+ isLowSurrogate(string->buffer[n + 1]))
{
- cp = SAL_RTL_COMBINE_SURROGATES(cu, string->buffer[n + 1]);
+ cp = combineSurrogates(cu, string->buffer[n + 1]);
} else {
cp = cu;
}
while (incrementCodePoints > 0) {
assert(n < string->length);
cu = string->buffer[n++];
- if (SAL_RTL_IS_HIGH_SURROGATE(cu) && n != string->length &&
- SAL_RTL_IS_LOW_SURROGATE(string->buffer[n]))
+ if (isHighSurrogate(cu) && n != string->length &&
+ isLowSurrogate(string->buffer[n]))
{
++n;
}