Workaround MSCRT brain damage, take 2.

This commit is contained in:
Victor Zverovich 2013-02-27 14:17:07 -08:00
parent ab05af06f2
commit 6cc758b6e2

View File

@ -40,11 +40,6 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# define FMT_RESTORE_WARNINGS
#endif
namespace fmt { namespace fmt {
namespace internal { namespace internal {
@ -188,6 +183,8 @@ inline int IsInf(double x) {
#endif #endif
} }
#define FMT_SNPRINTF snprintf
#else #else
inline int SignBit(double value) { inline int SignBit(double value) {
@ -200,8 +197,7 @@ inline int SignBit(double value) {
inline int IsInf(double x) { return !_finite(x); } inline int IsInf(double x) { return !_finite(x); }
# undef snprintf #define FMT_SNPRINTF sprintf_s
# define snprintf _snprintf
#endif #endif
@ -698,12 +694,13 @@ void BasicWriter<Char>::FormatDouble(
Char *start = &buffer_[offset]; Char *start = &buffer_[offset];
if (width_for_sprintf == 0) { if (width_for_sprintf == 0) {
n = precision < 0 ? n = precision < 0 ?
snprintf(start, size, format, value) : FMT_SNPRINTF(start, size, format, value) :
snprintf(start, size, format, precision, value); FMT_SNPRINTF(start, size, format, precision, value);
} else { } else {
n = precision < 0 ? n = precision < 0 ?
snprintf(start, size, format, width_for_sprintf, value) : FMT_SNPRINTF(start, size, format, width_for_sprintf, value) :
snprintf(start, size, format, width_for_sprintf, precision, value); FMT_SNPRINTF(start, size, format, width_for_sprintf,
precision, value);
} }
if (n >= 0 && offset + n < buffer_.capacity()) { if (n >= 0 && offset + n < buffer_.capacity()) {
if (sign) { if (sign) {
@ -1552,8 +1549,4 @@ void BasicFormatter<Char>::DoFormat() {
} }
} }
#ifndef FMT_RESTORE_WARNINGS
# undef _CRT_SECURE_NO_WARNINGS
#endif
#endif // FORMAT_H_ #endif // FORMAT_H_