aboutsummaryrefslogtreecommitdiff
path: root/src/functioncommandtolist.cpp
blob: 708db5bd3e76482ff86883c89acde2604075617d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "functioncommandtolist.h"
#include "plugger.h"

PluginInterface2(commandToList, FunctionCommandToList, Function, "Mike Buland", 0, 1 );

FunctionCommandToList::FunctionCommandToList()
{
}

FunctionCommandToList::~FunctionCommandToList()
{
}

void FunctionCommandToList::execute( Build *bld, const StringList &lInput, StringList &lOutput )
{
	//rView.beginExtraRequiresCheck( s.c_str() );
	//rView.executeCmd( s.c_str() );
	FILE *fcmd = popen( lParams.front().c_str(), "r" );
	std::string rhs;
	bool bHeader = true;
	for(;;)
	{
		if( feof( fcmd ) )
			break;
		int cc = fgetc( fcmd );
		if( cc == EOF )
			break;
		unsigned char c = cc;
		if( bHeader )
		{
			if( c == ':' )
				bHeader = false;
		}
		else
		{
			if( c == ' ' || c == '\t' )
			{
				if( rhs != "" )
				{
					lOutput.push_back( rhs );
					rhs = "";
				}
			}
			else
			{
				if( c == '\\' )
					c = fgetc( fcmd );
				if( c != '\n' )
					rhs += c;
			}
		}
	}
	if( rhs != "" )
	{
		lOutput.push_back( rhs );
		rhs = "";
	}
	pclose( fcmd );
	//rView.endExtraRequiresCheck();
}

Function *FunctionCommandToList::duplicate( Build &bld, const std::string &cont, VarMap *mExtra )
{
	Function *pRet = new FunctionCommandToList();
	pRet->copyData( this, bld, cont, mExtra );
	return pRet;
}