Browse Source

added egg2c

David Rose 24 years ago
parent
commit
8702491c5b

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

@@ -99,43 +99,6 @@ post_command_line() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void EggBase::
 void EggBase::
 append_command_comment(EggData &data) {
 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));
   data.insert(data.begin(), new EggComment("", comment));
 }
 }

+ 8 - 0
pandatool/src/eggprogs/Sources.pp

@@ -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

+ 50 - 0
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
 //     Function: ProgramBase::handle_args

+ 2 - 0
pandatool/src/progbase/programBase.h

@@ -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;