Skip to content

Commit

Permalink
Refactor global.params.runargs to be Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed May 15, 2015
1 parent 0e700a5 commit 25d080d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/globals.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/* Compiler implementation of the D programming language
* Copyright (c) 1999-2014 by Digital Mars
* Copyright (c) 1999-2015 by Digital Mars
* All Rights Reserved
* written by Walter Bright
* http://www.digitalmars.com
Expand All @@ -18,6 +18,7 @@

#include "longdouble.h"
#include "outbuffer.h"
#include "filename.h"

// Can't include arraytypes.h here, need to declare these directly.
template <typename TYPE> struct Array;
Expand Down Expand Up @@ -132,8 +133,7 @@ struct Param
bool debugy;

bool run; // run resulting executable
size_t runargs_length;
const char** runargs; // arguments for executable
Strings runargs; // arguments for executable

// Linker stuff
Array<const char *> *objfiles;
Expand Down
6 changes: 3 additions & 3 deletions src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,16 +843,16 @@ int runProgram()
if (global.params.verbose)
{
fprintf(global.stdmsg, "%s", global.params.exefile);
for (size_t i = 0; i < global.params.runargs_length; i++)
fprintf(global.stdmsg, " %s", (char *)global.params.runargs[i]);
for (size_t i = 0; i < global.params.runargs.dim; ++i)
fprintf(global.stdmsg, " %s", global.params.runargs[i]);
fprintf(global.stdmsg, "\n");
}

// Build argv[]
Strings argv;

argv.push(global.params.exefile);
for (size_t i = 0; i < global.params.runargs_length; i++)
for (size_t i = 0; i < global.params.runargs.dim; ++i)
{ const char *a = global.params.runargs[i];

#if _WIN32
Expand Down
13 changes: 8 additions & 5 deletions src/mars.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,8 @@ Language changes listed by -transition=id:\n\
else if (strcmp(p + 1, "run") == 0)
{
global.params.run = true;
global.params.runargs_length = ((i >= argcstart) ? argc : argcstart) - i - 1;
if (global.params.runargs_length)
size_t length = ((i >= argcstart) ? argc : argcstart) - i - 1;
if (length)
{
const char *ext = FileName::ext(argv[i + 1]);
if (ext && FileName::equals(ext, "d") == 0
Expand All @@ -986,9 +986,12 @@ Language changes listed by -transition=id:\n\
}

files.push(argv[i + 1]);
global.params.runargs = &argv[i + 2];
i += global.params.runargs_length;
global.params.runargs_length--;
global.params.runargs.setDim(length - 1);
for (size_t j = 0; j < length - 1; ++j)
{
global.params.runargs[j] = argv[i + 2 + j];
}
i += length;
}
else
{
Expand Down

0 comments on commit 25d080d

Please sign in to comment.