1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update the {fmt} library to fix the colision with C string.h header.

This commit is contained in:
Sandu Liviu Catalin 2016-05-23 22:42:49 +03:00
parent 250407feda
commit 82c3fa4439
11 changed files with 24 additions and 28 deletions

View File

@ -392,7 +392,6 @@
<Add directory="../source" /> <Add directory="../source" />
<Add directory="../shared" /> <Add directory="../shared" />
<Add directory="../include" /> <Add directory="../include" />
<Add directory="../include/fmt" />
<Add directory="../config/common" /> <Add directory="../config/common" />
<Add directory="../external/Common" /> <Add directory="../external/Common" />
<Add directory="../external/Hash" /> <Add directory="../external/Hash" />
@ -401,8 +400,8 @@
<Add library="squirrel" /> <Add library="squirrel" />
</Linker> </Linker>
<Unit filename="../external/Common/aes256.cpp" /> <Unit filename="../external/Common/aes256.cpp" />
<Unit filename="../external/Common/posix.cc" />
<Unit filename="../external/CppFormat/format.cc" /> <Unit filename="../external/CppFormat/format.cc" />
<Unit filename="../external/CppFormat/posix.cc" />
<Unit filename="../external/Hash/crc32.cpp" /> <Unit filename="../external/Hash/crc32.cpp" />
<Unit filename="../external/Hash/crc32.h" /> <Unit filename="../external/Hash/crc32.h" />
<Unit filename="../external/Hash/digest.cpp" /> <Unit filename="../external/Hash/digest.cpp" />

View File

@ -154,7 +154,6 @@
<Add directory="../sandbox" /> <Add directory="../sandbox" />
<Add directory="../source" /> <Add directory="../source" />
<Add directory="../shared" /> <Add directory="../shared" />
<Add directory="../include/fmt" />
<Add directory="../config/common" /> <Add directory="../config/common" />
<Add directory="../external/Common" /> <Add directory="../external/Common" />
<Add directory="../external/Hash" /> <Add directory="../external/Hash" />

View File

@ -25,7 +25,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "format.h" #include "fmt/format.h"
#include <string.h> #include <string.h>

View File

@ -25,7 +25,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "ostream.h" #include "fmt/ostream.h"
namespace fmt { namespace fmt {

View File

@ -30,7 +30,7 @@
# define _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS
#endif #endif
#include "posix.h" #include "fmt/posix.h"
#include <limits.h> #include <limits.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -910,23 +910,6 @@ class ThousandsSep {
} }
}; };
// Returns the thousands separator for the current locale.
// On android the lconv structure is stubbed using an empty structure.
// The test is for the size only, not for the presense of
// thousands_sep in std::lconv, because if one would add thousands_sep
// at some point, the size of structure would be at least sizeof(char*).
template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))>
struct Locale {
static fmt::StringRef thousands_sep() { return ""; }
};
template<typename Lconv>
struct Locale<Lconv, true> {
static fmt::StringRef thousands_sep() {
return static_cast<Lconv*>(std::localeconv())->thousands_sep;
}
};
// Formats a decimal unsigned integer value writing into buffer. // Formats a decimal unsigned integer value writing into buffer.
// thousands_sep is a functor that is called after writing each char to // thousands_sep is a functor that is called after writing each char to
// add a thousands separator if necessary. // add a thousands separator if necessary.
@ -1135,6 +1118,21 @@ struct Not { enum { value = 0 }; };
template<> template<>
struct Not<false> { enum { value = 1 }; }; struct Not<false> { enum { value = 1 }; };
template<typename T, T> struct LConvCheck {
LConvCheck(int) {}
};
// Returns the thousands separator for the current locale.
// We check if ``lconv`` contains ``thousands_sep`` because on Android
// ``lconv`` is stubbed as an empty struct.
template <typename LConv>
inline StringRef thousands_sep(
LConv *lc, LConvCheck<char *LConv::*, &LConv::thousands_sep> = 0) {
return lc->thousands_sep;
}
inline fmt::StringRef thousands_sep(...) { return ""; }
// Makes an Arg object from any type. // Makes an Arg object from any type.
template <typename Formatter> template <typename Formatter>
class MakeValue : public Arg { class MakeValue : public Arg {
@ -2795,7 +2793,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
} }
case 'n': { case 'n': {
unsigned num_digits = internal::count_digits(abs_value); unsigned num_digits = internal::count_digits(abs_value);
fmt::StringRef sep = internal::Locale<lconv>::thousands_sep(); fmt::StringRef sep = internal::thousands_sep(std::localeconv());
unsigned size = static_cast<unsigned>( unsigned size = static_cast<unsigned>(
num_digits + sep.size() * (num_digits - 1) / 3); num_digits + sep.size() * (num_digits - 1) / 3);
CharPtr p = prepare_int_buffer(size, spec, prefix, prefix_size) + 1; CharPtr p = prepare_int_buffer(size, spec, prefix, prefix_size) + 1;

View File

@ -28,7 +28,7 @@
#ifndef FMT_OSTREAM_H_ #ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_ #define FMT_OSTREAM_H_
#include "format.h" #include "fmt/format.h"
#include <ostream> #include <ostream>
namespace fmt { namespace fmt {

View File

@ -45,7 +45,7 @@
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X # include <xlocale.h> // for LC_NUMERIC_MASK on OS X
#endif #endif
#include "format.h" #include "fmt/format.h"
#ifndef FMT_POSIX #ifndef FMT_POSIX
# if defined(_WIN32) && !defined(__MINGW32__) # if defined(_WIN32) && !defined(__MINGW32__)

View File

@ -10,7 +10,7 @@
#ifndef FMT_STRING_H_ #ifndef FMT_STRING_H_
#define FMT_STRING_H_ #define FMT_STRING_H_
#include "format.h" #include "fmt/format.h"
namespace fmt { namespace fmt {

View File

@ -15,7 +15,7 @@
#include <algorithm> #include <algorithm>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <format.h> #include <fmt/format.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {