Commit 4791701a authored by Brad King's avatar Brad King
Browse files

SystemTools: Remove ConvertWindowsCommandLineToUnixArguments method

This method is no longer used.  The CommandLineToArgvW function
could be used instead on Windows anyway.

Change-Id: I46d9197c80a5ab1515686890f396b1cd631943cf
parent e787837a
......@@ -4600,111 +4600,6 @@ void SystemTools::Delay(unsigned int msec)
#endif
}
void SystemTools::ConvertWindowsCommandLineToUnixArguments(
const char *cmd_line, int *argc, char ***argv)
{
if (!cmd_line || !argc || !argv)
{
return;
}
// A space delimites an argument except when it is inside a quote
(*argc) = 1;
size_t cmd_line_len = strlen(cmd_line);
size_t i;
for (i = 0; i < cmd_line_len; i++)
{
while (isspace(cmd_line[i]) && i < cmd_line_len)
{
i++;
}
if (i < cmd_line_len)
{
if (cmd_line[i] == '\"')
{
i++;
while (cmd_line[i] != '\"' && i < cmd_line_len)
{
i++;
}
(*argc)++;
}
else
{
while (!isspace(cmd_line[i]) && i < cmd_line_len)
{
i++;
}
(*argc)++;
}
}
}
(*argv) = new char* [(*argc) + 1];
(*argv)[(*argc)] = NULL;
// Set the first arg to be the exec name
(*argv)[0] = new char [1024];
#ifdef _WIN32
wchar_t tmp[1024];
::GetModuleFileNameW(0, tmp, 1024);
strcpy((*argv)[0], Encoding::ToNarrow(tmp).c_str());
#else
(*argv)[0][0] = '\0';
#endif
// Allocate the others
int j;
for (j = 1; j < (*argc); j++)
{
(*argv)[j] = new char [cmd_line_len + 10];
}
// Grab the args
size_t pos;
int argc_idx = 1;
for (i = 0; i < cmd_line_len; i++)
{
while (isspace(cmd_line[i]) && i < cmd_line_len)
{
i++;
}
if (i < cmd_line_len)
{
if (cmd_line[i] == '\"')
{
i++;
pos = i;
while (cmd_line[i] != '\"' && i < cmd_line_len)
{
i++;
}
memcpy((*argv)[argc_idx], &cmd_line[pos], i - pos);
(*argv)[argc_idx][i - pos] = '\0';
argc_idx++;
}
else
{
pos = i;
while (!isspace(cmd_line[i]) && i < cmd_line_len)
{
i++;
}
memcpy((*argv)[argc_idx], &cmd_line[pos], i - pos);
(*argv)[argc_idx][i - pos] = '\0';
argc_idx++;
}
}
}
}
kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
{
kwsys_stl::string res;
......
......@@ -856,15 +856,6 @@ public:
*/
static kwsys_stl::string GetOperatingSystemNameAndVersion();
/**
* Convert windows-style arguments given as a command-line string
* into more traditional argc/argv arguments.
* Note that argv[0] will be assigned the executable name using
* the GetModuleFileName() function.
*/
static void ConvertWindowsCommandLineToUnixArguments(
const char *cmd_line, int *argc, char ***argv);
/** -----------------------------------------------------------------
* URL Manipulation Routines
* -----------------------------------------------------------------
......
......@@ -507,28 +507,6 @@ static bool CheckStringOperations()
res = false;
}
int targc;
char **targv;
kwsys::SystemTools::ConvertWindowsCommandLineToUnixArguments
("\"Local Mojo\\Voodoo.asp\" -CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"",
&targc, &targv);
if (targc != 4 || strcmp(targv[1],"Local Mojo\\Voodoo.asp") ||
strcmp(targv[2],"-CastHex") ||
strcmp(targv[3],"D:\\My Secret Mojo\\Voodoo.mp3"))
{
kwsys_ios::cerr
<< "Problem with ConvertWindowsCommandLineToUnixArguments"
<< "\'\"Local Mojo\\Voodoo.asp\" "
<< "-CastHex \"D:\\My Secret Mojo\\Voodoo.mp3\"\'"
<< kwsys_ios::endl;
res = false;
}
for (;targc >=0; --targc)
{
delete [] targv[targc];
}
delete [] targv;
return res;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment