build & run correctly w/ gcc 2.95+ and w/o STLport

This commit is contained in:
brc0x1 2021-04-14 23:55:55 -07:00
parent ed558c1578
commit 523882f8e9
44 changed files with 700 additions and 187 deletions

View File

@ -57,6 +57,9 @@
/* Define to 1 if you have the `connect' function. */ /* Define to 1 if you have the `connect' function. */
#undef HAVE_CONNECT #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. */ /* Define to 1 if you have the `directio' function. */
#undef HAVE_DIRECTIO #undef HAVE_DIRECTIO
@ -79,6 +82,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H #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. */ /* Define to 1 if you have the `fopen' function. */
#undef HAVE_FOPEN #undef HAVE_FOPEN
@ -94,6 +100,9 @@
/* Define to 1 if you have the `fstatat' function. */ /* Define to 1 if you have the `fstatat' function. */
#undef HAVE_FSTATAT #undef HAVE_FSTATAT
/* Define to 1 if you have the `ftruncate' function. */
#undef HAVE_FTRUNCATE
/* Uses the GNU g++ compiler */ /* Uses the GNU g++ compiler */
#undef HAVE_GCC #undef HAVE_GCC
@ -142,6 +151,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #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. */ /* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H #undef HAVE_LANGINFO_H
@ -157,6 +169,9 @@
/* Define to 1 if you have the <locale> header file. */ /* Define to 1 if you have the <locale> header file. */
#undef HAVE_LOCALE #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. */ /* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT #undef HAVE_LSTAT
@ -253,9 +268,15 @@
/* Define to 1 if you have the `readlinkat' function. */ /* Define to 1 if you have the `readlinkat' function. */
#undef HAVE_READLINKAT #undef HAVE_READLINKAT
/* Define to 1 if you have the `rename' function. */
#undef HAVE_RENAME
/* Define to 1 if you have the `setgid' function. */ /* Define to 1 if you have the `setgid' function. */
#undef HAVE_SETGID #undef HAVE_SETGID
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the `setuid' function. */ /* Define to 1 if you have the `setuid' function. */
#undef HAVE_SETUID #undef HAVE_SETUID
@ -405,6 +426,9 @@
/* Define to 1 if you have the <unixlib/local.h> header file. */ /* Define to 1 if you have the <unixlib/local.h> header file. */
#undef HAVE_UNIXLIB_LOCAL_H #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. */ /* Define to 1 if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H #undef HAVE_VARARGS_H

67
configure vendored
View File

@ -6525,6 +6525,17 @@ fi
done 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 for ac_header in sys/file.h
do : do :
@ -7982,6 +7993,18 @@ _ACEOF
fi fi
done 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 for ac_func in openlog syslog closelog
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@ -8054,6 +8077,50 @@ fi
done 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. # Check whether --enable-commoncrypto was given.
if test "${enable_commoncrypto+set}" = set; then : if test "${enable_commoncrypto+set}" = set; then :

View File

@ -186,7 +186,7 @@ AC_CHECK_HEADERS(stdint.h)
AC_CHECK_HEADERS(syslog.h sys/syslog.h, break) AC_CHECK_HEADERS(syslog.h sys/syslog.h, break)
AC_CHECK_HEADERS(termios.h) AC_CHECK_HEADERS(termios.h)
AC_CHECK_HEADERS(unistd.h sys/unistd.h, break) AC_CHECK_HEADERS(unistd.h sys/unistd.h, break)
AC_CHECK_HEADERS(features.h)
AC_CHECK_HEADERS(sys/file.h) AC_CHECK_HEADERS(sys/file.h)
AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/mount.h,,, AC_CHECK_HEADERS(sys/mount.h,,,
@ -296,6 +296,8 @@ AC_CHECK_FUNCS(readlinkat readlink)
dnl posix fns that make filesystem changes dnl posix fns that make filesystem changes
AC_CHECK_FUNCS(chown chmod link symlink mknod mkfifo) 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 dnl posix syslog fns
AC_CHECK_FUNCS(openlog syslog closelog) AC_CHECK_FUNCS(openlog syslog closelog)
dnl posix process fns dnl posix process fns
@ -308,6 +310,10 @@ AC_CHECK_FUNCS(setuid setgid getgrgid)
dnl check for posix_fadvise dnl check for posix_fadvise
AC_CHECK_HEADERS(fcntl.h, [AC_CHECK_FUNCS(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 dnl check for OSX builtin hash algorithms
AC_ARG_ENABLE(commoncrypto, AC_ARG_ENABLE(commoncrypto,

View File

@ -80,17 +80,18 @@ iCodeConverter* iCodeConverter::m_pInst = NULL;
// has a maximum of 512 chars of output // has a maximum of 512 chars of output
std::string util_output_bytes(void* p, size_t n) std::string util_output_bytes(void* p, size_t n)
{ {
std::ostringstream ss; TOSTRINGSTREAM ss;
ss.imbue(std::locale::classic()); tss_classic_locale(ss);
ss.setf(std::ios_base::hex, std::ios_base::basefield); ss.setf(std::ios::hex, std::ios::basefield);
for (size_t i = 0; i < n; i++) for (size_t i = 0; i < n; i++)
{ {
ss.width(2); ss.width(2);
ss << toupper(tss::util::char_to_size(((char*)p)[i])) << " "; ss << toupper(tss::util::char_to_size(((char*)p)[i])) << " ";
} }
std::string s = ss.str(); tss_mkstr(s, ss);
if (s.length() > 512) if (s.length() > 512)
{ {
s = "truncated output: " + s; s = "truncated output: " + s;

View File

@ -106,13 +106,13 @@ void cDebug::DoTrace(const char* format, va_list& args)
ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long
ASSERT(strlen(out) < 1024); ASSERT(strlen(out) < 1024);
std::ostringstream ostr; TOSTRINGSTREAM ostr;
ostr.setf(std::ios::left); ostr.setf(std::ios::left);
ostr.width(40); ostr.width(40);
ostr << mLabel; ostr << mLabel;
ostr.width(0); ostr.width(0);
ostr << out; ostr << out;
tss_end(ostr);
if ((mOutMask & OUT_STDOUT) != 0) if ((mOutMask & OUT_STDOUT) != 0)
{ {
@ -120,6 +120,8 @@ void cDebug::DoTrace(const char* format, va_list& args)
std::cout.flush(); std::cout.flush();
} }
tss_free(ostr);
// //
//make it output to log file! //make it output to log file!
// //
@ -280,9 +282,9 @@ bool cDebug::SetOutputFile(const char* filename)
// already open! // already open!
// TODO -- make this work with wide chars // TODO -- make this work with wide chars
if (!logfile) 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 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. //make sure info. will not be clobbered.
//Should be open now- if not, abort. //Should be open now- if not, abort.

View File

@ -479,7 +479,7 @@ TSTRING cCharEncoderUtil::CharStringToHexValue(const TSTRING& str)
for (at = str.begin(); at < str.end(); at++) for (at = str.begin(); at < str.end(); at++)
{ {
strOut += char_to_hex(*at); strOut += char_to_hex(*at);
} }
return strOut; 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) 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 max_char = TSS_TCHAR_MAX;
static const TCHAR min_char = std::numeric_limits<TCHAR>::min(); static const TCHAR min_char = TSS_TCHAR_MIN;
if (first + TCHAR_AS_HEX__IN_TCHARS != last) if (first + TCHAR_AS_HEX__IN_TCHARS != last)
ThrowAndAssert(eBadHexConversion()); {
ThrowAndAssert(eBadHexConversion(TSTRING(first,last)));
}
TISTRINGSTREAM ss(TSTRING(first, last)); #if ARCHAIC_STL
ss.imbue(std::locale::classic()); 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.fill(_T('0'));
ss.setf(std::ios_base::hex, std::ios_base::basefield); ss.setf(std::ios::hex, std::ios::basefield);
unsigned long ch; unsigned long ch;
ss >> ch; ss >> ch;
if (ss.bad() || ss.fail()) if (ss.bad() || ss.fail())
{
ThrowAndAssert(eBadHexConversion(TSTRING(first, last))); 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))); ThrowAndAssert(eBadHexConversion(TSTRING(first, last)));
}
return (TCHAR)ch; 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) TSTRING cCharEncoderUtil::char_to_hex(TCHAR ch)
{ {
TOSTRINGSTREAM ss; TOSTRINGSTREAM ss;
tss_classic_locale(ss);
ss.imbue(std::locale::classic()); ss.setf(std::ios::hex, std::ios::basefield);
ss.fill(_T('0')); ss.fill(_T('0'));
ss.width(TCHAR_AS_HEX__IN_TCHARS); ss.width(TCHAR_AS_HEX__IN_TCHARS);
ss.setf(std::ios_base::hex, std::ios_base::basefield);
ss << tss::util::char_to_size(ch); 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))); ThrowAndAssert(eBadHexConversion(TSTRING(1, ch)));
return ss.str(); }
return out;
} }
TSTRING cCharEncoderUtil::DecodeHexToChar(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) 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) if (n != TCHAR_AS_HEX__IN_TCHARS)
ThrowAndAssert(eBadDecoderInput()); {
ThrowAndAssert(eBadDecoderInput());
}
// convert hex numbers // convert hex numbers
return HexValueToCharString(str); return HexValueToCharString(str);
} }
@ -734,10 +753,10 @@ void cEncoder::ValidateSchema() const
bool cEncoder::OnlyOneCatagoryPerChar() const bool cEncoder::OnlyOneCatagoryPerChar() const
{ {
// TODO:BAM - man, is there a better way to do this? // 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); TSTRING ach(1, ch);
if (ch != std::numeric_limits<TCHAR>::max()) if (ch != TSS_TCHAR_MAX)
{ {
do do
{ {
@ -755,7 +774,7 @@ bool cEncoder::OnlyOneCatagoryPerChar() const
} }
} }
ch++; ch++;
} while (ch != std::numeric_limits<TCHAR>::max()); } while (ch != TSS_TCHAR_MAX);
} }
return true; return true;
} }

View File

@ -94,5 +94,5 @@ TSTRING cDisplayUtil::FormatMultiLineString(const TSTRING& str, int nOffset, int
// now add last string // now add last string
sstr << strT; sstr << strT;
return (sstr.str()); tss_return_stream(sstr, out);
} }

View File

@ -79,7 +79,7 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
TOSTRINGSTREAM strm; TOSTRINGSTREAM strm;
ASSERT(sizeof(uint32_t) == sizeof(unsigned int)); // for cast on next line ASSERT(sizeof(uint32_t) == sizeof(unsigned int)); // for cast on next line
strm << _T("Unknown Error ID ") << (unsigned int)error.GetID(); 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 //int len = errStr.length(); // save for later

View File

@ -268,7 +268,7 @@ void cFile::Close() //throw(eFile)
mpData->mpCurrStream = NULL; mpData->mpCurrStream = NULL;
} }
mpData->mFileName.clear(); //mpData->mFileName.clear();
} }
bool cFile::IsOpen(void) const bool cFile::IsOpen(void) const
@ -485,6 +485,9 @@ bool cDosPath::IsAbsolutePath(const TSTRING& in)
// For paths of type C:\DOS // For paths of type C:\DOS
TSTRING cDosPath::AsPosix(const TSTRING& in) TSTRING cDosPath::AsPosix(const TSTRING& in)
{ {
#if (defined(__MINGW32__) || defined(__OS2__))
return in;
#else
if (in[0] == '/') if (in[0] == '/')
{ {
return in; return in;
@ -495,6 +498,7 @@ TSTRING cDosPath::AsPosix(const TSTRING& in)
out.erase(std::remove(out.begin(), out.end(), ':'), out.end()); out.erase(std::remove(out.begin(), out.end(), ':'), out.end());
return out; return out;
#endif
} }
TSTRING cDosPath::AsNative(const TSTRING& in) TSTRING cDosPath::AsNative(const TSTRING& in)

View File

@ -78,10 +78,12 @@ typedef std::u16string dbstring;
} }
#elif (WCHAR_IS_32_BITS) #elif (WCHAR_IS_32_BITS)
#if HAVE_LOCALE
namespace std namespace std
{ {
template<> struct char_traits<dbchar_t>; template<> struct char_traits<dbchar_t>;
} }
#endif
namespace tss namespace tss
{ {
typedef std::basic_string<dbchar_t> dbstring; typedef std::basic_string<dbchar_t> dbstring;
@ -97,7 +99,6 @@ typedef std::basic_string<dbchar_t> dbstring;
#if HAVE_LOCALE #if HAVE_LOCALE
# include <locale> # include <locale>
#endif
// specialize *std*::char_traits!!! // specialize *std*::char_traits!!!
@ -230,6 +231,7 @@ template<> struct std::char_traits<dbchar_t>
return (wint_t)(0xFFFF); return (wint_t)(0xFFFF);
} }
}; };
#endif
# endif //WCHAR_IS_16_BITS // We already have a dbstring implicitly in wstring!!! # endif //WCHAR_IS_16_BITS // We already have a dbstring implicitly in wstring!!!

View File

@ -44,6 +44,10 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#if HAVE_FEATURES_H
#include <features.h>
#endif
//NOTE: Autoconf is strongly preferred as the Right Way to detect platform-specific features/behaviors. //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. // These macros should really only be used when autoconf can't get the job done.
@ -132,7 +136,7 @@
#elif defined(_SORTIX_SOURCE) #elif defined(_SORTIX_SOURCE)
# define IS_SORTIX 1 # define IS_SORTIX 1
#elif defined(__AROS__) #elif defined(__AROS__) || defined(AMIGA)
# define IS_AROS 1 # define IS_AROS 1
#elif defined(__riscos__) #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_2011_OR_GREATER (__cplusplus >= 201103L)
#define CPLUSPLUS_PRE_2011 !CPLUSPLUS_2011_OR_GREATER #define CPLUSPLUS_PRE_2011 !CPLUSPLUS_2011_OR_GREATER
#define CPLUSPLUS_2017_OR_GREATER (__cplusplus >= 201703L) #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 // 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)) #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 || \ (USE_CLIB_LOCALE || IS_SUNPRO || \
IS_MSVC) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters 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_MEMBER_TEMPLATES (!IS_SUNPRO)
#define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST (!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_POSIX_FILE_IO (HAVE_OPEN && HAVE_READ && HAVE_CLOSE)
#define SUPPORTS_SYMLINKS (HAVE_READLINK || HAVE_READLINKAT) #define SUPPORTS_SYMLINKS (HAVE_READLINK || HAVE_READLINKAT)
#define ARCHAIC_STL (!HAVE_LOCALE && !HAVE_SSTREAM)
#if (SIZEOF_WCHAR_T == 2) #if (SIZEOF_WCHAR_T == 2)
# define WCHAR_IS_16_BITS 1 # define WCHAR_IS_16_BITS 1
# define WCHAR_REP_IS_UCS2 1 # define WCHAR_REP_IS_UCS2 1
@ -262,6 +276,10 @@
# define MKDIR_TAKES_SINGLE_ARG 1 # define MKDIR_TAKES_SINGLE_ARG 1
#endif #endif
#if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(BBNDK_VERSION_CURRENT)
# define SWAB_TAKES_CHAR_PTRS 1
#endif
#if (!defined(__ANROID__) && !defined(__AROS__)) #if (!defined(__ANROID__) && !defined(__AROS__))
# define USES_MBLEN (HAVE_MBLEN) # define USES_MBLEN (HAVE_MBLEN)
#endif #endif
@ -304,7 +322,7 @@
// Unlinking an open file (to make a temporary file nobody else can see) is a Posix-ism // Unlinking an open file (to make a temporary file nobody else can see) is a Posix-ism
// that other platforms generally don't support. // 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 # define CAN_UNLINK_WHILE_OPEN 1
#endif #endif

View File

@ -113,7 +113,8 @@ void cSerializerImpl::RegisterSerializable(const cType& type, iTypedSerializable
ASSERT(false); ASSERT(false);
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << _T("Duplicate entry in type table: ") << type.AsString() << std::endl; 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; cSerializerImpl::mSerCreateMap[crc] = pFunc;
} }
@ -129,7 +130,8 @@ void cSerializerImpl::RegisterSerializableRefCt(const cType& type, iSerRefCountO
ASSERT(false); ASSERT(false);
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << _T("Duplicate entry in type table: ") << type.AsString() << std::ends; 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; cSerializerImpl::mSerRefCountCreateMap[crc] = pFunc;
} }
@ -269,12 +271,15 @@ iTypedSerializable* cSerializerImpl::ReadObjectDynCreate()
{ {
// unable to find the creation function... // unable to find the creation function...
d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc); d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc);
TOSTRINGSTREAM str; TSTRING errStr;
#ifdef DEBUG #ifdef DEBUG
TOSTRINGSTREAM str;
// Let's only report the actual crc in debug mode // Let's only report the actual crc in debug mode
str << (int32_t)crc << std::ends; str << (int32_t)crc << std::ends;
tss_mkstr(errStr, str);
#endif #endif
ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE)); ThrowAndAssert(eSerializerUnknownType(errStr, mFileName, eSerializer::TY_FILE));
} }
iTypedSerializable* pObj = ((*si).second)(); iTypedSerializable* pObj = ((*si).second)();
d.TraceDetail("Created non-ref counted object %s(%p)\n", pObj->GetType().AsString(), pObj); 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... // unable to find the creation function...
d.TraceError("Unable to find creation function for ref counted object %d\n", crc); d.TraceError("Unable to find creation function for ref counted object %d\n", crc);
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << (int32_t)crc << std::ends; str << (int32_t)crc;;
ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE)); tss_mkstr(errStr, str);
ThrowAndAssert(eSerializerUnknownType(errStr, mFileName, eSerializer::TY_FILE));
} }
pObj = ((*rci).second)(); pObj = ((*rci).second)();
d.TraceDetail("Creating Ref-Counted object [%d] %s(%p)\n", objIdx, pObj->GetType().AsString(), pObj); d.TraceDetail("Creating Ref-Counted object [%d] %s(%p)\n", objIdx, pObj->GetType().AsString(), pObj);

View File

@ -55,8 +55,13 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <utility> #include <utility>
#include <sstream>
#include <iostream> #if HAVE_SSTREAM
# include <sstream>
#elif HAVE_STRSTREAM
# include <iostream>
#endif
#include <algorithm> #include <algorithm>
#include <set> #include <set>
#include <stack> #include <stack>

View File

@ -60,19 +60,35 @@
// A little macro that's useful for finding the number of characters in a TCHAR ARRAY // A little macro that's useful for finding the number of characters in a TCHAR ARRAY
#define countof(x) (sizeof(x) / sizeof(x[0])) #define countof(x) (sizeof(x) / sizeof(x[0]))
#include "platform.h"
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <sstream>
#include <iostream> #include <iostream>
#include <fstream>
#if HAVE_SSTREAM
# include <sstream>
#elif HAVE_STRSTREAM
# include <strstream>
#endif
#define TCHAR char #define TCHAR char
#define _tmain main #define _tmain main
typedef std::string TSTRING; typedef std::string TSTRING;
typedef std::stringstream TSTRINGSTREAM;
typedef std::ostringstream TOSTRINGSTREAM; #if HAVE_SSTREAM
typedef std::istringstream TISTRINGSTREAM; 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::ostream TOSTREAM;
typedef std::istream TISTREAM; typedef std::istream TISTREAM;
typedef std::ofstream TOFSTREAM; typedef std::ofstream TOFSTREAM;
@ -125,4 +141,36 @@ typedef std::ifstream TIFSTREAM;
# define __cdecl # define __cdecl
# endif # 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 #endif // __TCHAR_H

View File

@ -1,4 +1,3 @@
//
// The developer of the original code and/or files is Tripwire, Inc. // The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000-2019 Tripwire, // Portions created by Tripwire, Inc. are copyright (C) 2000-2019 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
@ -44,12 +43,23 @@
// METHOD CODE // 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) bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
{ {
ASSERT(pi != 0); ASSERT(pi != 0);
bool fFormatOK = true; bool fFormatOK = true;
#if !ARCHAIC_STL
// //
// make sure string is not longer than a string representation of LIMIT_MAX // 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; sstr << cInterpretInt::LIMIT_MAX;
if (str.length() > sstr.str().length()) if (str.length() > sstr.str().length())
fFormatOK = false; fFormatOK = false;
#endif
// //
// make sure string is not too short // make sure string is not too short
// //
@ -69,7 +80,7 @@ bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
// //
if (fFormatOK) if (fFormatOK)
{ {
if (!(_T('-') == str[0] || std::isdigit<TCHAR>(str[0], std::locale()))) if (!(_T('-') == str[0] || tss_isdigit(str[0])))
fFormatOK = false; fFormatOK = false;
} }
@ -79,7 +90,7 @@ bool cInterpretInt::InterpretInt(const TSTRING& str, int* pi)
// TODO:BAM -- check this... // TODO:BAM -- check this...
for (TSTRING::size_type j = 1; fFormatOK && j < str.length(); j++) 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; fFormatOK = false;
} }

View File

@ -114,8 +114,8 @@ TSTRING cTWLocale::FormatNumberAsHex( int32_t i )
// convert long to a string // convert long to a string
// //
TOSTRINGSTREAM sstr; TOSTRINGSTREAM sstr;
sstr.imbue( std::locale::classic() ); tss_classic_locale(sstr);
sstr.setf( std::ios_base::hex, std::ios_base::basefield ); sstr.setf( std::ios::hex, std::ios::basefield );
const std::num_put< TCHAR > *pnp = 0, &np = tss::GetFacet( sstr.getloc(), pnp ); const std::num_put< TCHAR > *pnp = 0, &np = tss::GetFacet( sstr.getloc(), pnp );
np.put( sstr, sstr, sstr.fill(), (long)i ); np.put( sstr, sstr, sstr.fill(), (long)i );
@ -141,21 +141,27 @@ public:
// EFFECTS: Does all actual formatting for FormatNumber methods // EFFECTS: Does all actual formatting for FormatNumber methods
static numT Format(const std::basic_string<CharT>& s, bool fCStyleFormatting) static numT Format(const std::basic_string<CharT>& s, bool fCStyleFormatting)
{ {
#if !ARCHAIC_STL
static const std::num_get<CharT>* png; static const std::num_get<CharT>* png;
std::basic_istringstream<CharT> ss(s); std::ios::iostate state;
std::ios_base::iostate state;
numT n; numT n;
std::basic_istringstream<CharT> ss(s);
if (fCStyleFormatting) 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); 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(); throw eTWLocaleBadNumFormat();
return (n); 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) 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; static const std::num_put<CharT>* pnp;
std::basic_ostringstream<CharT> ss; std::basic_ostringstream<CharT> ss;
if (fCStyleFormatting) if (fCStyleFormatting)
ss.imbue(std::locale::classic()); tss_classic_locale(ss);
tss::GetFacet(ss.getloc(), pnp).put(ss, ss, ss.fill(), n); tss::GetFacet(ss.getloc(), pnp).put(ss, ss, ss.fill(), n);
#else
strstream ss;
ss << n;
#endif
sBuf = ss.str(); 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'); tss::GetFacet(sstr.getloc(), ptp).put(sstr, sstr, sstr.fill(), ptm, 'c');
# endif # endif
strBuf = sstr.str(); tss_stream_to_string(sstr, strBuf);
return strBuf; return strBuf;
} }
#endif #endif

View File

@ -98,8 +98,10 @@ public:
// INLINE FUNCTIONS // INLINE FUNCTIONS
//========================================================================= //=========================================================================
#if !ARCHAIC_STL
namespace tss namespace tss
{ {
//////////////////////////////////////////////// ////////////////////////////////////////////////
// GetFacet // GetFacet
// //
@ -116,5 +118,6 @@ template<class FacetT> inline const FacetT& GetFacet(const std::locale& l, const
#endif #endif
} }
} // namespace tss } // namespace tss
#endif
#endif //__TWLOCALE_H #endif //__TWLOCALE_H

View File

@ -80,6 +80,20 @@ typedef unsigned long long uint64_t;
#endif #endif
#endif // !HAVE_STDINT_H #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 #ifdef INT8_MIN
# define TSS_INT8_MIN INT8_MIN # define TSS_INT8_MIN INT8_MIN

View File

@ -193,12 +193,15 @@ void cUnixFSServices::GetHostID(TSTRING& name) const
{ {
TOSTRINGSTREAM ret; TOSTRINGSTREAM ret;
ret.setf(ios_base::hex, ios_base::basefield); ret.setf(std::ios::hex, std::ios::basefield);
#if HAVE_GETHOSTID #if HAVE_GETHOSTID
ret << gethostid(); ret << gethostid();
#else #else
ret << 999999; ret << 999999;
#endif #endif
tss_stream_to_string(ret, name);
} }
// returns "/" for unix and "\\" for win32 // returns "/" for unix and "\\" for win32
@ -610,9 +613,10 @@ bool cUnixFSServices::GetUserName(uid_t user_id, TSTRING& tstrUser) const
else else
{ {
#endif #endif
std::stringstream sstr; TOSTRINGSTREAM sstr;
sstr << user_id; sstr << user_id;
tstrUser = sstr.str(); tss_stream_to_string(sstr, tstrUser);
#if HAVE_PWD_H #if HAVE_PWD_H
} }
#endif #endif
@ -639,9 +643,10 @@ bool cUnixFSServices::GetGroupName(gid_t group_id, TSTRING& tstrGroup) const
else else
{ {
#endif #endif
std::stringstream sstr; TOSTRINGSTREAM sstr;
sstr << group_id; sstr << group_id;
tstrGroup = sstr.str(); tss_stream_to_string(sstr, tstrGroup);
#if !IS_REDOX && HAVE_GRP_H #if !IS_REDOX && HAVE_GRP_H
} }
#endif #endif

View File

@ -125,9 +125,11 @@ TSTRING cFCOPropInt32::AsString() const
//TODO:mdb -- implement this through twlocale! //TODO:mdb -- implement this through twlocale!
// //
TOSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
ostr.imbue(std::locale::classic()); tss_classic_locale(ostr);
ostr << mValue; ostr << mValue;
return TSTRING(ostr.str()); tss_mkstr(out, ostr);
return out;
} }
iFCOProp::CmpResult cFCOPropInt32::Compare(const iFCOProp* rhs, iFCOProp::Op op) const 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! //TODO:mdb -- implement this through twlocale!
// //
TOSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
ostr.imbue(std::locale::classic()); tss_classic_locale(ostr);
ostr << (int32_t)mValue; // TODO: remove this cast where possible 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 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! //TODO:mdb -- implement this through twlocale!
// //
TOSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
ostr.imbue(std::locale::classic()); tss_classic_locale(ostr);
ostr << (int32_t)mValue; // TODO: remove this cast where possible 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 iFCOProp::CmpResult cFCOPropUint64::Compare(const iFCOProp* rhs, iFCOProp::Op op) const

View File

@ -450,6 +450,7 @@ void cFCOPropVector::TraceContents(int dl) const
if (ContainsItem(i)) if (ContainsItem(i))
ostr << i << _T(", "); 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());
} }

View File

@ -113,10 +113,11 @@ void cFCOSpecStopPointSet::SetStartPoint(const cFCOName& startPoint)
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << "Bad start point [" << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(startPoint) str << "Bad start point [" << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(startPoint)
<< "] added to spec with stop point " << "] added to spec with stop point "
<< iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(*i) << std::ends; << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(*i);
tss_mkstr(errText, str);
d.TraceError("%s\n", str.str().c_str());
throw eSerializerInputStreamFmt(str.str().c_str()); d.TraceError("%s\n", errText.c_str());
throw eSerializerInputStreamFmt(errText);
} }
} }
@ -178,10 +179,12 @@ void cFCOSpecStopPointSet::Add(const cFCOName& name)
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << "Attempt to add stop point that is not below start point!" str << "Attempt to add stop point that is not below start point!"
<< " start point = " << iTWFactory::GetInstance()->GetNameTranslator()->ToStringDisplay(mStartPoint) << " 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()); tss_mkstr(errText, str);
throw eSerializerInputStreamFmt(str.str().c_str());
d.TraceError(_T("%s\n"), errText.c_str());
throw eSerializerInputStreamFmt(errText);
} }
std::set<cFCOName>::iterator i; std::set<cFCOName>::iterator i;

View File

@ -342,14 +342,14 @@ TSTRING cChecksumSignature::AsString() const
TSTRING cChecksumSignature::AsStringHex() const TSTRING cChecksumSignature::AsStringHex() const
{ {
TOSTRINGSTREAM ss; TOSTRINGSTREAM ss;
tss_classic_locale(ss);
ss.imbue(std::locale::classic()); ss.setf(std::ios::hex, std::ios::basefield);
ss.setf(ios::hex, ios::basefield);
ASSERT(false); ASSERT(false);
ss << (size_t)(uint32_t)mChecksum; // TODO:BAM -- this is truncating a 64-bit value to 32 bits! 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 bool cChecksumSignature::IsEqual(const iSignature& rhs) const
@ -431,13 +431,13 @@ TSTRING cCRC32Signature::AsString() const
TSTRING cCRC32Signature::AsStringHex() const TSTRING cCRC32Signature::AsStringHex() const
{ {
TOSTRINGSTREAM ss; TOSTRINGSTREAM ss;
tss_classic_locale(ss);
ss.imbue(std::locale::classic()); ss.setf(std::ios::hex, std::ios::basefield);
ss.setf(ios::hex, ios::basefield);
ss << (size_t)mCRCInfo.crc; ss << (size_t)mCRCInfo.crc;
tss_mkstr(out, ss);
return ss.str();
return out;
} }
bool cCRC32Signature::IsEqual(const iSignature& rhs) const bool cCRC32Signature::IsEqual(const iSignature& rhs) const

View File

@ -171,7 +171,10 @@ TSTRING& cFSPropDisplayer::GetDetailsHeader(TSTRING& strBuf, int iMargin) const
static cFSPropSet set; static cFSPropSet set;
TOSTRINGSTREAM sstr; TOSTRINGSTREAM sstr;
#if !ARCHAIC_STL
sstr << std::left; sstr << std::left;
#endif
sstr << _T(" ") << std::setw(PROP_MODE_WIDTH) << set.GetPropName(cFSPropSet::PROP_MODE); 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_OWNER_WIDTH) << set.GetPropName(cFSPropSet::PROP_UID);
sstr << _T(" ") << std::setw(PROP_SIZE_WIDTH) << set.GetPropName(cFSPropSet::PROP_SIZE); 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_SIZE_WIDTH) << _T("----------");
sstr << _T(" ") << std::setw(PROP_MTIME_WIDTH) << _T("----------"); sstr << _T(" ") << std::setw(PROP_MTIME_WIDTH) << _T("----------");
strBuf = sstr.str(); tss_stream_to_string(sstr, strBuf);
return strBuf; return strBuf;
} }
@ -204,8 +207,10 @@ TSTRING& cFSPropDisplayer::GetDetails(const iFCO* const pfco, TSTRING& strBuf) c
TOSTRINGSTREAM sstr; TOSTRINGSTREAM sstr;
const cFCOPropVector pv = pfco->GetPropSet()->GetValidVector(); const cFCOPropVector pv = pfco->GetPropSet()->GetValidVector();
#if !ARCHAIC_STL
sstr << std::left; sstr << std::left;
#endif
sstr << _T(" ") << std::setw(PROP_MODE_WIDTH); sstr << _T(" ") << std::setw(PROP_MODE_WIDTH);
if (pv.ContainsItem(cFSPropSet::PROP_MODE)) if (pv.ContainsItem(cFSPropSet::PROP_MODE))
sstr << PropAsString(pfco, cFSPropSet::PROP_MODE).c_str(); sstr << PropAsString(pfco, cFSPropSet::PROP_MODE).c_str();
@ -230,7 +235,7 @@ TSTRING& cFSPropDisplayer::GetDetails(const iFCO* const pfco, TSTRING& strBuf) c
else else
sstr << _T("XXXXXXXXXXXXXXXXX"); sstr << _T("XXXXXXXXXXXXXXXXX");
strBuf = sstr.str(); tss_stream_to_string(sstr, strBuf);
return strBuf; return strBuf;
} }
@ -359,10 +364,10 @@ TSTRING cFSPropDisplayer::PropAsString(const iFCO* const pFCO, const int propIdx
ASSERT(pTypedProp != 0); ASSERT(pTypedProp != 0);
if (GetUsername(pTypedProp->GetValue(), strProp)) if (GetUsername(pTypedProp->GetValue(), strProp))
{ {
TSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
//TODO: can we get rid of this cast now? //TODO: can we get rid of this cast now?
ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")"); ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")");
strProp = ostr.str(); tss_stream_to_string(ostr, strProp);
} }
else else
strProp = pProp->AsString(); strProp = pProp->AsString();
@ -374,10 +379,10 @@ TSTRING cFSPropDisplayer::PropAsString(const iFCO* const pFCO, const int propIdx
ASSERT(pTypedProp != 0); ASSERT(pTypedProp != 0);
if (GetGroupname(pTypedProp->GetValue(), strProp)) if (GetGroupname(pTypedProp->GetValue(), strProp))
{ {
TSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
//TODO: can we get rid of this cast now? //TODO: can we get rid of this cast now?
ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")"); ostr << strProp << _T(" (") << (int32_t)pTypedProp->GetValue() << _T(")");
strProp = ostr.str(); tss_stream_to_string(ostr, strProp);
} }
else else
strProp = pProp->AsString(); strProp = pProp->AsString();

View File

