diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 9d106df560..6225f4382c 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -99,43 +99,6 @@ post_command_line() { //////////////////////////////////////////////////////////////////// void EggBase:: append_command_comment(EggData &data) { - string comment; - - 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 + "'"; - } - } - + string comment = get_exec_command(); data.insert(data.begin(), new EggComment("", comment)); } diff --git a/pandatool/src/eggprogs/Sources.pp b/pandatool/src/eggprogs/Sources.pp index 63995fffd8..7e92a73fbf 100644 --- a/pandatool/src/eggprogs/Sources.pp +++ b/pandatool/src/eggprogs/Sources.pp @@ -31,3 +31,11 @@ eggTopstrip.cxx eggTopstrip.h #end bin_target + +#begin bin_target + #define TARGET egg2c + + #define SOURCES \ + eggToC.cxx eggToC.h + +#end bin_target diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 633ff8dcdd..bdf8428a98 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -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 diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index efe8624a4e..bf8c2e3edf 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -51,6 +51,8 @@ public: virtual void parse_command_line(int argc, char *argv[]); + string get_exec_command() const; + typedef pdeque Args; Filename _program_name; Args _program_args;