Merge branch 'master' of github.com:cppformat/cppformat

This commit is contained in:
Victor Zverovich 2014-06-16 07:49:37 -07:00
commit 8666ea82f7
6 changed files with 21 additions and 6 deletions

View File

@ -42,6 +42,9 @@
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# ifdef __MINGW32__
# include <cstring>
# endif
# include <windows.h>
# undef ERROR
#endif
@ -228,7 +231,11 @@ int fmt::internal::StrError(
result = ERANGE;
buffer = message;
#elif _WIN32
# ifdef __MINGW32__
strerror(result);
# else
result = strerror_s(buffer, buffer_size, error_code);
# endif
// If the buffer is full then the message is probably truncated.
if (result == 0 && std::strlen(buffer) == buffer_size - 1)
result = ERANGE;

View File

@ -61,9 +61,13 @@
// Compatibility with compilers other than clang.
#ifdef __has_feature
# define FMT_HAS_FEATURE(x) __has_feature(x)
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
#else
# define FMT_HAS_FEATURE(x) 0
#endif
#ifdef __has_builtin
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
#else
# define FMT_HAS_BUILTIN(x) 0
#endif
@ -311,7 +315,7 @@ template <typename T, std::size_t SIZE>
void Array<T, SIZE>::append(const T *begin, const T *end) {
std::ptrdiff_t num_elements = end - begin;
if (size_ + num_elements > capacity_)
Grow(num_elements);
Grow(size_ + num_elements);
std::copy(begin, end, CheckPtr(ptr_, capacity_) + size_);
size_ += num_elements;
}

View File

@ -41,6 +41,10 @@
# define S_IRUSR _S_IREAD
# define S_IWUSR _S_IWRITE
# ifdef __MINGW32__
# define _SH_DENYNO 0x40
# endif
#endif // _WIN32
namespace {

View File

@ -35,7 +35,7 @@
#include <memory>
#include <sstream>
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
// Fix MSVC warning about "unsafe" fopen.
FILE *FOpen(const char *filename, const char *mode) {
FILE *f = 0;

View File

@ -32,13 +32,13 @@
#include <stdexcept>
#include <gtest/gtest-spi.h>
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
# include <crtdbg.h> // for _CrtSetReportMode
#endif // _WIN32
namespace {
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
// Suppresses Windows assertions on invalid file descriptors, making
// POSIX functions return proper error codes instead of crashing on Windows.

View File

@ -43,7 +43,7 @@ using fmt::StringRef;
namespace {
std::string GetSystemErrorMessage(int error_code) {
#ifndef _WIN32
#if defined(__MINGW32__) || !defined(_WIN32)
return strerror(error_code);
#else
enum { BUFFER_SIZE = 200 };