@ -110,7 +110,9 @@ void cFSPropSet::TraceContents(int dl) const
<< _T(", "); << _T(", ");
} }
} }
d.Trace(dl, _T("%s\n"), ostr.str().c_str());
tss_mkstr(out, ostr);
d.Trace(dl, _T("%s\n"), out.c_str());
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -176,7 +176,12 @@ bool cMailMessage::GetAttachmentsAsString(std::string& s)
std::string cMailMessage::Create822Header() std::string cMailMessage::Create822Header()
{ {
#if !ARCHAIC_STL
std::ostringstream ss; std::ostringstream ss;
#else
strstream ss;
#endif
std::string strToList; std::string strToList;
for (std::vector<TSTRING>::size_type i = 0; i < mvstrRecipients.size(); i++) 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) static std::string EncodeChar(char ch)
{ {
std::ostringstream ss; TOSTRINGSTREAM ss;
tss_classic_locale(ss);
ss.imbue(std::locale::classic()); ss.setf(std::ios::hex, std::ios::basefield);
ss.fill('0'); ss.fill('0');
ss.setf(std::ios_base::hex, std::ios_base::basefield);
ss.width(2); ss.width(2);
ss << (unsigned int)(unsigned char)ch; ss << (unsigned int)(unsigned char)ch;
tss_end(ss);
ASSERT(ss.str().length() == 2); ASSERT(ss.str().length() == 2);
// Make sure the hex is uppercase // Make sure the hex is uppercase
std::string s = ss.str(); std::string s = ss.str();
tss_free(ss);
std::transform(s.begin(), s.end(), s.begin(), toupper); std::transform(s.begin(), s.end(), s.begin(), toupper);
return s; return s;

View File

@ -36,7 +36,11 @@
#include "tw/twutil.h" #include "tw/twutil.h"
#include "tripwirestrings.h" #include "tripwirestrings.h"
#include "core/stringutil.h" #include "core/stringutil.h"
#if HAVE_SSTREAM
#include <sstream> #include <sstream>
#elif HAVE_STRSTREAM
#include <strstream>
#endif
#include "core/file.h" #include "core/file.h"
#include <time.h> #include <time.h>
@ -201,8 +205,10 @@ bool cSMTPMailMessage::OpenConnection()
TOSTRINGSTREAM estr; TOSTRINGSTREAM estr;
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName;
throw eMailSMTPIPUnresolvable(estr.str()); tss_mkstr(errStr, estr);
return false;
throw eMailSMTPIPUnresolvable(errStr);
return false;
} }
// Create the socket // Create the socket
@ -223,7 +229,9 @@ bool cSMTPMailMessage::OpenConnection()
TOSTRINGSTREAM estr; TOSTRINGSTREAM estr;
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER) << mstrServerName;
throw eMailSMTPOpenConnection(estr.str()); tss_mkstr(errStr, estr);
throw eMailSMTPOpenConnection(errStr);
return false; return false;
} }
@ -303,7 +311,12 @@ bool cSMTPMailMessage::MailMessage()
// mpfnGethostname (see below). It won't be used // mpfnGethostname (see below). It won't be used
// after that. // after that.
#if !ARCHAIC_STL
std::ostringstream strmSend; std::ostringstream strmSend;
#else
strstream strmSend;
#endif
// This should be a stream object, so we don't have // This should be a stream object, so we don't have
// to use nasty calls to sprintf that might overflow // to use nasty calls to sprintf that might overflow
// the buffer. Before, we used a fixed buffer of 512 // the buffer. Before, we used a fixed buffer of 512
@ -325,21 +338,33 @@ bool cSMTPMailMessage::MailMessage()
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Say hello // 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. strmSend << "HELO " << sLocalHost << "\r\n"; //Fill the stream buffer.
SendString(strmSend.str()); SendString(strmSend.str());
if (!GetAcknowledgement()) if (!GetAcknowledgement())
return false; return false;
#if !ARCHAIC_STL
strmSend.str(""); //Clear the stream buffer. strmSend.str(""); //Clear the stream buffer.
#else
// TODO
#endif
strmSend << "MAIL FROM:<" << cStringUtil::TstrToStr(mstrFrom) << ">\r\n"; strmSend << "MAIL FROM:<" << cStringUtil::TstrToStr(mstrFrom) << ">\r\n";
SendString(strmSend.str()); SendString(strmSend.str());
if (!GetAcknowledgement()) if (!GetAcknowledgement())
return false; return false;
// Say who all we're sending to // Say who all we're sending to
#if !ARCHAIC_STL
strmSend.str(""); //Clear the stream buffer. strmSend.str(""); //Clear the stream buffer.
#else
// TODO
#endif
for (std::vector<TSTRING>::size_type i = 0; i < mvstrRecipients.size(); i++) for (std::vector<TSTRING>::size_type i = 0; i < mvstrRecipients.size(); i++)
{ {
sNarrowString = cStringUtil::TstrToStr(mvstrRecipients[i]); sNarrowString = cStringUtil::TstrToStr(mvstrRecipients[i]);
@ -364,8 +389,14 @@ bool cSMTPMailMessage::MailMessage()
// Send Header // Send Header
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// set up header // set up header
#if !ARCHAIC_STL
strmSend.str(""); strmSend.str("");
#else
// TODO
#endif
strmSend << cMailMessage::Create822Header(); strmSend << cMailMessage::Create822Header();
SendString(strmSend.str()); SendString(strmSend.str());
@ -499,7 +530,9 @@ bool cSMTPMailMessage::GetAcknowledgement()
TOSTRINGSTREAM estr; TOSTRINGSTREAM estr;
estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_SERVER_RETURNED_ERROR) << sRecvString; 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; return false;
} }
} }

View File

@ -277,7 +277,11 @@ static void util_InitTempDirectory(const cConfigFile& cf)
// //
if (*temp_directory.rbegin() != '/') if (*temp_directory.rbegin() != '/')
{ {
#if !ARCHAIC_STL
temp_directory.push_back('/'); temp_directory.push_back('/');
#else
temp_directory.append("/");
#endif
} }
#endif #endif
@ -1140,8 +1144,10 @@ int cTWModeIC::Execute(cErrorQueue* pQueue)
// TODO -- move these strings to the string table // TODO -- move these strings to the string table
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator() str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator()
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName << std::ends; << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName;
cTWUtil::PrintErrorMsg(eICDifferentUsers(str.str(), eError::NON_FATAL)); 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 // TODO -- move these strings to the string table
TOSTRINGSTREAM str; TOSTRINGSTREAM str;
str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator() str << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS1) << dbFile.GetHeader().GetCreator()
<< TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName << std::ends; << TSS_GetString(cTripwire, tripwire::STR_ERR2_DIFFERENT_USERS2) << userName;
cTWUtil::PrintErrorMsg(eICDifferentUsers(str.str(), eError::NON_FATAL)); tss_mkstr(errStr, str);
cTWUtil::PrintErrorMsg(eICDifferentUsers(errStr, eError::NON_FATAL));
} }
} }

View File

@ -104,7 +104,13 @@ void cTWCmdLineUtil::ParsePolicyFile(cGenreSpecListVector& genreSpecList,
cDisplayEncoder::EncodeInline(fileName).c_str()); cDisplayEncoder::EncodeInline(fileName).c_str());
// set up parser and parser policy file // set up parser and parser policy file
#if !ARCHAIC_STL
std::istringstream in(strPolicyText); std::istringstream in(strPolicyText);
#else
strstream in;
in << strPolicyText;
#endif
cPolicyParser parser(in); cPolicyParser parser(in);
parser.Execute(genreSpecList, pQueue); parser.Execute(genreSpecList, pQueue);
} }
@ -549,6 +555,7 @@ static bool EmailReportTo(const TSTRING& toAddress,
const cTWModeCommon* modeCommon, const cTWModeCommon* modeCommon,
const bool bForceFullReport) const bool bForceFullReport)
{ {
#if !ARCHAIC_STL
TW_UNIQUE_PTR<cMailMessage> reportMail; TW_UNIQUE_PTR<cMailMessage> reportMail;
// allocate the right kind of emailer object based on what came out of the config file. // 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 #if SUPPORTS_NETWORKING
case cMailMessage::MAIL_BY_SMTP: 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; break;
#endif #endif
case cMailMessage::MAIL_BY_PIPE: case cMailMessage::MAIL_BY_PIPE:
reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram)); reportMail = TW_UNIQUE_PTR<cMailMessage>(new cPipedMailMessage(modeCommon->mMailProgram));
break; break;
default: default:
return false; return false;
} }
@ -629,6 +637,9 @@ static bool EmailReportTo(const TSTRING& toAddress,
} }
return true; 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) bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING& mAddress, const cTWModeCommon* modeCommon)
{ {
#if !ARCHAIC_STL
TW_UNIQUE_PTR<cMailMessage> reportMail; TW_UNIQUE_PTR<cMailMessage> reportMail;
// allocate the right kind of emailer object based on what came out of the config file. // 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; return true;
#else
return false;
#endif
} }

View File

@ -193,9 +193,7 @@ void cConfigFile::WriteString(TSTRING& configText) // throw( eFSServices )
out << sKey << _T("=") << sVal << _T("\n"); out << sKey << _T("=") << sVal << _T("\n");
} }
configText = out.str(); tss_stream_to_string(out, configText);
return;
} }
void cConfigFile::ReadString(const TSTRING configText) // throw( eConfigFile ); 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; strErr << TSS_GetString(cTW, tw::STR_CUR_LINE) << mnLine;
} }
return strErr.str(); tss_mkstr(out, strErr);
return out;
} }
TSTRING& util_MakeTripwireDateString(TSTRING& strBuf) TSTRING& util_MakeTripwireDateString(TSTRING& strBuf)
{ {
struct tm* ptmLocal = cTimeUtil::TimeToDateLocal(cSystemInfo::GetExeStartTime()); struct tm* ptmLocal = cTimeUtil::TimeToDateLocal(cSystemInfo::GetExeStartTime());
TOSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
ostr.imbue(std::locale::classic()); tss_classic_locale(ostr);
// format is YYYYMMDD-HHMMSS // format is YYYYMMDD-HHMMSS
ostr.fill(_T('0')); ostr.fill(_T('0'));
ostr << std::setw(4) << ptmLocal->tm_year + 1900; 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_min;
ostr << std::setw(2) << ptmLocal->tm_sec; ostr << std::setw(2) << ptmLocal->tm_sec;
strBuf = ostr.str(); tss_stream_to_string(ostr, strBuf);
return strBuf; return strBuf;
} }

View File

