Permalink
Browse files

Use nullptr instead lf C-styled NULL

  • Loading branch information...
kirillbobyrev authored and pbeckingham committed Mar 7, 2018
1 parent 6f19a3f commit 511a23521522aa05bc990ee9d8d022e74b7bfcf7
@@ -1734,8 +1734,8 @@ void CLI2::insertIDExpr ()
else
{
bool ascending = true;
int low = strtol (r->first.c_str (), NULL, 10);
int high = strtol (r->second.c_str (), NULL, 10);
int low = strtol (r->first.c_str (), nullptr, 10);
int high = strtol (r->second.c_str (), nullptr, 10);
if (low <= high)
ascending = true;
else
@@ -1027,7 +1027,7 @@ void Context::getLimits (int& rows, int& lines)
}
else
{
rows = (int) strtol (limit.c_str (), NULL, 10);
rows = (int) strtol (limit.c_str (), nullptr, 10);
lines = 0;
}
}
@@ -279,7 +279,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
else if (type == Lexer::Type::number &&
token.find ('.') == std::string::npos)
{
auto id = strtol (token.c_str (), NULL, 10);
auto id = strtol (token.c_str (), nullptr, 10);
if (id && id != ref.id)
Context::getContext ().tdb2.get (id, ref);

@@ -375,7 +375,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
{
auto annos = ref.getAnnotations ();

int a = strtol (elements[1].c_str (), NULL, 10);
int a = strtol (elements[1].c_str (), nullptr, 10);
int count = 0;

// Count off the 'a'th annotation.
@@ -403,7 +403,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
{
auto annos = ref.getAnnotations ();

int a = strtol (elements[1].c_str (), NULL, 10);
int a = strtol (elements[1].c_str (), nullptr, 10);
int count = 0;

// Count off the 'a'th annotation.
@@ -1026,7 +1026,7 @@ void TDB2::show_diff (
const std::string& prior,
const std::string& when)
{
Datetime lastChange (strtol (when.c_str (), NULL, 10));
Datetime lastChange (strtol (when.c_str (), nullptr, 10));

// Set the colors.
Color color_red (Context::getContext ().color () ? Context::getContext ().config.get ("color.undo.before") : "");
@@ -218,7 +218,7 @@ void TLSClient::connect (const std::string& host, const std::string& port)
#if GNUTLS_VERSION_NUMBER >= 0x030406
// For _trust == TLSClient::allow_all we perform no action
if (_trust == TLSClient::ignore_hostname)
gnutls_session_set_verify_cert (_session, NULL, 0); // 3.4.6
gnutls_session_set_verify_cert (_session, nullptr, 0); // 3.4.6
else if (_trust == TLSClient::strict)
gnutls_session_set_verify_cert (_session, _host.c_str (), 0); // 3.4.6
#endif
@@ -251,7 +251,7 @@ void TLSClient::connect (const std::string& host, const std::string& port)

// Try them all, stop on success.
struct addrinfo* p;
for (p = res; p != NULL; p = p->ai_next)
for (p = res; p != nullptr; p = p->ai_next)
{
if ((_socket = ::socket (p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
continue;
@@ -275,7 +275,7 @@ void TLSClient::connect (const std::string& host, const std::string& port)

free (res);

if (p == NULL)
if (p == nullptr)
throw format ("Could not connect to {1} {2}", host, port);

#if GNUTLS_VERSION_NUMBER >= 0x030100
@@ -362,7 +362,7 @@ int TLSClient::verify_certificate () const
const char* hostname = _host.c_str();
#if GNUTLS_VERSION_NUMBER >= 0x030104
if (_trust == TLSClient::ignore_hostname)
hostname = NULL;
hostname = nullptr;

int ret = gnutls_certificate_verify_peers3 (_session, hostname, &status); // 3.1.4
if (ret < 0)
@@ -58,7 +58,7 @@ class TLSClient
std::string _host {""};
std::string _port {""};
gnutls_certificate_credentials_t _credentials {};
gnutls_session_t _session {0};
gnutls_session_t _session {nullptr};
int _socket {0};
int _limit {0};
bool _debug {false};
@@ -181,7 +181,7 @@ const std::string Task::identifier (bool shortened /* = false */) const
void Task::setAsNow (const std::string& att)
{
char now[16];
snprintf (now, 16, "%u", (unsigned int) time (NULL));
snprintf (now, 16, "%u", (unsigned int) time (nullptr));
set (att, now);

recalc_urgency = true;
@@ -231,7 +231,7 @@ int Task::get_int (const std::string& name) const
{
auto i = data.find (name);
if (i != data.end ())
return strtol (i->second.c_str (), NULL, 10);
return strtol (i->second.c_str (), nullptr, 10);

return 0;
}
@@ -241,7 +241,7 @@ unsigned long Task::get_ulong (const std::string& name) const
{
auto i = data.find (name);
if (i != data.end ())
return strtoul (i->second.c_str (), NULL, 10);
return strtoul (i->second.c_str (), nullptr, 10);

return 0;
}
@@ -251,7 +251,7 @@ float Task::get_float (const std::string& name) const
{
auto i = data.find (name);
if (i != data.end ())
return strtof (i->second.c_str (), NULL);
return strtof (i->second.c_str (), nullptr);

return 0.0;
}
@@ -261,7 +261,7 @@ time_t Task::get_date (const std::string& name) const
{
auto i = data.find (name);
if (i != data.end ())
return (time_t) strtoul (i->second.c_str (), NULL, 10);
return (time_t) strtoul (i->second.c_str (), nullptr, 10);

return 0;
}
@@ -1060,7 +1060,7 @@ bool Task::hasAnnotations () const
// timestamp.
void Task::addAnnotation (const std::string& description)
{
time_t now = time (NULL);
time_t now = time (nullptr);
std::string key;

do
@@ -1930,7 +1930,7 @@ float Task::urgency_active () const
float Task::urgency_scheduled () const
{
if (has ("scheduled") &&
get_date ("scheduled") < time (NULL))
get_date ("scheduled") < time (nullptr))
return 1.0;

return 0.0;
@@ -1864,9 +1864,9 @@ void Variant::cast (const enum type new_type)
_string == "0.0") ? false : true;
break;
case type_integer:
_integer = (int) strtol (_string.c_str (), NULL, (_string.substr (0, 2) == "0x" ? 16 : 10));
_integer = (int) strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10));
break;
case type_real: _real = strtod (_string.c_str (), NULL); break;
case type_real: _real = strtod (_string.c_str (), nullptr); break;
case type_string: break;
case type_date:
{
@@ -154,14 +154,14 @@ void ColumnDepends::modify (Task& task, const std::string& value)
if (dep.length () == 37)
task.removeDependency (dep.substr (1));
else
task.removeDependency (strtol (dep.substr (1).c_str (), NULL, 10));
task.removeDependency (strtol (dep.substr (1).c_str (), nullptr, 10));
}
else
{
if (dep.length () == 36)
task.addDependency (dep);
else
task.addDependency (strtol (dep.c_str (), NULL, 10));
task.addDependency (strtol (dep.c_str (), nullptr, 10));
}
}
}
@@ -171,7 +171,7 @@ void ColumnDescription::render (
{
for (const auto& i : task.getAnnotations ())
{
Datetime dt (strtol (i.first.substr (11).c_str (), NULL, 10));
Datetime dt (strtol (i.first.substr (11).c_str (), nullptr, 10));
description += '\n' + std::string (_indent, ' ') + dt.toString (_dateformat) + ' ' + i.second;
}
}
@@ -200,7 +200,7 @@ void ColumnDescription::render (
{
for (const auto& i : task.getAnnotations ())
{
Datetime dt (strtol (i.first.substr (11).c_str (), NULL, 10));
Datetime dt (strtol (i.first.substr (11).c_str (), nullptr, 10));
description += ' ' + dt.toString (_dateformat) + ' ' + i.second;
}
}
@@ -241,7 +241,7 @@ void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& ma
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat
Datetime date ((time_t) strtol (value.c_str (), NULL, 10));
Datetime date ((time_t) strtol (value.c_str (), nullptr, 10));
auto format = Context::getContext ().config.get ("report." + _report + ".dateformat");
if (format == "")
format = Context::getContext ().config.get ("dateformat.report");
@@ -287,7 +287,7 @@ void ColumnUDADate::render (
format = Context::getContext ().config.get ("dateformat");
}

renderStringLeft (lines, width, color, Datetime ((time_t) strtol (value.c_str (), NULL, 10)).toString (format));
renderStringLeft (lines, width, color, Datetime ((time_t) strtol (value.c_str (), nullptr, 10)).toString (format));
}
else if (_style == "indicator")
{
@@ -213,7 +213,7 @@ Column* Column::uda (const std::string& name)
else if (type != "")
throw std::string ("User defined attributes may only be of type 'string', 'date', 'duration' or 'numeric'.");

return NULL;
return nullptr;
}

////////////////////////////////////////////////////////////////////////////////
@@ -121,12 +121,12 @@ int CmdCalendar::execute (std::string& output)

// YYYY.
else if (Lexer::isAllDigits (arg) && arg.length () == 4)
argYear = strtol (arg.c_str (), NULL, 10);
argYear = strtol (arg.c_str (), nullptr, 10);

// MM.
else if (Lexer::isAllDigits (arg) && arg.length () <= 2)
{
argMonth = strtol (arg.c_str (), NULL, 10);
argMonth = strtol (arg.c_str (), nullptr, 10);
if (argMonth < 1 || argMonth > 12)
throw format ("Argument '{1}' is not a valid month.", arg);
}
@@ -564,7 +564,7 @@ std::string CmdCalendar::renderMonths (
task.has ("due"))
{
std::string due = task.get ("due");
Datetime duedmy (strtol (due.c_str(), NULL, 10));
Datetime duedmy (strtol (due.c_str(), nullptr, 10));

if (duedmy.day () == d &&
duedmy.month () == months[mpl] &&
@@ -211,9 +211,9 @@ int CmdDiagnostics::execute (std::string& output)
char* peditor;
if (Context::getContext ().config.get ("editor") != "")
out << " rc.editor: " << Context::getContext ().config.get ("editor") << '\n';
else if ((peditor = getenv ("VISUAL")) != NULL)
else if ((peditor = getenv ("VISUAL")) != nullptr)
out << " $VISUAL: " << peditor << '\n';
else if ((peditor = getenv ("EDITOR")) != NULL)
else if ((peditor = getenv ("EDITOR")) != nullptr)
out << " $EDITOR: " << peditor << '\n';

out << " Server: "
@@ -249,7 +249,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)

for (auto& anno : task.getAnnotations ())
{
Datetime dt (strtol (anno.first.substr (11).c_str (), NULL, 10));
Datetime dt (strtol (anno.first.substr (11).c_str (), nullptr, 10));
before << " Annotation: " << dt.toString (dateformat)
<< " -- " << json::encode (anno.second) << '\n';
}
@@ -652,7 +652,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
if (dep.length () >= 7)
task.addDependency (dep);
else
task.addDependency ((int) strtol (dep.c_str (), NULL, 10));
task.addDependency ((int) strtol (dep.c_str (), nullptr, 10));
}

// UDAs
@@ -217,7 +217,7 @@ int CmdInfo::execute (std::string& output)
auto created = task.get ("entry");
if (created.length ())
{
Datetime dt (strtol (created.c_str (), NULL, 10));
Datetime dt (strtol (created.c_str (), nullptr, 10));
age = Duration (now - dt).formatVague ();
}

@@ -531,7 +531,7 @@ int CmdInfo::execute (std::string& output)
{
int row = journal.addRow ();

Datetime timestamp (strtol (undo[when].substr (5).c_str (), NULL, 10));
Datetime timestamp (strtol (undo[when].substr (5).c_str (), nullptr, 10));
journal.set (row, 0, timestamp.toString (dateformat));

Task before (undo[previous].substr (4));
@@ -37,11 +37,11 @@ class CmdModify : public Command
int execute (std::string&);
void checkConsistency (Task &before, Task &after);
int modifyAndUpdate (Task &before, Task &after,
std::map <std::string, std::string> *projectChanges = NULL);
std::map <std::string, std::string> *projectChanges = nullptr);
int modifyRecurrenceSiblings (Task &task,
std::map <std::string, std::string> *projectChanges = NULL);
std::map <std::string, std::string> *projectChanges = nullptr);
int modifyRecurrenceParent (Task &task,
std::map <std::string, std::string> *projectChanges = NULL);
std::map <std::string, std::string> *projectChanges = nullptr);
};

#endif
@@ -89,7 +89,7 @@ int CmdStats::execute (std::string& output)
filter.subset (all, filtered);

Datetime now;
time_t earliest = time (NULL);
time_t earliest = time (nullptr);
time_t latest = 1;
int totalT = 0;
int deletedT = 0;
@@ -123,13 +123,13 @@ int CmdStats::execute (std::string& output)
if (task.is_blocked) ++blockedT;
if (task.is_blocking) ++blockingT;

time_t entry = strtol (task.get ("entry").c_str (), NULL, 10);
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry;

if (status == Task::completed)
{
time_t end = strtol (task.get ("end").c_str (), NULL, 10);
time_t end = strtol (task.get ("end").c_str (), nullptr, 10);
daysPending += (end - entry) / 86400.0;
}

@@ -79,7 +79,7 @@ int CmdSummary::execute (std::string& output)
std::map <std::string, int> countCompleted;
std::map <std::string, double> sumEntry;
std::map <std::string, int> counter;
time_t now = time (NULL);
time_t now = time (nullptr);

// Initialize counters.
for (auto& project : allProjects)
@@ -107,7 +107,7 @@ int CmdSummary::execute (std::string& output)
{
++countPending[parent];

time_t entry = strtol (task.get ("entry").c_str (), NULL, 10);
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
if (entry)
sumEntry[parent] = sumEntry[parent] + (double) (now - entry);
}
@@ -119,8 +119,8 @@ int CmdSummary::execute (std::string& output)
{
++countCompleted[parent];

time_t entry = strtol (task.get ("entry").c_str (), NULL, 10);
time_t end = strtol (task.get ("end").c_str (), NULL, 10);
time_t entry = strtol (task.get ("entry").c_str (), nullptr, 10);
time_t end = strtol (task.get ("end").c_str (), nullptr, 10);
if (entry && end)
sumEntry[parent] = sumEntry[parent] + (double) (end - entry);
}
@@ -247,7 +247,7 @@ std::string renderAttribute (const std::string& name, const std::string& value,
col->type () == "date" &&
value != "")
{
Datetime d ((time_t)strtol (value.c_str (), NULL, 10));
Datetime d ((time_t)strtol (value.c_str (), nullptr, 10));
if (format == "")
return d.toString (Context::getContext ().config.get ("dateformat"));

Oops, something went wrong.

0 comments on commit 511a235

Please sign in to comment.