diff --git a/CHANGELOG b/CHANGELOG index 8ee6838b66..e9f8037411 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ NEXT + - SET command processing has been cleaned up and streamlined. + Added /ERASE command line switch to clear the environment + block (DOSBox-X extension). (joncampbell123). - VESA BIOS: Add new option to adjust reported linear framebuffer address by a specific number of pixels. This is needed by "Out of Control" by Contract which for whatever reason, diff --git a/include/programs.h b/include/programs.h index aee6d40267..77668519c2 100644 --- a/include/programs.h +++ b/include/programs.h @@ -102,6 +102,7 @@ class Program { bool GetEnvNum(Bitu want_num,std::string & result); //! Return an environment variable by index Bitu GetEnvCount(void); //! Return the number of environmental variables bool SetEnv(const char * entry,const char * new_string); //! Set environment variable + bool EraseEnv(void); virtual void WriteOut(const char *format, const char * arguments); void WriteOut(const char * format,...); //! Write to standard output virtual int WriteOut_NoParsing(const char * format, bool dbcs = false); //! Write to standard output, no parsing diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 2114597fa4..9c7c4c29a3 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -497,6 +497,26 @@ void Program::DebugDumpEnv() { } } +bool Program::EraseEnv(void) { + PhysPt env_base,env_fence; + size_t nsl = 0,el = 0,needs; + + if (dos_kernel_disabled) { + LOG_MSG("BUG: Program::EraseEnv() called with DOS kernel disabled (such as OS boot).\n"); + return false; + } + + if (!LocateEnvironmentBlock(env_base,env_fence,psp->GetEnvironment())) { + LOG_MSG("Warning: SetEnv() was not able to locate the program's environment block\n"); + return false; + } + + for (PhysPt w=env_base;w < env_fence;w++) + mem_writeb(w,0); + + return true; +} + /* NTS: "entry" string must have already been converted to uppercase */ bool Program::SetEnv(const char * entry,const char * new_string) { PhysPt env_base,env_fence,env_scan; diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index fe999370d3..2ec439e1a2 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -2732,7 +2732,8 @@ void DOS_Shell::CMD_SET(char * args) { enum op_mode_t { show_all_env, set_env, - show_env + show_env, + erase_env }; op_mode_t op_mode = show_all_env; @@ -2753,6 +2754,9 @@ void DOS_Shell::CMD_SET(char * args) { WriteOut("Set /P is not supported. Use Choice!"); /* TODO: What is SET /P supposed to do? */ return; } + else if (sw == "ERASE") { /* DOSBox-X extension: Completely erase the environment block */ + op_mode = erase_env; + } else { WriteOut("Unknown switch /"); WriteOut(sw.c_str()); @@ -2806,6 +2810,10 @@ void DOS_Shell::CMD_SET(char * args) { WriteOut(MSG_Get("SHELL_CMD_SET_OUT_OF_SPACE")); break; + case erase_env: + if (!EraseEnv()) + WriteOut("Unable to erase environment block\n"); + break; default: abort(); break;