Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: tools/gn/visual_studio_writer.cc

Issue 2813213002: Moved/renamed EscapeString from visual_studio_writer to XmlEscape in xml_element_writer. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/gn/xml_element_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/visual_studio_writer.h" 5 #include "tools/gn/visual_studio_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 19 matching lines...) Expand all
30 #include "tools/gn/variables.h" 30 #include "tools/gn/variables.h"
31 #include "tools/gn/visual_studio_utils.h" 31 #include "tools/gn/visual_studio_utils.h"
32 #include "tools/gn/xml_element_writer.h" 32 #include "tools/gn/xml_element_writer.h"
33 33
34 #if defined(OS_WIN) 34 #if defined(OS_WIN)
35 #include "base/win/registry.h" 35 #include "base/win/registry.h"
36 #endif 36 #endif
37 37
38 namespace { 38 namespace {
39 39
40 std::string EscapeString(const std::string& value) {
41 std::string result;
42 for (char c : value) {
43 switch (c) {
44 case '\n':
45 result += "&#10;";
46 break;
47 case '\r':
48 result += "&#13;";
49 break;
50 case '\t':
51 result += "&#9;";
52 break;
53 case '"':
54 result += "&quot;";
55 break;
56 case '<':
57 result += "&lt;";
58 break;
59 case '>':
60 result += "&gt;";
61 break;
62 case '&':
63 result += "&amp;";
64 break;
65 default:
66 result += c;
67 }
68 }
69 return result;
70 }
71
72 struct SemicolonSeparatedWriter { 40 struct SemicolonSeparatedWriter {
73 void operator()(const std::string& value, std::ostream& out) const { 41 void operator()(const std::string& value, std::ostream& out) const {
74 out << EscapeString(value) + ';'; 42 out << XmlEscape(value) + ';';
75 } 43 }
76 }; 44 };
77 45
78 struct IncludeDirWriter { 46 struct IncludeDirWriter {
79 explicit IncludeDirWriter(PathOutput& path_output) 47 explicit IncludeDirWriter(PathOutput& path_output)
80 : path_output_(path_output) {} 48 : path_output_(path_output) {}
81 ~IncludeDirWriter() = default; 49 ~IncludeDirWriter() = default;
82 50
83 void operator()(const SourceDir& dir, std::ostream& out) const { 51 void operator()(const SourceDir& dir, std::ostream& out) const {
84 path_output_.WriteDir(out, dir, PathOutput::DIR_NO_LAST_SLASH); 52 path_output_.WriteDir(out, dir, PathOutput::DIR_NO_LAST_SLASH);
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 867 }
900 } 868 }
901 869
902 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { 870 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) {
903 std::ostringstream ninja_target_out; 871 std::ostringstream ninja_target_out;
904 DCHECK(!target->dependency_output_file().value().empty()); 872 DCHECK(!target->dependency_output_file().value().empty());
905 ninja_path_output_.WriteFile(ninja_target_out, 873 ninja_path_output_.WriteFile(ninja_target_out,
906 target->dependency_output_file()); 874 target->dependency_output_file());
907 return ninja_target_out.str(); 875 return ninja_target_out.str();
908 } 876 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/xml_element_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698