Commit 2ca160d1 authored by Max Lyon's avatar Max Lyon
Browse files

removed more c++11 features

parent 48cce671
Pipeline #1065 skipped
......@@ -6,6 +6,10 @@
#include "DebOut.hh"
#include <cstring>
#ifndef WIN32
#include <cstdio>
#endif
namespace Debug {
namespace {
......@@ -32,13 +36,13 @@ void append_function(std::string& _str, const char* const _func)
void append_entry(std::string& _str, const Enter* const _entr,
const bool _cmpct, const bool _entr_nmbr, const Enter* const _prev_entr)
{
if (_prev_entr != nullptr && // there is a previous entry and it is the same?
if (_prev_entr != NULL && // there is a previous entry and it is the same?
strcmp(_prev_entr->function(), _entr->function()) == 0)
{// ... so do nothing
return;
}
if (_prev_entr != nullptr)
if (_prev_entr != NULL)
_str.append("/");
if (_cmpct)
......@@ -47,7 +51,12 @@ void append_entry(std::string& _str, const Enter* const _entr,
_str.append(_entr->function());
if (_entr_nmbr)
_str.append('.' + std::to_string(_entr->number()));
{
_str.append(".");
std::stringstream ss;
ss << _entr->number();
_str.append(ss.str());
}
}
}//namespace
......@@ -68,7 +77,7 @@ const CallStack& CallStack::query()
//bool read(int _up, const char*& _funcname, int& _count)
//{
// const Enter* fcs = call(_up);
// if (fcs != nullptr)
// if (fcs != NULL)
// {
// _funcname = fcs->function();
// _count = fcs->number(); // Return most recent deb_enter_count
......@@ -80,7 +89,7 @@ const CallStack& CallStack::query()
void CallStack::append(std::string& _str, const bool _entr_nmbr) const
{
const Enter* prev = nullptr;
const Enter* prev = NULL;
for (size_t i = 0, n = depth(); i < n; prev = calls_[i++])
append_entry(_str, calls_[i], true, _entr_nmbr, prev);
}
......@@ -93,7 +102,11 @@ void CallStack::append_indent(std::string& _str, const int _indt,
if (_html)
{
char buffer[64];
#ifndef WIN32
sprintf(buffer, "<FONT SIZE=%i>", _indt);
#else
sprintf_s(buffer, sizeof(buffer), "<FONT SIZE=%i>", _indt);
#endif
_str.append(buffer);
}
int num = (int)calls_.size();
......
......@@ -35,7 +35,7 @@ public:
// TODO: this code below only works in ReForm, should be made to work
// for IGM, CoMISo, etc
const std::string root_dir("ReForm");
auto pos = flnm.rfind(root_dir);
size_t pos = flnm.rfind(root_dir);
if (pos != std::string::npos)
flnm = flnm.substr(pos + root_dir.size());
......@@ -51,8 +51,9 @@ private:
static bool search(const std::string& _flnm,
const std::list<std::string>& _sel_strings)
{
for (const auto& sel : _sel_strings)
for (std::list<std::string>::const_iterator sel_it = _sel_strings.begin(); sel_it != _sel_strings.end(); ++sel_it)
{
const std::string& sel = *sel_it;
if (_flnm.find(sel) != std::string::npos)
return true;
}
......@@ -84,7 +85,7 @@ private:
void Config::Impl::read()
{
const auto flnm =
const std::string flnm =
System::Environment::variable("REFORM_DEB_CONFIG", "reform_deb.cfg");
std::ifstream cnfg_strm(flnm.c_str());
......@@ -95,7 +96,7 @@ void Config::Impl::read()
std::string type;
line_stream >> type;
void (FilterLevelSelector::*add_string)(const std::string&) = nullptr;
void (FilterLevelSelector::*add_string)(const std::string&) = NULL;
if (type == "all")
{}
......@@ -108,7 +109,7 @@ void Config::Impl::read()
int lvl;
line_stream >> lvl;
if (add_string == nullptr)
if (add_string == NULL)
{
dflt_lvl_ = lvl; // We have read the default level.
continue;
......
......@@ -27,9 +27,9 @@ namespace {
// TODO: make this use std::string; check for html extension; case insensitive
bool is_html_filename(const char* const str)
{
if (str == nullptr) return false;
if (str == NULL) return false;
const char* dot = strrchr(str, '.');
if (dot == nullptr) return false;
if (dot == NULL) return false;
++dot;
return (!strncmp(dot, "htm", 3)) || (!strncmp(dot, "HTM", 3)) ;
}
......@@ -109,7 +109,7 @@ public:
const char* filename() const
{
if (this && (!flnm_.empty())) return flnm_.c_str();
return nullptr;
return NULL;
}
void clear()
......@@ -122,9 +122,9 @@ public:
char prev_char() const
{
if (!bffr_.empty())
return bffr_.back();
return *bffr_.rbegin();
if (!output_.empty())
return output_.back();
return *output_.rbegin();
return '\0';
}
......@@ -190,7 +190,7 @@ public:
void print(const char* const _s, bool _fork = true)
{
if (_s != nullptr)
if (_s != NULL)
{
for (int i = 0; ; ++i)
{
......@@ -232,7 +232,7 @@ public:
void set_double_format(const char* const str)
{
if (str == nullptr)
if (str == NULL)
double_format_.clear();
else
double_format_ = str;
......@@ -421,7 +421,7 @@ public:
return true;
const char* const flnm = filename();
if (flnm == nullptr && !file_is_open())
if (flnm == NULL && !file_is_open())
return false;
if (!file_is_open())
......@@ -473,7 +473,7 @@ public:
void set_filename(const char* const _flnm)
{
flnm_ = _flnm != nullptr ? _flnm : "";
flnm_ = _flnm != NULL ? _flnm : "";
if (is_html_filename(_flnm))
flags_ = flags_ | HTML;
}
......
Markdown is supported
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