repo git: Fix coding style for #823
This commit is contained in:
parent
9ddb9cbb7e
commit
be9f7de13f
|
@ -18,6 +18,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using SparkleLib;
|
||||
|
||||
|
@ -480,7 +481,7 @@ namespace SparkleLib.Git {
|
|||
|
||||
foreach (string line in lines) {
|
||||
string conflicting_path = line.Substring (3);
|
||||
conflicting_path = this.EnsureSpecialCharacters (conflicting_path);
|
||||
conflicting_path = EnsureSpecialCharacters (conflicting_path);
|
||||
|
||||
SparkleHelpers.DebugInfo ("Git", Name + " | Conflict type: " + line);
|
||||
|
||||
|
@ -710,8 +711,8 @@ namespace SparkleLib.Git {
|
|||
file_path = entry_line.Substring (42, tab_pos - 42);
|
||||
to_file_path = entry_line.Substring (tab_pos + 1);
|
||||
|
||||
file_path = this.EnsureSpecialCharacters (file_path);
|
||||
to_file_path = this.EnsureSpecialCharacters (to_file_path);
|
||||
file_path = EnsureSpecialCharacters (file_path);
|
||||
to_file_path = EnsureSpecialCharacters (to_file_path);
|
||||
|
||||
if (file_path.EndsWith (".empty"))
|
||||
file_path = file_path.Substring (0, file_path.Length - 6);
|
||||
|
@ -765,47 +766,47 @@ namespace SparkleLib.Git {
|
|||
return change_sets;
|
||||
}
|
||||
|
||||
private string EnsureSpecialCharacters (string file_path)
|
||||
|
||||
private string EnsureSpecialCharacters (string path)
|
||||
{
|
||||
if (file_path.StartsWith("\""))
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(file_path.Length > 2 && file_path.EndsWith("\""), "unexpected path");
|
||||
file_path = ResolveSpecialChars(file_path.Substring(1, file_path.Length - 2));
|
||||
}
|
||||
return file_path;
|
||||
// The path is quoted if it contains special characters
|
||||
if (path.StartsWith ("\""))
|
||||
path = ResolveSpecialChars (path.Substring (1, path.Length - 2));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves special characters like \303\244 (ä) to their real character
|
||||
/// </summary>
|
||||
/// <param name="file_path"></param>
|
||||
/// <returns></returns>
|
||||
private string ResolveSpecialChars (string file_path)
|
||||
private string ResolveSpecialChars (string s)
|
||||
{
|
||||
var builder = new System.Text.StringBuilder(file_path.Length);
|
||||
var codes = new List<byte>();
|
||||
for (int i = 0; i < file_path.Length; i++)
|
||||
{
|
||||
while (file_path[i] == '\\'
|
||||
&& file_path.Length - i > 3
|
||||
&& char.IsNumber(file_path[i + 1])
|
||||
&& char.IsNumber(file_path[i + 2])
|
||||
&& char.IsNumber(file_path[i + 3]))
|
||||
{
|
||||
codes.Add (Convert.ToByte(file_path.Substring(i + 1, 3), 8));
|
||||
StringBuilder builder = new StringBuilder (s.Length);
|
||||
List<byte> codes = new List<byte> ();
|
||||
|
||||
for (int i = 0; i < s.Length; i++) {
|
||||
while (s [i] == '\\' &&
|
||||
s.Length - i > 3 &&
|
||||
char.IsNumber (s [i + 1]) &&
|
||||
char.IsNumber (s [i + 2]) &&
|
||||
char.IsNumber (s [i + 3])) {
|
||||
|
||||
codes.Add (Convert.ToByte (s.Substring (i + 1, 3), 8));
|
||||
i += 4;
|
||||
}
|
||||
|
||||
if (codes.Count > 0)
|
||||
{
|
||||
builder.Append(System.Text.Encoding.UTF8.GetString (codes.ToArray ()));
|
||||
if (codes.Count > 0) {
|
||||
builder.Append (Encoding.UTF8.GetString (codes.ToArray ()));
|
||||
codes.Clear ();
|
||||
}
|
||||
|
||||
builder.Append(file_path[i]);
|
||||
builder.Append (s [i]);
|
||||
}
|
||||
return builder.ToString();
|
||||
//System.Text.Encoding.UTF8.
|
||||
|
||||
return builder.ToString ();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue