mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-18 06:38:41 +00:00
Arg list already has program name in it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20208 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
db1680b2be
commit
e5f7e65f95
@ -81,11 +81,7 @@ Program::ExecuteAndWait(const Path& path,
|
|||||||
// have embedded spaces.
|
// have embedded spaces.
|
||||||
|
|
||||||
// First, determine the length of the command line.
|
// First, determine the length of the command line.
|
||||||
std::string progname(path.getLast());
|
unsigned len = 0;
|
||||||
unsigned len = progname.length() + 1;
|
|
||||||
if (progname.find(' ') != std::string::npos)
|
|
||||||
len += 2;
|
|
||||||
|
|
||||||
for (unsigned i = 0; args[i]; i++) {
|
for (unsigned i = 0; args[i]; i++) {
|
||||||
len += strlen(args[i]) + 1;
|
len += strlen(args[i]) + 1;
|
||||||
if (strchr(args[i], ' '))
|
if (strchr(args[i], ' '))
|
||||||
@ -96,19 +92,10 @@ Program::ExecuteAndWait(const Path& path,
|
|||||||
char *command = reinterpret_cast<char *>(_alloca(len));
|
char *command = reinterpret_cast<char *>(_alloca(len));
|
||||||
char *p = command;
|
char *p = command;
|
||||||
|
|
||||||
bool needsQuoting = progname.find(' ') != std::string::npos;
|
|
||||||
if (needsQuoting)
|
|
||||||
*p++ = '"';
|
|
||||||
memcpy(p, progname.c_str(), progname.length());
|
|
||||||
p += progname.length();
|
|
||||||
if (needsQuoting)
|
|
||||||
*p++ = '"';
|
|
||||||
*p++ = ' ';
|
|
||||||
|
|
||||||
for (unsigned i = 0; args[i]; i++) {
|
for (unsigned i = 0; args[i]; i++) {
|
||||||
const char *arg = args[i];
|
const char *arg = args[i];
|
||||||
size_t len = strlen(arg);
|
size_t len = strlen(arg);
|
||||||
needsQuoting = strchr(arg, ' ') != 0;
|
bool needsQuoting = strchr(arg, ' ') != 0;
|
||||||
if (needsQuoting)
|
if (needsQuoting)
|
||||||
*p++ = '"';
|
*p++ = '"';
|
||||||
memcpy(p, arg, len);
|
memcpy(p, arg, len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user