added egg2c

This commit is contained in:
David Rose 2001-08-03 22:12:21 +00:00
parent afb6dacbe0
commit 8702491c5b
4 changed files with 61 additions and 38 deletions

View File

@ -99,43 +99,6 @@ post_command_line() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void EggBase:: void EggBase::
append_command_comment(EggData &data) { append_command_comment(EggData &data) {
string comment; string comment = get_exec_command();
comment = _program_name;
Args::const_iterator ai;
for (ai = _program_args.begin(); ai != _program_args.end(); ++ai) {
const string &arg = (*ai);
// First, check to see if the string is shell-acceptable.
bool legal = true;
string::const_iterator si;
for (si = arg.begin(); legal && si != arg.end(); ++si) {
switch (*si) {
case ' ':
case '\n':
case '\t':
case '*':
case '?':
case '\\':
case '(':
case ')':
case '|':
case '&':
case '<':
case '>':
case '"':
case ';':
case '$':
legal = false;
}
}
if (legal) {
comment += " " + arg;
} else {
comment += " '" + arg + "'";
}
}
data.insert(data.begin(), new EggComment("", comment)); data.insert(data.begin(), new EggComment("", comment));
} }

View File

@ -31,3 +31,11 @@
eggTopstrip.cxx eggTopstrip.h eggTopstrip.cxx eggTopstrip.h
#end bin_target #end bin_target
#begin bin_target
#define TARGET egg2c
#define SOURCES \
eggToC.cxx eggToC.h
#end bin_target

View File

@ -344,6 +344,56 @@ parse_command_line(int argc, char *argv[]) {
} }
} }
////////////////////////////////////////////////////////////////////
// Function: ProgramBase::get_exec_command
// Access: Public
// Description: Returns the command that invoked this program, as a
// shell-friendly string, suitable for pasting into the
// comments of output files.
////////////////////////////////////////////////////////////////////
string ProgramBase::
get_exec_command() const {
string command;
command = _program_name;
Args::const_iterator ai;
for (ai = _program_args.begin(); ai != _program_args.end(); ++ai) {
const string &arg = (*ai);
// First, check to see if the string is shell-acceptable.
bool legal = true;
string::const_iterator si;
for (si = arg.begin(); legal && si != arg.end(); ++si) {
switch (*si) {
case ' ':
case '\n':
case '\t':
case '*':
case '?':
case '\\':
case '(':
case ')':
case '|':
case '&':
case '<':
case '>':
case '"':
case ';':
case '$':
legal = false;
}
}
if (legal) {
command += " " + arg;
} else {
command += " '" + arg + "'";
}
}
return command;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: ProgramBase::handle_args // Function: ProgramBase::handle_args

View File

@ -51,6 +51,8 @@ public:
virtual void parse_command_line(int argc, char *argv[]); virtual void parse_command_line(int argc, char *argv[]);
string get_exec_command() const;
typedef pdeque<string> Args; typedef pdeque<string> Args;
Filename _program_name; Filename _program_name;
Args _program_args; Args _program_args;