summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-04-20 09:52:41 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-04-20 10:09:58 +0100
commitfd8c06aded20cfd6b4f9c729cec120c0d2d574aa (patch)
tree3c0d558218456ba87a2858019defcce0ed4c235a
parenta2fea109e6454b10e8e85148b93bdca89066fe8d (diff)
duplicate surrogate code
Change-Id: I9fad024e4b5c8a4ca272f2387df07351198cf5dc
-rw-r--r--include/rtl/surrogates.h (renamed from sal/rtl/surrogates.hxx)12
-rw-r--r--include/tools/inetmime.hxx30
-rw-r--r--sal/rtl/string.cxx2
-rw-r--r--sal/rtl/uri.cxx3
-rw-r--r--sal/rtl/ustring.cxx2
-rw-r--r--svl/source/misc/urihelper.cxx7
-rw-r--r--tools/source/fsys/urlobj.cxx5
7 files changed, 20 insertions, 41 deletions
diff --git a/sal/rtl/surrogates.hxx b/include/rtl/surrogates.h
index b100597d5da0..ab98cd666ca3 100644
--- a/sal/rtl/surrogates.hxx
+++ b/include/rtl/surrogates.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_SAL_RTL_SURROGATES_HXX
-#define INCLUDED_SAL_RTL_SURROGATES_HXX
+#ifndef INCLUDED_RTL_SURROGATES_H
+#define INCLUDED_RTL_SURROGATES_H
#include <sal/config.h>
@@ -29,6 +29,10 @@
#define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00
#define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF
+#ifdef __cplusplus
+extern "C" {
+#endif
+
inline bool isHighSurrogate(sal_uInt32 utf16) {
return utf16 >= SAL_RTL_FIRST_HIGH_SURROGATE
&& utf16 <= SAL_RTL_LAST_HIGH_SURROGATE;
@@ -44,6 +48,10 @@ inline sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low) {
+ (low - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 020e16a2e13c..45bf02a5878e 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -262,13 +262,6 @@ public:
*/
static sal_uInt32 getHexDigit(int nWeight);
- static inline bool isHighSurrogate(sal_uInt32 nUTF16);
-
- static inline bool isLowSurrogate(sal_uInt32 nUTF16);
-
- static inline sal_uInt32 toUTF32(sal_Unicode cHighSurrogate,
- sal_Unicode cLowSurrogate);
-
/** Check two US-ASCII strings for equality, ignoring case.
@param pBegin1 Points to the start of the first string, must not be
@@ -531,29 +524,6 @@ inline int INetMIME::getBase64Weight(sal_uInt32 nChar)
}
// static
-inline bool INetMIME::isHighSurrogate(sal_uInt32 nUTF16)
-{
- return nUTF16 >= 0xD800 && nUTF16 <= 0xDBFF;
-}
-
-// static
-inline bool INetMIME::isLowSurrogate(sal_uInt32 nUTF16)
-{
- return nUTF16 >= 0xDC00 && nUTF16 <= 0xDFFF;
-}
-
-// static
-inline sal_uInt32 INetMIME::toUTF32(sal_Unicode cHighSurrogate,
- sal_Unicode cLowSurrogate)
-{
- DBG_ASSERT(isHighSurrogate(cHighSurrogate)
- && isLowSurrogate(cLowSurrogate),
- "INetMIME::toUTF32(): Bad chars");
- return ((sal_uInt32(cHighSurrogate) & 0x3FF) << 10)
- | (sal_uInt32(cLowSurrogate) & 0x3FF);
-}
-
-// static
inline bool INetMIME::startsWithLineBreak(const sal_Char * pBegin,
const sal_Char * pEnd)
{
diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx
index 89459dbc2c0c..68a85f0ae841 100644
--- a/sal/rtl/string.cxx
+++ b/sal/rtl/string.cxx
@@ -32,7 +32,7 @@
#include <rtl/tencinfo.h>
#include "strimp.hxx"
-#include "surrogates.hxx"
+#include <rtl/surrogates.h>
#include <rtl/string.h>
#include "rtl/math.h"
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index f7c62649ca00..a90b40ba83d3 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -17,11 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "surrogates.hxx"
-
#include "osl/diagnose.h"
#include "rtl/character.hxx"
#include "rtl/strbuf.hxx"
+#include "rtl/surrogates.h"
#include "rtl/textenc.h"
#include "rtl/textcvt.h"
#include "rtl/uri.h"
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index d91aaad8ffe1..a418c6ad5841 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -39,7 +39,7 @@
#include "hash.hxx"
#include "strimp.hxx"
-#include "surrogates.hxx"
+#include <rtl/surrogates.h>
#include <rtl/ustring.h>
#include "rtl/math.h"
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index 362b6273c3e4..7d7cc2c90cbf 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -36,13 +36,14 @@
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <osl/diagnose.h>
+#include <rtl/instance.hxx>
+#include <rtl/surrogates.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <tools/inetmime.hxx>
#include <unotools/charclass.hxx>
-#include <rtl/instance.hxx>
using namespace com::sun::star;
@@ -280,9 +281,9 @@ namespace {
inline sal_Int32 nextChar(OUString const & rStr, sal_Int32 nPos)
{
- return INetMIME::isHighSurrogate(rStr[nPos])
+ return isHighSurrogate(rStr[nPos])
&& rStr.getLength() - nPos >= 2
- && INetMIME::isLowSurrogate(rStr[nPos + 1]) ?
+ && isLowSurrogate(rStr[nPos + 1]) ?
nPos + 2 : nPos + 1;
}
diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx
index f6cbcef56fc2..4dfe58895bce 100644
--- a/tools/source/fsys/urlobj.cxx
+++ b/tools/source/fsys/urlobj.cxx
@@ -31,6 +31,7 @@
#include <osl/file.hxx>
#include <rtl/character.hxx>
#include <rtl/string.h>
+#include <rtl/surrogates.h>
#include <rtl/textenc.h>
#include <rtl/ustring.hxx>
#include <sal/types.h>
@@ -4777,8 +4778,8 @@ sal_uInt32 INetURLObject::getUTF32(sal_Unicode const *& rBegin,
nShift -= 6;
}
if (bUTF8 && nEncoded >= nMin
- && !INetMIME::isHighSurrogate(nEncoded)
- && !INetMIME::isLowSurrogate(nEncoded)
+ && !isHighSurrogate(nEncoded)
+ && !isLowSurrogate(nEncoded)
&& nEncoded <= 0x10FFFF)
{
rBegin = p;