Skip to content

Commit b3b3392

Browse files
committed
Fixing issues with proposed TFS sync
1 parent 7e3ea6d commit b3b3392

File tree

4 files changed

+23
-39
lines changed

4 files changed

+23
-39
lines changed

Release/include/compat/SafeInt3.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Version 3.0
5656
#ifndef SAFEINT_HPP
5757
#define SAFEINT_HPP
5858

59-
// Enable compiling with /Wall under VC
59+
// Enable compiling with /Wall under VC
6060
#if !defined __GNUC__
6161
#pragma warning( push )
6262
// Disable warnings coming from headers
@@ -78,15 +78,10 @@ Version 3.0
7878
#pragma warning( pop )
7979
#endif
8080

81-
// Various things needed for GCC
81+
// Various things needed for GCC & clang
82+
// Note: Clang is clever and claims to be GCC by defining __GNUC__
8283
#if defined __GNUC__
8384

84-
#if !defined __clang__
85-
86-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
87-
88-
#endif
89-
9085
#define NEEDS_INT_DEFINED
9186

9287
#if !defined NULL
@@ -97,7 +92,13 @@ Version 3.0
9792

9893
#endif
9994

100-
// If the user made a choice, respect it #if !defined
95+
// This is only for GCC, not Clang.
96+
#if defined __GNUC__ && !defined __clang__
97+
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
98+
#endif
99+
100+
101+
// If the user made a choice, respect it #if !defined
101102
#if !defined NEEDS_NULLPTR_DEFINED
102103
// Visual Studio 2010 and higher support this
103104
#if defined(_MSC_VER)

Release/src/json/json.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -313,24 +313,10 @@ bool web::json::number::is_int64() const
313313
}
314314
}
315315

316-
struct has_escape_chars_impl {
317-
static const char* escapes8;
318-
static const wchar_t* escapes16;
319-
320-
static bool impl(const std::string& s) {
321-
return s.find_first_of(escapes8) != std::string::npos;
322-
}
323-
static bool impl(const std::wstring& s) {
324-
return s.find_first_of(escapes16) != std::wstring::npos;
325-
}
326-
};
327-
328-
const char* has_escape_chars_impl::escapes8 = "\"\\\b\f\r\n\t";
329-
const wchar_t* has_escape_chars_impl::escapes16 = L"\"\\\b\f\r\n\t";
330-
331316
bool web::json::details::_String::has_escape_chars(const _String &str)
332317
{
333-
return has_escape_chars_impl::impl(str.m_string);
318+
static const auto escapes = U("\"\\\b\f\r\n\t");
319+
return str.m_string.find_first_of(escapes) != utility::string_t::npos;
334320
}
335321

336322
web::json::details::_Object::_Object(const _Object& other):web::json::details::_Value(other)

Release/src/json/json_serialization.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ void web::json::details::_Number::format(std::basic_string<char>& stream) const
132132
{
133133
if(m_number.m_type != number::type::double_type)
134134
{
135+
#ifdef _MS_WINDOWS
135136
// #digits + 1 to avoid loss + 1 for the sign + 1 for null terminator.
136137
const size_t tempSize = std::numeric_limits<uint64_t>::digits10 + 3;
137138
char tempBuffer[tempSize];
138-
#ifdef _MS_WINDOWS
139139

140140
// This can be improved performance-wise if we implement our own routine
141141
if (m_number.m_type == number::type::signed_type)
@@ -144,19 +144,16 @@ void web::json::details::_Number::format(std::basic_string<char>& stream) const
144144
_ui64toa_s(m_number.m_uintval, tempBuffer, tempSize, 10);
145145

146146
const auto numChars = strnlen_s(tempBuffer, tempSize);
147+
stream.append(tempBuffer, numChars);
147148
#else
148149
std::stringstream ss;
149150
if (m_number.m_type == number::type::signed_type)
150151
ss << m_number.m_intval;
151152
else
152153
ss << m_number.m_uintval;
153154

154-
std::string s = ss.str();
155-
strncpy(tempBuffer, s.c_str(), tempSize - 1);
156-
tempBuffer[tempSize - 1] = '\0';
157-
const auto numChars = strlen(tempBuffer);
155+
stream.append(ss.str());
158156
#endif
159-
stream.append(tempBuffer, numChars);
160157
}
161158
else
162159
{
@@ -225,4 +222,4 @@ utility::string_t web::json::details::_String::as_string() const
225222
utility::string_t web::json::value::as_string() const
226223
{
227224
return m_value->as_string();
228-
}
225+
}

Release/tests/Common/UnitTestpp/src/TestList.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ ListAdder::ListAdder(TestList& list, Test* test, ...)
100100
test->m_properties.Add("Requires", "desktop");
101101
#endif
102102
#endif
103-
103+
104104
list.Add(test);
105105
}
106106

107-
UNITTEST_LINKAGE TestList GLOBAL_TESTLIST;
107+
UNITTEST_LINKAGE TestList GLOBAL_TESTLIST;
108108

109-
extern "C"
110-
UNITTEST_LINKAGE TestList& GetTestList()
111-
{
112-
return GLOBAL_TESTLIST;
113-
}
109+
extern "C"
110+
UNITTEST_LINKAGE TestList& GetTestList()
111+
{
112+
return GLOBAL_TESTLIST;
113+
}
114114

115115
}

0 commit comments

Comments
 (0)