diff --git a/include/loki/SafeFormat.h b/include/loki/SafeFormat.h index 76afd4b..90bc181 100755 --- a/include/loki/SafeFormat.h +++ b/include/loki/SafeFormat.h @@ -22,6 +22,8 @@ #include #include #include +#include +#include // Crude writing method: writes straight to the file, unbuffered // Must be combined with a buffer to work properly (and efficiently) @@ -314,7 +316,7 @@ private: } memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char)); fmtBuf[format_ - fmt] = 0; - const int stored = snprintf(resultBuf, + const int stored = _snprintf(resultBuf, sizeof(resultBuf) / sizeof(Char), fmtBuf, n); if (stored < 0) { result_ = -1; @@ -402,14 +404,14 @@ private: } void ParseDecimalUInt(unsigned int& dest) { - if (!std::isdigit(*format_)) return; + if (!std::isdigit(*format_, std::locale())) return; unsigned int r = 0; do { // TODO: inefficient - rewrite r *= 10; r += *format_ - '0'; ++format_; - } while (std::isdigit(*format_)); + } while (std::isdigit(*format_, std::locale())); dest = r; } @@ -444,7 +446,7 @@ private: blank = 4, alternateForm = 8, fillZeros = 16, - forceShort = 32, + forceShort = 32 }; bool LeftJustify() const { return (flags_ & leftJustify) != 0; } diff --git a/test/SafeFormat/main.cpp b/test/SafeFormat/main.cpp index 8fc9f92..8827920 100755 --- a/test/SafeFormat/main.cpp +++ b/test/SafeFormat/main.cpp @@ -9,7 +9,7 @@ // warranty. //////////////////////////////////////////////////////////////////////////////// -#include "loki/SafeFormat.h" +#include "SafeFormat.h" #include #include #include @@ -55,7 +55,7 @@ void TestCase(const string& fmt, T value) { char buf[4096]; std::string s; const int i1 = SPrintf(s, fmt.c_str())(value); - const int i2 = snprintf(buf, sizeof(buf), fmt.c_str(), value); + const int i2 = _snprintf(buf, sizeof(buf), fmt.c_str(), value); if (i1 != i2 || s != buf) { cout << "\nReference: " << i2 <<