diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2013-03-02 06:00:16 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-03-02 06:00:16 +0000 |
commit | b88d9480e04039188c39e49367cb13d64e644cf8 (patch) | |
tree | caffa443f1b8370b5bd89f41015958c91638f274 /lib/Tooling | |
parent | cc5dbdae70c6eb2423921f52a35ba4686d2969cf (diff) |
CommandLineArgumentParser: handle single quotes.
Differential Revision: http://llvm-reviews.chandlerc.com/D482
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176404 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling')
-rw-r--r-- | lib/Tooling/JSONCompilationDatabase.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index 9013f2143f..254b069952 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -49,7 +49,9 @@ class CommandLineArgumentParser { 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; } @@ -57,7 +59,7 @@ class CommandLineArgumentParser { return true; } - bool parseQuotedStringInto(std::string &String) { + bool parseDoubleQuotedStringInto(std::string &String) { if (!next()) return false; while (*Position != '"') { if (!skipEscapeCharacter()) return false; @@ -67,12 +69,21 @@ class CommandLineArgumentParser { 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; String.push_back(*Position); if (!next()) return false; - } while (*Position != ' ' && *Position != '"'); + } while (*Position != ' ' && *Position != '"' && *Position != '\''); return true; } |