@ -112,7 +112,12 @@ static const TCHAR* g_sz79Equals =
// UTIL FUNCTION PROTOTYES // UTIL FUNCTION PROTOTYES
//========================================================================= //=========================================================================
#if !ARCHAIC_STL
static void OpenOutputFile(fixed_basic_ofstream<TCHAR>& out, const TSTRING& strFile); // throw( eTextReportViewer ) 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 void OpenInputFile(std::ifstream& out, const TSTRING& strFile); // throw( eTextReportViewer )
static bool PrintableProp(const iFCO* pfcoOld, const iFCO* pfcoNew, int j); static bool PrintableProp(const iFCO* pfcoOld, const iFCO* pfcoNew, int j);
@ -277,7 +282,11 @@ void cTextReportViewer::PrintTextReport(const TSTRING& strFilename, ReportingLev
} }
else else
{ {
#if !ARCHAIC_STL
fixed_basic_ofstream<TCHAR> out; fixed_basic_ofstream<TCHAR> out;
#else
ofstream out;
#endif
OpenOutputFile(out, strFilename); OpenOutputFile(out, strFilename);
mpOut = &out; mpOut = &out;
OutputTextReport(); OutputTextReport();
@ -738,8 +747,10 @@ void cTextReportViewer::ReportError(const cErrorQueueIter& eqIter)
// output error number // output error number
TOSTRINGSTREAM ostr; TOSTRINGSTREAM ostr;
ostr << mErrorNum << _T("."); ostr << mErrorNum << _T(".");
tss_mkstr(numStr, ostr);
(*mpOut).width(nWidth); (*mpOut).width(nWidth);
(*mpOut) << ostr.str(); (*mpOut) << numStr;
// output general error // output general error
(*mpOut) << cErrorTable::GetInstance()->Get(eqIter.GetError().GetID()) << endl; (*mpOut) << cErrorTable::GetInstance()->Get(eqIter.GetError().GetID()) << endl;
@ -923,7 +934,11 @@ TSTRING cTextReportViewer::GetGenre()
bool cTextReportViewer::PeekIsEOF() bool cTextReportViewer::PeekIsEOF()
{ {
#if !ARCHAIC_STL
return (mpIn->peek() == char_traits<char>::eof()); 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 // 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; 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->mAddedObjects += newLine.mAddedObjects;
si->mRemovedObjects += newLine.mRemovedObjects; 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. // 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. // 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 (newLine.mStartPoint.length() <= si->mStartPoint.length())
{
#if !ARCHAIC_STL
if (newLine.mStartPoint.compare(0, newLine.mStartPoint.length(), si->mStartPoint) == 0) 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(); si->mStartPoint.erase();
}
}
#if !ARCHAIC_STL
else if (si->mStartPoint.compare(0, si->mStartPoint.length(), newLine.mStartPoint) == 0) 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 else
{
si->mStartPoint.erase(); si->mStartPoint.erase();
}
break; 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 ) 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); 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_REMOVED_SHORT) << _T(":") << nRemovedTotal;
sstrReport << _T(" ") << TSS_GetString(cTW, tw::STR_CHANGED_SHORT) << _T(":") << nChangedTotal; 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() char cTextReportViewer::PeekChar()
{ {
#if !ARCHAIC_STL
return char_traits<char>::to_char_type(mpIn->peek()); 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++) for (uint32_t i = 0; i < sizeof(mCurrentChar); i++)
mCurrentChar[i] = 0; 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()); 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(); std::streampos pos = mpIn->tellg();
for (size_t nch = 0; nch < (size_t)MB_CUR_MAX; nch++) 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")); d.TraceDebug(_T("Found EOF\n"));
#if !ARCHAIC_STL
mCurrentChar[0] = eof; mCurrentChar[0] = eof;
#else
mCurrentChar[0] = EOF;
#endif
mCurrentCharSize = 1; mCurrentCharSize = 1;
return; return;
@ -2030,8 +2079,11 @@ void cTextReportViewer::GetChar()
} }
// get character from input stream // get character from input stream
#if !ARCHAIC_STL
std::istream::char_type ch = std::char_traits<char>::to_char_type(mpIn->get()); 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 // add character to mb buffer
mCurrentChar[nch] = ch; mCurrentChar[nch] = ch;
mCurrentCharSize++; mCurrentCharSize++;
@ -2050,7 +2102,13 @@ void cTextReportViewer::GetChar()
} }
mpIn->seekg(pos); mpIn->seekg(pos);
#if !ARCHAIC_STL
std::istream::char_type c = std::char_traits<char>::to_char_type(mpIn->get()); 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) if ((unsigned char)c > 0x7f)
{ {
mCurrentChar[0] = c; mCurrentChar[0] = c;

View File

@ -661,7 +661,11 @@ void cTWUtil::ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchiv
throw eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE); throw eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE);
// check 8 byte header // check 8 byte header
#if !ARCHAIC_STL
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), CONFIG_FILE_MAGIC_8BYTE) != 0) 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)); ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
// remove 8 byte header // 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); ReadObject(filename, NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted);
// check 8 byte header // check 8 byte header
#if !ARCHAIC_STL
if (nstring.mString.compare(0, 8 * sizeof(uint8_t), POLICY_FILE_MAGIC_8BYTE) != 0) 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)); ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename, eSerializer::TY_FILE));
// remove 8 byte header // 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++) for (x = 0; s[x] && iswctype(s[x], wctype("space")); x++)
; ;
#else #else
#if !ARCHAIC_STL
for (x = 0; s[x] && std::isspace<TCHAR>(s[x], std::locale()); x++) 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 #endif

View File

