[PATCH] CommandLineArgumentParser: handle single quotes.

Peter Collingbourne peter at pcc.me.uk
Thu Feb 28 19:33:12 PST 2013


Hi klimek,

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

Files:
  lib/Tooling/JSONCompilationDatabase.cpp

Index: lib/Tooling/JSONCompilationDatabase.cpp
===================================================================
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -49,15 +49,17 @@
   bool parseStringInto(std::string &String) {
     do {
       if (*Position == '"') {
-        if (!parseQuotedStringInto(String)) return false;
+        if (!parseDoubleQuotedStringInto(String)) return false;
+      } else if (*Position == '\'') {
+        if (!parseSingleQuotedStringInto(String)) return false;
       } else {
         if (!parseFreeStringInto(String)) return false;
       }
     } while (*Position != ' ');
     return true;
   }
 
-  bool parseQuotedStringInto(std::string &String) {
+  bool parseDoubleQuotedStringInto(std::string &String) {
     if (!next()) return false;
     while (*Position != '"') {
       if (!skipEscapeCharacter()) return false;
@@ -67,6 +69,15 @@
     return next();
   }
 
+  bool parseSingleQuotedStringInto(std::string &String) {
+    if (!next()) return false;
+    while (*Position != '\'') {
+      String.push_back(*Position);
+      if (!next()) return false;
+    }
+    return next();
+  }
+
   bool parseFreeStringInto(std::string &String) {
     do {
       if (!skipEscapeCharacter()) return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D482.1.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130228/b6a4fedd/attachment.bin>


More information about the cfe-commits mailing list