tools/compare.cs: Rename methods

This commit is contained in:
Daniel Marjamäki 2018-02-15 14:50:13 +01:00
parent 7029b620d5
commit a796330a50
1 changed files with 16 additions and 16 deletions

View File

@ -10,7 +10,7 @@ namespace difftool
{ {
class Program class Program
{ {
static private string firstLine(string s) static private string FirstLine(string s)
{ {
int i = s.IndexOf('\n'); int i = s.IndexOf('\n');
return i > 0 ? s.Substring(0, i) : s; return i > 0 ? s.Substring(0, i) : s;
@ -33,20 +33,20 @@ namespace difftool
ret.Add(s1[i1]); ret.Add(s1[i1]);
continue; continue;
} }
if (firstLine(s1[i1]) == firstLine(s2[i2])) if (FirstLine(s1[i1]) == FirstLine(s2[i2]))
{ {
++i2; ++i2;
continue; continue;
} }
for (int i3 = i2 + 1; i3 < i2 + 300 && i3 < s2.Length; ++i3) for (int i3 = i2 + 1; i3 < i2 + 300 && i3 < s2.Length; ++i3)
{ {
if (firstLine(s1[i1]) == firstLine(s2[i3])) if (FirstLine(s1[i1]) == FirstLine(s2[i3]))
{ {
i2 = i3; i2 = i3;
break; break;
} }
} }
if (firstLine(s1[i1]) == firstLine(s2[i2])) if (FirstLine(s1[i1]) == FirstLine(s2[i2]))
{ {
++i2; ++i2;
continue; continue;
@ -56,12 +56,12 @@ namespace difftool
return ret; return ret;
} }
static private string textToHtml(string s) static private string TextToHtml(string s)
{ {
return s.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;"); return s.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");
} }
static Boolean isNameChar(char c) static Boolean IsNameChar(char c)
{ {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
} }
@ -133,7 +133,7 @@ namespace difftool
"static", "const", "template", "typename", "auto", "virtual", "static", "const", "template", "typename", "auto", "virtual",
"true", "false", "this" }; "true", "false", "this" };
System.IO.StreamWriter file = new System.IO.StreamWriter(path + filename); System.IO.StreamWriter file = new System.IO.StreamWriter(path + filename);
file.Write("<html><head><title>" + textToHtml(w) + "</title></head><body bgcolor=\"" + backgroundColor + "\"><pre>" + foregroundFont + textToHtml(w) + "\n"); file.Write("<html><head><title>" + TextToHtml(w) + "</title></head><body bgcolor=\"" + backgroundColor + "\"><pre>" + foregroundFont + TextToHtml(w) + "\n");
int linenr = 0; int linenr = 0;
bool multiline = false; bool multiline = false;
foreach (string line in lines) foreach (string line in lines)
@ -158,12 +158,12 @@ namespace difftool
if (currentToken.EndsWith("*/")) if (currentToken.EndsWith("*/"))
multiline = false; multiline = false;
} }
file.Write(multiLineCommentFont + textToHtml(currentToken) + "</font>"); file.Write(multiLineCommentFont + TextToHtml(currentToken) + "</font>");
} }
else if (isNameChar(line[i])) else if (IsNameChar(line[i]))
{ {
string currentToken = ""; string currentToken = "";
while (i < line.Length && isNameChar(line[i])) while (i < line.Length && IsNameChar(line[i]))
{ {
currentToken += line[i]; currentToken += line[i];
i++; i++;
@ -187,11 +187,11 @@ namespace difftool
if (currentToken.Length > 1 && currentToken[0] == line[i - 1]) if (currentToken.Length > 1 && currentToken[0] == line[i - 1])
break; break;
} }
file.Write(stringFont + textToHtml(currentToken) + "</font>"); file.Write(stringFont + TextToHtml(currentToken) + "</font>");
} }
else if (line[i] == '/' && i + 1 < line.Length && line[i + 1] == '/') else if (line[i] == '/' && i + 1 < line.Length && line[i + 1] == '/')
{ {
file.Write(singleLineCommentFont + textToHtml(line.Substring(i)) + "</font>"); file.Write(singleLineCommentFont + TextToHtml(line.Substring(i)) + "</font>");
i = line.Length; i = line.Length;
} }
else if (line[i] == '/' && i + 1 < line.Length && line[i + 1] == '*') else if (line[i] == '/' && i + 1 < line.Length && line[i + 1] == '*')
@ -206,18 +206,18 @@ namespace difftool
if (currentToken.Length > 3 && currentToken.EndsWith("*/")) if (currentToken.Length > 3 && currentToken.EndsWith("*/"))
multiline = false; multiline = false;
} }
file.Write(multiLineCommentFont + textToHtml(currentToken) + "</font>"); file.Write(multiLineCommentFont + TextToHtml(currentToken) + "</font>");
} }
else else
{ {
file.Write(textToHtml(line.Substring(i, 1))); file.Write(TextToHtml(line.Substring(i, 1)));
i++; i++;
} }
} }
file.Write('\n'); file.Write('\n');
if (errorLine == linenr) if (errorLine == linenr)
file.Write(" <mark>" + textToHtml(w.Substring(w.IndexOf(": "))) + "</mark>\n"); file.Write(" <mark>" + TextToHtml(w.Substring(w.IndexOf(": "))) + "</mark>\n");
} }
file.Write("</font></pre></body></html>"); file.Write("</font></pre></body></html>");
file.Close(); file.Close();
@ -303,7 +303,7 @@ namespace difftool
string filename = "code" + fileIndex.ToString() + ".html"; string filename = "code" + fileIndex.ToString() + ".html";
fileIndex++; fileIndex++;
writeSourceFile(path, w, "html/" + filename); writeSourceFile(path, w, "html/" + filename);
file.WriteLine("<a href=\"{0}\">{1}</a>", filename, textToHtml(w)); file.WriteLine("<a href=\"{0}\">{1}</a>", filename, TextToHtml(w));
} }
file.WriteLine("</pre>"); file.WriteLine("</pre>");
} }