build & run correctly w/ gcc 2.95+ and w/o STLport
This commit is contained in:
parent
ed558c1578
commit
523882f8e9
24
config.h.in
24
config.h.in
|
@ -57,6 +57,9 @@
|
|||
/* Define to 1 if you have the `connect' function. */
|
||||
#undef HAVE_CONNECT
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define to 1 if you have the `directio' function. */
|
||||
#undef HAVE_DIRECTIO
|
||||
|
||||
|
@ -79,6 +82,9 @@
|
|||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the <features.h> header file. */
|
||||
#undef HAVE_FEATURES_H
|
||||
|
||||
/* Define to 1 if you have the `fopen' function. */
|
||||
#undef HAVE_FOPEN
|
||||
|
||||
|
@ -94,6 +100,9 @@
|
|||
/* Define to 1 if you have the `fstatat' function. */
|
||||
#undef HAVE_FSTATAT
|
||||
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Uses the GNU g++ compiler */
|
||||
#undef HAVE_GCC
|
||||
|
||||
|
@ -142,6 +151,9 @@
|
|||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `isprint' function. */
|
||||
#undef HAVE_ISPRINT
|
||||
|
||||
/* Define to 1 if you have the <langinfo.h> header file. */
|
||||
#undef HAVE_LANGINFO_H
|
||||
|
||||
|
@ -157,6 +169,9 @@
|
|||
/* Define to 1 if you have the <locale> header file. */
|
||||
#undef HAVE_LOCALE
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if you have the `lstat' function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
|
@ -253,9 +268,15 @@
|
|||
/* Define to 1 if you have the `readlinkat' function. */
|
||||
#undef HAVE_READLINKAT
|
||||
|
||||
/* Define to 1 if you have the `rename' function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
/* Define to 1 if you have the `setgid' function. */
|
||||
#undef HAVE_SETGID
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define to 1 if you have the `setuid' function. */
|
||||
#undef HAVE_SETUID
|
||||
|
||||
|
@ -405,6 +426,9 @@
|
|||
/* Define to 1 if you have the <unixlib/local.h> header file. */
|
||||
#undef HAVE_UNIXLIB_LOCAL_H
|
||||
|
||||
/* Define to 1 if you have the `unlink' function. */
|
||||
#undef HAVE_UNLINK
|
||||
|
||||
/* Define to 1 if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
|
||||
|
|
|
@ -6525,6 +6525,17 @@ fi
|
|||
|
||||
done
|
||||
|
||||
for ac_header in features.h
|
||||
do :
|
||||
ac_fn_cxx_check_header_mongrel "$LINENO" "features.h" "ac_cv_header_features_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_features_h" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_FEATURES_H 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
for ac_header in sys/file.h
|
||||
do :
|
||||
|
@ -7982,6 +7993,18 @@ _ACEOF
|
|||
fi
|
||||
done
|
||||
|
||||
for ac_func in unlink rename ftruncate
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
for ac_func in openlog syslog closelog
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
|
@ -8054,6 +8077,50 @@ fi
|
|||
done
|
||||
|
||||
|
||||
for ac_header in locale.h
|
||||
do :
|
||||
ac_fn_cxx_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_locale_h" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_LOCALE_H 1
|
||||
_ACEOF
|
||||
for ac_func in setlocale
|
||||
do :
|
||||
ac_fn_cxx_check_func "$LINENO" "setlocale" "ac_cv_func_setlocale"
|
||||
if test "x$ac_cv_func_setlocale" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_SETLOCALE 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
for ac_header in ctype.h
|
||||
do :
|
||||
ac_fn_cxx_check_header_mongrel "$LINENO" "ctype.h" "ac_cv_header_ctype_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_ctype_h" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_CTYPE_H 1
|
||||
_ACEOF
|
||||
for ac_func in isprint
|
||||
do :
|
||||
ac_fn_cxx_check_func "$LINENO" "isprint" "ac_cv_func_isprint"
|
||||
if test "x$ac_cv_func_isprint" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_ISPRINT 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
# Check whether --enable-commoncrypto was given.
|
||||
if test "${enable_commoncrypto+set}" = set; then :
|
||||
|
|
|
@ -186,7 +186,7 @@ AC_CHECK_HEADERS(stdint.h)
|
|||
AC_CHECK_HEADERS(syslog.h sys/syslog.h, break)
|
||||
AC_CHECK_HEADERS(termios.h)
|
||||
AC_CHECK_HEADERS(unistd.h sys/unistd.h, break)
|
||||
|
||||
AC_CHECK_HEADERS(features.h)
|
||||
AC_CHECK_HEADERS(sys/file.h)
|
||||
AC_CHECK_HEADERS(sys/param.h)
|
||||
AC_CHECK_HEADERS(sys/mount.h,,,
|
||||
|
@ -296,6 +296,8 @@ AC_CHECK_FUNCS(readlinkat readlink)
|
|||
|
||||
dnl posix fns that make filesystem changes
|
||||
AC_CHECK_FUNCS(chown chmod link symlink mknod mkfifo)
|
||||
dnl more posix fns that make fs changes
|
||||
AC_CHECK_FUNCS(unlink rename ftruncate)
|
||||
dnl posix syslog fns
|
||||
AC_CHECK_FUNCS(openlog syslog closelog)
|
||||
dnl posix process fns
|
||||
|
@ -308,6 +310,10 @@ AC_CHECK_FUNCS(setuid setgid getgrgid)
|
|||
dnl check for posix_fadvise
|
||||
AC_CHECK_HEADERS(fcntl.h, [AC_CHECK_FUNCS(posix_fadvise)])
|
||||
|
||||
dnl check for setlocale
|
||||
AC_CHECK_HEADERS(locale.h, [AC_CHECK_FUNCS(setlocale)])
|
||||
dnl check for a C isprint
|
||||
AC_CHECK_HEADERS(ctype.h, [AC_CHECK_FUNCS(isprint)])
|
||||
|
||||
dnl check for OSX builtin hash algorithms
|
||||
AC_ARG_ENABLE(commoncrypto,
|
||||
|
|
|
@ -80,17 +80,18 @@ iCodeConverter* iCodeConverter::m_pInst = NULL;
|
|||
// has a maximum of 512 chars of output
|
||||
std::string util_output_bytes(void* p, size_t n)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss.imbue(std::locale::classic());
|
||||
ss.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
|
||||
TOSTRINGSTREAM ss;
|
||||
tss_classic_locale(ss);
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
ss.width(2);
|
||||
ss << toupper(tss::util::char_to_size(((char*)p)[i])) << " ";
|
||||
}
|
||||
|
||||
std::string s = ss.str();
|
||||
tss_mkstr(s, ss);
|
||||
|
||||
if (s.length() > 512)
|
||||
{
|
||||
s = "truncated output: " + s;
|
||||
|
|
|
@ -106,13 +106,13 @@ void cDebug::DoTrace(const char* format, va_list& args)
|
|||
ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long
|
||||
ASSERT(strlen(out) < 1024);
|
||||
|
||||
std::ostringstream ostr;
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr.setf(std::ios::left);
|
||||
ostr.width(40);
|
||||
ostr << mLabel;
|
||||
ostr.width(0);
|
||||
ostr << out;
|
||||
|
||||
tss_end(ostr);
|
||||
|
||||
if ((mOutMask & OUT_STDOUT) != 0)
|
||||
{
|
||||
|
@ -120,6 +120,8 @@ void cDebug::DoTrace(const char* format, va_list& args)
|
|||
std::cout.flush();
|
||||
}
|
||||
|
||||
tss_free(ostr);
|
||||
|
||||
//
|
||||
//make it output to log file!
|
||||
//
|
||||
|
@ -280,9 +282,9 @@ bool cDebug::SetOutputFile(const char* filename)
|
|||
// already open!
|
||||
// TODO -- make this work with wide chars
|
||||
if (!logfile)
|
||||
logfile.open(filename, std::ios_base::out | std::ios_base::ate | std::ios_base::app);
|
||||
logfile.open(filename, std::ios::out | std::ios::ate | std::ios::app);
|
||||
else
|
||||
logfile.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
logfile.setf(std::ios::hex, std::ios::basefield);
|
||||
//make sure info. will not be clobbered.
|
||||
|
||||
//Should be open now- if not, abort.
|
||||
|
|
|
@ -479,7 +479,7 @@ TSTRING cCharEncoderUtil::CharStringToHexValue(const TSTRING& str)
|
|||
|
||||
for (at = str.begin(); at < str.end(); at++)
|
||||
{
|
||||
strOut += char_to_hex(*at);
|
||||
strOut += char_to_hex(*at);
|
||||
}
|
||||
|
||||
return strOut;
|
||||
|
@ -501,25 +501,38 @@ TSTRING cCharEncoderUtil::HexValueToCharString(const TSTRING& str)
|
|||
|
||||
TCHAR cCharEncoderUtil::hex_to_char(TSTRING::const_iterator first, TSTRING::const_iterator last)
|
||||
{
|
||||
static const TCHAR max_char = std::numeric_limits<TCHAR>::max();
|
||||
static const TCHAR min_char = std::numeric_limits<TCHAR>::min();
|
||||
|
||||
static const TCHAR max_char = TSS_TCHAR_MAX;
|
||||
static const TCHAR min_char = TSS_TCHAR_MIN;
|
||||
|
||||
if (first + TCHAR_AS_HEX__IN_TCHARS != last)
|
||||
ThrowAndAssert(eBadHexConversion());
|
||||
{
|
||||
ThrowAndAssert(eBadHexConversion(TSTRING(first,last)));
|
||||
}
|
||||
|
||||
TISTRINGSTREAM ss(TSTRING(first, last));
|
||||
ss.imbue(std::locale::classic());
|
||||
#if ARCHAIC_STL
|
||||
TSTRING in(first, last);
|
||||
TISTRINGSTREAM ss(in.c_str());
|
||||
#else
|
||||
TISTRINGSTREAM ss(TSTRING(first,last));
|
||||
#endif
|
||||
|
||||
tss_classic_locale(ss);
|
||||
|
||||
ss.fill(_T('0'));
|
||||
ss.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
unsigned long ch;
|
||||
ss >> ch;
|
||||
|
||||
if (ss.bad() || ss.fail())
|
||||
{
|
||||
ThrowAndAssert(eBadHexConversion(TSTRING(first, last)));
|
||||
if ((TCHAR)ch > max_char || (TCHAR)ch < min_char)
|
||||
}
|
||||
if ((TCHAR)ch > TSS_TCHAR_MAX || (TCHAR)ch < TSS_TCHAR_MIN)
|
||||
{
|
||||
ThrowAndAssert(eBadHexConversion(TSTRING(first, last)));
|
||||
|
||||
}
|
||||
|
||||
return (TCHAR)ch;
|
||||
}
|
||||
|
||||
|
@ -527,17 +540,21 @@ TCHAR cCharEncoderUtil::hex_to_char(TSTRING::const_iterator first, TSTRING::cons
|
|||
TSTRING cCharEncoderUtil::char_to_hex(TCHAR ch)
|
||||
{
|
||||
TOSTRINGSTREAM ss;
|
||||
|
||||
ss.imbue(std::locale::classic());
|
||||
tss_classic_locale(ss);
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
ss.fill(_T('0'));
|
||||
ss.width(TCHAR_AS_HEX__IN_TCHARS);
|
||||
ss.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
|
||||
ss << tss::util::char_to_size(ch);
|
||||
|
||||
if (ss.bad() || ss.fail() || ss.str().length() != TCHAR_AS_HEX__IN_TCHARS)
|
||||
tss_mkstr(out, ss);
|
||||
|
||||
if (ss.bad() || ss.fail() || out.length() != TCHAR_AS_HEX__IN_TCHARS)
|
||||
{
|
||||
ThrowAndAssert(eBadHexConversion(TSTRING(1, ch)));
|
||||
return ss.str();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
TSTRING cCharEncoderUtil::DecodeHexToChar(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end)
|
||||
|
@ -551,8 +568,10 @@ TSTRING cCharEncoderUtil::DecodeHexToChar(TSTRING::const_iterator* pcur, const T
|
|||
}
|
||||
|
||||
if (n != TCHAR_AS_HEX__IN_TCHARS)
|
||||
ThrowAndAssert(eBadDecoderInput());
|
||||
|
||||
{
|
||||
ThrowAndAssert(eBadDecoderInput());
|
||||
}
|
||||
|
||||
// convert hex numbers
|
||||
return HexValueToCharString(str);
|
||||
}
|
||||
|
@ -734,10 +753,10 @@ void cEncoder::ValidateSchema() const
|
|||
bool cEncoder::OnlyOneCatagoryPerChar() const
|
||||
{
|
||||
// TODO:BAM - man, is there a better way to do this?
|
||||
TCHAR ch = std::numeric_limits<TCHAR>::min();
|
||||
TCHAR ch = TSS_TCHAR_MIN;
|
||||
TSTRING ach(1, ch);
|
||||
|
||||
if (ch != std::numeric_limits<TCHAR>::max())
|
||||
if (ch != TSS_TCHAR_MAX)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -755,7 +774,7 @@ bool cEncoder::OnlyOneCatagoryPerChar() const
|
|||
}
|
||||
}
|
||||
ch++;
|
||||
} while (ch != std::numeric_limits<TCHAR>::max());
|
||||
} while (ch != TSS_TCHAR_MAX);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -94,5 +94,5 @@ TSTRING cDisplayUtil::FormatMultiLineString(const TSTRING& str, int nOffset, int
|
|||
// now add last string
|
||||
sstr << strT;
|
||||
|
||||
return (sstr.str());
|
||||
tss_return_stream(sstr, out);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
|||
TOSTRINGSTREAM strm;
|
||||
ASSERT(sizeof(uint32_t) == sizeof(unsigned int)); // for cast on next line
|
||||
strm << _T("Unknown Error ID ") << (unsigned int)error.GetID();
|
||||
errStr = strm.str();
|
||||
tss_stream_to_string(strm, errStr);
|
||||
}
|
||||
|
||||
//int len = errStr.length(); // save for later
|
||||
|
|
|
@ -268,7 +268,7 @@ void cFile::Close() //throw(eFile)
|
|||
mpData->mpCurrStream = NULL;
|
||||
}
|
||||
|
||||
mpData->mFileName.clear();
|
||||
//mpData->mFileName.clear();
|
||||
}
|
||||
|
||||
bool cFile::IsOpen(void) const
|
||||
|
@ -485,6 +485,9 @@ bool cDosPath::IsAbsolutePath(const TSTRING& in)
|
|||
// For paths of type C:\DOS
|
||||
TSTRING cDosPath::AsPosix(const TSTRING& in)
|
||||
{
|
||||
#if (defined(__MINGW32__) || defined(__OS2__))
|
||||
return in;
|
||||
#else
|
||||
if (in[0] == '/')
|
||||
{
|
||||
return in;
|
||||
|
@ -495,6 +498,7 @@ TSTRING cDosPath::AsPosix(const TSTRING& in)
|
|||
out.erase(std::remove(out.begin(), out.end(), ':'), out.end());
|
||||
|
||||
return out;
|
||||
#endif
|
||||
}
|
||||
|
||||
TSTRING cDosPath::AsNative(const TSTRING& in)
|
||||
|
|
|
@ -78,10 +78,12 @@ typedef std::u16string dbstring;
|
|||
}
|
||||
|
||||
#elif (WCHAR_IS_32_BITS)
|
||||
#if HAVE_LOCALE
|
||||
namespace std
|
||||
{
|
||||
template<> struct char_traits<dbchar_t>;
|
||||
}
|
||||
#endif
|
||||
namespace tss
|
||||
{
|
||||
typedef std::basic_string<dbchar_t> dbstring;
|
||||
|
@ -97,7 +99,6 @@ typedef std::basic_string<dbchar_t> dbstring;
|
|||
|
||||
#if HAVE_LOCALE
|
||||
# include <locale>
|
||||
#endif
|
||||
|
||||
// specialize *std*::char_traits!!!
|
||||
|
||||
|
@ -230,6 +231,7 @@ template<> struct std::char_traits<dbchar_t>
|
|||
return (wint_t)(0xFFFF);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
# endif //WCHAR_IS_16_BITS // We already have a dbstring implicitly in wstring!!!
|
||||
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_FEATURES_H
|
||||
#include <features.h>
|
||||
#endif
|
||||
|
||||
//NOTE: Autoconf is strongly preferred as the Right Way to detect platform-specific features/behaviors.
|
||||
// These macros should really only be used when autoconf can't get the job done.
|
||||
|
||||
|
@ -132,7 +136,7 @@
|
|||
#elif defined(_SORTIX_SOURCE)
|
||||
# define IS_SORTIX 1
|
||||
|
||||
#elif defined(__AROS__)
|
||||
#elif defined(__AROS__) || defined(AMIGA)
|
||||
# define IS_AROS 1
|
||||
|
||||
#elif defined(__riscos__)
|
||||
|
@ -175,12 +179,18 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
#define CPLUSPLUS_1998_OR_GREATER (__cplusplus >= 199711L)
|
||||
#define CPLUSPLUS_PRE_1998 !CPLUSPLUS_1998_OR_GREATER
|
||||
|
||||
#define CPLUSPLUS_2011_OR_GREATER (__cplusplus >= 201103L)
|
||||
#define CPLUSPLUS_PRE_2011 !CPLUSPLUS_2011_OR_GREATER
|
||||
|
||||
#define CPLUSPLUS_2017_OR_GREATER (__cplusplus >= 201703L)
|
||||
#define CPLUSPLUS_PRE_2017 !CPLUSPLUS_2011_OR_GREATER
|
||||
#define CPLUSPLUS_PRE_2017 !CPLUSPLUS_2017_OR_GREATER
|
||||
|
||||
#define CPLUSPLUS_2020_OR_GREATER (__cplusplus >= 202002L)
|
||||
#define CPLUSPLUS_PRE_2020 !CPLUSPLUS_2020_OR_GREATER
|
||||
|
||||
// KAI 3.4 uses a much improved stl
|
||||
#define IS_KAI_3_4 (IS_KAI && (COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA || COMP == COMP_KAI_GLIBC))
|
||||
|
||||
|
@ -194,8 +204,10 @@
|
|||
(USE_CLIB_LOCALE || IS_SUNPRO || \
|
||||
IS_MSVC) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
#define USES_GLIBC 1
|
||||
#endif
|
||||
|
||||
#define USES_GLIBC ((COMP == COMP_KAI_GLIBC) || HAVE_GCC)
|
||||
#define SUPPORTS_MEMBER_TEMPLATES (!IS_SUNPRO)
|
||||
#define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST (!IS_SUNPRO)
|
||||
|
||||
|
@ -208,6 +220,8 @@
|
|||
#define SUPPORTS_POSIX_FILE_IO (HAVE_OPEN && HAVE_READ && HAVE_CLOSE)
|
||||
#define SUPPORTS_SYMLINKS (HAVE_READLINK || HAVE_READLINKAT)
|
||||
|
||||
#define ARCHAIC_STL (!HAVE_LOCALE && !HAVE_SSTREAM)
|
||||
|
||||
#if (SIZEOF_WCHAR_T == 2)
|
||||
# define WCHAR_IS_16_BITS 1
|
||||
# define WCHAR_REP_IS_UCS2 1
|
||||
|
@ -262,6 +276,10 @@
|
|||
# define MKDIR_TAKES_SINGLE_ARG 1
|
||||
#endif
|
||||
|
||||
#if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(BBNDK_VERSION_CURRENT)
|
||||
# define SWAB_TAKES_CHAR_PTRS 1
|
||||
#endif
|
||||
|
||||
#if (!defined(__ANROID__) && !defined(__AROS__))
|
||||
# define USES_MBLEN (HAVE_MBLEN)
|
||||
#endif
|
||||
|
@ -304,7 +322,7 @@
|
|||
|
||||
// Unlinking an open file (to make a temporary file nobody else can see) is a Posix-ism
|
||||
// that other platforms generally don't support.
|
||||
#if (!defined(__DJGPP__) && !defined(__riscos__) && !defined(__redox__) && !IS_AROS)
|
||||
#if (!defined(__CYGWIN__) && !defined(__DJGPP__) && !defined(__riscos__) && !defined(__redox__) && !defined(_WIN32) && !defined(__OS2__) && !IS_AROS)
|
||||
# define CAN_UNLINK_WHILE_OPEN 1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -113,7 +113,8 @@ void cSerializerImpl::RegisterSerializable(const cType& type, iTypedSerializable
|
|||
ASSERT(false);
|
||||
TOSTRINGSTREAM str;
|
||||
str << _T("Duplicate entry in type table: ") << type.AsString() << std::endl;
|
||||
throw eInternal(str.str());
|
||||
tss_mkstr(errStr, str);
|
||||
throw eInternal(errStr);
|
||||
}
|
||||
cSerializerImpl::mSerCreateMap[crc] = pFunc;
|
||||
}
|
||||
|
@ -129,7 +130,8 @@ void cSerializerImpl::RegisterSerializableRefCt(const cType& type, iSerRefCountO
|
|||
ASSERT(false);
|
||||
TOSTRINGSTREAM str;
|
||||
str << _T("Duplicate entry in type table: ") << type.AsString() << std::ends;
|
||||
throw eInternal(str.str());
|
||||
tss_mkstr(errStr, str);
|
||||
throw eInternal(errStr);
|
||||
}
|
||||
cSerializerImpl::mSerRefCountCreateMap[crc] = pFunc;
|
||||
}
|
||||
|
@ -269,12 +271,15 @@ iTypedSerializable* cSerializerImpl::ReadObjectDynCreate()
|
|||
{
|
||||
// unable to find the creation function...
|
||||
d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc);
|
||||
TOSTRINGSTREAM str;
|
||||
TSTRING errStr;
|
||||
|
||||
#ifdef DEBUG
|
||||
TOSTRINGSTREAM str;
|
||||
// Let's only report the actual crc in debug mode
|
||||
str << (int32_t)crc << std::ends;
|
||||
tss_mkstr(errStr, str);
|
||||
#endif
|
||||
ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE));
|
||||
ThrowAndAssert(eSerializerUnknownType(errStr, mFileName, eSerializer::TY_FILE));
|
||||
}
|
||||
iTypedSerializable* pObj = ((*si).second)();
|
||||
d.TraceDetail("Created non-ref counted object %s(%p)\n", pObj->GetType().AsString(), pObj);
|
||||
|
@ -300,8 +305,9 @@ iTypedSerializable* cSerializerImpl::ReadObjectDynCreate()
|
|||
// unable to find the creation function...
|
||||
d.TraceError("Unable to find creation function for ref counted object %d\n", crc);
|
||||
TOSTRINGSTREAM str;
|
||||
str << (int32_t)crc << std::ends;
|
||||
ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE));
|
||||
str << (int32_t)crc;;
|
||||
tss_mkstr(errStr, str);
|
||||
ThrowAndAssert(eSerializerUnknownType(errStr, mFileName, eSerializer::TY_FILE));
|
||||
}
|
||||
pObj = ((*rci).second)();
|
||||
d.TraceDetail("Creating Ref-Counted object [%d] %s(%p)\n", objIdx, pObj->GetType().AsString(), pObj);
|
||||
|
|
|
@ -55,8 +55,13 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#if HAVE_SSTREAM
|
||||
# include <sstream>
|
||||
#elif HAVE_STRSTREAM
|
||||
# include <iostream>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
|
|
|
@ -60,19 +60,35 @@
|
|||
// A little macro that's useful for finding the number of characters in a TCHAR ARRAY
|
||||
#define countof(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#if HAVE_SSTREAM
|
||||
# include <sstream>
|
||||
#elif HAVE_STRSTREAM
|
||||
# include <strstream>
|
||||
#endif
|
||||
|
||||
|
||||
#define TCHAR char
|
||||
#define _tmain main
|
||||
|
||||
typedef std::string TSTRING;
|
||||
typedef std::stringstream TSTRINGSTREAM;
|
||||
typedef std::ostringstream TOSTRINGSTREAM;
|
||||
typedef std::istringstream TISTRINGSTREAM;
|
||||
|
||||
#if HAVE_SSTREAM
|
||||
typedef std::stringstream TSTRINGSTREAM;
|
||||
typedef std::ostringstream TOSTRINGSTREAM;
|
||||
typedef std::istringstream TISTRINGSTREAM;
|
||||
#elif HAVE_STRSTREAM
|
||||
typedef strstream TSTRINGSTREAM;
|
||||
typedef ostrstream TOSTRINGSTREAM;
|
||||
typedef istrstream TISTRINGSTREAM;
|
||||
#endif
|
||||
|
||||
typedef std::ostream TOSTREAM;
|
||||
typedef std::istream TISTREAM;
|
||||
typedef std::ofstream TOFSTREAM;
|
||||
|
@ -125,4 +141,36 @@ typedef std::ifstream TIFSTREAM;
|
|||
# define __cdecl
|
||||
# endif
|
||||
|
||||
#if HAVE_LOCALE
|
||||
# define tss_classic_locale(x) x.imbue(std::locale::classic())
|
||||
#else
|
||||
# define tss_classic_locale(x)
|
||||
#endif
|
||||
|
||||
#if ARCHAIC_STL
|
||||
# define tss_end(x) x << std::ends
|
||||
# define tss_free(x) x.freeze(0)
|
||||
# define tss_mkstr(y,x) \
|
||||
tss_end(x); \
|
||||
TSTRING y = x.str(); \
|
||||
tss_free(x);
|
||||
|
||||
# define tss_stream_to_string(x,y) \
|
||||
tss_end(x); \
|
||||
y = x.str(); \
|
||||
tss_free(x);
|
||||
|
||||
# define tss_return_stream(x,y) \
|
||||
tss_mkstr(y,x) \
|
||||
return y;
|
||||
|
||||
#else
|
||||
# define tss_end(x)
|
||||
# define tss_free(x)
|
||||
# define tss_mkstr(y,x) TSTRING y = x.str();
|
||||
# define tss_stream_to_string(x,y) y = x.str();
|
||||
# define tss_return_stream(x,y) return x.str();
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __TCHAR_H
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//
|
||||
// The developer of the original code and/or files is Tripwire, Inc.
|
||||
// Portions created by Tripwire, Inc. are copyright (C) 2000-2019 Tripwire,
|
||||
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
|
||||
|
@ -44,12 +43,23 @@
|
|||
// METHOD CODE
|
||||
//=========================================================================
|
||||
|
||||
bool tss_isdigit(const TCHAR in)
|
||||
{
|
||||
#if ARCHAIC_STL
|
||||
return isdigit(in);
|
||||
#else
|
||||
return std::isdigit<TCHAR>(in, std::locale());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
|
||||
{
|
||||
ASSERT(pi != 0);
|
||||
|
||||
bool fFormatOK = true;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
//
|
||||
// make sure string is not longer than a string representation of LIMIT_MAX
|
||||
//
|
||||
|
@ -57,7 +67,8 @@ bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
|
|||
sstr << cInterpretInt::LIMIT_MAX;
|
||||
if (str.length() > sstr.str().length())
|
||||
fFormatOK = false;
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// make sure string is not too short
|
||||
//
|
||||
|
@ -69,7 +80,7 @@ bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
|
|||
//
|
||||
if (fFormatOK)
|
||||
{
|
||||
if (!(_T('-') == str[0] || std::isdigit<TCHAR>(str[0], std::locale())))
|
||||
if (!(_T('-') == str[0] || tss_isdigit(str[0])))
|
||||
fFormatOK = false;
|
||||
}
|
||||
|
||||
|
@ -79,7 +90,7 @@ bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
|
|||
// TODO:BAM -- check this...
|
||||
for (TSTRING::size_type j = 1; fFormatOK && j < str.length(); j++)
|
||||
{
|
||||
if (!std::isdigit<TCHAR>(str[j], std::locale()))
|
||||
if (!tss_isdigit(str[j]))
|
||||
fFormatOK = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ TSTRING cTWLocale::FormatNumberAsHex( int32_t i )
|
|||
// convert long to a string
|
||||
//
|
||||
TOSTRINGSTREAM sstr;
|
||||
sstr.imbue( std::locale::classic() );
|
||||
sstr.setf( std::ios_base::hex, std::ios_base::basefield );
|
||||
tss_classic_locale(sstr);
|
||||
sstr.setf( std::ios::hex, std::ios::basefield );
|
||||
const std::num_put< TCHAR > *pnp = 0, &np = tss::GetFacet( sstr.getloc(), pnp );
|
||||
np.put( sstr, sstr, sstr.fill(), (long)i );
|
||||
|
||||
|
@ -141,21 +141,27 @@ public:
|
|||
// EFFECTS: Does all actual formatting for FormatNumber methods
|
||||
static numT Format(const std::basic_string<CharT>& s, bool fCStyleFormatting)
|
||||
{
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
static const std::num_get<CharT>* png;
|
||||
std::basic_istringstream<CharT> ss(s);
|
||||
std::ios_base::iostate state;
|
||||
std::ios::iostate state;
|
||||
numT n;
|
||||
|
||||
std::basic_istringstream<CharT> ss(s);
|
||||
|
||||
if (fCStyleFormatting)
|
||||
ss.imbue(std::locale::classic());
|
||||
tss_classic_locale(ss);
|
||||
|
||||
tss::GetFacet(ss.getloc(), png).get(ss, std::istreambuf_iterator<CharT>(), ss, state, n);
|
||||
|
||||
|
||||
if ((state & std::ios_base::failbit) != 0)
|
||||
if ((state & std::ios::failbit) != 0)
|
||||
throw eTWLocaleBadNumFormat();
|
||||
|
||||
return (n);
|
||||
#else
|
||||
return atoi(s.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -166,16 +172,22 @@ public:
|
|||
//
|
||||
static std::basic_string<CharT>& Format(numT n, std::basic_string<CharT>& sBuf, bool fCStyleFormatting = false)
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
static const std::num_put<CharT>* pnp;
|
||||
|
||||
std::basic_ostringstream<CharT> ss;
|
||||
|
||||
if (fCStyleFormatting)
|
||||
ss.imbue(std::locale::classic());
|
||||
tss_classic_locale(ss);
|
||||
|
||||
tss::GetFacet(ss.getloc(), pnp).put(ss, ss, ss.fill(), n);
|
||||
|
||||
#else
|
||||
strstream ss;
|
||||
ss << n;
|
||||
#endif
|
||||
sBuf = ss.str();
|
||||
return (sBuf);
|
||||
return (sBuf);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -285,7 +297,7 @@ TSTRING& util_FormatTimeCPlusPlus(struct tm* ptm, TSTRING& strBuf)
|
|||
tss::GetFacet(sstr.getloc(), ptp).put(sstr, sstr, sstr.fill(), ptm, 'c');
|
||||
# endif
|
||||
|
||||
strBuf = sstr.str();
|
||||
tss_stream_to_string(sstr, strBuf);
|
||||
return strBuf;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -98,8 +98,10 @@ public:
|
|||
// INLINE FUNCTIONS
|
||||
//=========================================================================
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
namespace tss
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// GetFacet
|
||||
//
|
||||
|
@ -116,5 +118,6 @@ template<class FacetT> inline const FacetT& GetFacet(const std::locale& l, const
|
|||
#endif
|
||||
}
|
||||
} // namespace tss
|
||||
#endif
|
||||
|
||||
#endif //__TWLOCALE_H
|
||||
|
|
|
@ -80,6 +80,20 @@ typedef unsigned long long uint64_t;
|
|||
#endif
|
||||
#endif // !HAVE_STDINT_H
|
||||
|
||||
#ifdef CHAR_MIN
|
||||
# define TSS_CHAR_MIN CHAR_MIN
|
||||
#else
|
||||
# define TSS_CHAR_MIN (-127 - 1)
|
||||
#endif
|
||||
|
||||
#ifdef CHAR_MAX
|
||||
# define TSS_CHAR_MAX CHAR_MAX
|
||||
#else
|
||||
# define TSS_CHAR_MAX 127
|
||||
#endif
|
||||
|
||||
#define TSS_TCHAR_MIN TSS_CHAR_MIN
|
||||
#define TSS_TCHAR_MAX TSS_CHAR_MAX
|
||||
|
||||
#ifdef INT8_MIN
|
||||
# define TSS_INT8_MIN INT8_MIN
|
||||
|
|
|
@ -193,12 +193,15 @@ void cUnixFSServices::GetHostID(TSTRING& name) const
|
|||
{
|
||||
TOSTRINGSTREAM ret;
|
||||
|
||||
ret.setf(ios_base::hex, ios_base::basefield);
|
||||
ret.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
#if HAVE_GETHOSTID
|
||||
ret << gethostid();
|
||||
#else
|
||||
ret << 999999;
|
||||
#endif
|
||||
|
||||
tss_stream_to_string(ret, name);
|
||||
}
|
||||
|
||||
// returns "/" for unix and "\\" for win32
|
||||
|
@ -610,9 +613,10 @@ bool cUnixFSServices::GetUserName(uid_t user_id, TSTRING& tstrUser) const
|
|||
else
|
||||
{
|
||||
#endif
|
||||
std::stringstream sstr;
|
||||
TOSTRINGSTREAM sstr;
|
||||
sstr << user_id;
|
||||
tstrUser = sstr.str();
|
||||
tss_stream_to_string(sstr, tstrUser);
|
||||
|
||||
#if HAVE_PWD_H
|
||||
}
|
||||
#endif
|
||||
|
@ -639,9 +643,10 @@ bool cUnixFSServices::GetGroupName(gid_t group_id, TSTRING& tstrGroup) const
|
|||
else
|
||||
{
|
||||
#endif
|
||||
std::stringstream sstr;
|
||||
TOSTRINGSTREAM sstr;
|
||||
sstr << group_id;
|
||||
tstrGroup = sstr.str();
|
||||
tss_stream_to_string(sstr, tstrGroup);
|
||||
|
||||
#if !IS_REDOX && HAVE_GRP_H
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -125,9 +125,11 @@ TSTRING cFCOPropInt32::AsString() const
|
|||
//TODO:mdb -- implement this through twlocale!
|
||||
//
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr.imbue(std::locale::classic());
|
||||
tss_classic_locale(ostr);
|
||||
ostr << mValue;
|
||||
return TSTRING(ostr.str());
|
||||
tss_mkstr(out, ostr);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
iFCOProp::CmpResult cFCOPropInt32::Compare(const iFCOProp* rhs, iFCOProp::Op op) const
|
||||
|
@ -165,9 +167,10 @@ TSTRING cFCOPropInt64::AsString() const
|
|||
//TODO:mdb -- implement this through twlocale!
|
||||
//
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr.imbue(std::locale::classic());
|
||||
tss_classic_locale(ostr);
|
||||
ostr << (int32_t)mValue; // TODO: remove this cast where possible
|
||||
return TSTRING(ostr.str());
|
||||
tss_mkstr(out, ostr);
|
||||
return out;
|
||||
}
|
||||
|
||||
iFCOProp::CmpResult cFCOPropInt64::Compare(const iFCOProp* rhs, iFCOProp::Op op) const
|
||||
|
@ -205,9 +208,9 @@ TSTRING cFCOPropUint64::AsString() const
|
|||
//TODO:mdb -- implement this through twlocale!
|
||||
//
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr.imbue(std::locale::classic());
|
||||
tss_classic_locale(ostr);
|
||||
ostr << (int32_t)mValue; // TODO: remove this cast where possible
|
||||
return TSTRING(ostr.str());
|
||||
tss_return_stream(ostr, out);
|
||||
}
|
||||
|
||||
iFCOProp::CmpResult cFCOPropUint64::Compare(const iFCOProp* rhs, iFCOProp::Op op) const
|
||||
|
|
|
@ -450,6 +450,7 @@ void cFCOPropVector::TraceContents(int dl) const
|
|||
if (ContainsItem(i))
|
||||
ostr << i << _T(", ");
|
||||
}
|
||||
ostr << std::ends;
|
||||
d.Trace(dl, _T("Size = %d Contents = %s\n"), GetSize(), ostr.str().c_str());
|
||||
|
||||
tss_mkstr(contents, ostr);
|
||||
d.Trace(dl, _T("Size = %d Contents = %s\n"), GetSize(), contents.c_str());
|
||||
}
|
||||
|
|
|
@ -113,10 +113,11 @@ void cFCOSpecStopPointSet::SetStartPoint(const cFCOName& startPoint)
|
|||
TOSTRINGSTREAM str;
|
||||
str << "Bad start point [" << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(startPoint)
|
||||
<< "] added to spec with stop point "
|
||||
<< iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(*i) << std::ends;
|
||||
|
||||
d.TraceError("%s\n", str.str().c_str());
|
||||
throw eSerializerInputStreamFmt(str.str().c_str());
|
||||
<< iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(*i);
|
||||
tss_mkstr(errText, str);
|
||||
|
||||
d.TraceError("%s\n", errText.c_str());
|
||||
throw eSerializerInputStreamFmt(errText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,10 +179,12 @@ void cFCOSpecStopPointSet::Add(const cFCOName& name)
|
|||
TOSTRINGSTREAM str;
|
||||
str << "Attempt to add stop point that is not below start point!"
|
||||
<< " start point = " << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(mStartPoint)
|
||||
<< " stop point = " << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(name) << std::ends;
|
||||
<< " stop point = " << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(name);
|
||||
|
||||
d.TraceError(_T("%s\n"), str.str().c_str());
|
||||
throw eSerializerInputStreamFmt(str.str().c_str());
|
||||
tss_mkstr(errText, str);
|
||||
|
||||
d.TraceError(_T("%s\n"), errText.c_str());
|
||||
throw eSerializerInputStreamFmt(errText);
|
||||
}
|
||||
|
||||
std::set<cFCOName>::iterator i;
|
||||
|
|
|
@ -342,14 +342,14 @@ TSTRING cChecksumSignature::AsString() const
|
|||
TSTRING cChecksumSignature::AsStringHex() const
|
||||
{
|
||||
TOSTRINGSTREAM ss;
|
||||
|
||||
ss.imbue(std::locale::classic());
|
||||
ss.setf(ios::hex, ios::basefield);
|
||||
|
||||
tss_classic_locale(ss);
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
ASSERT(false);
|
||||
ss << (size_t)(uint32_t)mChecksum; // TODO:BAM -- this is truncating a 64-bit value to 32 bits!
|
||||
|
||||
return ss.str();
|
||||
tss_mkstr(out, ss);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool cChecksumSignature::IsEqual(const iSignature& rhs) const
|
||||
|
@ -431,13 +431,13 @@ TSTRING cCRC32Signature::AsString() const
|
|||
TSTRING cCRC32Signature::AsStringHex() const
|
||||
{
|
||||
TOSTRINGSTREAM ss;
|
||||
|
||||
ss.imbue(std::locale::classic());
|
||||
ss.setf(ios::hex, ios::basefield);
|
||||
|
||||
tss_classic_locale(ss);
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
ss << (size_t)mCRCInfo.crc;
|
||||
|
||||
return ss.str();
|
||||
tss_mkstr(out, ss);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool cCRC32Signature::IsEqual(const iSignature& rhs) const
|
||||
|
|
|
@ -171,7 +171,10 @@ TSTRING& cFSPropDisplayer::GetDetailsHeader(TSTRING& strBuf, int iMargin) const
|
|||
static cFSPropSet set;
|
||||
TOSTRINGSTREAM sstr;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
sstr << std::left;
|
||||
#endif
|
||||
|
||||
sstr << _T(" ") << std::setw(PROP_MODE_WIDTH) << set.GetPropName(cFSPropSet::PROP_MODE);
|
||||
sstr << _T(" ") << std::setw(PROP_OWNER_WIDTH) << set.GetPropName(cFSPropSet::PROP_UID);
|
||||
sstr << _T(" ") << std::setw(PROP_SIZE_WIDTH) << set.GetPropName(cFSPropSet::PROP_SIZE);
|
||||
|
@ -184,7 +187,7 @@ TSTRING& cFSPropDisplayer::GetDetailsHeader(TSTRING& strBuf, int iMargin) const
|
|||
sstr << _T(" ") << std::setw(PROP_SIZE_WIDTH) << _T("----------");
|
||||
sstr << _T(" ") << std::setw(PROP_MTIME_WIDTH) << _T("----------");
|
||||
|
||||
strBuf = sstr.str();
|
||||
tss_stream_to_string(sstr, strBuf);
|
||||
return strBuf;
|
||||
}
|
||||
|
||||
|
@ -204,8 +207,10 @@ TSTRING& cFSPropDisplayer::GetDetails(const iFCO* const pfco, TSTRING& strBuf) c
|
|||
TOSTRINGSTREAM sstr;
|
||||
const cFCOPropVector pv = pfco->GetPropSet()->GetValidVector();
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
sstr << std::left;
|
||||
|
||||
#endif
|
||||
|
||||
sstr << _T(" ") << std::setw(PROP_MODE_WIDTH);
|
||||
if (pv.ContainsItem(cFSPropSet::PROP_MODE))
|
||||
sstr << PropAsString(pfco, cFSPropSet::PROP_MODE).c_str();
|
||||
|
@ -230,7 +235,7 @@ TSTRING& cFSPropDisplayer::GetDetails(const iFCO* const pfco, TSTRING& strBuf) c
|
|||
else
|
||||
sstr << _T("XXXXXXXXXXXXXXXXX");
|
||||
|
||||
strBuf = sstr.str();
|
||||
tss_stream_to_string(sstr, strBuf);
|
||||
return strBuf;
|
||||
}
|
||||
|
||||
|
@ -359,10 +364,10 @@ TSTRING cFSPropDisplayer::PropAsString(const iFCO* const pFCO, const int propIdx
|
|||
ASSERT(pTypedProp != 0);
|
||||
if (GetUsername(pTypedProp->GetValue(), strProp))
|
||||
{
|
||||
TSTRINGSTREAM ostr;
|
||||
TOSTRINGSTREAM ostr;
|
||||
//TODO: can we get rid of this cast now?
|
||||
ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")");
|
||||
strProp = ostr.str();
|
||||
tss_stream_to_string(ostr, strProp);
|
||||
}
|
||||
else
|
||||
strProp = pProp->AsString();
|
||||
|
@ -374,10 +379,10 @@ TSTRING cFSPropDisplayer::PropAsString(const iFCO* const pFCO, const int propIdx
|
|||
ASSERT(pTypedProp != 0);
|
||||
if (GetGroupname(pTypedProp->GetValue(), strProp))
|
||||
{
|
||||
TSTRINGSTREAM ostr;
|
||||
TOSTRINGSTREAM ostr;
|
||||
//TODO: can we get rid of this cast now?
|
||||
ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")");
|
||||
strProp = ostr.str();
|
||||
tss_stream_to_string(ostr, strProp);
|
||||
}
|
||||
else
|
||||
strProp = pProp->AsString();
|
||||
|
|
|
@ -110,7 +110,9 @@ void cFSPropSet::TraceContents(int dl) const
|
|||
<< _T(", ");
|
||||
}
|
||||
}
|
||||
d.Trace(dl, _T("%s\n"), ostr.str().c_str());
|
||||
|
||||
tss_mkstr(out, ostr);
|
||||
d.Trace(dl, _T("%s\n"), out.c_str());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -176,7 +176,12 @@ bool cMailMessage::GetAttachmentsAsString(std::string& s)
|
|||
|
||||
std::string cMailMessage::Create822Header()
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
std::ostringstream ss;
|
||||
#else
|
||||
strstream ss;
|
||||
#endif
|
||||
|
||||
std::string strToList;
|
||||
for (std::vector<TSTRING>::size_type i = 0; i < mvstrRecipients.size(); i++)
|
||||
{
|
||||
|
@ -280,19 +285,23 @@ static bool NeedsEncoding(char ch)
|
|||
|
||||
static std::string EncodeChar(char ch)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss.imbue(std::locale::classic());
|
||||
TOSTRINGSTREAM ss;
|
||||
tss_classic_locale(ss);
|
||||
ss.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
ss.fill('0');
|
||||
ss.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
|
||||
ss.width(2);
|
||||
|
||||
ss << (unsigned int)(unsigned char)ch;
|
||||
|
||||
tss_end(ss);
|
||||
|
||||
ASSERT(ss.str().length() == 2);
|
||||
|
||||
// Make sure the hex is uppercase
|
||||
std::string s = ss.str();
|
||||
tss_free(ss);
|
||||
|
||||
std::transform(s.begin(), s.end(), s.begin(), toupper);
|
||||
|
||||
return s;
|
||||
|
|
|
@ -36,7 +36,11 @@
|
|||
#include "tw/twutil.h"
|
||||
#include "tripwirestrings.h"
|
||||
#include "core/stringutil.h"
|
||||
#if HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#elif HAVE_STRSTREAM
|
||||
#include <strstream>
|
||||
#endif
|
||||
#include "core/file.h"
|
||||
|
||||
#include <time.h>
|
||||
|
@ -201,8 +205,10 @@ bool cSMTPMailMessage::OpenConnection()
|
|||
TOSTRINGSTREAM estr;
|
||||
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName;
|
||||
|
||||
throw eMailSMTPIPUnresolvable(estr.str());
|
||||
return false;
|
||||
tss_mkstr(errStr, estr);
|
||||
|
||||
throw eMailSMTPIPUnresolvable(errStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the socket
|
||||
|
@ -223,7 +229,9 @@ bool cSMTPMailMessage::OpenConnection()
|
|||
TOSTRINGSTREAM estr;
|
||||
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName;
|
||||
|
||||
throw eMailSMTPOpenConnection(estr.str());
|
||||
tss_mkstr(errStr, estr);
|
||||
|
||||
throw eMailSMTPOpenConnection(errStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -303,7 +311,12 @@ bool cSMTPMailMessage::MailMessage()
|
|||
// mpfnGethostname (see below). It won't be used
|
||||
// after that.
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
std::ostringstream strmSend;
|
||||
#else
|
||||
strstream strmSend;
|
||||
#endif
|
||||
|
||||
// This should be a stream object, so we don't have
|
||||
// to use nasty calls to sprintf that might overflow
|
||||
// the buffer. Before, we used a fixed buffer of 512
|
||||
|
@ -325,21 +338,33 @@ bool cSMTPMailMessage::MailMessage()
|
|||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// Say hello
|
||||
strmSend.str(""); //Clear the stream buffer.
|
||||
#if !ARCHAIC_STL
|
||||
strmSend.str(""); //Clear the stream buffer.
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
strmSend << "HELO " << sLocalHost << "\r\n"; //Fill the stream buffer.
|
||||
SendString(strmSend.str());
|
||||
if (!GetAcknowledgement())
|
||||
return false;
|
||||
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
strmSend.str(""); //Clear the stream buffer.
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
strmSend << "MAIL FROM:<" << cStringUtil::TstrToStr(mstrFrom) << ">\r\n";
|
||||
SendString(strmSend.str());
|
||||
if (!GetAcknowledgement())
|
||||
return false;
|
||||
|
||||
// Say who all we're sending to
|
||||
#if !ARCHAIC_STL
|
||||
strmSend.str(""); //Clear the stream buffer.
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
for (std::vector<TSTRING>::size_type i = 0; i < mvstrRecipients.size(); i++)
|
||||
{
|
||||
sNarrowString = cStringUtil::TstrToStr(mvstrRecipients[i]);
|
||||
|
@ -364,8 +389,14 @@ bool cSMTPMailMessage::MailMessage()
|
|||
// Send Header
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
// set up header
|
||||
#if !ARCHAIC_STL
|
||||
strmSend.str("");
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
|
||||
strmSend << cMailMessage::Create822Header();
|
||||
SendString(strmSend.str());
|
||||
|
||||
|
@ -499,7 +530,9 @@ bool cSMTPMailMessage::GetAcknowledgement()
|
|||
TOSTRINGSTREAM estr;
|
||||
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER_RETURNED_ERROR) << sRecvString;
|
||||
|
||||
throw eMailSMTPServer(estr.str());
|
||||
tss_mkstr(errStr, estr);
|
||||
|
||||
throw eMailSMTPServer(errStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,7 +277,11 @@ static void util_InitTempDirectory(const cConfigFile& cf)
|
|||
//
|
||||
if (*temp_directory.rbegin() != '/')
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
temp_directory.push_back('/');
|
||||
#else
|
||||
temp_directory.append("/");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1140,8 +1144,10 @@ int cTWModeIC::Execute(cErrorQueue* pQueue)
|
|||
// TODO -- move these strings to the string table
|
||||
TOSTRINGSTREAM str;
|
||||
str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator()
|
||||
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName << std::ends;
|
||||
cTWUtil::PrintErrorMsg(eICDifferentUsers(str.str(), eError::NON_FATAL));
|
||||
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName;
|
||||
tss_mkstr(errStr, str);
|
||||
|
||||
cTWUtil::PrintErrorMsg(eICDifferentUsers(errStr, eError::NON_FATAL));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2142,8 +2148,10 @@ int cTWModePolUpdate::Execute(cErrorQueue* pQueue)
|
|||
// TODO -- move these strings to the string table
|
||||
TOSTRINGSTREAM str;
|
||||
str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator()
|
||||
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName << std::ends;
|
||||
cTWUtil::PrintErrorMsg(eICDifferentUsers(str.str(), eError::NON_FATAL));
|
||||
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName;
|
||||
tss_mkstr(errStr, str);
|
||||
|
||||
cTWUtil::PrintErrorMsg(eICDifferentUsers(errStr, eError::NON_FATAL));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,13 @@ void cTWCmdLineUtil::ParsePolicyFile(cGenreSpecListVector& genreSpecList,
|
|||
cDisplayEncoder::EncodeInline(fileName).c_str());
|
||||
|
||||
// set up parser and parser policy file
|
||||
#if !ARCHAIC_STL
|
||||
std::istringstream in(strPolicyText);
|
||||
#else
|
||||
strstream in;
|
||||
in << strPolicyText;
|
||||
#endif
|
||||
|
||||
cPolicyParser parser(in);
|
||||
parser.Execute(genreSpecList, pQueue);
|
||||
}
|
||||
|
@ -549,6 +555,7 @@ static bool EmailReportTo(const TSTRING& toAddress,
|
|||
const cTWModeCommon* modeCommon,
|
||||
const bool bForceFullReport)
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
TW_UNIQUE_PTR<cMailMessage> reportMail;
|
||||
|
||||
// allocate the right kind of emailer object based on what came out of the config file.
|
||||
|
@ -556,12 +563,13 @@ static bool EmailReportTo(const TSTRING& toAddress,
|
|||
{
|
||||
#if SUPPORTS_NETWORKING
|
||||
case cMailMessage::MAIL_BY_SMTP:
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
reportMail = TW_UNIQUE_PTR<cSMTPMailMessage>(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort));
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case cMailMessage::MAIL_BY_PIPE:
|
||||
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -629,6 +637,9 @@ static bool EmailReportTo(const TSTRING& toAddress,
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -707,6 +718,7 @@ bool cTWCmdLineUtil::EmailReport(const cFCOReportHeader& header,
|
|||
|
||||
bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING& mAddress, const cTWModeCommon* modeCommon)
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
TW_UNIQUE_PTR<cMailMessage> reportMail;
|
||||
|
||||
// allocate the right kind of emailer object based on what came out of the config file.
|
||||
|
@ -760,4 +772,7 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING& mAddress, const cTWMode
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -193,9 +193,7 @@ void cConfigFile::WriteString(TSTRING& configText) // throw( eFSServices )
|
|||
out << sKey << _T("=") << sVal << _T("\n");
|
||||
}
|
||||
|
||||
configText = out.str();
|
||||
|
||||
return;
|
||||
tss_stream_to_string(out, configText);
|
||||
}
|
||||
|
||||
void cConfigFile::ReadString(const TSTRING configText) // throw( eConfigFile );
|
||||
|
@ -660,15 +658,16 @@ TSTRING cConfigFile::MakeErrorString(const TSTRING& strMsg, bool fShowLineNum) c
|
|||
strErr << TSS_GetString(cTW, tw::STR_CUR_LINE) << mnLine;
|
||||
}
|
||||
|
||||
return strErr.str();
|
||||
tss_mkstr(out, strErr);
|
||||
return out;
|
||||
}
|
||||
|
||||
TSTRING& util_MakeTripwireDateString(TSTRING& strBuf)
|
||||
{
|
||||
struct tm* ptmLocal = cTimeUtil::TimeToDateLocal(cSystemInfo::GetExeStartTime());
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr.imbue(std::locale::classic());
|
||||
|
||||
tss_classic_locale(ostr);
|
||||
|
||||
// format is YYYYMMDD-HHMMSS
|
||||
ostr.fill(_T('0'));
|
||||
ostr << std::setw(4) << ptmLocal->tm_year + 1900;
|
||||
|
@ -679,7 +678,6 @@ TSTRING& util_MakeTripwireDateString(TSTRING& strBuf)
|
|||
ostr << std::setw(2) << ptmLocal->tm_min;
|
||||
ostr << std::setw(2) << ptmLocal->tm_sec;
|
||||
|
||||
strBuf = ostr.str();
|
||||
|
||||
tss_stream_to_string(ostr, strBuf);
|
||||
return strBuf;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,12 @@ static const TCHAR* g_sz79Equals =
|
|||
// UTIL FUNCTION PROTOTYES
|
||||
//=========================================================================
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
static void OpenOutputFile(fixed_basic_ofstream<TCHAR>& out, const TSTRING& strFile); // throw( eTextReportViewer )
|
||||
#else
|
||||
static void OpenOutputFile(ofstream& out, const TSTRING& strFile); // throw( eTextReportViewer )
|
||||
#endif
|
||||
|
||||
static void OpenInputFile(std::ifstream& out, const TSTRING& strFile); // throw( eTextReportViewer )
|
||||
static bool PrintableProp(const iFCO* pfcoOld, const iFCO* pfcoNew, int j);
|
||||
|
||||
|
@ -277,7 +282,11 @@ void cTextReportViewer::PrintTextReport(const TSTRING& strFilename, ReportingLev
|
|||
}
|
||||
else
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
fixed_basic_ofstream<TCHAR> out;
|
||||
#else
|
||||
ofstream out;
|
||||
#endif
|
||||
OpenOutputFile(out, strFilename);
|
||||
mpOut = &out;
|
||||
OutputTextReport();
|
||||
|
@ -738,8 +747,10 @@ void cTextReportViewer::ReportError(const cErrorQueueIter& eqIter)
|
|||
// output error number
|
||||
TOSTRINGSTREAM ostr;
|
||||
ostr << mErrorNum << _T(".");
|
||||
tss_mkstr(numStr, ostr);
|
||||
|
||||
(*mpOut).width(nWidth);
|
||||
(*mpOut) << ostr.str();
|
||||
(*mpOut) << numStr;
|
||||
|
||||
// output general error
|
||||
(*mpOut) << cErrorTable::GetInstance()->Get(eqIter.GetError().GetID()) << endl;
|
||||
|
@ -923,7 +934,11 @@ TSTRING cTextReportViewer::GetGenre()
|
|||
|
||||
bool cTextReportViewer::PeekIsEOF()
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
return (mpIn->peek() == char_traits<char>::eof());
|
||||
#else
|
||||
return (mpIn->peek() == EOF);
|
||||
#endif
|
||||
}
|
||||
|
||||
// if the next character in the stream is ('X' or 'x'), it eats the x, else it returns false
|
||||
|
@ -1327,7 +1342,7 @@ void cTextReportViewer::CollateRulesSummary(const cFCOReportGenreIter& genreIter
|
|||
break;
|
||||
}
|
||||
|
||||
if (si->mSpecName.compare(newLine.mSpecName) == 0 && si->mSeverity == newLine.mSeverity)
|
||||
if (si->mSpecName == newLine.mSpecName && si->mSeverity == newLine.mSeverity)
|
||||
{
|
||||
si->mAddedObjects += newLine.mAddedObjects;
|
||||
si->mRemovedObjects += newLine.mRemovedObjects;
|
||||
|
@ -1335,16 +1350,36 @@ void cTextReportViewer::CollateRulesSummary(const cFCOReportGenreIter& genreIter
|
|||
|
||||
// if one of the start points is a subset of the other, then we take the shorter one.
|
||||
// otherwise we set the startpoint to empty.
|
||||
// TODO this logic is not aware of strings as paths and may do the wrong thing in some cases.
|
||||
//
|
||||
if (newLine.mStartPoint.length() <= si->mStartPoint.length())
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
if (newLine.mStartPoint.compare(0, newLine.mStartPoint.length(), si->mStartPoint) == 0)
|
||||
si->mStartPoint = newLine.mStartPoint;
|
||||
else
|
||||
#else
|
||||
if (_tcsncmp(newLine.mStartPoint.c_str(), si->mStartPoint.c_str(), newLine.mStartPoint.length()) == 0)
|
||||
#endif
|
||||
{
|
||||
si->mStartPoint = newLine.mStartPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
si->mStartPoint.erase();
|
||||
}
|
||||
}
|
||||
#if !ARCHAIC_STL
|
||||
else if (si->mStartPoint.compare(0, si->mStartPoint.length(), newLine.mStartPoint) == 0)
|
||||
#else
|
||||
else if (_tcsncmp(si->mStartPoint.c_str(), newLine.mStartPoint.c_str(), si->mStartPoint.length()) == 0)
|
||||
#endif
|
||||
{
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
si->mStartPoint.erase();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1725,7 +1760,11 @@ void OpenInputFile(std::ifstream& in, const TSTRING& strFile) // throw( eTextRep
|
|||
}
|
||||
}
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
void OpenOutputFile(fixed_basic_ofstream<TCHAR>& out, const TSTRING& strFile) // throw( eTextReportViewer )
|
||||
#else
|
||||
void OpenOutputFile(ofstream& out, const TSTRING& strFile) // throw( eTextReportViewer )
|
||||
#endif
|
||||
{
|
||||
std::string narrowFilename = cStringUtil::TstrToStr(strFile);
|
||||
|
||||
|
@ -1924,7 +1963,7 @@ TSTRING cTextReportViewer::SingleLineReport()
|
|||
sstrReport << _T(" ") << TSS_GetString(cTW, tw::STR_REMOVED_SHORT) << _T(":") << nRemovedTotal;
|
||||
sstrReport << _T(" ") << TSS_GetString(cTW, tw::STR_CHANGED_SHORT) << _T(":") << nChangedTotal;
|
||||
|
||||
return sstrReport.str();
|
||||
tss_return_stream(sstrReport, out);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1978,7 +2017,11 @@ void cTextReportViewer::OutputParseableReport()
|
|||
|
||||
char cTextReportViewer::PeekChar()
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
return char_traits<char>::to_char_type(mpIn->peek());
|
||||
#else
|
||||
return (char)mpIn->peek();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1996,8 +2039,10 @@ void cTextReportViewer::GetChar()
|
|||
for (uint32_t i = 0; i < sizeof(mCurrentChar); i++)
|
||||
mCurrentChar[i] = 0;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
static const std::istream::char_type eof = std::char_traits<char>::to_char_type(std::char_traits<char>::eof());
|
||||
|
||||
#endif
|
||||
|
||||
std::streampos pos = mpIn->tellg();
|
||||
|
||||
for (size_t nch = 0; nch < (size_t)MB_CUR_MAX; nch++)
|
||||
|
@ -2016,7 +2061,11 @@ void cTextReportViewer::GetChar()
|
|||
|
||||
d.TraceDebug(_T("Found EOF\n"));
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
mCurrentChar[0] = eof;
|
||||
#else
|
||||
mCurrentChar[0] = EOF;
|
||||
#endif
|
||||
mCurrentCharSize = 1;
|
||||
|
||||
return;
|
||||
|
@ -2030,8 +2079,11 @@ void cTextReportViewer::GetChar()
|
|||
}
|
||||
|
||||
// get character from input stream
|
||||
#if !ARCHAIC_STL
|
||||
std::istream::char_type ch = std::char_traits<char>::to_char_type(mpIn->get());
|
||||
|
||||
#else
|
||||
char ch = mpIn->get();
|
||||
#endif
|
||||
// add character to mb buffer
|
||||
mCurrentChar[nch] = ch;
|
||||
mCurrentCharSize++;
|
||||
|
@ -2050,7 +2102,13 @@ void cTextReportViewer::GetChar()
|
|||
}
|
||||
|
||||
mpIn->seekg(pos);
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
std::istream::char_type c = std::char_traits<char>::to_char_type(mpIn->get());
|
||||
#else
|
||||
char c = mpIn->get();
|
||||
#endif
|
||||
|
||||
if ((unsigned char)c > 0x7f)
|
||||
{
|
||||
mCurrentChar[0] = c;
|
||||
|
|
|
@ -661,7 +661,11 @@ void cTWUtil::ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchiv
|
|||
throw eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE);
|
||||
|
||||
// check 8 byte header
|
||||
#if !ARCHAIC_STL
|
||||
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), CONFIG_FILE_MAGIC_8BYTE) != 0)
|
||||
#else
|
||||
if (_tcsncmp(nstring.mString.c_str(), CONFIG_FILE_MAGIC_8BYTE, 8 * sizeof(uint8_t)) != 0)
|
||||
#endif
|
||||
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
||||
|
||||
// remove 8 byte header
|
||||
|
@ -716,7 +720,11 @@ void cTWUtil::ReadPolicyText(const TCHAR* filename, std::string& polText, const
|
|||
ReadObject(filename, NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted);
|
||||
|
||||
// check 8 byte header
|
||||
#if !ARCHAIC_STL
|
||||
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), POLICY_FILE_MAGIC_8BYTE) != 0)
|
||||
#else
|
||||
if (_tcsncmp(nstring.mString.c_str(), POLICY_FILE_MAGIC_8BYTE, 8 * sizeof(uint8_t)) != 0)
|
||||
#endif
|
||||
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
|
||||
|
||||
// remove 8 byte header
|
||||
|
@ -1213,7 +1221,11 @@ bool cTWUtil::ConfirmYN(const TCHAR* prompt)
|
|||
for (x = 0; s[x] && iswctype(s[x], wctype("space")); x++)
|
||||
;
|
||||
#else
|
||||
#if !ARCHAIC_STL
|
||||
for (x = 0; s[x] && std::isspace<TCHAR>(s[x], std::locale()); x++)
|
||||
#else
|
||||
for (x = 0; s[x] && isspace(s[x]); x++)
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -646,7 +646,13 @@ int cTWAModeCreatePol::Execute(cErrorQueue* pQueue)
|
|||
//
|
||||
// make sure the policy file parses correctly before we update the old one
|
||||
//
|
||||
#if !ARCHAIC_STL
|
||||
std::istringstream in(plaintext);
|
||||
#else
|
||||
strstream in;
|
||||
in << plaintext;
|
||||
#endif
|
||||
|
||||
cPolicyParser parser(in);
|
||||
try
|
||||
{
|
||||
|
|
|
@ -488,14 +488,16 @@ void cRSAPublicKey::TraceContents()
|
|||
cDebug d("cRSAPublicKey::TraceContents");
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetTrapdoorFunction().GetModulus();
|
||||
d.TraceDebug("Modulus = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("Modulus = %s\n", msg.c_str());
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetTrapdoorFunction().GetExponent();
|
||||
d.TraceDebug("Exponent = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("Exponent = %s\n", msg.c_str());
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
@ -968,24 +970,28 @@ void cElGamalSigPublicKey::TraceContents()
|
|||
cDebug d("cElGamalSigPublicKey::TraceContents");
|
||||
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetPrime();
|
||||
d.TraceDebug("Prime = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("Prime = %s\n", msg.c_str());
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetParameterQ();
|
||||
d.TraceDebug("Q = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("Q = %s\n", msg.c_str());
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetParameterG();
|
||||
d.TraceDebug("G = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("G = %s\n", msg.c_str());
|
||||
}
|
||||
{
|
||||
std::ostringstream os;
|
||||
TOSTRINGSTREAM os;
|
||||
os << mpData->mpKey->GetParameterY();
|
||||
d.TraceDebug("Y = %s\n", os.str().c_str());
|
||||
tss_mkstr(msg, os);
|
||||
d.TraceDebug("Y = %s\n", msg.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -113,7 +113,9 @@ eParserHelper::eParserHelper(const TSTRING& strMsg, int nLine /*= CURRENT_LINE *
|
|||
strErr << nLine;
|
||||
}
|
||||
|
||||
tss_end(strErr);
|
||||
mMsg = strErr.str();
|
||||
tss_free(strErr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -455,9 +457,13 @@ void cParserUtil::InterpretEscapedString(const std::string& strEscapedString, TS
|
|||
pchCur++; // go to char past '\'
|
||||
|
||||
if (*pchCur == 'x' &&
|
||||
#if !ARCHAIC_STL
|
||||
std::isxdigit<TCHAR>(
|
||||
*(pchCur + 1),
|
||||
std::locale())) // deal with \xXXXX where 'x' is the character 'x', and 'X' is a hex number
|
||||
#else
|
||||
isxdigit(*(pchCur + 1)))
|
||||
#endif
|
||||
{
|
||||
pchCur++; // go to char past 'x'
|
||||
char cEscapedChar = static_cast<char>(util_ConvertHex(pchCur, &nCharsRead));
|
||||
|
@ -883,23 +889,42 @@ int util_ConvertHex(const char* const cpsz, int* const pnCharsRead)
|
|||
ASSERT(util_AsciiCharsActLikeTheyShould());
|
||||
ASSERT(cpsz && pnCharsRead);
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale()))
|
||||
#else
|
||||
if (*cpsz == 0 || !isxdigit(*cpsz))
|
||||
#endif
|
||||
|
||||
throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
|
||||
|
||||
int iValue;
|
||||
const char* psz = cpsz;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
for (*pnCharsRead = 0, iValue = 0; *psz && std::isxdigit<TCHAR>(*psz, std::locale()) && (*pnCharsRead < 2);
|
||||
psz++, (*pnCharsRead)++)
|
||||
#else
|
||||
for (*pnCharsRead = 0, iValue = 0; *psz && isxdigit(*psz) && (*pnCharsRead < 2);
|
||||
psz++, (*pnCharsRead)++)
|
||||
#endif
|
||||
{
|
||||
iValue *= 0x10;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
if (std::isdigit<TCHAR>(*psz, std::locale()))
|
||||
#else
|
||||
if (isdigit(*psz))
|
||||
#endif
|
||||
{
|
||||
iValue += (*psz - '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
if (std::islower<TCHAR>(*psz, std::locale()))
|
||||
#else
|
||||
if (islower(*psz))
|
||||
#endif
|
||||
iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15
|
||||
else // is uppercase
|
||||
iValue += (*psz - 'A' + 10); // so that a=10, a=11, ..., f=15
|
||||
|
@ -914,26 +939,43 @@ int util_ConvertUnicode(const char* const cpsz, int* const pnCharsRead)
|
|||
ASSERT(util_AsciiCharsActLikeTheyShould());
|
||||
ASSERT(cpsz && pnCharsRead);
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale()))
|
||||
#else
|
||||
if (*cpsz == 0 || !isxdigit(*cpsz))
|
||||
#endif
|
||||
throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
|
||||
|
||||
int iValue;
|
||||
const char* psz = cpsz;
|
||||
for (*pnCharsRead = 0, iValue = 0; *pnCharsRead < 4; psz++, (*pnCharsRead)++)
|
||||
{
|
||||
|
||||
// we require 4 chars for unicode escapes
|
||||
#if !ARCHAIC_STL
|
||||
if (*psz == 0 || !std::isxdigit<TCHAR>(*psz, std::locale()))
|
||||
#else
|
||||
if (*psz == 0 || !isxdigit(*psz))
|
||||
#endif
|
||||
throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
|
||||
|
||||
iValue *= 0x10;
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
if (std::isdigit<TCHAR>(*psz, std::locale()))
|
||||
#else
|
||||
if (isdigit(*psz))
|
||||
#endif
|
||||
{
|
||||
iValue += (*psz - '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
if (std::islower<TCHAR>(*psz, std::locale()))
|
||||
#else
|
||||
if (islower(*psz))
|
||||
#endif
|
||||
iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15
|
||||
else // is uppercase
|
||||
iValue += (*psz - 'A' + 10); // so that a=10, a=11, ..., f=15
|
||||
|
|
|
@ -85,7 +85,9 @@ void tw_yy_scan::output(int c)
|
|||
sz[1] = 0;
|
||||
sstr << sz;
|
||||
|
||||
throw eParseFailed(sstr.str());
|
||||
tss_mkstr(errStr, sstr);
|
||||
|
||||
throw eParseFailed(errStr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,8 +101,14 @@ void cPolicyParser::Check(cErrorBucket* pError) //throw(eError);
|
|||
cParserHelper::Init(pError);
|
||||
cParserHelper::SetParseOnly(true);
|
||||
|
||||
std::basic_stringstream<char> in(ConvertMultibyte(mIn));
|
||||
tw_yy_scan lexer(in);
|
||||
#if !ARCHAIC_STL
|
||||
TISTRINGSTREAM in(ConvertMultibyte(mIn));
|
||||
#else
|
||||
TSTRINGSTREAM in;
|
||||
in << ConvertMultibyte(mIn);
|
||||
#endif
|
||||
|
||||
tw_yy_scan lexer(in);
|
||||
|
||||
// start the parsing
|
||||
if (mParser.yyparse(&lexer) != 0)
|
||||
|
@ -119,8 +127,14 @@ void cPolicyParser::Execute(cGenreSpecListVector& policy, cErrorBucket* pError)
|
|||
{
|
||||
cParserHelper::Init(pError);
|
||||
|
||||
std::basic_stringstream<char> in(ConvertMultibyte(mIn));
|
||||
tw_yy_scan lexer(in);
|
||||
#if !ARCHAIC_STL
|
||||
TISTRINGSTREAM in(ConvertMultibyte(mIn));
|
||||
#else
|
||||
TSTRINGSTREAM in;
|
||||
in << ConvertMultibyte(mIn);
|
||||
#endif
|
||||
|
||||
tw_yy_scan lexer(in);
|
||||
|
||||
// start the parsing
|
||||
if (mParser.yyparse(&lexer) != 0)
|
||||
|
@ -136,17 +150,21 @@ void cPolicyParser::Execute(cGenreSpecListVector& policy, cErrorBucket* pError)
|
|||
// Parser will ALWAYS call the narrow-char version, so special case Unicode compile
|
||||
void tw_yy_scan::yyerror(const char* pszErr, ...) //throw( eParserHelper )
|
||||
{
|
||||
#if 0
|
||||
TOSTRINGSTREAM ssError; // final error string
|
||||
ssError << pszErr;
|
||||
|
||||
throw eParseFailed(ssError.str());
|
||||
throw eParseFailed(ssError.str());
|
||||
#endif
|
||||
|
||||
TSTRING errText = pszErr ? pszErr : "";
|
||||
throw eParseFailed(errText);
|
||||
}
|
||||
|
||||
// Throw this in the display encoder?
|
||||
std::string cPolicyParser::ConvertMultibyte(std::istream& in)
|
||||
{
|
||||
// get this file as a stringstream
|
||||
std::stringstream ss;
|
||||
TOSTRINGSTREAM ss;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -168,6 +186,8 @@ std::string cPolicyParser::ConvertMultibyte(std::istream& in)
|
|||
throw eParserBadCharacter();
|
||||
}
|
||||
|
||||
tss_end(ss);
|
||||
|
||||
#ifdef DEBUG
|
||||
TCERR << _T("*** begin policy text ***") << std::endl;
|
||||
std::cerr << ss.str() << std::endl;
|
||||
|
@ -176,7 +196,8 @@ std::string cPolicyParser::ConvertMultibyte(std::istream& in)
|
|||
|
||||
// convert it to single byte escaped
|
||||
std::string str = util_ConvertMB(ss.str());
|
||||
|
||||
tss_free(ss);
|
||||
|
||||
#ifdef DEBUG
|
||||
TCERR << _T("*** begin policy converted to ***") << std::endl;
|
||||
std::cerr << str << std::endl;
|
||||
|
@ -188,20 +209,24 @@ std::string cPolicyParser::ConvertMultibyte(std::istream& in)
|
|||
|
||||
std::string convert_to_encoded_hex(char ch)
|
||||
{
|
||||
std::basic_stringstream<char> sstr;
|
||||
TOSTRINGSTREAM sstr;
|
||||
|
||||
// set up stringstream
|
||||
sstr.imbue(std::locale::classic());
|
||||
sstr.setf(std::ios_base::hex, std::ios_base::basefield);
|
||||
tss_classic_locale(sstr);
|
||||
sstr.setf(std::ios::hex, std::ios::basefield);
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
// get the num_put facet
|
||||
const std::num_put<char>*pnp = 0, &np = tss::GetFacet(sstr.getloc(), pnp);
|
||||
|
||||
// output the char
|
||||
sstr << "\\x";
|
||||
|
||||
np.put(sstr, sstr, sstr.fill(), (long)(unsigned char)ch);
|
||||
#else
|
||||
sstr << "\\x" << ch;
|
||||
#endif
|
||||
|
||||
return sstr.str();
|
||||
tss_return_stream(sstr, out);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -552,12 +552,12 @@ std::string FormatSyntaxError( char ch, const char* pszAdditionalMsg = NULL )
|
|||
// we do it here as well, I suppose that's OK. This should be eventually
|
||||
// corrected.
|
||||
|
||||
std::ostringstream ssErr;
|
||||
TOSTRINGSTREAM ssErr;
|
||||
ssErr << "Syntax error: \'" << ch << "\'";
|
||||
if( pszAdditionalMsg )
|
||||
ssErr << ", " << pszAdditionalMsg;
|
||||
|
||||
return ssErr.str();
|
||||
tss_return_stream(ssErr, out);
|
||||
}
|
||||
|
||||
// saves typing
|
||||
|
|
|
@ -48,8 +48,10 @@ static void PrintPropVector(const cFCOPropVector& v, cDebug& d)
|
|||
stream << i << ","
|
||||
<< " ";
|
||||
}
|
||||
stream << std::ends;
|
||||
d.TraceDebug("%s\n", stream.str().c_str());
|
||||
|
||||
tss_mkstr(out, stream);
|
||||
|
||||
d.TraceDebug("%s\n", out.c_str());
|
||||
}
|
||||
|
||||
void TestFSPropSet()
|
||||
|
|
|
@ -76,17 +76,17 @@ void TestGenreSpecList()
|
|||
gslVector.push_back(gslPair2);
|
||||
gslVector.push_back(gslPair3);
|
||||
|
||||
TEST(gslVector.at(0).GetGenre() == gslPair.GetGenre());
|
||||
TEST(gslVector.at(0).GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector.at(0).GetSpecList().Lookup(fsSpec)->GetName() == gslPair.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
TEST(gslVector[0].GetGenre() == gslPair.GetGenre());
|
||||
TEST(gslVector[0].GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector[0].GetSpecList().Lookup(fsSpec)->GetName() == gslPair.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
|
||||
TEST(gslVector.at(1).GetGenre() == gslPair2.GetGenre());
|
||||
TEST(gslVector.at(1).GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector.at(1).GetSpecList().Lookup(fsSpec)->GetName() == gslPair2.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
TEST(gslVector[1].GetGenre() == gslPair2.GetGenre());
|
||||
TEST(gslVector[1].GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector[1].GetSpecList().Lookup(fsSpec)->GetName() == gslPair2.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
|
||||
TEST(gslVector.at(2).GetGenre() == gslPair3.GetGenre());
|
||||
TEST(gslVector.at(2).GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector.at(2).GetSpecList().Lookup(fsSpec)->GetName() == gslPair3.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
TEST(gslVector[2].GetGenre() == gslPair3.GetGenre());
|
||||
TEST(gslVector[2].GetSpecList().Lookup(fsSpec) != 0);
|
||||
TEST(gslVector[2].GetSpecList().Lookup(fsSpec)->GetName() == gslPair3.GetSpecList().Lookup(fsSpec)->GetName());
|
||||
|
||||
d.TraceDebug("All tests passed.\n");
|
||||
}
|
||||
|
|
|
@ -197,6 +197,7 @@ void TestAlignment2()
|
|||
TEST("BYTE_ALIGN ok"); // yet again, the test is not falling over a couple of lines up. */
|
||||
}
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
// Not sure this is a super valuable test, since it just verifies that builtin integer types
|
||||
// work the way we think they do.
|
||||
void TestSizes()
|
||||
|
@ -231,12 +232,14 @@ template<class E, class T> bool CanBeRepresentedAs(E e, T t)
|
|||
|
||||
return fReturn;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////
|
||||
void RegisterSuite_Platform()
|
||||
{
|
||||
RegisterTest("Platform", "Alignment", TestAlignment);
|
||||
RegisterTest("Platform", "Alignment2", TestAlignment2);
|
||||
RegisterTest("Platform", "Alignment2", TestAlignment2);
|
||||
#if !ARCHAIC_STL
|
||||
RegisterTest("Platform", "Sizes", TestSizes);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
#ifndef __STRINGUTIL_T_H
|
||||
# define __STRINGUTIL_T_H
|
||||
|
||||
#include "core/platform.h"
|
||||
#include "core/tchar.h"
|
||||
|
||||
#include "core/ntmbs.h"
|
||||
#include "core/ntdbs.h"
|
||||
|
||||
|
@ -81,7 +84,9 @@ inline void TestStringUtil()
|
|||
TEST(b.size() == 0);
|
||||
|
||||
a.resize(3);
|
||||
#if !ARCHAIC_STL
|
||||
TEST(a.c_str() != b.c_str());
|
||||
#endif
|
||||
TEST(std::equal(a.begin(), a.end(), NTDBS1));
|
||||
TEST(std::equal(b.begin(), b.end(), NTDBS1));
|
||||
|
||||
|
|
|
@ -74,9 +74,19 @@ void TestTCHAR()
|
|||
TSTRING test1 = _T("word");
|
||||
|
||||
d.TraceDetail("Testing TOSTRINGSTREAM with TSTRING:\n");
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
TOSTRINGSTREAM ost(_T("test up"));
|
||||
#else
|
||||
TOSTRINGSTREAM ost;
|
||||
ost << _T("test up");
|
||||
#endif
|
||||
ost << test1;
|
||||
d.TraceDetail("%s \n", ost.str().c_str());
|
||||
|
||||
tss_mkstr(out, ost);
|
||||
|
||||
d.TraceDetail("%s \n", out.c_str());
|
||||
|
||||
//if this gives output, then I'm really baffled...
|
||||
//test gets overwritten, yielding "word up"
|
||||
|
||||
|
@ -89,7 +99,10 @@ void TestTCHAR()
|
|||
TSTRING send = _T("These should appear on separate lines");
|
||||
test_wist(send, d);
|
||||
//Did they?
|
||||
}
|
||||
|
||||
void TestFstreams()
|
||||
{
|
||||
//Testing file streams
|
||||
|
||||
//explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char*
|
||||
|
@ -98,16 +111,16 @@ void TestTCHAR()
|
|||
|
||||
//Set up the input file.
|
||||
TOFSTREAM out;
|
||||
out.open(inputfile.c_str(), std::ios_base::out);
|
||||
out.open(inputfile.c_str(), std::ios::out);
|
||||
out << "Unicode is fun\n";
|
||||
out.close();
|
||||
|
||||
TIFSTREAM from;
|
||||
from.open(inputfile.c_str(), std::ios_base::in);
|
||||
from.open(inputfile.c_str(), std::ios::in);
|
||||
TEST(from);
|
||||
|
||||
|
||||
TOFSTREAM to(outputfile.c_str(), std::ios_base::trunc);
|
||||
TOFSTREAM to(outputfile.c_str(), std::ios::trunc);
|
||||
TEST(to);
|
||||
|
||||
//Copy contents of input file to output file.
|
||||
|
@ -120,9 +133,15 @@ void TestTCHAR()
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
TSTRING test_wost(int n, const TSTRING& inject)
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
TOSTRINGSTREAM wost(_T("Weird how this doesn't show up! "));
|
||||
#else
|
||||
TOSTRINGSTREAM wost;
|
||||
wost << _T("Weird how this doesn't show up! ");
|
||||
#endif
|
||||
//It's getting overwritten, why?
|
||||
wost << _T("One out of every ") << n << _T(" children loves ") << inject << _T("!\n");
|
||||
return wost.str();
|
||||
|
@ -130,7 +149,12 @@ TSTRING test_wost(int n, const TSTRING& inject)
|
|||
|
||||
void test_wist(const TSTRING& input, cDebug& d)
|
||||
{
|
||||
#if !ARCHAIC_STL
|
||||
TISTRINGSTREAM wist(input);
|
||||
#else
|
||||
TSTRINGSTREAM wist;
|
||||
wist << input;
|
||||
#endif
|
||||
TSTRING parse;
|
||||
while (wist >> parse)
|
||||
d.TraceDetail("%s \n", parse.c_str());
|
||||
|
@ -139,4 +163,7 @@ void test_wist(const TSTRING& input, cDebug& d)
|
|||
void RegisterSuite_TCHAR()
|
||||
{
|
||||
RegisterTest("TCHAR", "Basic", TestTCHAR);
|
||||
#if !ARCHAIC_STL
|
||||
RegisterTest("TCHAR", "FStreams", TestFstreams);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
|
|||
{
|
||||
TCERR << "SKIPPED: " << e.what() << std::endl;
|
||||
|
||||
std::stringstream sstr;
|
||||
TSTRINGSTREAM sstr;
|
||||
sstr << "Test " << suiteName << "/" << testName << ": " << e.what();
|
||||
skipped_strings.push_back(sstr.str());
|
||||
|
||||
|
@ -227,7 +227,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
|
|||
TCERR << "FAILED: ";
|
||||
cTWUtil::PrintErrorMsg(error);
|
||||
|
||||
std::stringstream sstr;
|
||||
TSTRINGSTREAM sstr;
|
||||
sstr << "Test " << suiteName << "/" << testName << ": " << error.GetMsg();
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
|
@ -237,7 +237,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
|
|||
{
|
||||
TCERR << "FAILED: " << e.what() << std::endl;
|
||||
|
||||
std::stringstream sstr;
|
||||
TSTRINGSTREAM sstr;
|
||||
sstr << "Test " << suiteName << "/" << testName << ": " << e.what();
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
|
@ -247,7 +247,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
|
|||
{
|
||||
TCERR << "FAILED: <unknown>" << std::endl;
|
||||
|
||||
std::stringstream sstr;
|
||||
TSTRINGSTREAM sstr;
|
||||
sstr << "Test " << suiteName << "/" << testName << ": <unknown>";
|
||||
error_strings.push_back(sstr.str());
|
||||
|
||||
|
@ -395,12 +395,13 @@ std::string TwTestDir()
|
|||
|
||||
std::string TwTestPath(const std::string& child)
|
||||
{
|
||||
std::stringstream sstr;
|
||||
TOSTRINGSTREAM sstr;
|
||||
sstr << TwTestDir();
|
||||
if (child[0] != '/')
|
||||
sstr << '/';
|
||||
sstr << child;
|
||||
return sstr.str();
|
||||
|
||||
tss_return_stream(sstr, out);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -80,6 +80,7 @@ void TestItoa()
|
|||
cTWLocale::FormatNumber(n, str);
|
||||
TEST(str == "123456");
|
||||
|
||||
#if !ARCHAIC_STL
|
||||
//
|
||||
// Try formatting with "" locale
|
||||
//
|
||||
|
@ -93,6 +94,7 @@ void TestItoa()
|
|||
std::locale::global(std::locale(""));
|
||||
cTWLocale::FormatNumber(n, str);
|
||||
TEST(str == "123,456");
|
||||
#endif
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue