From 77db41ef5a2211c0d4e5fa3275ba1bc7794b474e Mon Sep 17 00:00:00 2001
From: Philip Taylor <philip@zaynar.co.uk>
Date: Tue, 20 Jan 2015 23:15:48 +0000
Subject: [PATCH 04/13] cppformat: Fix -Wundef build warnings from GCC.
---
source/third_party/cppformat/format.cpp | 15 ++++++++++-----
source/third_party/cppformat/format.h | 19 ++++++++++++-------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/source/third_party/cppformat/format.cpp b/source/third_party/cppformat/format.cpp
index ce9b90d..4aee869 100644
a
|
b
|
|
1 | 1 | /* |
| 2 | * Slightly modified version of cppformat, by Wildfire Games, for 0 A.D. |
| 3 | * Based on cppformat v0.11.0 from https://github.com/cppformat/cppformat |
| 4 | */ |
| 5 | |
| 6 | /* |
2 | 7 | Formatting library for C++ |
3 | 8 | |
4 | 9 | Copyright (c) 2012 - 2014, Victor Zverovich |
… |
… |
using fmt::LongLong;
|
54 | 59 | using fmt::ULongLong; |
55 | 60 | using fmt::internal::Arg; |
56 | 61 | |
57 | | #if _MSC_VER |
| 62 | #ifdef _MSC_VER |
58 | 63 | # pragma warning(push) |
59 | 64 | # pragma warning(disable: 4127) // conditional expression is constant |
60 | 65 | #endif |
… |
… |
int fmt::internal::safe_strerror(
|
430 | 435 | if (message == buffer && strlen(buffer) == buffer_size - 1) |
431 | 436 | result = ERANGE; |
432 | 437 | buffer = message; |
433 | | #elif __MINGW32__ |
| 438 | #elif defined(__MINGW32__) |
434 | 439 | errno = 0; |
435 | 440 | (void)buffer_size; |
436 | 441 | buffer = strerror(error_code); |
437 | 442 | result = errno; |
438 | | #elif _WIN32 |
| 443 | #elif defined(_WIN32) |
439 | 444 | result = strerror_s(buffer, buffer_size, error_code); |
440 | 445 | // If the buffer is full then the message is probably truncated. |
441 | 446 | if (result == 0 && std::strlen(buffer) == buffer_size - 1) |
… |
… |
void fmt::BasicWriter<Char>::write_double(T value, const FormatSpec &spec) {
|
692 | 697 | Char fill = static_cast<Char>(spec.fill()); |
693 | 698 | for (;;) { |
694 | 699 | std::size_t size = buffer_.capacity() - offset; |
695 | | #if _MSC_VER |
| 700 | #ifdef _MSC_VER |
696 | 701 | // MSVC's vsnprintf_s doesn't work with zero size, so reserve |
697 | 702 | // space for at least one extra character to make the size non-zero. |
698 | 703 | // Note that the buffer's capacity will increase by more than 1. |
… |
… |
template void fmt::internal::PrintfFormatter<wchar_t>::format(
|
1299 | 1304 | BasicWriter<wchar_t> &writer, BasicStringRef<wchar_t> format, |
1300 | 1305 | const ArgList &args); |
1301 | 1306 | |
1302 | | #if _MSC_VER |
| 1307 | #ifdef _MSC_VER |
1303 | 1308 | # pragma warning(pop) |
1304 | 1309 | #endif |
diff --git a/source/third_party/cppformat/format.h b/source/third_party/cppformat/format.h
index 94a1747..b3c93eb 100644
a
|
b
|
|
1 | 1 | /* |
| 2 | * Slightly modified version of cppformat, by Wildfire Games, for 0 A.D. |
| 3 | * Based on cppformat v0.11.0 from https://github.com/cppformat/cppformat |
| 4 | */ |
| 5 | |
| 6 | /* |
2 | 7 | Formatting library for C++ |
3 | 8 | |
4 | 9 | Copyright (c) 2012 - 2014, Victor Zverovich |
… |
… |
|
39 | 44 | #include <string> |
40 | 45 | #include <sstream> |
41 | 46 | |
42 | | #if _SECURE_SCL |
| 47 | #if defined(_SECURE_SCL) && _SECURE_SCL |
43 | 48 | # include <iterator> |
44 | 49 | #endif |
45 | 50 | |
… |
… |
|
78 | 83 | // since version 2013. |
79 | 84 | # define FMT_USE_VARIADIC_TEMPLATES \ |
80 | 85 | (FMT_HAS_FEATURE(cxx_variadic_templates) || \ |
81 | | (FMT_GCC_VERSION >= 404 && __cplusplus >= 201103) || _MSC_VER >= 1800) |
| 86 | (FMT_GCC_VERSION >= 404 && __cplusplus >= 201103) || (defined(_MSC_VER) && _MSC_VER >= 1800)) |
82 | 87 | #endif |
83 | 88 | |
84 | 89 | #ifndef FMT_USE_RVALUE_REFERENCES |
… |
… |
|
89 | 94 | # else |
90 | 95 | # define FMT_USE_RVALUE_REFERENCES \ |
91 | 96 | (FMT_HAS_FEATURE(cxx_rvalue_references) || \ |
92 | | (FMT_GCC_VERSION >= 403 && __cplusplus >= 201103) || _MSC_VER >= 1600) |
| 97 | (FMT_GCC_VERSION >= 403 && __cplusplus >= 201103) || (defined(_MSC_VER) && _MSC_VER >= 1600)) |
93 | 98 | # endif |
94 | 99 | #endif |
95 | 100 | |
… |
… |
|
98 | 103 | #endif |
99 | 104 | |
100 | 105 | // Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature). |
101 | | #if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ |
| 106 | #if (defined(FMT_USE_NOEXPECT) && FMT_USE_NOEXCEPT) || FMT_HAS_FEATURE(cxx_noexcept) || \ |
102 | 107 | (FMT_GCC_VERSION >= 408 && __cplusplus >= 201103) |
103 | 108 | # define FMT_NOEXCEPT(expr) noexcept(expr) |
104 | 109 | #else |
… |
… |
namespace internal {
|
225 | 230 | // output buffer, itself to avoid dynamic memory allocation. |
226 | 231 | enum { INLINE_BUFFER_SIZE = 500 }; |
227 | 232 | |
228 | | #if _SECURE_SCL |
| 233 | #if defined(_SECURE_SCL) && _SECURE_SCL |
229 | 234 | // Use checked iterator to avoid warnings on MSVC. |
230 | 235 | template <typename T> |
231 | 236 | inline stdext::checked_array_iterator<T*> make_ptr(T *ptr, std::size_t size) { |
… |
… |
void Array<T, SIZE>::append(const T *begin, const T *end) {
|
344 | 349 | template <typename Char> |
345 | 350 | class BasicCharTraits { |
346 | 351 | public: |
347 | | #if _SECURE_SCL |
| 352 | #if defined(_SECURE_SCL) && _SECURE_SCL |
348 | 353 | typedef stdext::checked_array_iterator<Char*> CharPtr; |
349 | 354 | #else |
350 | 355 | typedef Char *CharPtr; |
… |
… |
class BasicWriter {
|
1306 | 1311 | |
1307 | 1312 | typedef typename internal::CharTraits<Char>::CharPtr CharPtr; |
1308 | 1313 | |
1309 | | #if _SECURE_SCL |
| 1314 | #if defined(_SECURE_SCL) && _SECURE_SCL |
1310 | 1315 | // Returns pointer value. |
1311 | 1316 | static Char *get(CharPtr p) { return p.base(); } |
1312 | 1317 | #else |