- Removed ::appendStdin.
This commit is contained in:
Paul Beckingham 2014-09-07 13:40:00 -04:00
parent 0da5f9160e
commit 090c80cb90
3 changed files with 0 additions and 48 deletions

View file

@ -38,10 +38,6 @@
#include <util.h>
#include <i18n.h>
#ifdef FEATURE_STDIN
#include <sys/select.h>
#endif
extern Context context;
// Overridden by rc.abbreviation.minimum.
@ -166,48 +162,6 @@ void Parser::clear ()
_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 ()
{

View file

@ -42,7 +42,6 @@ public:
void initialize (int, const char**);
void clear ();
void appendStdin ();
Tree* tree ();
Tree* parse ();
void alias (const std::string&, const std::string&);

View file

@ -28,7 +28,6 @@
#define INCLUDED_MAIN
#define FEATURE_COLOR 1 // Enable color.
//#define FEATURE_STDIN 1 // Enable reading stdin.
#include <string>
#include <vector>