1
0
Fork 0

Change first_shell to be DOS_Shell instead of Program. Makes future manipulations easier.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4211
This commit is contained in:
Peter Veenstra 2019-04-20 13:48:55 +00:00
parent 8a156f17d8
commit eb26b9a58e
4 changed files with 18 additions and 14 deletions

View file

@ -35,11 +35,12 @@
#define CMD_MAXCMDS 20
#define CMD_OLDSIZE 4096
extern Bitu call_shellstop;
class DOS_Shell;
/* first_shell is used to add and delete stuff from the shell env
* by "external" programs. (config) */
extern Program * first_shell;
extern DOS_Shell * first_shell;
class DOS_Shell;
class BatchFile {
public:

View file

@ -165,12 +165,12 @@ public:
/* remap drives */
Drives[i_newz] = Drives[25];
Drives[25] = 0;
DOS_Shell *fs = static_cast<DOS_Shell *>(first_shell); //dynamic ?
if (!first_shell) return; //Should not be possible
/* Update environment */
std::string line = "";
char ppp[2] = {newz[0],0};
std::string tempenv = ppp; tempenv += ":\\";
if (fs->GetEnvStr("PATH",line)){
if (first_shell->GetEnvStr("PATH",line)){
std::string::size_type idx = line.find('=');
std::string value = line.substr(idx +1 , std::string::npos);
while ( (idx = value.find("Z:\\")) != std::string::npos ||
@ -179,13 +179,13 @@ public:
line = value;
}
if (!line.size()) line = tempenv;
fs->SetEnv("PATH",line.c_str());
first_shell->SetEnv("PATH",line.c_str());
tempenv += "COMMAND.COM";
fs->SetEnv("COMSPEC",tempenv.c_str());
first_shell->SetEnv("COMSPEC",tempenv.c_str());
/* Update batch file if running from Z: (very likely: autoexec) */
if(fs->bf) {
std::string &name = fs->bf->filename;
if(first_shell->bf) {
std::string &name = first_shell->bf->filename;
if(name.length() >2 && name[0] == 'Z' && name[1] == ':') name[0] = newz[0];
}
/* Change the active drive */

View file

@ -38,7 +38,6 @@
#include <assert.h>
extern Bit8u int10_font_14[256 * 14];
extern Program * first_shell;
extern bool MSG_Write(const char *);
extern void GFX_SetTitle(Bit32s cycles, Bits frameskip, bool paused);
@ -454,10 +453,9 @@ public:
if (arg == "OK") section->data = *(std::string*)content->getText();
if (arg == "OK" || arg == "Cancel") close();
else if (arg == "Append Shell Commands") {
DOS_Shell *s = static_cast<DOS_Shell *>(first_shell);
std::list<std::string>::reverse_iterator i = s->l_history.rbegin();
std::list<std::string>::reverse_iterator i = first_shell->l_history.rbegin();
std::string lines = *(std::string*)content->getText();
while (i != s->l_history.rend()) {
while (i != first_shell->l_history.rend()) {
lines += "\n";
lines += *i;
++i;

View file

@ -31,7 +31,7 @@
Bitu call_shellstop;
/* Larger scope so shell_del autoexec can use it to
* remove things from the environment */
Program * first_shell = 0;
DOS_Shell * first_shell = 0;
static Bitu shellstop_handler(void) {
return CBRET_STOP;
@ -40,6 +40,11 @@ static Bitu shellstop_handler(void) {
static void SHELL_ProgramStart(Program * * make) {
*make = new DOS_Shell;
}
//Repeat it with the correct type, could do it in the function below, but this way it should be
//clear that if the above function is changed, this function might need a change as well.
static void SHELL_ProgramStart_First_shell(DOS_Shell * * make) {
*make = new DOS_Shell;
}
#define AUTOEXEC_SIZE 4096
static char autoexec_data[AUTOEXEC_SIZE] = { 0 };
@ -746,7 +751,7 @@ void SHELL_Init() {
dos.psp(psp_seg);
SHELL_ProgramStart(&first_shell);
SHELL_ProgramStart_First_shell(&first_shell);
first_shell->Run();
delete first_shell;
first_shell = 0;//Make clear that it shouldn't be used anymore