diff options
-rw-r--r-- | Source/cmAddTestCommand.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 5802779..4a2cb20 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -67,18 +67,23 @@ void cmAddTestCommand::FinalPass() ++it; for (; it != m_Args.end(); ++it) { - if(it->find(" ") != std::string::npos) + // Just double-quote all arguments so they are re-parsed + // correctly by the test system. + fout << " \""; + for(std::string::iterator c = it->begin(); c != it->end(); ++c) + { + // Escape quotes and backslashes within arguments. + if((*c == '"') || (*c == '\\')) { - fout << " \"" << *it << "\""; - } - else - { - fout << " " << *it; + fout << '\\'; } + fout << *c; + } + fout << "\""; } fout << ")" << std::endl; fout.close(); - } + } return; } |