Merge "Fix _STLP_USE_EXCEPTIONS"
diff --git a/src/c_locale_dummy/c_locale_dummy.c b/src/c_locale_dummy/c_locale_dummy.c
index be48f23..01708ee 100644
--- a/src/c_locale_dummy/c_locale_dummy.c
+++ b/src/c_locale_dummy/c_locale_dummy.c
@@ -44,8 +44,12 @@
static const char *_C_name = "C";
static const char *_empty_str = "";
#ifndef _STLP_NO_WCHAR_T
+#if defined(WCHAR_MAX) && WCHAR_MAX == 255
+static const wchar_t *_empty_wstr = "";
+#else
static const wchar_t *_empty_wstr = L"";
#endif
+#endif
static _Locale_mask_t ctable[256];
@@ -207,14 +211,14 @@
_Locale_mask_t ret = 0;
if ((mask & _Locale_ALPHA) != 0 && iswalpha(wc))
ret |= _Locale_ALPHA;
-
+
if ((mask & _Locale_CNTRL) != 0 && iswcntrl(wc))
ret |= _Locale_CNTRL;
if ((mask & _Locale_DIGIT) != 0 && iswdigit(wc))
ret |= _Locale_DIGIT;
- if ((mask & _Locale_PRINT) != 0 && iswprint(wc))
+ if ((mask & _Locale_PRINT) != 0 && iswprint(wc))
ret |= _Locale_PRINT;
if ((mask & _Locale_PUNCT) != 0 && iswpunct(wc))
@@ -344,11 +348,18 @@
{ return L'.'; }
wchar_t _WLocale_thousands_sep(struct _Locale_numeric* lnum)
{ return L','; }
+#if defined(WCHAR_MAX) && WCHAR_MAX == 255
+const wchar_t * _WLocale_true(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
+{ return "true"; }
+const wchar_t * _WLocale_false(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
+{ return "false"; }
+#else
const wchar_t * _WLocale_true(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return L"true"; }
const wchar_t * _WLocale_false(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return L"false"; }
#endif
+#endif
/* Monetary */
@@ -441,6 +452,40 @@
{ return "PM"; }
#ifndef _STLP_NO_WCHAR_T
+#if defined(WCHAR_MAX) && WCHAR_MAX == 255
+static const wchar_t* full_wmonthname[] =
+{ "January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December" };
+const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n,
+ wchar_t* buf, size_t bufSize)
+{ return full_wmonthname[n]; }
+
+static const wchar_t* abbrev_wmonthname[] =
+{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n,
+ wchar_t* buf, size_t bufSize)
+{ return abbrev_wmonthname[n]; }
+
+static const wchar_t* full_wdayname[] =
+{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
+const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n,
+ wchar_t* buf, size_t bufSize)
+{ return full_wdayname[n]; }
+
+static const wchar_t* abbrev_wdayname[] =
+{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n,
+ wchar_t* buf, size_t bufSize)
+{ return abbrev_wdayname[n]; }
+
+const wchar_t* _WLocale_am_str(struct _Locale_time* ltime,
+ wchar_t* buf, size_t bufSize)
+{ return "AM"; }
+const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
+ wchar_t* buf, size_t bufSize)
+{ return "PM"; }
+#else /* WCHAR_MAX != 255 */
static const wchar_t* full_wmonthname[] =
{ L"January", L"February", L"March", L"April", L"May", L"June",
L"July", L"August", L"September", L"October", L"November", L"December" };
@@ -473,6 +518,7 @@
const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
wchar_t* buf, size_t bufSize)
{ return L"PM"; }
+#endif /* WCHAR_MAX != 255 */
#endif
/* Messages */
diff --git a/src/complex.cpp b/src/complex.cpp
index 50f310c..6da5bc1 100644
--- a/src/complex.cpp
+++ b/src/complex.cpp
@@ -226,18 +226,24 @@
return r;
}
-static const float LN10_INVF = 1.f / ::log(10.f);
_STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>& z)
-{ return log10T(z, LN10_INVF); }
+{
+ const float LN10_INVF = 1.f / ::log(10.f);
+ return log10T(z, LN10_INVF);
+}
-static const double LN10_INV = 1. / ::log10(10.);
_STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>& z)
-{ return log10T(z, LN10_INV); }
+{
+ const double LN10_INV = 1. / ::log10(10.);
+ return log10T(z, LN10_INV);
+}
#if !defined (_STLP_NO_LONG_DOUBLE)
-static const long double LN10_INVL = 1.l / ::log(10.l);
_STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>& z)
-{ return log10T(z, LN10_INVL); }
+{
+ const long double LN10_INVL = 1.l / ::log(10.l);
+ return log10T(z, LN10_INVL);
+}
#endif
//----------------------------------------------------------------------
diff --git a/src/complex_trig.cpp b/src/complex_trig.cpp
index f566fe9..62d6be7 100644
--- a/src/complex_trig.cpp
+++ b/src/complex_trig.cpp
@@ -42,7 +42,7 @@
long double ld;
} ldouble_ulimit = {0x408633ce, 0x8fb9f87e, 0xbd23b659, 0x4e9bd8b1};
# if !defined (_STLP_NO_LONG_DOUBLE)
- static const long double ldouble_limit = ldouble_ulimit.ld;
+# define ldouble_limit ldouble_ulimit.ld
# endif
#else
# if defined (M_LN2) && defined (FLT_MAX_EXP)
@@ -54,9 +54,9 @@
# endif
# if !defined (_STLP_NO_LONG_DOUBLE)
# if defined (M_LN2l)
- static const long double ldouble_limit = M_LN2l * LDBL_MAX_EXP;
+# define ldouble_limit (M_LN2l * LDBL_MAX_EXP)
# else
- static const long double ldouble_limit = ::log(LDBL_MAX);
+# define ldouble_limit ::log(LDBL_MAX)
# endif
# endif
#endif
diff --git a/src/locale.cpp b/src/locale.cpp
index 8df976b..5564a6e 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -26,7 +26,8 @@
_STLP_BEGIN_NAMESPACE
-static const string _Nameless("*");
+#define _NAMELESS "*"
+static const char _Nameless[] = _NAMELESS;
static inline bool is_C_locale_name (const char* name)
{ return ((name[0] == 'C') && (name[1] == 0)); }
@@ -248,8 +249,8 @@
if (!name)
_M_throw_on_null_name();
- if (_Nameless == name)
- _STLP_THROW(runtime_error((string("Invalid locale name '") + _Nameless + "'").c_str()));
+ if (!::strcmp(_Nameless, name))
+ _STLP_THROW(runtime_error("Invalid locale name '" _NAMELESS "'"));
_Locale_impl* impl = 0;
diff --git a/src/locale_impl.cpp b/src/locale_impl.cpp
index 103b603..71e0864 100644
--- a/src/locale_impl.cpp
+++ b/src/locale_impl.cpp
@@ -28,7 +28,7 @@
_STLP_BEGIN_NAMESPACE
-static const string _Nameless("*");
+static const char _Nameless[] = "*";
static inline bool is_C_locale_name (const char* name)
{ return ((name[0] == 'C') && (name[1] == 0)); }
diff --git a/src/monetary.cpp b/src/monetary.cpp
index d9b213a..d4a6767 100644
--- a/src/monetary.cpp
+++ b/src/monetary.cpp
@@ -36,9 +36,9 @@
}
// This is being used throughout the library
-static const string _S_empty_string;
+static const char _S_empty_string[] = "";
#ifndef _STLP_NO_WCHAR_T
-static const wstring _S_empty_wstring;
+static const wchar_t _S_empty_wstring[] = L"";
#endif
//
diff --git a/src/num_get_float.cpp b/src/num_get_float.cpp
index 63e9fed..0407604 100644
--- a/src/num_get_float.cpp
+++ b/src/num_get_float.cpp
@@ -50,7 +50,7 @@
} i32;
};
-# if defined (__linux__) && !defined (ANDROID)
+# if defined (__linux__) && !defined (__ANDROID__)
# include <ieee754.h>
# else
union ieee854_long_double {
@@ -105,7 +105,7 @@
# define ULL(x) x##Ui64
#elif defined (__unix) || defined (__MINGW32__) || \
(defined (__DMC__) && (__LONGLONG)) || defined (__WATCOMC__) || \
- defined (ANDROID)
+ defined (__ANDROID__)
typedef uint32_t uint32;
typedef uint64_t uint64;
# define ULL(x) x##ULL
@@ -136,7 +136,7 @@
high = u1 * v1 + w2 + (x >> 32);
}
-#if !defined (__linux__) || defined (ANDROID)
+#if !defined (__linux__) || defined (__ANDROID__)
# define bit11 ULL(0x7ff)
# define exponent_mask (bit11 << 52)
@@ -324,7 +324,7 @@
// Third argument is base-10 exponent.
/* IEEE representation */
-#if !defined (__linux__) || defined (ANDROID)
+#if !defined (__linux__) || defined (__ANDROID__)
union _Double_rep {
uint64 ival;
@@ -641,7 +641,7 @@
}
#endif // __linux__
-#if !defined (__linux__) || defined (ANDROID)
+#if !defined (__linux__) || defined (__ANDROID__)
static double _Stl_string_to_double(const char *s) {
typedef numeric_limits<double> limits;
const int max_digits = limits::digits10 + 2;
@@ -845,7 +845,7 @@
void _STLP_CALL
__string_to_float(const __iostring& v, float& val)
{
-#if !defined (__linux__) || defined (ANDROID)
+#if !defined (__linux__) || defined (__ANDROID__)
val = (float)_Stl_string_to_double(v.c_str());
#else
val = (float)_Stl_string_to_doubleT<double,ieee754_double,12,IEEE754_DOUBLE_BIAS>(v.c_str());
@@ -855,7 +855,7 @@
void _STLP_CALL
__string_to_float(const __iostring& v, double& val)
{
-#if !defined (__linux__) || defined (ANDROID)
+#if !defined (__linux__) || defined (__ANDROID__)
val = _Stl_string_to_double(v.c_str());
#else
val = _Stl_string_to_doubleT<double,ieee754_double,12,IEEE754_DOUBLE_BIAS>(v.c_str());
diff --git a/stlport/stl/_clocale.h b/stlport/stl/_clocale.h
index 091a9b6..2dcf39a 100644
--- a/stlport/stl/_clocale.h
+++ b/stlport/stl/_clocale.h
@@ -31,7 +31,7 @@
# if defined (_STLP_IMPORT_VENDOR_CSTD)
_STLP_BEGIN_NAMESPACE
using _STLP_VENDOR_CSTD::lconv;
-# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
+# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) && !defined(__ANDROID__)
using _STLP_VENDOR_CSTD::localeconv;
using _STLP_VENDOR_CSTD::setlocale;
# endif
diff --git a/stlport/stl/_cmath.h b/stlport/stl/_cmath.h
index 2867c23..771c27d 100644
--- a/stlport/stl/_cmath.h
+++ b/stlport/stl/_cmath.h
@@ -205,7 +205,7 @@
/** rough characterization of compiler and native C library
For the compiler, it can either support long double or not. If it doesn't, the
-macro _STLP_NO_LONG_DOUBLE is not defined and we don't define any long double
+macro _STLP_NO_LONG_DOUBLE is defined and we don't define any long double
overloads.
For the native C library the question is whether it has variants with an 'f'
suffix (for float as opposed to double) or an 'l' suffix (for long double). If
@@ -531,7 +531,7 @@
#endif
#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
-#if defined (ANDROID)
+#if defined (__ANDROID__)
namespace __captured {
template<typename _Tp> inline int __capture_isfinite(_Tp __f) { return isfinite(__f); }
template<typename _Tp> inline int __capture_isinf(_Tp __f) { return isinf(__f); }
@@ -573,7 +573,7 @@
#if !(defined(__HP_aCC) && defined(_STLP_DEBUG))
using ::hypot;
#endif
-#if defined (ANDROID)
+#if defined (__ANDROID__)
using __captured::isfinite;
using __captured::isinf;
using __captured::isnan;
@@ -583,7 +583,7 @@
using ::log10;
using ::modf;
using ::pow;
-#if defined (ANDROID)
+#if defined (__ANDROID__)
using __captured::signbit;
#endif
using ::sin;
diff --git a/stlport/stl/_mbstate_t.h b/stlport/stl/_mbstate_t.h
index 53566a7..83f085e 100644
--- a/stlport/stl/_mbstate_t.h
+++ b/stlport/stl/_mbstate_t.h
@@ -27,7 +27,7 @@
#if defined (_STLP_USE_OWN_MBSTATE_T)
# if !defined (_STLP_CPP_MBSTATE_T) || !defined (__cplusplus) || !defined (_STLP_USE_NEW_C_HEADERS)
-# if !defined (ANDROID) /* mbstate_t conflicts with Android's definition */
+# if !defined (__ANDROID__) /* mbstate_t conflicts with Android's definition */
typedef int mbstate_t;
# endif
# endif
diff --git a/stlport/stl/_pair.h b/stlport/stl/_pair.h
index de0b08e..7da76a9 100644
--- a/stlport/stl/_pair.h
+++ b/stlport/stl/_pair.h
@@ -43,7 +43,7 @@
_STLP_BEGIN_NAMESPACE
-#if defined (ANDROID)
+#if defined (__ANDROID__)
/* Android has stl_pair.h, prevent using it by defining the header guard. */
# define __SGI_STL_INTERNAL_PAIR_H
#endif
diff --git a/stlport/stl/_rope.h b/stlport/stl/_rope.h
index f100f67..cc391f7 100644
--- a/stlport/stl/_rope.h
+++ b/stlport/stl/_rope.h
@@ -905,7 +905,9 @@
}
reference operator*() {
if (0 == this->_M_buf_ptr)
-#if !defined (__DMC__)
+#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 7))
+ this->_S_setcache(*this);
+#elif !defined (__DMC__)
_S_setcache(*this);
#else
{ _Rope_iterator_base<_CharT, _Alloc>* __x = this; _S_setcache(*__x); }
diff --git a/stlport/stl/config/_system.h b/stlport/stl/config/_system.h
index c0b4add..1e82095 100644
--- a/stlport/stl/config/_system.h
+++ b/stlport/stl/config/_system.h
@@ -59,7 +59,7 @@
# elif defined (__HP_aCC)
# include <stl/config/_hpacc.h>
# endif
-#elif defined (ANDROID)
+#elif defined (__ANDROID__)
/* Android mobile phone platform. Somewhat but not entirely GNU/Linux-like */
# include <stl/config/_android.h>
#elif defined (linux) || defined (__linux__)
diff --git a/stlport/stl/pointers/_tools.h b/stlport/stl/pointers/_tools.h
index 5bb7b25..d9b64e6 100644
--- a/stlport/stl/pointers/_tools.h
+++ b/stlport/stl/pointers/_tools.h
@@ -351,7 +351,10 @@
_IteWrapper(_Iterator &__ite) : _M_ite(__ite) {}
- const_reference operator*() const { return cast_traits::to_storage_type_cref(*_M_ite); }
+ const_reference operator*() const
+ // See http://code.google.com/p/android/issues/detail?id=38630
+ //{ return cast_traits::to_storage_type_cref(*_M_ite); }
+ { return reinterpret_cast<const_reference>(*_M_ite); }
_Self& operator= (_Self const& __rhs) {
_M_ite = __rhs._M_ite;