[PATCH] D58662: Handle consecutive-double-quotes in Windows argument parsing
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 12:25:10 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356193: Handle consecutive-double-quotes in Windows argument parsing (authored by ssrivastava, committed by ).
Herald added subscribers: llvm-commits, kristina.
Changed prior to commit:
https://reviews.llvm.org/D58662?vs=188284&id=190702#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58662/new/
https://reviews.llvm.org/D58662
Files:
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/unittests/Support/CommandLineTest.cpp
Index: llvm/trunk/lib/Support/CommandLine.cpp
===================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp
+++ llvm/trunk/lib/Support/CommandLine.cpp
@@ -874,6 +874,13 @@
// 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;
}
Index: llvm/trunk/unittests/Support/CommandLineTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/CommandLineTest.cpp
+++ llvm/trunk/unittests/Support/CommandLineTest.cpp
@@ -185,7 +185,7 @@
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 @@
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[] = { "\\" };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58662.190702.patch
Type: text/x-patch
Size: 1789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190314/2d2931f6/attachment.bin>
More information about the llvm-commits
mailing list