Cleanup: Prep for '-Wextra'

This commit is contained in:
Paul Beckingham 2015-10-16 16:27:05 -04:00
parent 84be60fdca
commit a82558064b
23 changed files with 48 additions and 54 deletions

View file

@ -584,7 +584,7 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */)
if (add_to_backlog) if (add_to_backlog)
context.hooks.onAdd (task); context.hooks.onAdd (task);
update (uuid, task, add_to_backlog, true); update (task, add_to_backlog, true);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -602,12 +602,11 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */)
context.hooks.onModify (original, task); context.hooks.onModify (original, task);
} }
update (uuid, task, add_to_backlog); update (task, add_to_backlog);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TDB2::update ( void TDB2::update (
const std::string& uuid,
Task& task, Task& task,
const bool add_to_backlog, const bool add_to_backlog,
const bool addition /* = false */) const bool addition /* = false */)
@ -775,10 +774,10 @@ void TDB2::revert ()
// Modify other data files accordingly. // Modify other data files accordingly.
std::vector <std::string> p = pending.get_lines (); std::vector <std::string> p = pending.get_lines ();
revert_pending (p, uuid, current, prior); revert_pending (p, uuid, prior);
std::vector <std::string> c = completed.get_lines (); std::vector <std::string> c = completed.get_lines ();
revert_completed (p, c, uuid, current, prior); revert_completed (p, c, uuid, prior);
std::vector <std::string> b = backlog.get_lines (); std::vector <std::string> b = backlog.get_lines ();
revert_backlog (b, uuid, current, prior); revert_backlog (b, uuid, current, prior);
@ -837,7 +836,6 @@ void TDB2::revert_undo (
void TDB2::revert_pending ( void TDB2::revert_pending (
std::vector <std::string>& p, std::vector <std::string>& p,
const std::string& uuid, const std::string& uuid,
const std::string& current,
const std::string& prior) const std::string& prior)
{ {
std::string uuid_att = "uuid:\"" + uuid + "\""; std::string uuid_att = "uuid:\"" + uuid + "\"";
@ -871,7 +869,6 @@ void TDB2::revert_completed (
std::vector <std::string>& p, std::vector <std::string>& p,
std::vector <std::string>& c, std::vector <std::string>& c,
const std::string& uuid, const std::string& uuid,
const std::string& current,
const std::string& prior) const std::string& prior)
{ {
std::string uuid_att = "uuid:\"" + uuid + "\""; std::string uuid_att = "uuid:\"" + uuid + "\"";

View file

@ -138,12 +138,12 @@ public:
private: private:
void gather_changes (); void gather_changes ();
void update (const std::string&, Task&, const bool, const bool addition = false); void update (Task&, const bool, const bool addition = false);
bool verifyUniqueUUID (const std::string&); bool verifyUniqueUUID (const std::string&);
void show_diff (const std::string&, const std::string&, const std::string&); void show_diff (const std::string&, const std::string&, const std::string&);
void revert_undo (std::vector <std::string>&, std::string&, std::string&, std::string&, std::string&); void revert_undo (std::vector <std::string>&, std::string&, std::string&, std::string&, std::string&);
void revert_pending (std::vector <std::string>&, const std::string&, const std::string&, const std::string&); void revert_pending (std::vector <std::string>&, const std::string&, const std::string&);
void revert_completed (std::vector <std::string>&, std::vector <std::string>&, const std::string&, const std::string&, const std::string&); void revert_completed (std::vector <std::string>&, std::vector <std::string>&, const std::string&, const std::string&);
void revert_backlog (std::vector <std::string>&, const std::string&, const std::string&, const std::string&); void revert_backlog (std::vector <std::string>&, const std::string&, const std::string&, const std::string&);
public: public:

View file

@ -39,7 +39,7 @@ Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Constants. // Constants.
bool get (const std::string& name, Variant& value) bool get (const std::string&, Variant&)
{ {
/* /*
// An example, although a bad one because this is supported by default. // An example, although a bad one because this is supported by default.

View file

@ -68,7 +68,7 @@ void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maxim
void ColumnMask::render ( void ColumnMask::render (
std::vector <std::string>& lines, std::vector <std::string>& lines,
Task& task, Task& task,
int width, int,
Color& color) Color& color)
{ {
if (task.has (_name)) if (task.has (_name))

View file

@ -53,7 +53,7 @@ CmdAnnotate::CmdAnnotate ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdAnnotate::execute (std::string& output) int CmdAnnotate::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -84,7 +84,7 @@ int CmdAnnotate::execute (std::string& output)
task.modify (Task::modAnnotate, true); task.modify (Task::modAnnotate, true);
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
context.tdb2.modify (task); context.tdb2.modify (task);
++count; ++count;

View file

@ -53,7 +53,7 @@ CmdAppend::CmdAppend ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdAppend::execute (std::string& output) int CmdAppend::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -84,7 +84,7 @@ int CmdAppend::execute (std::string& output)
task.modify (Task::modAppend, true); task.modify (Task::modAppend, true);
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
context.tdb2.modify (task); context.tdb2.modify (task);
++count; ++count;

View file

@ -68,9 +68,9 @@ int CmdContext::execute (std::string& output)
if (subcommand == "define") rc = defineContext (words, out); if (subcommand == "define") rc = defineContext (words, out);
else if (subcommand == "delete") rc = deleteContext (words, out); else if (subcommand == "delete") rc = deleteContext (words, out);
else if (subcommand == "list") rc = listContexts (words, out); else if (subcommand == "list") rc = listContexts (out);
else if (subcommand == "none") rc = unsetContext (words, out); else if (subcommand == "none") rc = unsetContext (out);
else if (subcommand == "show") rc = showContext (words, out); else if (subcommand == "show") rc = showContext (out);
else rc = setContext (words, out); else rc = setContext (words, out);
} }
@ -229,7 +229,7 @@ int CmdContext::deleteContext (const std::vector <std::string>& words, std::stri
// Invoked with: task context list // Invoked with: task context list
// Example: task context list // Example: task context list
// //
int CmdContext::listContexts (const std::vector <std::string>& words, std::stringstream& out) int CmdContext::listContexts (std::stringstream& out)
{ {
int rc = 0; int rc = 0;
std::vector <std::string> contexts = getContexts(); std::vector <std::string> contexts = getContexts();
@ -321,7 +321,7 @@ int CmdContext::setContext (const std::vector <std::string>& words, std::strings
// Invoked with: task context show // Invoked with: task context show
// Example: task context show // Example: task context show
// //
int CmdContext::showContext (const std::vector <std::string>& words, std::stringstream& out) int CmdContext::showContext (std::stringstream& out)
{ {
std::string currentContext = context.config.get ("context"); std::string currentContext = context.config.get ("context");
@ -346,7 +346,7 @@ int CmdContext::showContext (const std::vector <std::string>& words, std::string
// Invoked with: task context none // Invoked with: task context none
// Example: task context none // Example: task context none
// //
int CmdContext::unsetContext (const std::vector <std::string>& words, std::stringstream& out) int CmdContext::unsetContext (std::stringstream& out)
{ {
int rc = 0; int rc = 0;
int status = CmdConfig::unsetConfigVariable ("context", false); int status = CmdConfig::unsetConfigVariable ("context", false);

View file

@ -35,14 +35,14 @@ class CmdContext : public Command
public: public:
CmdContext (); CmdContext ();
int execute (std::string&); int execute (std::string&);
std::string joinWords (const std::vector <std::string>& words, unsigned int from, unsigned int to = 0); std::string joinWords (const std::vector <std::string>&, unsigned int, unsigned int = 0);
static std::vector <std::string> getContexts (); static std::vector <std::string> getContexts ();
int defineContext (const std::vector <std::string>& words, std::stringstream& out); int defineContext (const std::vector <std::string>&, std::stringstream&);
int deleteContext (const std::vector <std::string>& words, std::stringstream& out); int deleteContext (const std::vector <std::string>&, std::stringstream&);
int listContexts (const std::vector <std::string>& words, std::stringstream& out); int listContexts (std::stringstream&);
int setContext (const std::vector <std::string>& words, std::stringstream& out); int setContext (const std::vector <std::string>&, std::stringstream&);
int showContext (const std::vector <std::string>& words, std::stringstream& out); int showContext (std::stringstream&);
int unsetContext (const std::vector <std::string>& words, std::stringstream& out); int unsetContext (std::stringstream&);
}; };
class CmdCompletionContext : public Command class CmdCompletionContext : public Command

View file

@ -54,7 +54,7 @@ CmdDelete::CmdDelete ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdDelete::execute (std::string& output) int CmdDelete::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -94,7 +94,7 @@ int CmdDelete::execute (std::string& output)
if (! task.has ("end")) if (! task.has ("end"))
task.setAsNow ("end"); task.setAsNow ("end");
if (permission (task, question, filtered.size ())) if (permission (question, filtered.size ()))
{ {
updateRecurrenceMask (task); updateRecurrenceMask (task);
++count; ++count;

View file

@ -53,7 +53,7 @@ CmdDenotate::CmdDenotate ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdDenotate::execute (std::string& output) int CmdDenotate::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -130,7 +130,7 @@ int CmdDenotate::execute (std::string& output)
task.id, task.id,
task.get ("description")); task.get ("description"));
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
++count; ++count;
context.tdb2.modify (task); context.tdb2.modify (task);

View file

@ -53,7 +53,7 @@ CmdDone::CmdDone ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdDone::execute (std::string& output) int CmdDone::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -97,7 +97,7 @@ int CmdDone::execute (std::string& output)
task.addAnnotation (context.config.get ("journal.time.stop.annotation")); task.addAnnotation (context.config.get ("journal.time.stop.annotation"));
} }
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
updateRecurrenceMask (task); updateRecurrenceMask (task);
context.tdb2.modify (task); context.tdb2.modify (task);

View file

@ -53,7 +53,7 @@ CmdDuplicate::CmdDuplicate ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdDuplicate::execute (std::string& output) int CmdDuplicate::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -105,8 +105,7 @@ int CmdDuplicate::execute (std::string& output)
dup.modify (Task::modAnnotate); dup.modify (Task::modAnnotate);
if (permission (dup, if (permission (format (STRING_CMD_DUPLICATE_CONFIRM,
format (STRING_CMD_DUPLICATE_CONFIRM,
task.id, task.id,
task.get ("description")), task.get ("description")),
filtered.size ())) filtered.size ()))

View file

@ -65,7 +65,7 @@ CmdEdit::CmdEdit ()
// Introducing the Silver Bullet. This feature is the catch-all fixative for // Introducing the Silver Bullet. This feature is the catch-all fixative for
// various other ills. This is like opening up the hood and going in with a // various other ills. This is like opening up the hood and going in with a
// wrench. To be used sparingly. // wrench. To be used sparingly.
int CmdEdit::execute (std::string& output) int CmdEdit::execute (std::string&)
{ {
// Filter the tasks. // Filter the tasks.
handleRecurrence (); handleRecurrence ();

View file

@ -50,7 +50,7 @@ CmdExec::CmdExec ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdExec::execute (std::string& output) int CmdExec::execute (std::string&)
{ {
std::string command_line; std::string command_line;
join (command_line, " ", context.cli2.getWords ()); join (command_line, " ", context.cli2.getWords ());

View file

@ -55,7 +55,7 @@ CmdImport::CmdImport ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdImport::execute (std::string& output) int CmdImport::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;

View file

@ -53,7 +53,7 @@ CmdModify::CmdModify ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdModify::execute (std::string& output) int CmdModify::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -91,7 +91,7 @@ int CmdModify::execute (std::string& output)
task.get ("uuid"), task.get ("uuid"),
task.get ("description")); task.get ("description"));
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
count += modifyAndUpdate (before, task, &projectChanges); count += modifyAndUpdate (before, task, &projectChanges);
} }

View file

@ -53,7 +53,7 @@ CmdPrepend::CmdPrepend ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdPrepend::execute (std::string& output) int CmdPrepend::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -84,7 +84,7 @@ int CmdPrepend::execute (std::string& output)
task.modify (Task::modPrepend, true); task.modify (Task::modPrepend, true);
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
context.tdb2.modify (task); context.tdb2.modify (task);
++count; ++count;

View file

@ -53,7 +53,7 @@ CmdStart::CmdStart ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdStart::execute (std::string& output) int CmdStart::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -95,7 +95,7 @@ int CmdStart::execute (std::string& output)
if (context.config.getBoolean ("journal.time")) if (context.config.getBoolean ("journal.time"))
task.addAnnotation (context.config.get ("journal.time.start.annotation")); task.addAnnotation (context.config.get ("journal.time.start.annotation"));
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
updateRecurrenceMask (task); updateRecurrenceMask (task);
context.tdb2.modify (task); context.tdb2.modify (task);

View file

@ -52,7 +52,7 @@ CmdStop::CmdStop ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdStop::execute (std::string& output) int CmdStop::execute (std::string&)
{ {
int rc = 0; int rc = 0;
int count = 0; int count = 0;
@ -87,7 +87,7 @@ int CmdStop::execute (std::string& output)
if (context.config.getBoolean ("journal.time")) if (context.config.getBoolean ("journal.time"))
task.addAnnotation (context.config.get ("journal.time.stop.annotation")); task.addAnnotation (context.config.get ("journal.time.stop.annotation"));
if (permission (task, taskDifferences (before, task) + question, filtered.size ())) if (permission (taskDifferences (before, task) + question, filtered.size ()))
{ {
updateRecurrenceMask (task); updateRecurrenceMask (task);
context.tdb2.modify (task); context.tdb2.modify (task);

View file

@ -49,7 +49,7 @@ CmdUndo::CmdUndo ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdUndo::execute (std::string& output) int CmdUndo::execute (std::string&)
{ {
context.tdb2.revert (); context.tdb2.revert ();
return 0; return 0;

View file

@ -25,7 +25,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <cmake.h> #include <cmake.h>
#include <iostream>
#include <string> #include <string>
#include <set> #include <set>
#include <algorithm> #include <algorithm>
@ -88,7 +87,7 @@ int CmdUnique::execute (std::string& output)
// Generate list of unique values. // Generate list of unique values.
for (auto& value : values) for (auto& value : values)
std::cout << value << "\n"; output += value + "\n";
context.headers.clear (); context.headers.clear ();
return 0; return 0;

View file

@ -312,7 +312,6 @@ Command::Category Command::category () const
// rc.confirmation // rc.confirmation
// this->_read_only // this->_read_only
bool Command::permission ( bool Command::permission (
const Task& task,
const std::string& question, const std::string& question,
unsigned int quantity) unsigned int quantity)
{ {

View file

@ -71,7 +71,7 @@ public:
virtual int execute (std::string&) = 0; virtual int execute (std::string&) = 0;
protected: protected:
bool permission (const Task&, const std::string&, unsigned int); bool permission (const std::string&, unsigned int);
static const std::map <Command::Category, std::string> categoryNames; static const std::map <Command::Category, std::string> categoryNames;
protected: protected: