Skip to content

Commit 433a074

Browse files
committed
Disabling thread local locale on Android, tracked with CodePlex 269.
1 parent 7cac8bc commit 433a074

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Release/include/cpprest/asyncrt_utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ namespace pplx = Concurrency;
4949

5050
#ifndef _MS_WINDOWS
5151
#include <boost/algorithm/string.hpp>
52+
#ifndef ANDROID // CodePlex 269
5253
#include <xlocale.h>
5354
#endif
55+
#endif
5456

5557
/// Various utilities for string conversions and date and time manipulation.
5658
namespace utility
@@ -170,18 +172,20 @@ namespace details
170172
_ASYNCRTIMP scoped_c_thread_locale();
171173
_ASYNCRTIMP ~scoped_c_thread_locale();
172174

175+
#ifndef ANDROID // CodePlex 269
173176
#ifdef _MS_WINDOWS
174177
typedef _locale_t xplat_locale;
175178
#else
176179
typedef locale_t xplat_locale;
177180
#endif
178181

179182
static _ASYNCRTIMP xplat_locale __cdecl c_locale();
183+
#endif
180184
private:
181185
#ifdef _MS_WINDOWS
182186
std::string m_prevLocale;
183187
int m_prevThreadSetting;
184-
#else
188+
#elif !defined(ANDROID)
185189
locale_t m_prevLocale;
186190
#endif
187191
scoped_c_thread_locale(const scoped_c_thread_locale &);

Release/src/json/json_serialization.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,25 @@ void web::json::details::_Number::format(std::basic_string<char>& stream) const
164164
#else
165165
int numChars;
166166
if (m_number.m_type == number::type::signed_type)
167-
numChars = snprintf(tempBuffer, tempSize, "%" PRId64, m_number.m_intval);
167+
numChars = snprintf(
168+
tempBuffer,
169+
tempSize,
170+
#ifdef ANDROID // CodePlex 269
171+
"%lld",
172+
#else
173+
"%" PRId64,
174+
#endif
175+
m_number.m_intval);
168176
else
169-
numChars = snprintf(tempBuffer, tempSize, "%" PRIu64, m_number.m_uintval);
177+
numChars = snprintf(
178+
tempBuffer,
179+
tempSize,
180+
#ifdef ANDROID
181+
"%llu",
182+
#else
183+
"%" PRIu64,
184+
#endif
185+
m_number.m_uintval);
170186
#endif
171187
stream.append(tempBuffer, numChars);
172188
}

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace utility
5555
namespace details
5656
{
5757

58+
#ifndef ANDROID
5859
std::once_flag g_c_localeFlag;
5960
std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)> g_c_locale(nullptr, [](scoped_c_thread_locale::xplat_locale *){});
6061
scoped_c_thread_locale::xplat_locale scoped_c_thread_locale::c_locale()
@@ -87,6 +88,7 @@ scoped_c_thread_locale::xplat_locale scoped_c_thread_locale::c_locale()
8788
});
8889
return *g_c_locale;
8990
}
91+
#endif
9092

9193
#ifdef _MS_WINDOWS
9294
scoped_c_thread_locale::scoped_c_thread_locale()
@@ -122,6 +124,9 @@ scoped_c_thread_locale::~scoped_c_thread_locale()
122124
_configthreadlocale(m_prevThreadSetting);
123125
}
124126
}
127+
#elif defined(ANDROID)
128+
scoped_c_thread_locale::scoped_c_thread_locale() {}
129+
scoped_c_thread_locale::~scoped_c_thread_locale() {}
125130
#else
126131
scoped_c_thread_locale::scoped_c_thread_locale()
127132
: m_prevLocale(nullptr)

0 commit comments

Comments
 (0)