Ticket #3011: 0004-cppformat-Fix-Wundef-build-warnings-from-GCC.patch

File 0004-cppformat-Fix-Wundef-build-warnings-from-GCC.patch, 4.8 KB (added by Philip Taylor, 9 years ago)
  • source/third_party/cppformat/format.cpp

    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  
    11/*
     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/*
    27 Formatting library for C++
    38
    49 Copyright (c) 2012 - 2014, Victor Zverovich
    using fmt::LongLong;  
    5459using fmt::ULongLong;
    5560using fmt::internal::Arg;
    5661
    57 #if _MSC_VER
     62#ifdef _MSC_VER
    5863# pragma warning(push)
    5964# pragma warning(disable: 4127) // conditional expression is constant
    6065#endif
    int fmt::internal::safe_strerror(  
    430435  if (message == buffer && strlen(buffer) == buffer_size - 1)
    431436    result = ERANGE;
    432437  buffer = message;
    433 #elif __MINGW32__
     438#elif defined(__MINGW32__)
    434439  errno = 0;
    435440  (void)buffer_size;
    436441  buffer = strerror(error_code);
    437442  result = errno;
    438 #elif _WIN32
     443#elif defined(_WIN32)
    439444  result = strerror_s(buffer, buffer_size, error_code);
    440445  // If the buffer is full then the message is probably truncated.
    441446  if (result == 0 && std::strlen(buffer) == buffer_size - 1)
    void fmt::BasicWriter<Char>::write_double(T value, const FormatSpec &spec) {  
    692697  Char fill = static_cast<Char>(spec.fill());
    693698  for (;;) {
    694699    std::size_t size = buffer_.capacity() - offset;
    695 #if _MSC_VER
     700#ifdef _MSC_VER
    696701    // MSVC's vsnprintf_s doesn't work with zero size, so reserve
    697702    // space for at least one extra character to make the size non-zero.
    698703    // Note that the buffer's capacity will increase by more than 1.
    template void fmt::internal::PrintfFormatter<wchar_t>::format(  
    12991304    BasicWriter<wchar_t> &writer, BasicStringRef<wchar_t> format,
    13001305    const ArgList &args);
    13011306
    1302 #if _MSC_VER
     1307#ifdef _MSC_VER
    13031308# pragma warning(pop)
    13041309#endif
  • source/third_party/cppformat/format.h

    diff --git a/source/third_party/cppformat/format.h b/source/third_party/cppformat/format.h
    index 94a1747..b3c93eb 100644
    a b  
    11/*
     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/*
    27 Formatting library for C++
    38
    49 Copyright (c) 2012 - 2014, Victor Zverovich
     
    3944#include <string>
    4045#include <sstream>
    4146
    42 #if _SECURE_SCL
     47#if defined(_SECURE_SCL) && _SECURE_SCL
    4348# include <iterator>
    4449#endif
    4550
     
    7883// since version 2013.
    7984# define FMT_USE_VARIADIC_TEMPLATES \
    8085   (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))
    8287#endif
    8388
    8489#ifndef FMT_USE_RVALUE_REFERENCES
     
    8994# else
    9095#  define FMT_USE_RVALUE_REFERENCES \
    9196    (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))
    9398# endif
    9499#endif
    95100
     
    98103#endif
    99104
    100105// 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) || \
    102107  (FMT_GCC_VERSION >= 408 && __cplusplus >= 201103)
    103108# define FMT_NOEXCEPT(expr) noexcept(expr)
    104109#else
    namespace internal {  
    225230// output buffer, itself to avoid dynamic memory allocation.
    226231enum { INLINE_BUFFER_SIZE = 500 };
    227232
    228 #if _SECURE_SCL
     233#if defined(_SECURE_SCL) && _SECURE_SCL
    229234// Use checked iterator to avoid warnings on MSVC.
    230235template <typename T>
    231236inline stdext::checked_array_iterator<T*> make_ptr(T *ptr, std::size_t size) {
    void Array<T, SIZE>::append(const T *begin, const T *end) {  
    344349template <typename Char>
    345350class BasicCharTraits {
    346351 public:
    347 #if _SECURE_SCL
     352#if defined(_SECURE_SCL) && _SECURE_SCL
    348353  typedef stdext::checked_array_iterator<Char*> CharPtr;
    349354#else
    350355  typedef Char *CharPtr;
    class BasicWriter {  
    13061311
    13071312  typedef typename internal::CharTraits<Char>::CharPtr CharPtr;
    13081313
    1309 #if _SECURE_SCL
     1314#if defined(_SECURE_SCL) && _SECURE_SCL
    13101315  // Returns pointer value.
    13111316  static Char *get(CharPtr p) { return p.base(); }
    13121317#else