Kaydet (Commit) fd8c06ad authored tarafından Caolán McNamara's avatar Caolán McNamara

duplicate surrogate code

Change-Id: I9fad024e4b5c8a4ca272f2387df07351198cf5dc
üst a2fea109
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#ifndef INCLUDED_SAL_RTL_SURROGATES_HXX #ifndef INCLUDED_RTL_SURROGATES_H
#define INCLUDED_SAL_RTL_SURROGATES_HXX #define INCLUDED_RTL_SURROGATES_H
#include <sal/config.h> #include <sal/config.h>
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00 #define SAL_RTL_FIRST_LOW_SURROGATE 0xDC00
#define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF #define SAL_RTL_LAST_LOW_SURROGATE 0xDFFF
#ifdef __cplusplus
extern "C" {
#endif
inline bool isHighSurrogate(sal_uInt32 utf16) { inline bool isHighSurrogate(sal_uInt32 utf16) {
return utf16 >= SAL_RTL_FIRST_HIGH_SURROGATE return utf16 >= SAL_RTL_FIRST_HIGH_SURROGATE
&& utf16 <= SAL_RTL_LAST_HIGH_SURROGATE; && utf16 <= SAL_RTL_LAST_HIGH_SURROGATE;
...@@ -44,6 +48,10 @@ inline sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low) { ...@@ -44,6 +48,10 @@ inline sal_uInt32 combineSurrogates(sal_uInt32 high, sal_uInt32 low) {
+ (low - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000; + (low - SAL_RTL_FIRST_LOW_SURROGATE) + 0x10000;
} }
#ifdef __cplusplus
}
#endif
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -262,13 +262,6 @@ public: ...@@ -262,13 +262,6 @@ public:
*/ */
static sal_uInt32 getHexDigit(int nWeight); 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. /** Check two US-ASCII strings for equality, ignoring case.
@param pBegin1 Points to the start of the first string, must not be @param pBegin1 Points to the start of the first string, must not be
...@@ -530,29 +523,6 @@ inline int INetMIME::getBase64Weight(sal_uInt32 nChar) ...@@ -530,29 +523,6 @@ inline int INetMIME::getBase64Weight(sal_uInt32 nChar)
nChar == '=' ? -1 : -2; nChar == '=' ? -1 : -2;
} }
// 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 // static
inline bool INetMIME::startsWithLineBreak(const sal_Char * pBegin, inline bool INetMIME::startsWithLineBreak(const sal_Char * pBegin,
const sal_Char * pEnd) const sal_Char * pEnd)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <rtl/tencinfo.h> #include <rtl/tencinfo.h>
#include "strimp.hxx" #include "strimp.hxx"
#include "surrogates.hxx" #include <rtl/surrogates.h>
#include <rtl/string.h> #include <rtl/string.h>
#include "rtl/math.h" #include "rtl/math.h"
......
...@@ -17,11 +17,10 @@ ...@@ -17,11 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "surrogates.hxx"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/character.hxx" #include "rtl/character.hxx"
#include "rtl/strbuf.hxx" #include "rtl/strbuf.hxx"
#include "rtl/surrogates.h"
#include "rtl/textenc.h" #include "rtl/textenc.h"
#include "rtl/textcvt.h" #include "rtl/textcvt.h"
#include "rtl/uri.h" #include "rtl/uri.h"
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "hash.hxx" #include "hash.hxx"
#include "strimp.hxx" #include "strimp.hxx"
#include "surrogates.hxx" #include <rtl/surrogates.h>
#include <rtl/ustring.h> #include <rtl/ustring.h>
#include "rtl/math.h" #include "rtl/math.h"
......
...@@ -36,13 +36,14 @@ ...@@ -36,13 +36,14 @@
#include <com/sun/star/uri/XUriReferenceFactory.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <rtl/instance.hxx>
#include <rtl/surrogates.h>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <rtl/ustring.h> #include <rtl/ustring.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/types.h> #include <sal/types.h>
#include <tools/inetmime.hxx> #include <tools/inetmime.hxx>
#include <unotools/charclass.hxx> #include <unotools/charclass.hxx>
#include <rtl/instance.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -280,9 +281,9 @@ namespace { ...@@ -280,9 +281,9 @@ namespace {
inline sal_Int32 nextChar(OUString const & rStr, sal_Int32 nPos) inline sal_Int32 nextChar(OUString const & rStr, sal_Int32 nPos)
{ {
return INetMIME::isHighSurrogate(rStr[nPos]) return isHighSurrogate(rStr[nPos])
&& rStr.getLength() - nPos >= 2 && rStr.getLength() - nPos >= 2
&& INetMIME::isLowSurrogate(rStr[nPos + 1]) ? && isLowSurrogate(rStr[nPos + 1]) ?
nPos + 2 : nPos + 1; nPos + 2 : nPos + 1;
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#include <rtl/character.hxx> #include <rtl/character.hxx>
#include <rtl/string.h> #include <rtl/string.h>
#include <rtl/surrogates.h>
#include <rtl/textenc.h> #include <rtl/textenc.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/types.h> #include <sal/types.h>
...@@ -4777,8 +4778,8 @@ sal_uInt32 INetURLObject::getUTF32(sal_Unicode const *& rBegin, ...@@ -4777,8 +4778,8 @@ sal_uInt32 INetURLObject::getUTF32(sal_Unicode const *& rBegin,
nShift -= 6; nShift -= 6;
} }
if (bUTF8 && nEncoded >= nMin if (bUTF8 && nEncoded >= nMin
&& !INetMIME::isHighSurrogate(nEncoded) && !isHighSurrogate(nEncoded)
&& !INetMIME::isLowSurrogate(nEncoded) && !isLowSurrogate(nEncoded)
&& nEncoded <= 0x10FFFF) && nEncoded <= 0x10FFFF)
{ {
rBegin = p; rBegin = p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment