From 4ebe5e6879ba1650b6d8f53ed0b1609fb060c7ad Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Sat, 22 Apr 2017 10:17:54 +0000 Subject: [PATCH] If setenv() is present on Windows and variable BXSHARE is not set, use the function get_builtin_variable() to set it up with either the value of the Bochs registry key or the BX_SHARE_PATH constant. --- bochs/bochs.h | 3 ++- bochs/config.cc | 3 +-- bochs/main.cc | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bochs/bochs.h b/bochs/bochs.h index 5bb4849e7..06ac95cb9 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2001-2016 The Bochs Project +// Copyright (C) 2001-2017 The Bochs Project // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -115,6 +115,7 @@ extern "C" { int bx_begin_simulation(int argc, char *argv[]); void bx_stop_simulation(); char *bx_find_bochsrc(void); +const char *get_builtin_variable(const char *varname); int bx_parse_cmdline(int arg, int argc, char *argv[]); int bx_read_configuration(const char *rcfile); int bx_write_configuration(const char *rcfile, int overwrite); diff --git a/bochs/config.cc b/bochs/config.cc index 53c5af8d4..c0d205f53 100644 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -45,7 +45,6 @@ Bit8u bx_user_plugin_count = 0; extern bx_debug_t bx_dbg; -static const char *get_builtin_variable(const char *varname); static int parse_line_unformatted(const char *context, char *line); static int parse_line_formatted(const char *context, int num_params, char *params[]); static int parse_bochsrc(const char *rcfile); @@ -1849,7 +1848,7 @@ static int parse_bochsrc(const char *rcfile) return retval; } -static const char *get_builtin_variable(const char *varname) +const char *get_builtin_variable(const char *varname) { #ifdef WIN32 int code; diff --git a/bochs/main.cc b/bochs/main.cc index a4ed848da..d419b2721 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -855,9 +855,15 @@ int bx_init_main(int argc, char *argv[]) if (getenv("BXSHARE") != NULL) { BX_INFO(("BXSHARE is set to '%s'", getenv("BXSHARE"))); } else { +#ifdef WIN32 + BX_INFO(("BXSHARE not set. using system default '%s'", + get_builtin_variable("BXSHARE"))); + setenv("BXSHARE", get_builtin_variable("BXSHARE"), 1); +#else BX_INFO(("BXSHARE not set. using compile time default '%s'", BX_SHARE_PATH)); setenv("BXSHARE", BX_SHARE_PATH, 1); +#endif } #else // we don't have getenv or setenv. Do nothing.