mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Handle consecutive-double-quotes in Windows argument parsing
Windows command line argument processing treats consecutive double quotes as a single double-quote. This patch implements this functionality. Differential Revision: https://reviews.llvm.org/D58662 llvm-svn: 356193
This commit is contained in:
parent
cd6dce3d39
commit
53ebef63af
@ -874,6 +874,13 @@ void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver,
|
||||
// QUOTED state means that it's reading a token quoted by double quotes.
|
||||
if (State == QUOTED) {
|
||||
if (C == '"') {
|
||||
if (I < (E - 1) && Src[I + 1] == '"') {
|
||||
// Consecutive double-quotes inside a quoted string implies one
|
||||
// double-quote.
|
||||
Token.push_back('"');
|
||||
I = I + 1;
|
||||
continue;
|
||||
}
|
||||
State = UNQUOTED;
|
||||
continue;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ TEST(CommandLineTest, TokenizeGNUCommandLine) {
|
||||
array_lengthof(Output));
|
||||
}
|
||||
|
||||
TEST(CommandLineTest, TokenizeWindowsCommandLine) {
|
||||
TEST(CommandLineTest, TokenizeWindowsCommandLine1) {
|
||||
const char Input[] = "a\\b c\\\\d e\\\\\"f g\" h\\\"i j\\\\\\\"k \"lmn\" o pqr "
|
||||
"\"st \\\"u\" \\v";
|
||||
const char *const Output[] = { "a\\b", "c\\\\d", "e\\f g", "h\"i", "j\\\"k",
|
||||
@ -194,6 +194,13 @@ TEST(CommandLineTest, TokenizeWindowsCommandLine) {
|
||||
array_lengthof(Output));
|
||||
}
|
||||
|
||||
TEST(CommandLineTest, TokenizeWindowsCommandLine2) {
|
||||
const char Input[] = "clang -c -DFOO=\"\"\"ABC\"\"\" x.cpp";
|
||||
const char *const Output[] = { "clang", "-c", "-DFOO=\"ABC\"", "x.cpp"};
|
||||
testCommandLineTokenizer(cl::TokenizeWindowsCommandLine, Input, Output,
|
||||
array_lengthof(Output));
|
||||
}
|
||||
|
||||
TEST(CommandLineTest, TokenizeConfigFile1) {
|
||||
const char *Input = "\\";
|
||||
const char *const Output[] = { "\\" };
|
||||
|
Loading…
x
Reference in New Issue
Block a user