mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
- Removed the BuildString() override that took a char** argv, because it was used nowhere.
- Fixed: BuildString() failed to properly generate command lines for arguments with embedded " characters. SVN r4025 (trunk)
This commit is contained in:
parent
3111b6e7b0
commit
6a3b07c441
2 changed files with 18 additions and 29 deletions
|
@ -1019,32 +1019,7 @@ FConsoleAlias::~FConsoleAlias ()
|
|||
m_Command[1] = m_Command[0] = FString();
|
||||
}
|
||||
|
||||
FString BuildString (int argc, char **argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
return *argv;
|
||||
}
|
||||
else
|
||||
{
|
||||
FString buf;
|
||||
int arg;
|
||||
|
||||
for (arg = 0; arg < argc; arg++)
|
||||
{
|
||||
if (strchr (argv[arg], ' '))
|
||||
{
|
||||
buf.AppendFormat ("\"%s\" ", argv[arg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.AppendFormat ("%s ", argv[arg]);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
// Given an argument vector, reconstitute the command line it could have been produced from.
|
||||
FString BuildString (int argc, FString *argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
|
@ -1058,8 +1033,23 @@ FString BuildString (int argc, FString *argv)
|
|||
|
||||
for (arg = 0; arg < argc; arg++)
|
||||
{
|
||||
if (strchr (argv[arg], ' '))
|
||||
{
|
||||
if (strchr(argv[arg], '"'))
|
||||
{ // If it contains one or more quotes, we need to escape them.
|
||||
buf << '"';
|
||||
long substr_start = 0, quotepos;
|
||||
while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0)
|
||||
{
|
||||
if (substr_start < quotepos)
|
||||
{
|
||||
buf << argv[arg].Mid(substr_start, quotepos - substr_start);
|
||||
}
|
||||
buf << "\\\"";
|
||||
substr_start = quotepos + 1;
|
||||
}
|
||||
buf << argv[arg].Mid(substr_start) << "\" ";
|
||||
}
|
||||
else if (strchr(argv[arg], ' '))
|
||||
{ // If it contains a space, it needs to be quoted.
|
||||
buf << '"' << argv[arg] << "\" ";
|
||||
}
|
||||
else
|
||||
|
|
|
@ -61,7 +61,6 @@ void C_SetAlias (const char *name, const char *cmd);
|
|||
void C_ClearAliases ();
|
||||
|
||||
// build a single string out of multiple strings
|
||||
FString BuildString (int argc, char **argv);
|
||||
FString BuildString (int argc, FString *argv);
|
||||
|
||||
// Class that can parse command lines
|
||||
|
|
Loading…
Reference in a new issue