Mgfractal: Add 3D and 4D fractals
[oweals/minetest.git] / src / cguittfont / irrUString.h
index f41fa1f7bfdd0d3265d119c592800883c796c4d1..eb7abe5a13d25be685244b7fcca7e82536b0023f 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef _WIN32
+#define __BYTE_ORDER 0
+#define __LITTLE_ENDIAN 0
+#define __BIG_ENDIAN 1
+#elif defined(__MACH__) && defined(__APPLE__)
+#include <machine/endian.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#else
+#include <endian.h>
+#endif
 
 #ifdef USTRING_CPP0X
 #      include <utility>
@@ -205,6 +216,10 @@ inline core::array<u8> getUnicodeBOM(EUTF_ENCODE mode)
                case EUTFE_UTF32_LE:
                        COPY_ARRAY(BOM_ENCODE_UTF32_LE, BOM_ENCODE_UTF32_LEN);
                        break;
+               case EUTFE_NONE:
+                       // TODO sapier: fixed warning only,
+                       // don't know if something needs to be done here
+                       break;
        }
        return ret;
 
@@ -257,7 +272,7 @@ public:
                                _set(c);
                                return *this;
                        }
-                       
+
                        //! Increments the value by 1.
                        //! \return Myself.
                        _ustring16_iterator_access& operator++()
@@ -392,7 +407,7 @@ public:
                                        return unicode::toUTF32(a[pos], a[pos + 1]);
                                }
                        }
-                       
+
                        //! Sets a uchar32_t at our current position.
                        void _set(uchar32_t c)
                        {
@@ -707,7 +722,6 @@ public:
                        //! Moves the iterator to the end of the string.
                        void toEnd()
                        {
-                               const uchar16_t* a = ref->c_str();
                                pos = ref->size_raw();
                        }
 
@@ -732,12 +746,13 @@ public:
                        typedef typename _Base::const_pointer const_pointer;
                        typedef typename _Base::const_reference const_reference;
 
+
                        typedef typename _Base::value_type value_type;
                        typedef typename _Base::difference_type difference_type;
                        typedef typename _Base::distance_type distance_type;
                        typedef access pointer;
                        typedef access reference;
-                       
+
                        using _Base::pos;
                        using _Base::ref;
 
@@ -802,7 +817,7 @@ public:
        ustring16()
        : array(0), allocated(1), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -816,7 +831,7 @@ public:
        ustring16(const ustring16<TAlloc>& other)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -830,7 +845,7 @@ public:
        ustring16(const string<B, A>& other)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -845,7 +860,7 @@ public:
        ustring16(const std::basic_string<B, A, Alloc>& other)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -859,7 +874,7 @@ public:
        ustring16(Itr first, Itr last)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -878,7 +893,7 @@ public:
        ustring16(const char* const c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -893,7 +908,7 @@ public:
        ustring16(const char* const c, u32 length)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -908,7 +923,7 @@ public:
        ustring16(const uchar8_t* const c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -922,7 +937,7 @@ public:
        ustring16(const char c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -936,7 +951,7 @@ public:
        ustring16(const uchar8_t* const c, u32 length)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -950,7 +965,7 @@ public:
        ustring16(const uchar16_t* const c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -964,7 +979,7 @@ public:
        ustring16(const uchar16_t* const c, u32 length)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -978,7 +993,7 @@ public:
        ustring16(const uchar32_t* const c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -992,7 +1007,7 @@ public:
        ustring16(const uchar32_t* const c, u32 length)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -1006,7 +1021,7 @@ public:
        ustring16(const wchar_t* const c)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -1025,7 +1040,7 @@ public:
        ustring16(const wchar_t* const c, u32 length)
        : array(0), allocated(0), used(0)
        {
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
                encoding = unicode::EUTFE_UTF16_BE;
 #else
                encoding = unicode::EUTFE_UTF16_LE;
@@ -2096,7 +2111,7 @@ public:
        }
 #endif
 
-       
+
        //! Appends a number to this ustring16.
        //! \param c Number to append.
        //! \return A reference to our current string.
@@ -2958,7 +2973,7 @@ public:
                if (endian != unicode::EUTFEE_NATIVE && getEndianness() != endian)
                {
                        for (u32 i = 0; i <= used; ++i)
-                               *ptr++ = unicode::swapEndian16(*ptr);
+                               ptr[i] = unicode::swapEndian16(ptr[i]);
                }
                ret.set_used(used + (addBOM ? unicode::BOM_UTF16_LEN : 0));
                ret.push_back(0);
@@ -3391,7 +3406,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const short ri
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const short left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3411,7 +3426,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const unsigned short left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3431,7 +3446,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const int righ
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const int left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3451,7 +3466,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const unsigned int left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3471,7 +3486,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const long rig
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const long left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3491,7 +3506,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const unsigned
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const unsigned long left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3511,7 +3526,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const float ri
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const float left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }
@@ -3531,7 +3546,7 @@ inline ustring16<TAlloc> operator+(const ustring16<TAlloc>& left, const double r
 template <typename TAlloc>
 inline ustring16<TAlloc> operator+(const double left, const ustring16<TAlloc>& right)
 {
-       ustring16<TAlloc> ret(core::stringc(left));
+       ustring16<TAlloc> ret((core::stringc(left)));
        ret += right;
        return ret;
 }