Permalink
Browse files

Parse VM options before booting the VM.

  • Loading branch information...
1 parent c12764c commit 803e4593a0af440241fe5397e142e957e46a03f0 Brian Ford committed Oct 12, 2010
Showing with 26 additions and 11 deletions.
  1. +25 −10 vm/environment.cpp
  2. +1 −1 vm/environment.hpp
View
@@ -276,32 +276,46 @@ namespace rubinius {
signal(SIGUSR2, quit_handler);
}
+ void Environment::load_vm_options(int argc, char**argv) {
+ for(int i=1; i < argc; i++) {
+ char* arg = argv[i];
+
+ if(strcmp(arg, "--") == 0) {
+ break;
+ }
+
+ if(strncmp(arg, "-X", 2) == 0) {
+ config_parser.import_line(arg + 2);
+ }
+ }
+
+ config_parser.update_configuration(config);
+ }
+
void Environment::load_argv(int argc, char** argv) {
- bool process_xflags = true;
state->set_const("ARG0", String::create(state, argv[0]));
Array* ary = Array::create(state, argc - 1);
int which_arg = 0;
+ bool load_xflags = false;
+
for(int i=1; i < argc; i++) {
char* arg = argv[i];
- if(arg[0] != '-' || strcmp(arg, "--") == 0) {
- process_xflags = false;
+ if(strcmp(arg, "--") == 0) {
+ load_xflags = true;
}
- if(process_xflags && strncmp(arg, "-X", 2) == 0) {
- config_parser.import_line(arg + 2);
- } else {
- ary->set(state, which_arg++, String::create(state, arg)->taint(state));
+ if(!load_xflags && strncmp(arg, "-X", 2) == 0) {
+ continue;
}
+
+ ary->set(state, which_arg++, String::create(state, arg)->taint(state));
}
state->set_const("ARGV", ary);
// Now finish up with the config
-
- config_parser.update_configuration(config);
-
if(config.print_config > 1) {
std::cout << "========= Configuration =========\n";
config.print(true);
@@ -541,6 +555,7 @@ namespace rubinius {
state->set_stack_start(&i);
load_platform_conf(root);
+ load_vm_options(argc_, argv_);
boot_vm();
load_argv(argc_, argv_);
View
@@ -49,7 +49,7 @@ namespace rubinius {
void setup_cpp_terminate();
- void load_config_argv(int argc, char** argv);
+ void load_vm_options(int argc, char** argv);
void load_argv(int argc, char** argv);
void load_kernel(std::string root);
void load_directory(std::string dir);

0 comments on commit 803e459

Please sign in to comment.