MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / writeSourceFile

Method writeSourceFile

tools/compare.cs:98–239  ·  view source on GitHub ↗
(string path, string w, string filename)

Source from the content-addressed store, hash-verified

96 private const string graphTextColor = "black";
97
98 static private void writeSourceFile(string path, string w, string filename)
99 {
100 string errorLoc;
101 string errorMessage;
102 if (w[0] == '[')
103 {
104 errorLoc = w.Substring(1, w.IndexOf(']') - 1);
105 int i1 = w.IndexOf(')') + 1;
106 errorMessage = w.Substring(i1);
107 }
108 else
109 {
110 errorLoc = w.Substring(0, w.IndexOf(':', w.IndexOf(':') + 1));
111 int i1 = w.IndexOf(": ", w.IndexOf(": ") + 1) + 1;
112 int i2 = w.LastIndexOf('[') - 1;
113 errorMessage = w.Substring(i1, i2 - i1).Trim();
114 }
115 string f = errorLoc.Substring(0, errorLoc.LastIndexOf(':'));
116 int errorLine = Int32.Parse(errorLoc.Substring(1 + errorLoc.LastIndexOf(':')));
117 string symbolName = "";
118 if (errorMessage.IndexOf(": ") > 5)
119 {
120 string end = errorMessage.Substring(errorMessage.LastIndexOf(": "));
121 // get symbol name
122 Regex regex = new Regex(": '?[a-zA-Z_][a-zA-Z0-9_]*'?\\.?");
123 if (regex.IsMatch(end))
124 symbolName = end.Trim(':', ' ', '\'', '.');
125 }
126 string[] lines = System.IO.File.ReadAllLines(path + f);
127 string[] keywords = { "void", "bool", "char", "short", "int", "long", "double", "float",
128 "class", "struct", "union", "enum", "namespace", "friend", "using",
129 "for", "if", "while", "switch", "case", "default",
130 "return", "goto", "break", "continue", "throw",
131 "unsigned", "signed",
132 "private", "protected", "public",
133 "static", "const", "template", "typename", "auto", "virtual",
134 "true", "false", "this" };
135 System.IO.StreamWriter file = new System.IO.StreamWriter(path + filename);
136 file.WriteLine("<html>");
137 file.WriteLine("<head>");
138 file.WriteLine("<title>" + TextToHtml(w) + "</title>");
139 file.WriteLine("<style>");
140 file.WriteLine(" table {");
141 file.WriteLine(" border: 0px;");
142 file.WriteLine(" border-spacing: 0;");
143 file.WriteLine(" }");
144 file.WriteLine(" td {");
145 file.WriteLine(" border: 1px solid red;");
146 file.WriteLine(" padding: 5px;");
147 file.WriteLine(" background-color: #ffe0e0;");
148 file.WriteLine("}");
149 file.WriteLine("</style>");
150 file.WriteLine("</head>");
151 file.WriteLine("<body bgcolor=\"" + backgroundColor + "\"><pre>" + foregroundFont + TextToHtml(w) + "\n");
152 int linenr = 0;
153 bool multiline = false;
154 foreach (string line in lines)
155 {

Callers

nothing calls this directly

Calls 3

IsNameCharFunction · 0.85
ParseMethod · 0.80
WriteMethod · 0.80

Tested by

no test coverage detected