From 5836430cc11f6f8ddb9a8737ad17ee90a8ba0942 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 11 Jun 2009 21:34:40 -0400 Subject: [PATCH] Code Cleanup - Removed obsolete code from main.cpp. --- src/Context.cpp | 19 +++++++++ src/custom.cpp | 11 +++++- src/main.cpp | 101 +----------------------------------------------- 3 files changed, 29 insertions(+), 102 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 2d2e1145f..0c6cc3f49 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -66,6 +66,13 @@ Context::~Context () //////////////////////////////////////////////////////////////////////////////// void Context::initialize (int argc, char** argv) { + // Set up randomness. +#ifdef HAVE_SRANDOM + srandom (time (NULL)); +#else + srand (time (NULL)); +#endif + // Capture the args. for (int i = 0; i < argc; ++i) if (i == 0) @@ -221,6 +228,18 @@ void Context::shadow () std::string shadowFile = expandPath (config.get ("shadow.file")); if (shadowFile != "") { + // TODO Reinstate these checks. +/* + // Check for silly shadow file settings. + if (shadowFile == dataLocation + "/pending.data") + throw std::string ("Configuration variable 'shadow.file' is set to " + "overwrite your pending tasks. Please change it."); + + if (shadowFile == dataLocation + "/completed.data") + throw std::string ("Configuration variable 'shadow.file' is set to " + "overwrite your completed tasks. Please change it."); +*/ + std::string oldCurses = config.get ("curses"); std::string oldColor = config.get ("color"); config.set ("curses", "off"); diff --git a/src/custom.cpp b/src/custom.cpp index c3648b9fa..f00362a27 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -54,7 +54,6 @@ extern Context context; // via the .taskrc file. std::string handleCustomReport (const std::string& report) { -/* // Load report configuration. std::string columnList = context.config.get ("report." + report + ".columns"); std::vector columns; @@ -67,7 +66,7 @@ std::string handleCustomReport (const std::string& report) if (columns.size () != labels.size () && labels.size () != 0) throw std::string ("There are a different number of columns than labels ") + - "for report '" + report + "'. Please correct this."; + "for report '" + report + "'."; std::map columnLabels; if (labels.size ()) @@ -83,6 +82,14 @@ std::string handleCustomReport (const std::string& report) std::vector filterArgs; split (filterArgs, filterList, ' '); + // Get all the tasks. + std::vector tasks; + context.tdb.lock (context.config.get ("locking", true)); + // TODO Include filter from custom report. + context.tdb.load (tasks, context.filter); + context.tdb.unlock (); + +/* // Load all pending tasks. std::vector tasks; tdb.allPendingT (tasks); diff --git a/src/main.cpp b/src/main.cpp index f7345f5ba..877147074 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,44 +24,14 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "Context.h" -#include "Date.h" -#include "Duration.h" -#include "Table.h" -#include "T.h" -#include "text.h" -#include "util.h" -#include "main.h" -#ifdef HAVE_LIBNCURSES -#include -#endif - -// Global context for use by all. Context context; -//////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - // Set up randomness. -#ifdef HAVE_SRANDOM - srandom (time (NULL)); -#else - srand (time (NULL)); -#endif - int status = 0; try @@ -71,33 +41,6 @@ int main (int argc, char** argv) status = context.interactive (); else status = context.run (); - -// start OBSOLETE -/* - TDB tdb; - std::string dataLocation = expandPath (context.config.get ("data.location")); - tdb.dataDirectory (dataLocation); - - // Allow user override of file locking. Solaris/NFS machines may want this. - if (! context.config.get ("locking", true)) - tdb.noLock (); - - // Check for silly shadow file settings. - std::string shadowFile = expandPath (context.config.get ("shadow.file")); - if (shadowFile != "") - { - if (shadowFile == dataLocation + "/pending.data") - throw std::string ("Configuration variable 'shadow.file' is set to " - "overwrite your pending tasks. Please change it."); - - if (shadowFile == dataLocation + "/completed.data") - throw std::string ("Configuration variable 'shadow.file' is set to " - "overwrite your completed tasks. Please change it."); - } - - std::cout << runTaskCommand (context.args, tdb); -*/ -// end OBSOLETE } catch (std::string& error) @@ -116,45 +59,3 @@ int main (int argc, char** argv) } //////////////////////////////////////////////////////////////////////////////// -// TODO Obsolete -void updateShadowFile () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO Obsolete -std::string runTaskCommand ( - int argc, - char** argv, -// TDB& tdb, - bool gc /* = true */, - bool shadow /* = true */) -{ -/* - std::vector args; - for (int i = 1; i < argc; ++i) - if (strncmp (argv[i], "rc:", 3) && - strncmp (argv[i], "rc.", 3)) -{ -std::cout << "arg=" << argv[i] << std::endl; - args.push_back (argv[i]); -} - - return runTaskCommand (args, tdb, gc, shadow); -*/ - return ""; -} - -//////////////////////////////////////////////////////////////////////////////// -// TODO Obsolete -std::string runTaskCommand ( - std::vector & args, -// TDB& tdb, - bool gc /* = false */, - bool shadow /* = false */) -{ - std::string out; - return out; -} - -////////////////////////////////////////////////////////////////////////////////