|
@@ -292,7 +292,8 @@ string DefaultValue(const FieldDescriptor* field) {
|
|
ClassName(field->enum_type(), true),
|
|
ClassName(field->enum_type(), true),
|
|
field->default_value_enum()->number());
|
|
field->default_value_enum()->number());
|
|
case FieldDescriptor::CPPTYPE_STRING:
|
|
case FieldDescriptor::CPPTYPE_STRING:
|
|
- return "\"" + CEscape(field->default_value_string()) + "\"";
|
|
|
|
|
|
+ return "\"" + EscapeTrigraphs(CEscape(field->default_value_string())) +
|
|
|
|
+ "\"";
|
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
|
case FieldDescriptor::CPPTYPE_MESSAGE:
|
|
return FieldMessageTypeName(field) + "::default_instance()";
|
|
return FieldMessageTypeName(field) + "::default_instance()";
|
|
}
|
|
}
|
|
@@ -335,6 +336,11 @@ string GlobalShutdownFileName(const string& filename) {
|
|
return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
|
|
return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Escape C++ trigraphs by escaping question marks to \?
|
|
|
|
+string EscapeTrigraphs(const string& to_escape) {
|
|
|
|
+ return StringReplace(to_escape, "?", "\\?", true);
|
|
|
|
+}
|
|
|
|
+
|
|
} // namespace cpp
|
|
} // namespace cpp
|
|
} // namespace compiler
|
|
} // namespace compiler
|
|
} // namespace protobuf
|
|
} // namespace protobuf
|