chokes on quotes in paths
in GatherIncludes for example. Please tell me if you need more info.
This implcitly includes that spaces in paths must be handled correctly.
By default it will wrap all paths in quotes incase they have spaces. I guess I need to check for any pre-wrapped with quotes and skip that process.
It's worse. It also received paths like "aa\b\c\d" (read it as-is, \ aren't escapes) This is my quickly and dirty fix:
CVXBuildSystem.cs | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/CVXBuildSystem.cs b/CVXBuildSystem.cs
index de1768a..493ea74 100644
--- a/CVXBuildSystem.cs
+++ b/CVXBuildSystem.cs
@@ -530,6 +530,24 @@ namespace ClangVSx
#region Data Gathering
+ static internal string addQuotes(string input)
+ {
+ if (!input.Contains("\""))
+ return "\"" + input + "\"";
+ // check if they are in the right place
+ if (!(input[0] == '"' && input[input.Length - 1] == '"'))
+ throw new Exception("Unexpected quotes inside the string: " + input);
+ return input;
+ }
+
+ static internal string sanitizePath(string input)
+ {
+ input = input.Replace("\"", "");
+ if (input[0] == '/') input = input.Substring(1);
+ if (input[input.Length - 1] == '/') input = input.Remove(input.Length - 1);
+ return input;
+ }
+
/// <summary>
///
/// </summary>
@@ -554,16 +572,13 @@ namespace ClangVSx
result.Append("-I");
String incCheck = parsedInc.Replace("\\", "/");
- // Clang doesn't like the trailing / on these
- if (incCheck == "./") incCheck = ".";
- if (incCheck == "../") incCheck = "..";
+ // remove /
+ incCheck = sanitizePath(incCheck);
// resolve any relative paths
incCheck = Path.GetFullPath(incCheck);
- result.Append("\"");
- result.Append(incCheck);
- result.Append("\" ");
+ result.Append(addQuotes(incCheck));
+ result.Append(" ");
}
}
}
@@ -587,9 +602,9 @@ namespace ClangVSx
// resolve any relative paths
incCheck = Path.GetFullPath(incCheck);
- result.Append("-include \"");
- result.Append(incCheck);
- result.Append("\" ");
+ result.Append("-include ");
+ result.Append(addQuotes(incCheck));
+ result.Append(" ");
}
}
}
@@ -747,16 +762,16 @@ namespace ClangVSx
{
if (inc.Length > 0)
{
- uniqueDirs.Add(Path.GetFullPath(inc.Replace("\\", "/")));
+ uniqueDirs.Add(Path.GetFullPath(sanitizePath(inc.Replace("\\", "/"))));
}
}
foreach (String inc in uniqueDirs)
{
- defaultCompilerString.Append("-isystem \"");
- defaultCompilerString.Append(inc);
- defaultCompilerString.Replace("\\", "", defaultCompilerString.Length - 1, 1);
- defaultCompilerString.Append("\" ");
+ defaultCompilerString.Append("-isystem ");
+ defaultCompilerString.Append(addQuotes(inc));
+ defaultCompilerString.Replace("\\", "", defaultCompilerString.Length - 2, 1);
+ defaultCompilerString.Append(" ");
}
}
defaultCompilerString.Append(" -fms-compatibility ");
Now it manages to run clang, but preprocessed output is always empty.
Looks like it didn't like the show compiler phases switch.