From 8376d99e88991f6975ffef55f224c0faa8bf7a1e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 16:07:03 -0400 Subject: [PATCH 1/4] Tree - Added node pointer to ::dump output. Helps debugging. --- src/Tree.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tree.cpp b/src/Tree.cpp index 6d60d2627..0e5bcc045 100644 --- a/src/Tree.cpp +++ b/src/Tree.cpp @@ -273,7 +273,8 @@ void Tree::dumpNode (Tree* t, int depth, std::stringstream& output) for (int i = 0; i < depth; ++i) output << " "; - output << "\033[1m" << t->_name << "\033[0m"; + output << std::hex << t << " " + << "\033[1m" << t->_name << "\033[0m"; // Dump attributes. std::string atts; From 079669e73b78c0fa1c8ff974b9351b4d68a194da Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 16:07:31 -0400 Subject: [PATCH 2/4] Parser - Modified ::getWords to look at all nodes, including parents. --- src/Parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 6c72ecd59..29a4b03f9 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -797,7 +797,7 @@ const std::vector Parser::getWords () const { std::vector words; std::vector nodes; - collect (nodes, collectTerminated); + collect (nodes, collectAll); std::vector ::iterator i; for (i = nodes.begin (); i != nodes.end (); ++i) { From a735c7eb63ff2a06bfcdcd401cd8865d9e800ef7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 16:08:16 -0400 Subject: [PATCH 3/4] CmdInfo - Removed the 'total active time' display. Should have done this a long time ago. --- src/commands/CmdInfo.cpp | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 7167aca4a..0781ff78b 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -441,7 +441,6 @@ int CmdInfo::execute (std::string& output) std::string previous; std::string current; unsigned int i = 0; - long total_time = 0; long last_timestamp = 0; while (i < undo.size ()) { @@ -465,39 +464,9 @@ int CmdInfo::execute (std::string& output) Task before (previous.substr (4)); Task after (current.substr (4)); journal.set (row, 1, taskInfoDifferences (before, after, dateformat, last_timestamp, timestamp.toEpoch())); - - // calculate the total active time - if (before.get ("start") == "" - && after.get ("start") != "") - { - // task started - total_time -= timestamp.toEpoch (); - } - else if (((before.get ("start") != "" && - after.get ("start") == "") || - (before.get ("status") != "completed" && - after.get ("status") == "completed")) && - total_time < 0) - { - // task stopped or done - total_time += timestamp.toEpoch (); - } } } } - - // add now() if task is still active - if (total_time < 0) - total_time += Date ().toEpoch (); - - // print total active time - if (total_time > 0) - { - row = journal.addRow (); - journal.set (row, 0, STRING_CMD_INFO_TOTAL_ACTIVE); - journal.set (row, 1, Duration (total_time).formatPrecise (), - (context.color () ? Color ("bold") : Color ())); - } } out << optionalBlankLine () From 3aef4f74b95c35812795b21bd710ef60a3694cbc Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 Aug 2014 22:36:10 -0400 Subject: [PATCH 4/4] Parser - Rewrote ::collect to be simpler. --- src/Parser.cpp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 29a4b03f9..3310e242f 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -309,32 +309,23 @@ void Parser::collect ( if (tree == NULL) tree = _tree; + if (type == collectAll || tree->_branches.size () == 0) + nodes.push_back (tree); + std::vector ::iterator i; for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i) { - if ((*i)->_branches.size ()) + if (type == collectLeaf) { - if (type == collectAll) - nodes.push_back (*i); + if ((*i)->hasTag ("TERMINATOR") || + (*i)->hasTag ("TERMINATED")) + break; - collect (nodes, type, *i); + if (! (*i)->hasTag ("?")) + continue; } - else - { - if (type == collectLeaf) - { - // Parser override operator. - if ((*i)->hasTag ("TERMINATOR") || - (*i)->hasTag ("TERMINATED")) - break; - // Skip known args. - if (! (*i)->hasTag ("?")) - continue; - } - - nodes.push_back (*i); - } + collect (nodes, type, *i); } } @@ -1593,7 +1584,6 @@ void Parser::findModifications () { context.debug ("Parser::findModifications"); bool action = false; - bool after_writecmd = false; std::vector nodes; @@ -1602,9 +1592,10 @@ void Parser::findModifications () for (i = nodes.begin (); i != nodes.end (); ++i) { if ((*i)->hasTag ("WRITECMD")) + { after_writecmd = true; - - if (after_writecmd && + } + else if (after_writecmd && ! (*i)->hasTag ("CMD") && ! (*i)->hasTag ("TERMINATOR") && ! (*i)->hasTag ("BINARY") &&