Merge commit 'e96676aeddb4763f6353675724fd6a033d60fbcb' into 4.3.4

This commit is contained in:
Carbenium committed 2015-07-22 00:08:04 +02:00
commit 069f4c279b
10 files changed
+128 -63

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ bzip2 (a freely available, patent free, high-quality data compressor)
cppformat (type safe format library)
https://github.com/cppformat/cppformat
Version: 1.1.0 da547f5533f338cc0c65877b44ca40adf31754f7
Version: 1.1.0 bf8636c9596fbfddded3d0f5879abc7579c9f4dd
G3D (a commercial-grade C++ 3D engine available as Open Source (BSD License)
http://g3d.sourceforge.net/
+1 -1
View File
@@ -8,7 +8,7 @@ add_definitions(-DFMT_VARIADIC_TEMPLATES=1)
# Check if initializer lists are supported.
check_cxx_source_compiles("
#include <initilizer_list>
#include <initializer_list>
int main() {}" FMT_INITIALIZER_LIST)
# Use delete
+87 -38
View File
@@ -66,10 +66,26 @@ using fmt::internal::Arg;
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# define FMT_THROW(x) throw x
# define FMT_RETURN_AFTER_THROW(x)
# else
# define FMT_THROW(x) assert(false)
# define FMT_RETURN_AFTER_THROW(x) return x
# ifndef NDEBUG
# define FMT_THROW(x) assert(false && #x)
# elif defined _MSC_VER
# define FMT_THROW(x) __assume(0)
# elif defined __clang__ || FMT_GCC_VERSION >= 405
# define FMT_THROW(x) __builtin_unreachable()
# else
# define FMT_THROW(x) std::abort()
# endif
# endif
#endif
#ifndef FMT_NORETURN
# if defined __GNUC__ || defined __clang__
# define FMT_NORETURN __attribute__((__noreturn__))
# elif defined _MSC_VER
# define FMT_NORETURN __declspec(noreturn)
# else
# define FMT_NORETURN
# endif
#endif
@@ -83,8 +99,20 @@ using fmt::internal::Arg;
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4702) // unreachable code
// Disable deprecation warning for strerror. The latter is not called but
// MSVC fails to detect it.
# pragma warning(disable: 4996)
#endif
// Dummy implementations of strerror_r and strerror_s called if corresponding
// system functions are not available.
static inline fmt::internal::None<> strerror_r(int, char *, ...) {
return fmt::internal::None<>();
}
static inline fmt::internal::None<> strerror_s(char *, std::size_t, ...) {
return fmt::internal::None<>();
}
namespace {
#ifndef _MSC_VER
@@ -141,35 +169,54 @@ typedef void (*FormatFunc)(fmt::Writer &, int, fmt::StringRef);
int safe_strerror(
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT {
assert(buffer != 0 && buffer_size != 0);
int result = 0;
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || __ANDROID__
// XSI-compliant version of strerror_r.
result = strerror_r(error_code, buffer, buffer_size);
if (result != 0)
result = errno;
#elif _GNU_SOURCE
// GNU-specific version of strerror_r.
char *message = strerror_r(error_code, buffer, buffer_size);
// If the buffer is full then the message is probably truncated.
if (message == buffer && strlen(buffer) == buffer_size - 1)
result = ERANGE;
buffer = message;
#elif __MINGW32__
errno = 0;
(void)buffer_size;
buffer = strerror(error_code);
result = errno;
#elif _WIN32
result = strerror_s(buffer, buffer_size, error_code);
// If the buffer is full then the message is probably truncated.
if (result == 0 && std::strlen(buffer) == buffer_size - 1)
result = ERANGE;
#else
result = strerror_r(error_code, buffer, buffer_size);
if (result == -1)
result = errno; // glibc versions before 2.13 return result in errno.
#endif
return result;
class StrError {
private:
int error_code_;
char *&buffer_;
std::size_t buffer_size_;
// Handle the result of XSI-compliant version of strerror_r.
int handle(int result) {
// glibc versions before 2.13 return result in errno.
return result == -1 ? errno : result;
}
// Handle the result of GNU-specific version of strerror_r.
int handle(char *message) {
// If the buffer is full then the message is probably truncated.
if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1)
return ERANGE;
buffer_ = message;
return 0;
}
// Handle the case when strerror_r is not available.
int handle(fmt::internal::None<>) {
return fallback(strerror_s(buffer_, buffer_size_, error_code_));
}
// Fallback to strerror_s when strerror_r is not available.
int fallback(int result) {
// If the buffer is full then the message is probably truncated.
return result == 0 && strlen(buffer_) == buffer_size_ - 1 ?
ERANGE : result;
}
// Fallback to strerror if strerror_r and strerror_s are not available.
int fallback(fmt::internal::None<>) {
errno = 0;
buffer_ = strerror(error_code_);
return errno;
}
public:
StrError(int error_code, char *&buffer, std::size_t buffer_size)
: error_code_(error_code), buffer_(buffer), buffer_size_(buffer_size) {}
int run() { return handle(strerror_r(error_code_, buffer_, buffer_size_)); }
};
return StrError(error_code, buffer, buffer_size).run();
}
void format_error_code(fmt::Writer &out, int error_code,
@@ -179,14 +226,14 @@ void format_error_code(fmt::Writer &out, int error_code,
// bad_alloc.
out.clear();
static const char SEP[] = ": ";
static const char ERR[] = "error ";
static const char _ERR[] = "error ";
fmt::internal::IntTraits<int>::MainType ec_value = error_code;
// Subtract 2 to account for terminating null characters in SEP and ERR.
// Subtract 2 to account for terminating null characters in SEP and _ERR.
std::size_t error_code_size =
sizeof(SEP) + sizeof(ERR) + fmt::internal::count_digits(ec_value) - 2;
sizeof(SEP) + sizeof(_ERR) + fmt::internal::count_digits(ec_value) - 2;
if (message.size() <= fmt::internal::INLINE_BUFFER_SIZE - error_code_size)
out << message << SEP;
out << ERR << error_code;
out << _ERR << error_code;
assert(out.size() <= fmt::internal::INLINE_BUFFER_SIZE);
}
@@ -257,9 +304,9 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
public:
explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {}
FMT_NORETURN
unsigned visit_unhandled_arg() {
FMT_THROW(fmt::FormatError("width is not integer"));
FMT_RETURN_AFTER_THROW(0);
}
template <typename T>
@@ -279,9 +326,9 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
class PrecisionHandler :
public fmt::internal::ArgVisitor<PrecisionHandler, int> {
public:
FMT_NORETURN
unsigned visit_unhandled_arg() {
FMT_THROW(fmt::FormatError("precision is not integer"));
FMT_RETURN_AFTER_THROW(0);
}
template <typename T>
@@ -437,6 +484,7 @@ const uint64_t fmt::internal::BasicData<T>::POWERS_OF_10_64[] = {
};
FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) {
(void)type;
if (std::isprint(static_cast<unsigned char>(code))) {
FMT_THROW(fmt::FormatError(
fmt::format("unknown format code '{}' for {}", code, type)));
@@ -711,6 +759,7 @@ void fmt::internal::PrintfFormatter<Char>::parse_flags(
template <typename Char>
Arg fmt::internal::PrintfFormatter<Char>::get_arg(
const Char *s, unsigned arg_index) {
(void)s;
const char *error = 0;
Arg arg = arg_index == UINT_MAX ?
next_arg(error) : FormatterBase::get_arg(arg_index - 1, error);
+4 -3
View File
@@ -749,7 +749,7 @@ struct Arg : Value {
Type type;
};
template <typename T>
template <typename T = void>
struct None {};
// A helper class template to enable or disable overloads taking wide
@@ -773,9 +773,10 @@ class IsConvertibleToInt {
typedef char no[2];
static const T &get();
static yes &check(int);
static no &check(...);
static yes &check(fmt::ULongLong);
static no &check(...);
public:
enum { value = (sizeof(check(get())) == sizeof(yes)) };
};
+24 -14
View File
@@ -45,16 +45,17 @@
# define O_CREAT _O_CREAT
# define O_TRUNC _O_TRUNC
#ifndef S_IRUSR
# define S_IRUSR _S_IREAD
#endif
# ifndef S_IRUSR
# define S_IRUSR _S_IREAD
# endif
#ifndef S_IWUSR
# define S_IWUSR _S_IWRITE
#endif
# ifndef S_IWUSR
# define S_IWUSR _S_IWRITE
# endif
# ifdef __MINGW32__
# define _SH_DENYNO 0x40
# undef fileno
# endif
#endif // _WIN32
@@ -97,8 +98,11 @@ void fmt::BufferedFile::close() {
throw SystemError(errno, "cannot close file");
}
// A macro used to prevent expansion of fileno on broken versions of MinGW.
#define FMT_ARGS
int fmt::BufferedFile::fileno() const {
int fd = FMT_POSIX_CALL(fileno(file_));
int fd = FMT_POSIX_CALL(fileno FMT_ARGS(file_));
if (fd == -1)
throw SystemError(errno, "cannot get file descriptor");
return fd;
@@ -106,7 +110,7 @@ int fmt::BufferedFile::fileno() const {
fmt::File::File(fmt::StringRef path, int oflag) {
int mode = S_IRUSR | S_IWUSR;
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
fd_ = -1;
FMT_POSIX_CALL(sopen_s(&fd_, path.c_str(), oflag, _SH_DENYNO, mode));
#else
@@ -136,13 +140,19 @@ void fmt::File::close() {
fmt::LongLong fmt::File::size() const {
#ifdef _WIN32
LARGE_INTEGER filesize = {};
// Use GetFileSize instead of GetFileSizeEx for the case when _WIN32_WINNT
// is less than 0x0500 as is the case with some default MinGW builds.
// Both functions support large file sizes.
DWORD size_upper = 0;
HANDLE handle = reinterpret_cast<HANDLE>(_get_osfhandle(fd_));
if (!FMT_SYSTEM(GetFileSizeEx(handle, &filesize)))
throw WindowsError(GetLastError(), "cannot get file size");
FMT_STATIC_ASSERT(sizeof(fmt::LongLong) >= sizeof(filesize.QuadPart),
"return type of File::size is not large enough");
return filesize.QuadPart;
DWORD size_lower = FMT_SYSTEM(GetFileSize(handle, &size_upper));
if (size_lower == INVALID_FILE_SIZE) {
DWORD error = GetLastError();
if (error != NO_ERROR)
throw WindowsError(GetLastError(), "cannot get file size");
}
fmt::ULongLong size = size_upper;
return (size << sizeof(DWORD) * CHAR_BIT) | size_lower;
#else
typedef struct stat Stat;
Stat file_stat = Stat();
+9 -2
View File
@@ -28,6 +28,11 @@
#ifndef FMT_POSIX_H_
#define FMT_POSIX_H_
#ifdef __MINGW32__
// Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/.
# undef __STRICT_ANSI__
#endif
#include <errno.h>
#include <fcntl.h> // for O_RDONLY
#include <stdio.h>
@@ -41,7 +46,7 @@
#endif
#ifndef FMT_POSIX
# ifdef _WIN32
# if defined(_WIN32) && !defined(__MINGW32__)
// Fix warnings about deprecated symbols.
# define FMT_POSIX(call) _##call
# else
@@ -188,7 +193,9 @@ public:
// Returns the pointer to a FILE object representing this file.
FILE *get() const FMT_NOEXCEPT { return file_; }
int fileno() const;
// We place parentheses around fileno to workaround a bug in some versions
// of MinGW that define fileno as a macro.
int (fileno)() const;
void print(fmt::StringRef format_str, const ArgList &args) {
fmt::print(file_, format_str, args);
@@ -443,8 +443,6 @@ bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction)
// we need to delete the entry, it is not referenced any more
delete auction;
auction = NULL;
return wasInMap;
}
@@ -133,6 +133,7 @@ public:
uiCyanigosaEventTimer = 3 * IN_MILLISECONDS;
bActive = false;
bWiped = false;
bIsDoorSpellCast = false;
bCrystalActivated = false;
defenseless = true;
+1
View File
@@ -26,6 +26,7 @@
#include <boost/asio/io_service.hpp>
#include <boost/asio/strand.hpp>
#include <stdarg.h>
#include <unordered_map>
#include <string>
#include <memory>
@@ -30,8 +30,6 @@ using boost::asio::ip::tcp;
const size_t bufferSize = 4096;
#define BUFFER_SIZE 4096
class RASession : public std::enable_shared_from_this <RASession>
{
public: