Skip to content

Commit

Permalink
Remove args setting code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sh committed Nov 20, 2012
1 parent 92143c5 commit 5fe14e7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions internal/dmain2.d
Expand Up @@ -133,18 +133,23 @@ extern (C) int _d_run_main(size_t argc, char **argv, void *p)
am = cast(char[] *) malloc(argc * (char[]).sizeof);
}

if (no_catch_exceptions)
void setArgs()
{
_moduleCtor();
_moduleUnitTests();

for (size_t i = 0; i < argc; i++)
{
auto len = strlen(argv[i]);
am[i] = argv[i][0 .. len];
}

args = am[0 .. argc];
}

if (no_catch_exceptions)
{
_moduleCtor();
_moduleUnitTests();

setArgs();

result = main(args);
_moduleDtor();
Expand All @@ -157,13 +162,7 @@ extern (C) int _d_run_main(size_t argc, char **argv, void *p)
_moduleCtor();
_moduleUnitTests();

for (size_t i = 0; i < argc; i++)
{
auto len = strlen(argv[i]);
am[i] = argv[i][0 .. len];
}

args = am[0 .. argc];
setArgs();

result = main(args);
_moduleDtor();
Expand Down

0 comments on commit 5fe14e7

Please sign in to comment.