mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
added egg2c
This commit is contained in:
parent
afb6dacbe0
commit
8702491c5b
@ -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));
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user