You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.3 KiB
59 lines
1.3 KiB
11 years ago
|
#include <cmSystemTools.h>
|
||
10 years ago
|
#include <cmsys/Encoding.hxx>
|
||
11 years ago
|
#include <string>
|
||
|
|
||
|
#define RETVAL @_retval@
|
||
|
|
||
|
int
|
||
10 years ago
|
main(int ac, char **av)
|
||
11 years ago
|
{
|
||
10 years ago
|
cmsys::Encoding::CommandLineArguments args =
|
||
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
||
|
int argc = args.argc();
|
||
|
const char* const* argv = args.argv();
|
||
|
|
||
11 years ago
|
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());
|
||
|
}
|
||
|
// keep searching, it may be overridden later to provoke an error
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!logfile.empty())
|
||
|
cmSystemTools::Touch(logfile.c_str(), true);
|
||
|
}
|
||
|
|
||
|
return RETVAL;
|
||
|
}
|