Use nullptr instead lf C-styled NULL

This commit is contained in:
Kirill Bobyrev
2018-03-07 22:21:28 +03:00
committed by Paul Beckingham
parent 6f19a3fbae
commit 511a235215
22 changed files with 56 additions and 56 deletions

View File

@@ -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] &&

View File

@@ -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: "

View File

@@ -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

View File

@@ -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));

View File

@@ -37,11 +37,11 @@ public:
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

View File

@@ -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;
}

View File

@@ -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);
}