浏览代码

properly enquote spam text

David Rose 23 年之前
父节点
当前提交
23d9bf4583
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. 22 1
      dtool/src/interrogate/interfaceMaker.cxx

+ 22 - 1
dtool/src/interrogate/interfaceMaker.cxx

@@ -763,10 +763,31 @@ hash_function_signature(FunctionRemap *remap) {
 ////////////////////////////////////////////////////////////////////
 void InterfaceMaker::
 write_spam_message(ostream &out, FunctionRemap *remap) const {
+  ostringstream strm;
+  remap->write_orig_prototype(strm, 0);
+  string prototype = strm.str();
+
   out <<
     "  if (interrogatedb_cat.is_spam()) {\n"
     "    interrogatedb_cat.spam() << \"";
-  remap->write_orig_prototype(out, 0);
+
+  for (string::const_iterator si = prototype.begin();
+       si != prototype.end();
+       ++si) {
+    switch (*si) {
+    case '"':
+      out << "\\\"";
+      break;
+
+    case '\\':
+      out << "\\\\";
+      break;
+
+    default:
+      out << *si;
+    }
+  }
+
   out << "\\n\";\n"
     "  }\n";
 }