2013-05-05 19:00:24 +04:00
|
|
|
#include <cmSystemTools.h>
|
2014-07-15 21:11:18 +04:00
|
|
|
#include <cmsys/Encoding.hxx>
|
2013-05-22 00:58:36 +04:00
|
|
|
#include <string>
|
2013-05-05 19:00:24 +04:00
|
|
|
|
|
|
|
#define RETVAL @_retval@
|
|
|
|
|
|
|
|
int
|
2014-07-15 21:11:18 +04:00
|
|
|
main(int ac, char **av)
|
2013-05-05 19:00:24 +04:00
|
|
|
{
|
2014-07-15 21:11:18 +04:00
|
|
|
cmsys::Encoding::CommandLineArguments args =
|
|
|
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
|
|
|
int argc = args.argc();
|
|
|
|
const char* const* argv = args.argv();
|
|
|
|
|
2013-05-05 19:00:24 +04:00
|
|
|
std::string exename = argv[0];
|
|
|
|
std::string logarg;
|
|
|
|
bool nextarg = false;
|
|
|
|
|
|
|
|
if (exename.find("valgrind") != exename.npos)
|
|
|
|
logarg = "--log-file=";
|
|
|
|
else if (exename.find("purify") != exename.npos)
|
|
|
|
#ifdef _WIN32
|
|
|
|
logarg = "/SAVETEXTDATA=";
|
|
|
|
#else
|
|
|
|
logarg = "-log-file=";
|
|
|
|
#endif
|
|
|
|
else if (exename.find("BC") != exename.npos)
|
|
|
|
{
|
|
|
|
nextarg = true;
|
|
|
|
logarg = "/X";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!logarg.empty()) {
|
|
|
|
std::string logfile;
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
std::string arg = argv[i];
|
|
|
|
if (arg.find(logarg) == 0)
|
|
|
|
{
|
|
|
|
if (nextarg)
|
|
|
|
{
|
|
|
|
if (i == argc - 1)
|
|
|
|
return 1; // invalid command line
|
|
|
|
logfile = argv[i + 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logfile = arg.substr(logarg.length());
|
|
|
|
}
|
2013-08-08 00:25:48 +04:00
|
|
|
// keep searching, it may be overridden later to provoke an error
|
2013-05-05 19:00:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!logfile.empty())
|
2016-05-26 23:52:22 +03:00
|
|
|
cmSystemTools::Touch(logfile, true);
|
2013-05-05 19:00:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return RETVAL;
|
|
|
|
}
|