[PATCH] Implement TokenizeWindowsCommandLine.

Rui Ueyama ruiu at google.com
Tue Jul 30 11:03:56 PDT 2013



================
Comment at: lib/Support/CommandLine.cpp:504
@@ +503,3 @@
+/// escape double quote. This method consumes runs of backslashes as well as the
+/// following backslash if it's escaped.
+///
----------------
Reid Kleckner wrote:
> Did you mean the following quote?
Yup. Fixed.

================
Comment at: lib/Support/CommandLine.cpp:509
@@ +508,3 @@
+///    quote remains unconsumed. The double quote will later be interpreted as
+///    the start of a quoted string in the main loop outside of this function.
+///
----------------
Reid Kleckner wrote:
> I guess I'd say "start or end" of a quoted string.
Fixed.

================
Comment at: lib/Support/CommandLine.cpp:516
@@ +515,3 @@
+///
+///  * Otherwise, backslahses are interpreted literally.
+static size_t parseBackslash(StringRef Src, size_t I, SmallString<128> &Token) {
----------------
Reid Kleckner wrote:
> typo on backslashes
Fixed.

================
Comment at: lib/Support/CommandLine.cpp:526
@@ +525,3 @@
+
+  bool followedByDoubleQuote = (I != E && Src[I] == '"');
+  if (followedByDoubleQuote) {
----------------
Reid Kleckner wrote:
> nit: variables are StudlyCaps.
Fixed.

================
Comment at: lib/Support/CommandLine.cpp:536
@@ +535,3 @@
+
+  for (int J = 0; J < BackslashCount; ++J)
+    Token.push_back('\\');
----------------
Reid Kleckner wrote:
> This can be Token.append(BackslashCount, '\\');
I was looking for the method. Thanks!

================
Comment at: lib/Support/CommandLine.cpp:547
@@ +546,3 @@
+  // end of the source string.
+  enum { INIT, UNQUOTED, QUOTED } state = INIT;
+  for (size_t I = 0, E = Src.size(); I != E; ++I) {
----------------
Reid Kleckner wrote:
> nit: enums and the variable are StudlyCaps.
Fixed.

================
Comment at: unittests/Support/CommandLineTest.cpp:156
@@ +155,3 @@
+TEST(CommandLineTest, TokenizeWindowsCommandLine) {
+  const char *Input = "a\\b c\\\\d e\\\\\"f g\" h\\\"i j\\\\\\\"k \"lmn\" o pqr "
+                      "\"st \\\"u\" \\v";
----------------
Reid Kleckner wrote:
> Oof, reading this test case is hard, but I don't have any good suggestions.  :)
Yeah, one bare quoted backslash became four backslashes in C string. That's annoying but there's no good way to write it :/


http://llvm-reviews.chandlerc.com/D1235



More information about the llvm-commits mailing list