From 5f30c8caac40c930abab4f8c6a9f3fd0ddf1280d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 3 Nov 2003 15:19:27 -0500 Subject: [PATCH] BUG#259: ADD_TEST command generated in DartTestfile.txt now quotes/escapes all arguments. --- Source/cmAddTestCommand.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 580277995..4a2cb2092 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; }