CommandLineArgumentParser: handle single quotes.

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

llvm-svn: 176404
This commit is contained in:
Peter Collingbourne
2013-03-02 06:00:16 +00:00
parent 20ef54f4c1
commit fe7a348614
2 changed files with 20 additions and 3 deletions

View File

@@ -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;
}