small gcc and msvc8 corrections

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@220 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2005-08-27 12:47:56 +00:00
parent 0f678b97e2
commit cdb70a208b
2 changed files with 8 additions and 6 deletions

View file

@ -22,6 +22,8 @@
#include <string>
#include <stdexcept>
#include <utility>
#include <cassert>
#include <locale>
// 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; }

View file

@ -9,7 +9,7 @@
// warranty.
////////////////////////////////////////////////////////////////////////////////
#include "loki/SafeFormat.h"
#include "SafeFormat.h"
#include <iostream>
#include <cassert>
#include <utility>
@ -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 <<