mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Parser
- Removed ::appendStdin.
This commit is contained in:
parent
0da5f9160e
commit
090c80cb90
3 changed files with 0 additions and 48 deletions
|
@ -38,10 +38,6 @@
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
|
||||||
#ifdef FEATURE_STDIN
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
// Overridden by rc.abbreviation.minimum.
|
// Overridden by rc.abbreviation.minimum.
|
||||||
|
@ -166,48 +162,6 @@ void Parser::clear ()
|
||||||
_tree = new Tree ("root");
|
_tree = new Tree ("root");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Add an arg for every word from std::cin.
|
|
||||||
//
|
|
||||||
// echo one two -- three | task zero --> task zero one two
|
|
||||||
// 'three' is left in the input buffer.
|
|
||||||
void Parser::appendStdin ()
|
|
||||||
{
|
|
||||||
#ifdef FEATURE_STDIN
|
|
||||||
// Use 'select' to determine whether there is any std::cin content buffered
|
|
||||||
// before trying to read it, to prevent blocking.
|
|
||||||
struct timeval tv;
|
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 1000;
|
|
||||||
|
|
||||||
fd_set fds;
|
|
||||||
FD_ZERO (&fds);
|
|
||||||
FD_SET (STDIN_FILENO, &fds);
|
|
||||||
|
|
||||||
int result = select (STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
|
|
||||||
if (result && result != -1)
|
|
||||||
{
|
|
||||||
if (FD_ISSET (0, &fds))
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
std::string arg;
|
|
||||||
while (std::cin >> arg)
|
|
||||||
{
|
|
||||||
// It the terminator token is found, stop reading.
|
|
||||||
if (arg == "--")
|
|
||||||
break;
|
|
||||||
|
|
||||||
Tree* branch = _tree->addBranch (new Tree (format ("stdin{1}", i++)));
|
|
||||||
branch->attribute ("raw", arg);
|
|
||||||
branch->tag ("ORIGINAL");
|
|
||||||
branch->tag ("STDIN");
|
|
||||||
branch->tag ("?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Tree* Parser::tree ()
|
Tree* Parser::tree ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,6 @@ public:
|
||||||
|
|
||||||
void initialize (int, const char**);
|
void initialize (int, const char**);
|
||||||
void clear ();
|
void clear ();
|
||||||
void appendStdin ();
|
|
||||||
Tree* tree ();
|
Tree* tree ();
|
||||||
Tree* parse ();
|
Tree* parse ();
|
||||||
void alias (const std::string&, const std::string&);
|
void alias (const std::string&, const std::string&);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#define INCLUDED_MAIN
|
#define INCLUDED_MAIN
|
||||||
|
|
||||||
#define FEATURE_COLOR 1 // Enable color.
|
#define FEATURE_COLOR 1 // Enable color.
|
||||||
//#define FEATURE_STDIN 1 // Enable reading stdin.
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue