Skip to content

Instantly share code, notes, and snippets.

@darktears
Created April 3, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darktears/7988e2ee71df2d7f65314c950f02e408 to your computer and use it in GitHub Desktop.
Save darktears/7988e2ee71df2d7f65314c950f02e408 to your computer and use it in GitHub Desktop.
diff --git a/tools/gn/visual_studio_writer.cc b/tools/gn/visual_studio_writer.cc
index 8a8cf528fc15..59d27bf6a0be 100644
--- a/tools/gn/visual_studio_writer.cc
+++ b/tools/gn/visual_studio_writer.cc
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
#include <queue>
+#include <regex>
#include <set>
#include <string>
@@ -37,9 +38,10 @@
namespace {
-struct SemicolonSeparatedWriter {
+struct SemicolonSeparatedAndSpecialCharacterConverterWriter {
void operator()(const std::string& value, std::ostream& out) const {
- out << value + ';';
+ std::string result = std::regex_replace(value, std::regex("<<"), "%3C%3C");
+ out << result + ';';
}
};
@@ -545,7 +547,8 @@ bool VisualStudioWriter::WriteProjectFileContents(
std::unique_ptr<XmlElementWriter> preprocessor_definitions =
cl_compile->SubElement("PreprocessorDefinitions");
RecursiveTargetConfigToStream<std::string>(
- target, &ConfigValues::defines, SemicolonSeparatedWriter(),
+ target, &ConfigValues::defines,
+ SemicolonSeparatedAndSpecialCharacterConverterWriter(),
preprocessor_definitions->StartContent(false));
preprocessor_definitions->Text("%(PreprocessorDefinitions)");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment