[Libreoffice-commits] core.git: include/rtl include/tools sal/rtl svl/source tools/source

Caolán McNamara caolanm at redhat.com
Mon Apr 20 02:13:30 PDT 2015


 include/rtl/surrogates.h      |   57 ++++++++++++++++++++++++++++++++++++++++++
 include/tools/inetmime.hxx    |   30 ----------------------
 sal/rtl/string.cxx            |    2 -
 sal/rtl/surrogates.hxx        |   49 ------------------------------------
 sal/rtl/uri.cxx               |    3 --
 sal/rtl/ustring.cxx           |    2 -
 svl/source/misc/urihelper.cxx |    7 ++---
 tools/source/fsys/urlobj.cxx  |    5 ++-
 8 files changed, 67 insertions(+), 88 deletions(-)

New commits:
commit fd8c06aded20cfd6b4f9c729cec120c0d2d574aa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 20 09:52:41 2015 +0100

    duplicate surrogate code
    
    Change-Id: I9fad024e4b5c8a4ca272f2387df07351198cf5dc

diff --git a/sal/rtl/surrogates.hxx b/include/rtl/surrogates.h
similarity index 92%
rename from sal/rtl/surrogates.hxx
rename to include/rtl/surrogates.h
index b100597..ab98cd6 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 020e16a..45bf02a 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 89459db..68a85f0 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 f7c6264..a90b40b 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 d91aaad..a418c6a 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 362b627..7d7cc2c 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 f6cbcef..4dfe588 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;


More information about the Libreoffice-commits mailing list