Merge branch 'master' into 2.4.0

This commit is contained in:
Paul Beckingham
2014-01-15 22:17:30 -05:00
31 changed files with 139 additions and 219 deletions

View File

@@ -155,7 +155,6 @@ void A3::capture (int argc, const char** argv)
// Append an Arg with a blank category.
void A3::capture (const std::string& arg)
{
std::vector <std::string> parts;
this->push_back (Arg (arg));
}

View File

@@ -674,7 +674,9 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
{
std::string value = findValue (after, "\n UDA " + col->first + ":");
if ((task.get (col->first) != value) && (type != "date" ||
(task.get (col->first) != Date(value, dateformat).toEpochString ())))
(task.get (col->first) != Date (value, dateformat).toEpochString ())) &&
(type != "duration" ||
(task.get (col->first) != (std::string) OldDuration (value) )))
{
if (value != "")
{

View File

@@ -11,18 +11,9 @@ set (tasksh_SRCS Readline.cpp Readline.h)
add_library (tasksh STATIC ${tasksh_SRCS})
add_executable (tasksh_executable main.cpp)
# Yes, 'task' is included twice, other linking fails on CentOS.
# Yes, 'task' is included twice, otherwise linking fails on CentOS.
target_link_libraries (tasksh_executable task commands columns tasksh task ${TASK_LIBRARIES})
set_property (TARGET tasksh_executable PROPERTY OUTPUT_NAME "tasksh")
install (TARGETS tasksh_executable DESTINATION ${TASK_BINDIR})
set (CMAKE_BUILD_TYPE debug)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wall")
#SET(CMAKE_BUILD_TYPE gcov)
#SET(CMAKE_CXX_FLAGS_GCOV "--coverage")
#SET(CMAKE_C_FLAGS_GCOV "--coverage")
#SET(CMAKE_EXE_LINKER_FLAGS_GCOV "--coverage")

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
// Copyright 2006 - 2014, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -75,46 +75,3 @@ bool Readline::interactiveMode (const std::istream& in)
}
////////////////////////////////////////////////////////////////////////////////
Wordexp::Wordexp (const std::string &str)
{
std::string tmpStr(str);
escapeSpecialChars(tmpStr);
wordexp (tmpStr.c_str (), &_p, 0);
}
////////////////////////////////////////////////////////////////////////////////
Wordexp::~Wordexp ()
{
wordfree (&_p);
}
////////////////////////////////////////////////////////////////////////////////
int Wordexp::argc ()
{
return _p.we_wordc;
}
////////////////////////////////////////////////////////////////////////////////
char** Wordexp::argv ()
{
return _p.we_wordv;
}
////////////////////////////////////////////////////////////////////////////////
char* Wordexp::argv (int i)
{
return _p.we_wordv[i];
}
////////////////////////////////////////////////////////////////////////////////
void Wordexp::escapeSpecialChars(std::string& str)
{
size_t i = 0;
while ((i = str.find_first_of ("$*?!|&;<>(){}~#@", i)) != std::string::npos)
{
str.insert(i, 1, '\\');
i += 2;
}
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
// Copyright 2006 - 2014, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,9 @@
#include <string>
#include <stdio.h>
#ifdef HAVE_WORDEXP
#include <wordexp.h>
#endif
// Static class that offers a C++ API to readline C functions.
class Readline
@@ -47,22 +49,5 @@ private:
Readline& operator= (const Readline&); // Don't implement.
};
// RAII for wordexp_t
class Wordexp
{
public:
Wordexp (const std::string& str);
~Wordexp ();
int argc ();
char** argv ();
char* argv (int i);
void escapeSpecialChars(std::string& str);
private:
wordexp_t _p;
};
#endif
////////////////////////////////////////////////////////////////////////////////

View File

@@ -30,6 +30,7 @@
#include <fstream>
#include <iostream>
#include <cstring>
#include <string.h>
#include <text.h>
#include <i18n.h>
@@ -39,6 +40,8 @@
Context context;
#define MAX_ARGUMENTS 256
////////////////////////////////////////////////////////////////////////////////
int main (int argc, const char** argv)
{
@@ -154,19 +157,72 @@ int main (int argc, const char** argv)
try
{
Wordexp w ("task " + trim (input + permanent_overrides));
#ifdef HAVE_WORDEXP
std::string command = "task " + trim (input + permanent_overrides);
for (int i = 0; i < w.argc (); ++i)
// Escape special chars.
size_t i = 0;
while ((i = command.find_first_of ("$*?!|&;<>(){}~#@", i)) != std::string::npos)
{
command.insert(i, 1, '\\');
i += 2;
}
// Perform expansion.
wordexp_t p;
wordexp (command.c_str (), &p, 0);
char** w = p.we_wordv;
for (int i = 0; i < p.we_wordc; ++i)
{
if (std::find (quit_commands.begin (), quit_commands.end (),
lowerCase (w.argv (i))) != quit_commands.end ())
lowerCase (w[i])) != quit_commands.end ())
{
context.clearMessages ();
return 0;
}
}
int status = context.initialize (w.argc (), (const char**)w.argv ());
// External calls.
if (strcmp (w[1], "xc") == 0 && p.we_wordc > 2)
{
std::string combined = "";
for (int i = 2; i < p.we_wordc - 1 ; ++i)
{
combined += std::string (w[i]) + " ";
}
combined += w[p.we_wordc - 1]; // last goes without a blank
system (combined.c_str ()); // not checked
continue;
}
int status = context.initialize (p.we_wordc, (const char**)p.we_wordv);
wordfree(&p);
#else
std::string command = "task " + trim (input + permanent_overrides);
int arg_count = 0;
char* arg_vector[MAX_ARGUMENTS];
char* arg = strtok ((char*)command.c_str (), " ");
while (arg && arg_count < MAX_ARGUMENTS)
{
arg_vector[arg_count++] = arg;
arg = strtok (0, " ");
}
for (int i = 1; i < arg_count; ++i)
{
if (std::find (quit_commands.begin (), quit_commands.end (),
lowerCase (arg_vector[i])) != quit_commands.end ())
{
context.clearMessages ();
return 0;
}
}
int status = context.initialize (arg_count, (const char**) arg_vector);
#endif
if (status == 0)
context.run ();
}