Commit 33c61790 authored by Martin Marinov's avatar Martin Marinov
Browse files

Merge remote-tracking branch 'VCI/master' into merge-from-VCI

parents e876c815 c64f3c23
......@@ -18,7 +18,7 @@
#include <sstream>
#include <cstring>
#ifndef WIN32
#if !defined(WIN32) && !defined(_WIN32)
#define sprintf_s snprintf
#endif
......@@ -118,7 +118,10 @@ public:
if (_cnsl)
std::cout << _c; // print on the console
if (_c == '\n')
{
std::cout << std::flush;
line_strt_ = true;
}
}
void line_break(const bool _cnsl = true) { print('\n', _cnsl); }
......@@ -131,7 +134,7 @@ public:
void print(const char* const _s, const bool _cnsl = true)
{
if (_s == nullptr)
if (_s == NULL)
return;
for (int i = 0, c = _s[0]; c != '\0'; c = _s[++i])
print((char)c, _cnsl);
......
......@@ -90,14 +90,14 @@ private:
Type type_;
private:
static const char** descriptions(size_t* _nmbr = nullptr)
static const char** descriptions(size_t* _nmbr = NULL)
{
// There is a long and a short description. The short one is the first letter
// for the long one. For OK it is desirable to have a blank as short description,
// and this is the reason of the extra blank in " OK".
static const char* descr[] =
{ " OK", "WARNING", "ERROR", "FAILURE" , "CRASH", "HANG" };
if (_nmbr != nullptr)
if (_nmbr != NULL)
*_nmbr = std::end(descr) - std::begin(descr);
return descr;
}
......
......@@ -17,7 +17,7 @@ bool variable(const char* _vrbl_name, std::string& _vrbl)
{
#ifdef WIN32 // The Windows implementation uses the secure getenv_s()
size_t char_nmbr;
getenv_s(&char_nmbr, nullptr, 0, _vrbl_name);
getenv_s(&char_nmbr, NULL, 0, _vrbl_name);
if (char_nmbr == 0)
return false;
_vrbl.resize(char_nmbr);
......@@ -36,10 +36,10 @@ bool variable(const char* _vrbl_name, std::string& _vrbl)
LocaleSession::LocaleSession(const char* const _ssn_lcle)
{
lcl_bckp_ = std::locale::global(std::locale(_ssn_lcle));
auto* lcle = ::setlocale(LC_ALL, nullptr);
DEB_error_if(lcle == nullptr,
char* lcle = ::setlocale(LC_ALL, NULL);
DEB_error_if(lcle == NULL,
"std::locale::global() failed to set " << _ssn_lcle);
DEB_error_if(lcle != nullptr && strcmp(lcle, _ssn_lcle) != 0,
DEB_error_if(lcle != NULL && strcmp(lcle, _ssn_lcle) != 0,
"set_locale() was asked to set " << _ssn_lcle <<
", but actually set " << lcle);
}
......@@ -54,8 +54,8 @@ std::string time()
time_t rawtime;
::time(&rawtime);
struct tm timeinfo;
#ifdef WIN32
struct tm timeinfo;
int err = ::localtime_s(&timeinfo, &rawtime);
if (err == 0)
{
......@@ -66,10 +66,10 @@ std::string time()
}
return std::string("time() failed");
#else//WIN32
//TODO: Implement a secure version of this code for Linux, OSX
//timeinfo = *localtime(&rawtime);
//char* buffer = asctime(&timeinfo);
return std::string("TODO: time() implemented only on Windows");
char str[100];
// Format: <Abbreviated weekday name> <abbreviated month name> <day of month> <HH>:<MM>:<SS> <Year>
std::strftime(str, sizeof(str), "%a %b %d %H:%M:%S %Y", std::localtime(&rawtime));
return std::string(str);
#endif//WIN32
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment