Escape double quotes in 'help'.

llvm-svn: 94543
This commit is contained in:
Mikhail Glushenkov 2010-01-26 14:55:04 +00:00
parent 98ca79435a
commit 81068d0a3d
1 changed files with 17 additions and 2 deletions

View File

@ -116,7 +116,7 @@ bool IsDagEmpty (const DagInit& d) {
// EscapeVariableName - Escape commas and other symbols not allowed
// in the C++ variable names. Makes it possible to use options named
// like "Wa," (useful for prefix options).
std::string EscapeVariableName(const std::string& Var) {
std::string EscapeVariableName (const std::string& Var) {
std::string ret;
for (unsigned i = 0; i != Var.size(); ++i) {
char cur_char = Var[i];
@ -136,6 +136,21 @@ std::string EscapeVariableName(const std::string& Var) {
return ret;
}
/// EscapeQuotes - Replace '"' with '\"'.
std::string EscapeQuotes (const std::string& Var) {
std::string ret;
for (unsigned i = 0; i != Var.size(); ++i) {
char cur_char = Var[i];
if (cur_char == '"') {
ret += "\\\"";
}
else {
ret.push_back(cur_char);
}
}
return ret;
}
/// OneOf - Does the input string contain this character?
bool OneOf(const char* lst, char c) {
while (*lst) {
@ -594,7 +609,7 @@ private:
void onHelp (const DagInit& d) {
CheckNumberOfArguments(d, 1);
optDesc_.Help = InitPtrToString(d.getArg(0));
optDesc_.Help = EscapeQuotes(InitPtrToString(d.getArg(0)));
}
void onHidden (const DagInit& d) {