Escape double quotes in 'help'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94543 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov 2010-01-26 14:55:04 +00:00
parent b06f3ad5f9
commit ae779383be

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) {