Source: src/cl_cmdexpand.cc


Annotated List
Files
Globals
Hierarchy
Index
//command expander for Lua language

#include "cl_cmdexpand.h"

void CMD_EXPANDER::init()
{
	enable_expanding = 1;
}

string CMD_EXPANDER::expand(string s)
{
	string cmd = s;
	int i;
	int exp = 1;
#ifdef DEBUG
	cout << "# " << s << endl;
#endif

	if((!enable_expanding) || (!s.length())) {
		return s;
	}
	
	cmd = remove_newline(cmd);
	
	if(((int)cmd.find("(") == -1) || ((int)cmd.find("[") == -1) ||
			((int)cmd.find("{") == -1)){
		exp = 0;
	}
	
	if(((int)cmd.find(" ") != -1) && (!exp)) {
		i = (int)cmd.find(" ");
		cmd.replace(i,1,"(\"");
		while((i = (int)cmd.find(" ")) != -1) {
			cmd.replace(i,1,"\",\"");
		}
		cmd = cmd + "\")";
	}
	if(((int)cmd.find("(") == -1) && ((int)cmd.find("[") == -1) &&
			((int)cmd.find("{") == -1) && (!exp)){
		cmd = cmd + "()";
	}

//	message("Expanded [%s] to [%s]", s.c_str(), cmd.c_str());
	return cmd;
}

void CMD_EXPANDER::enable()
{
	enable_expanding = 1;
}

void CMD_EXPANDER::disable()
{
	enable_expanding = 0;
}


Generated by: georgik on armada on Sat Jul 24 07:07:15 2004, using kdoc 2.0a54.