diff options
author | dos-reis <gdr@axiomatics.org> | 2013-04-07 17:31:35 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2013-04-07 17:31:35 +0000 |
commit | 2917bc0408655024981f07c66b7ffb3c44f41fce (patch) | |
tree | bb7a5ccbff1e9cdeceaf0cbce4315add1060f3fd /src/utils | |
parent | 075711d2d69a4295c8cef2b5e08708ee8b3d5f3f (diff) | |
download | open-axiom-2917bc0408655024981f07c66b7ffb3c44f41fce.tar.gz |
small cleanup
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/command.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/utils/command.cc b/src/utils/command.cc index 2a8041bb..f3517a8d 100644 --- a/src/utils/command.cc +++ b/src/utils/command.cc @@ -69,11 +69,11 @@ namespace OpenAxiom { "|AxiomCore|::|topLevel|" // -- Arguments -- - Arguments::Arguments(int n) : std::vector<char*>(n > 0 ? n + 1 : 0) + Arguments::Arguments(int n) : std::vector<char*>(n + 1) { } int Arguments::size() const { - return empty() ? 0 : std::vector<char*>::size() - 1; + return std::vector<char*>::size() - 1; } void Arguments::allocate(int n) { @@ -444,6 +444,13 @@ preprocess_arguments(Command* command, int argc, char** argv) : make_path_for(command->root_dir, driver); } + // Return the total number of command-line arguments. + static int + args_count(const Command* cmd) { + return cmd->core.argc > 0 + ? cmd->rt_args.size() + cmd->core.argc + 1 + : cmd->rt_args.size(); + } /* Execute the Core Executable as described by `command'. On POSIX systems, this is a non-return function on success. @@ -520,7 +527,7 @@ execute_core(const Command* command, Driver driver) #else /* __WIN32__ */ int i; - Arguments args(command->rt_args.size() + command->core.argc + 2); + Arguments args(args_count(command)); /* GCL has this oddity that it wants to believe that argv[0] has something to tell about what GCL's own runtime is. Silly. */ if (OPENAXIOM_BASE_RTS == Runtime::gcl) @@ -543,10 +550,7 @@ execute_core(const Command* command, Driver driver) /* Then, copy over the arguments received from the command line. */ for (i = 1; i < command->core.argc; ++i) args[command->rt_args.size() + i + 1] = command->core.argv[i]; - args[command->rt_args.size() + command->core.argc + 1] = NULL; } - else - args[command->rt_args.size() + command->core.argc] = NULL; execv(execpath, args.data()); perror(execpath); |