@ -646,7 +646,13 @@ int cTWAModeCreatePol::Execute(cErrorQueue* pQueue)
// //
// make sure the policy file parses correctly before we update the old one // make sure the policy file parses correctly before we update the old one
// //
#if !ARCHAIC_STL
std::istringstream in(plaintext); std::istringstream in(plaintext);
#else
strstream in;
in << plaintext;
#endif
cPolicyParser parser(in); cPolicyParser parser(in);
try try
{ {

View File

@ -488,14 +488,16 @@ void cRSAPublicKey::TraceContents()
cDebug d("cRSAPublicKey::TraceContents"); cDebug d("cRSAPublicKey::TraceContents");
{ {
std::ostringstream os; TOSTRINGSTREAM os;
os << mpData->mpKey->GetTrapdoorFunction().GetModulus(); 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(); 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 # endif
@ -968,24 +970,28 @@ void cElGamalSigPublicKey::TraceContents()
cDebug d("cElGamalSigPublicKey::TraceContents"); cDebug d("cElGamalSigPublicKey::TraceContents");
{ {
std::ostringstream os; TOSTRINGSTREAM os;
os << mpData->mpKey->GetPrime(); 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(); 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(); 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(); 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 #endif

View File

@ -113,7 +113,9 @@ eParserHelper::eParserHelper(const TSTRING& strMsg, int nLine /*= CURRENT_LINE *
strErr << nLine; strErr << nLine;
} }
tss_end(strErr);
mMsg = strErr.str(); mMsg = strErr.str();
tss_free(strErr);
} }
@ -455,9 +457,13 @@ void cParserUtil::InterpretEscapedString(const std::string& strEscapedString, TS
pchCur++; // go to char past '\' pchCur++; // go to char past '\'
if (*pchCur == 'x' && if (*pchCur == 'x' &&
#if !ARCHAIC_STL
std::isxdigit<TCHAR>( std::isxdigit<TCHAR>(
*(pchCur + 1), *(pchCur + 1),
std::locale())) // deal with \xXXXX where 'x' is the character 'x', and 'X' is a hex number 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' pchCur++; // go to char past 'x'
char cEscapedChar = static_cast<char>(util_ConvertHex(pchCur, &nCharsRead)); 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(util_AsciiCharsActLikeTheyShould());
ASSERT(cpsz && pnCharsRead); ASSERT(cpsz && pnCharsRead);
#if !ARCHAIC_STL
if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale())) if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale()))
#else
if (*cpsz == 0 || !isxdigit(*cpsz))
#endif
throw eParserBadHex(cStringUtil::StrToTstr(cpsz)); throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
int iValue; int iValue;
const char* psz = cpsz; const char* psz = cpsz;
#if !ARCHAIC_STL
for (*pnCharsRead = 0, iValue = 0; *psz && std::isxdigit<TCHAR>(*psz, std::locale()) && (*pnCharsRead < 2); for (*pnCharsRead = 0, iValue = 0; *psz && std::isxdigit<TCHAR>(*psz, std::locale()) && (*pnCharsRead < 2);
psz++, (*pnCharsRead)++) psz++, (*pnCharsRead)++)
#else
for (*pnCharsRead = 0, iValue = 0; *psz && isxdigit(*psz) && (*pnCharsRead < 2);
psz++, (*pnCharsRead)++)
#endif
{ {
iValue *= 0x10; iValue *= 0x10;
#if !ARCHAIC_STL
if (std::isdigit<TCHAR>(*psz, std::locale())) if (std::isdigit<TCHAR>(*psz, std::locale()))
#else
if (isdigit(*psz))
#endif
{ {
iValue += (*psz - '0'); iValue += (*psz - '0');
} }
else else
{ {
#if !ARCHAIC_STL
if (std::islower<TCHAR>(*psz, std::locale())) if (std::islower<TCHAR>(*psz, std::locale()))
#else
if (islower(*psz))
#endif
iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15 iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15
else // is uppercase else // is uppercase
iValue += (*psz - 'A' + 10); // so that a=10, a=11, ..., f=15 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(util_AsciiCharsActLikeTheyShould());
ASSERT(cpsz && pnCharsRead); ASSERT(cpsz && pnCharsRead);
#if !ARCHAIC_STL
if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale())) if (*cpsz == 0 || !std::isxdigit<TCHAR>(*cpsz, std::locale()))
#else
if (*cpsz == 0 || !isxdigit(*cpsz))
#endif
throw eParserBadHex(cStringUtil::StrToTstr(cpsz)); throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
int iValue; int iValue;
const char* psz = cpsz; const char* psz = cpsz;
for (*pnCharsRead = 0, iValue = 0; *pnCharsRead < 4; psz++, (*pnCharsRead)++) for (*pnCharsRead = 0, iValue = 0; *pnCharsRead < 4; psz++, (*pnCharsRead)++)
{ {
// we require 4 chars for unicode escapes // we require 4 chars for unicode escapes
#if !ARCHAIC_STL
if (*psz == 0 || !std::isxdigit<TCHAR>(*psz, std::locale())) if (*psz == 0 || !std::isxdigit<TCHAR>(*psz, std::locale()))
#else
if (*psz == 0 || !isxdigit(*psz))
#endif
throw eParserBadHex(cStringUtil::StrToTstr(cpsz)); throw eParserBadHex(cStringUtil::StrToTstr(cpsz));
iValue *= 0x10; iValue *= 0x10;
#if !ARCHAIC_STL
if (std::isdigit<TCHAR>(*psz, std::locale())) if (std::isdigit<TCHAR>(*psz, std::locale()))
#else
if (isdigit(*psz))
#endif
{ {
iValue += (*psz - '0'); iValue += (*psz - '0');
} }
else else
{ {
#if !ARCHAIC_STL
if (std::islower<TCHAR>(*psz, std::locale())) if (std::islower<TCHAR>(*psz, std::locale()))
#else
if (islower(*psz))
#endif
iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15 iValue += (*psz - 'a' + 10); // so that A=10, B=11, ..., F=15
else // is uppercase else // is uppercase
iValue += (*psz - 'A' + 10); // so that a=10, a=11, ..., f=15 iValue += (*psz - 'A' + 10); // so that a=10, a=11, ..., f=15

View File

@ -85,7 +85,9 @@ void tw_yy_scan::output(int c)
sz[1] = 0; sz[1] = 0;
sstr << sz; 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::Init(pError);
cParserHelper::SetParseOnly(true); cParserHelper::SetParseOnly(true);
std::basic_stringstream<char> in(ConvertMultibyte(mIn)); #if !ARCHAIC_STL
tw_yy_scan lexer(in); TISTRINGSTREAM in(ConvertMultibyte(mIn));
#else
TSTRINGSTREAM in;
in << ConvertMultibyte(mIn);
#endif
tw_yy_scan lexer(in);
// start the parsing // start the parsing
if (mParser.yyparse(&lexer) != 0) if (mParser.yyparse(&lexer) != 0)
@ -119,8 +127,14 @@ void cPolicyParser::Execute(cGenreSpecListVector& policy, cErrorBucket* pError)
{ {
cParserHelper::Init(pError); cParserHelper::Init(pError);
std::basic_stringstream<char> in(ConvertMultibyte(mIn)); #if !ARCHAIC_STL
tw_yy_scan lexer(in); TISTRINGSTREAM in(ConvertMultibyte(mIn));
#else
TSTRINGSTREAM in;
in << ConvertMultibyte(mIn);
#endif
tw_yy_scan lexer(in);
// start the parsing // start the parsing
if (mParser.yyparse(&lexer) != 0) 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 // Parser will ALWAYS call the narrow-char version, so special case Unicode compile
void tw_yy_scan::yyerror(const char* pszErr, ...) //throw( eParserHelper ) void tw_yy_scan::yyerror(const char* pszErr, ...) //throw( eParserHelper )
{ {
#if 0
TOSTRINGSTREAM ssError; // final error string TOSTRINGSTREAM ssError; // final error string
ssError << pszErr; ssError << pszErr;
throw eParseFailed(ssError.str());
throw eParseFailed(ssError.str()); #endif
TSTRING errText = pszErr ? pszErr : "";
throw eParseFailed(errText);
} }
// Throw this in the display encoder? // Throw this in the display encoder?
std::string cPolicyParser::ConvertMultibyte(std::istream& in) std::string cPolicyParser::ConvertMultibyte(std::istream& in)
{ {
// get this file as a stringstream // get this file as a stringstream
std::stringstream ss; TOSTRINGSTREAM ss;
while (true) while (true)
{ {
@ -168,6 +186,8 @@ std::string cPolicyParser::ConvertMultibyte(std::istream& in)
throw eParserBadCharacter(); throw eParserBadCharacter();
} }
tss_end(ss);
#ifdef DEBUG #ifdef DEBUG
TCERR << _T("*** begin policy text ***") << std::endl; TCERR << _T("*** begin policy text ***") << std::endl;
std::cerr << ss.str() << 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 // convert it to single byte escaped
std::string str = util_ConvertMB(ss.str()); std::string str = util_ConvertMB(ss.str());
tss_free(ss);
#ifdef DEBUG #ifdef DEBUG
TCERR << _T("*** begin policy converted to ***") << std::endl; TCERR << _T("*** begin policy converted to ***") << std::endl;
std::cerr << str << 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::string convert_to_encoded_hex(char ch)
{ {
std::basic_stringstream<char> sstr; TOSTRINGSTREAM sstr;
// set up stringstream // set up stringstream
sstr.imbue(std::locale::classic()); tss_classic_locale(sstr);
sstr.setf(std::ios_base::hex, std::ios_base::basefield); sstr.setf(std::ios::hex, std::ios::basefield);
#if !ARCHAIC_STL
// get the num_put facet // get the num_put facet
const std::num_put<char>*pnp = 0, &np = tss::GetFacet(sstr.getloc(), pnp); const std::num_put<char>*pnp = 0, &np = tss::GetFacet(sstr.getloc(), pnp);
// output the char // output the char
sstr << "\\x"; sstr << "\\x";
np.put(sstr, sstr, sstr.fill(), (long)(unsigned char)ch); np.put(sstr, sstr, sstr.fill(), (long)(unsigned char)ch);
#else
sstr << "\\x" << ch;
#endif
return sstr.str(); tss_return_stream(sstr, out);
} }

View File

@ -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 // we do it here as well, I suppose that's OK. This should be eventually
// corrected. // corrected.
std::ostringstream ssErr; TOSTRINGSTREAM ssErr;
ssErr << "Syntax error: \'" << ch << "\'"; ssErr << "Syntax error: \'" << ch << "\'";
if( pszAdditionalMsg ) if( pszAdditionalMsg )
ssErr << ", " << pszAdditionalMsg; ssErr << ", " << pszAdditionalMsg;
return ssErr.str(); tss_return_stream(ssErr, out);
} }
// saves typing // saves typing

View File

@ -48,8 +48,10 @@ static void PrintPropVector(const cFCOPropVector& v, cDebug& d)
stream << i << "," 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() void TestFSPropSet()

View File

@ -76,17 +76,17 @@ void TestGenreSpecList()
gslVector.push_back(gslPair2); gslVector.push_back(gslPair2);
gslVector.push_back(gslPair3); gslVector.push_back(gslPair3);
TEST(gslVector.at(0).GetGenre() == gslPair.GetGenre()); TEST(gslVector[0].GetGenre() == gslPair.GetGenre());
TEST(gslVector.at(0).GetSpecList().Lookup(fsSpec) != 0); TEST(gslVector[0].GetSpecList().Lookup(fsSpec) != 0);
TEST(gslVector.at(0).GetSpecList().Lookup(fsSpec)->GetName() == gslPair.GetSpecList().Lookup(fsSpec)->GetName()); TEST(gslVector[0].GetSpecList().Lookup(fsSpec)->GetName() == gslPair.GetSpecList().Lookup(fsSpec)->GetName());
TEST(gslVector.at(1).GetGenre() == gslPair2.GetGenre()); TEST(gslVector[1].GetGenre() == gslPair2.GetGenre());
TEST(gslVector.at(1).GetSpecList().Lookup(fsSpec) != 0); TEST(gslVector[1].GetSpecList().Lookup(fsSpec) != 0);
TEST(gslVector.at(1).GetSpecList().Lookup(fsSpec)->GetName() == gslPair2.GetSpecList().Lookup(fsSpec)->GetName()); TEST(gslVector[1].GetSpecList().Lookup(fsSpec)->GetName() == gslPair2.GetSpecList().Lookup(fsSpec)->GetName());
TEST(gslVector.at(2).GetGenre() == gslPair3.GetGenre()); TEST(gslVector[2].GetGenre() == gslPair3.GetGenre());
TEST(gslVector.at(2).GetSpecList().Lookup(fsSpec) != 0); TEST(gslVector[2].GetSpecList().Lookup(fsSpec) != 0);
TEST(gslVector.at(2).GetSpecList().Lookup(fsSpec)->GetName() == gslPair3.GetSpecList().Lookup(fsSpec)->GetName()); TEST(gslVector[2].GetSpecList().Lookup(fsSpec)->GetName() == gslPair3.GetSpecList().Lookup(fsSpec)->GetName());
d.TraceDebug("All tests passed.\n"); d.TraceDebug("All tests passed.\n");
} }

View File

@ -197,6 +197,7 @@ void TestAlignment2()
TEST("BYTE_ALIGN ok"); // yet again, the test is not falling over a couple of lines up. */ 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 // Not sure this is a super valuable test, since it just verifies that builtin integer types
// work the way we think they do. // work the way we think they do.
void TestSizes() void TestSizes()
@ -231,12 +232,14 @@ template<class E, class T> bool CanBeRepresentedAs(E e, T t)
return fReturn; return fReturn;
} }
#endif
//////////////////////////// ////////////////////////////
void RegisterSuite_Platform() void RegisterSuite_Platform()
{ {
RegisterTest("Platform", "Alignment", TestAlignment); RegisterTest("Platform", "Alignment", TestAlignment);
RegisterTest("Platform", "Alignment2", TestAlignment2); RegisterTest("Platform", "Alignment2", TestAlignment2);
#if !ARCHAIC_STL
RegisterTest("Platform", "Sizes", TestSizes); RegisterTest("Platform", "Sizes", TestSizes);
#endif
} }

View File

@ -41,6 +41,9 @@
#ifndef __STRINGUTIL_T_H #ifndef __STRINGUTIL_T_H
# define __STRINGUTIL_T_H # define __STRINGUTIL_T_H
#include "core/platform.h"
#include "core/tchar.h"
#include "core/ntmbs.h" #include "core/ntmbs.h"
#include "core/ntdbs.h" #include "core/ntdbs.h"
@ -81,7 +84,9 @@ inline void TestStringUtil()
TEST(b.size() == 0); TEST(b.size() == 0);
a.resize(3); a.resize(3);
#if !ARCHAIC_STL
TEST(a.c_str() != b.c_str()); TEST(a.c_str() != b.c_str());
#endif
TEST(std::equal(a.begin(), a.end(), NTDBS1)); TEST(std::equal(a.begin(), a.end(), NTDBS1));
TEST(std::equal(b.begin(), b.end(), NTDBS1)); TEST(std::equal(b.begin(), b.end(), NTDBS1));

View File

@ -74,9 +74,19 @@ void TestTCHAR()
TSTRING test1 = _T("word"); TSTRING test1 = _T("word");
d.TraceDetail("Testing TOSTRINGSTREAM with TSTRING:\n"); d.TraceDetail("Testing TOSTRINGSTREAM with TSTRING:\n");
#if !ARCHAIC_STL
TOSTRINGSTREAM ost(_T("test up")); TOSTRINGSTREAM ost(_T("test up"));
#else
TOSTRINGSTREAM ost;
ost << _T("test up");
#endif
ost << test1; 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... //if this gives output, then I'm really baffled...
//test gets overwritten, yielding "word up" //test gets overwritten, yielding "word up"
@ -89,7 +99,10 @@ void TestTCHAR()
TSTRING send = _T("These should appear on separate lines"); TSTRING send = _T("These should appear on separate lines");
test_wist(send, d); test_wist(send, d);
//Did they? //Did they?
}
void TestFstreams()
{
//Testing file streams //Testing file streams
//explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char* //explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char*
@ -98,16 +111,16 @@ void TestTCHAR()
//Set up the input file. //Set up the input file.
TOFSTREAM out; 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 << "Unicode is fun\n";
out.close(); out.close();
TIFSTREAM from; TIFSTREAM from;
from.open(inputfile.c_str(), std::ios_base::in); from.open(inputfile.c_str(), std::ios::in);
TEST(from); TEST(from);
TOFSTREAM to(outputfile.c_str(), std::ios_base::trunc); TOFSTREAM to(outputfile.c_str(), std::ios::trunc);
TEST(to); TEST(to);
//Copy contents of input file to output file. //Copy contents of input file to output file.
@ -120,9 +133,15 @@ void TestTCHAR()
return; return;
} }
TSTRING test_wost(int n, const TSTRING& inject) TSTRING test_wost(int n, const TSTRING& inject)
{ {
#if !ARCHAIC_STL
TOSTRINGSTREAM wost(_T("Weird how this doesn't show up! ")); 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? //It's getting overwritten, why?
wost << _T("One out of every ") << n << _T(" children loves ") << inject << _T("!\n"); wost << _T("One out of every ") << n << _T(" children loves ") << inject << _T("!\n");
return wost.str(); return wost.str();
@ -130,7 +149,12 @@ TSTRING test_wost(int n, const TSTRING& inject)
void test_wist(const TSTRING& input, cDebug& d) void test_wist(const TSTRING& input, cDebug& d)
{ {
#if !ARCHAIC_STL
TISTRINGSTREAM wist(input); TISTRINGSTREAM wist(input);
#else
TSTRINGSTREAM wist;
wist << input;
#endif
TSTRING parse; TSTRING parse;
while (wist >> parse) while (wist >> parse)
d.TraceDetail("%s \n", parse.c_str()); d.TraceDetail("%s \n", parse.c_str());
@ -139,4 +163,7 @@ void test_wist(const TSTRING& input, cDebug& d)
void RegisterSuite_TCHAR() void RegisterSuite_TCHAR()
{ {
RegisterTest("TCHAR", "Basic", TestTCHAR); RegisterTest("TCHAR", "Basic", TestTCHAR);
#if !ARCHAIC_STL
RegisterTest("TCHAR", "FStreams", TestFstreams);
#endif
} }

View File

@ -216,7 +216,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
{ {
TCERR << "SKIPPED: " << e.what() << std::endl; TCERR << "SKIPPED: " << e.what() << std::endl;
std::stringstream sstr; TSTRINGSTREAM sstr;
sstr << "Test " << suiteName << "/" << testName << ": " << e.what(); sstr << "Test " << suiteName << "/" << testName << ": " << e.what();
skipped_strings.push_back(sstr.str()); skipped_strings.push_back(sstr.str());
@ -227,7 +227,7 @@ static void RunTest(const std::string& suiteName, const std::string& testName, T
TCERR << "FAILED: "; TCERR << "FAILED: ";
cTWUtil::PrintErrorMsg(error); cTWUtil::PrintErrorMsg(error);
std::stringstream sstr; TSTRINGSTREAM sstr;
sstr << "Test " << suiteName << "/" << testName << ": " << error.GetMsg(); sstr << "Test " << suiteName << "/" << testName << ": " << error.GetMsg();
error_strings.push_back(sstr.str()); 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; TCERR << "FAILED: " << e.what() << std::endl;
std::stringstream sstr; TSTRINGSTREAM sstr;
sstr << "Test " << suiteName << "/" << testName << ": " << e.what(); sstr << "Test " << suiteName << "/" << testName << ": " << e.what();
error_strings.push_back(sstr.str()); 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; TCERR << "FAILED: <unknown>" << std::endl;
std::stringstream sstr; TSTRINGSTREAM sstr;
sstr << "Test " << suiteName << "/" << testName << ": <unknown>"; sstr << "Test " << suiteName << "/" << testName << ": <unknown>";
error_strings.push_back(sstr.str()); error_strings.push_back(sstr.str());
@ -395,12 +395,13 @@ std::string TwTestDir()
std::string TwTestPath(const std::string& child) std::string TwTestPath(const std::string& child)
{ {
std::stringstream sstr; TOSTRINGSTREAM sstr;
sstr << TwTestDir(); sstr << TwTestDir();
if (child[0] != '/') if (child[0] != '/')
sstr << '/'; sstr << '/';
sstr << child; sstr << child;
return sstr.str();
tss_return_stream(sstr, out);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -80,6 +80,7 @@ void TestItoa()
cTWLocale::FormatNumber(n, str); cTWLocale::FormatNumber(n, str);
TEST(str == "123456"); TEST(str == "123456");
#if !ARCHAIC_STL
// //
// Try formatting with "" locale // Try formatting with "" locale
// //
@ -93,6 +94,7 @@ void TestItoa()
std::locale::global(std::locale("")); std::locale::global(std::locale(""));
cTWLocale::FormatNumber(n, str); cTWLocale::FormatNumber(n, str);
TEST(str == "123,456"); TEST(str == "123,456");
#endif
} }
catch (const std::runtime_error& e) catch (const std::runtime_error& e)
{ {