Bläddra i källkod

extend append_command_comment a bit

David Rose 23 år sedan
förälder
incheckning
fcd244a06c

+ 16 - 1
pandatool/src/eggbase/eggBase.cxx

@@ -144,6 +144,21 @@ post_command_line() {
 ////////////////////////////////////////////////////////////////////
 void EggBase::
 append_command_comment(EggData &data) {
-  string comment = get_exec_command();
+  append_command_comment(data, get_exec_command());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggBase::append_command_comment
+//       Access: Protected, Static
+//  Description: Inserts a comment into the beginning of the indicated
+//               egg file corresponding to the command line that
+//               invoked this program.
+//
+//               Normally this function is called automatically when
+//               appropriate by EggWriter, and it's not necessary to
+//               call it explicitly.
+////////////////////////////////////////////////////////////////////
+void EggBase::
+append_command_comment(EggData &data, const string &comment) {
   data.insert(data.begin(), new EggComment("", comment));
 }

+ 1 - 0
pandatool/src/eggbase/eggBase.h

@@ -53,6 +53,7 @@ public:
 protected:
   virtual bool post_command_line();
   void append_command_comment(EggData &_data);
+  static void append_command_comment(EggData &_data, const string &comment);
 
 protected:
   bool _got_coordinate_system;

+ 17 - 39
pandatool/src/eggbase/eggMultiBase.cxx

@@ -55,49 +55,27 @@ EggMultiBase() {
 //               invoked this program.
 //
 //               Normally this function is called automatically when
-//               appropriate by EggMultiFilter, and it's not necessary
-//               to call it explicitly.
+//               appropriate by EggWriter, and it's not necessary to
+//               call it explicitly.
 ////////////////////////////////////////////////////////////////////
 void EggMultiBase::
 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 + "'";
-    }
-  }
+  append_command_comment(data, get_exec_command());
+}
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggMultiBase::append_command_comment
+//       Access: Protected, Static
+//  Description: Inserts a comment into the beginning of the indicated
+//               egg file corresponding to the command line that
+//               invoked this program.
+//
+//               Normally this function is called automatically when
+//               appropriate by EggWriter, and it's not necessary to
+//               call it explicitly.
+////////////////////////////////////////////////////////////////////
+void EggMultiBase::
+append_command_comment(EggData &data, const string &comment) {
   data.insert(data.begin(), new EggComment("", comment));
 }
 

+ 1 - 0
pandatool/src/eggbase/eggMultiBase.h

@@ -43,6 +43,7 @@ public:
 
 protected:
   void append_command_comment(EggData &_data);
+  static void append_command_comment(EggData &_data, const string &comment);
 
   virtual PT(EggData) read_egg(const Filename &filename);