1
0
Fork 0

Add patch 1463945 from XulChris and add a tiny part of patch 1235377 of msharov

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2583
This commit is contained in:
Peter Veenstra 2006-04-07 19:56:45 +00:00
parent 3359eee956
commit d000d714e9

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: shell_misc.cpp,v 1.43 2006-02-28 19:41:27 qbix79 Exp $ */
/* $Id: shell_misc.cpp,v 1.44 2006-04-07 19:56:45 qbix79 Exp $ */
#include <stdlib.h>
#include <string.h>
@ -39,16 +39,12 @@ static void outc(Bit8u c) {
DOS_WriteFile(STDOUT,&c,&n);
}
static void outs(char * str) {
Bit16u n=strlen(str);
DOS_WriteFile(STDOUT,(Bit8u *)str,&n);
}
void DOS_Shell::InputCommand(char * line) {
Bitu size=CMD_MAXLINE-2; //lastcharacter+0
Bit8u c;Bit16u n=1;
Bitu str_len=0;Bitu str_index=0;
Bit16u len;
Bit16u len=0;
bool current_hist=false; // current command stored in history?
line[0] = '\0';
@ -116,6 +112,12 @@ void DOS_Shell::InputCommand(char * line) {
case 0x48: /* UP */
if (l_history.empty() || it_history == l_history.end()) break;
// store current command in history if we are at beginning
if (it_history == l_history.begin() && !current_hist) {
current_hist=true;
l_history.push_front(line);
}
for (;str_index>0; str_index--) {
// removes all characters
outc(8); outc(' '); outc(8);
@ -136,6 +138,12 @@ void DOS_Shell::InputCommand(char * line) {
if (it_history == l_history.begin()) {
// no previous commands in history
it_history ++;
// remove current command from history
if (current_hist) {
current_hist=false;
l_history.pop_front();
}
break;
} else it_history --;
@ -209,13 +217,13 @@ void DOS_Shell::InputCommand(char * line) {
// build new completion list
// get completion mask
char *completion_start = strrchr(line, ' ');
char *p_completion_start = strrchr(line, ' ');
if (completion_start) {
completion_start ++;
completion_index = str_index - strlen(completion_start);
if (p_completion_start) {
p_completion_start ++;
completion_index = str_index - strlen(p_completion_start);
} else {
completion_start = line;
p_completion_start = line;
completion_index = 0;
}
@ -225,8 +233,8 @@ void DOS_Shell::InputCommand(char * line) {
// build the completion list
char mask[DOS_PATHLENGTH];
if (completion_start) {
strcpy(mask, completion_start);
if (p_completion_start) {
strcpy(mask, p_completion_start);
char* dot_pos=strrchr(mask,'.');
char* bs_pos=strrchr(mask,'\\');
char* fs_pos=strrchr(mask,'/');
@ -249,11 +257,11 @@ void DOS_Shell::InputCommand(char * line) {
}
DOS_DTA dta(dos.dta());
char name[DOS_NAMELENGTH_ASCII];Bit32u size;Bit16u date;Bit16u time;Bit8u attr;
char name[DOS_NAMELENGTH_ASCII];Bit32u sz;Bit16u date;Bit16u time;Bit8u att;
std::list<std::string> executable;
while (res) {
dta.GetResult(name,size,date,time,attr);
dta.GetResult(name,sz,date,time,att);
// add result to completion list
char *ext; // file extension
@ -329,6 +337,12 @@ void DOS_Shell::InputCommand(char * line) {
if (!str_len) return;
str_len++;
// remove current command from history if it's there
if (current_hist) {
current_hist=false;
l_history.pop_front();
}
// add command line to history
l_history.push_front(line); it_history = l_history.begin();
if (l_completion.size()) l_completion.clear();
@ -365,7 +379,7 @@ bool DOS_Shell::Execute(char * name,char * args) {
fullname=Which(name);
if (!fullname) return false;
char* extension =strrchr(fullname,'.');
const char* extension =strrchr(fullname,'.');
/*always disallow files without extension from being executed. */
/*only internal commands can be run this way and they never get in this handler */
@ -426,17 +440,17 @@ bool DOS_Shell::Execute(char * name,char * args) {
RealPt file_name=RealMakeSeg(ss,reg_sp+0x20);
MEM_BlockWrite(Real2Phys(file_name),fullname,strlen(fullname)+1);
/* Fill the command line */
CommandTail cmd;
CommandTail cmdtail;
if (strlen(line)>126) line[126]=0;
cmd.count=strlen(line);
memcpy(cmd.buffer,line,strlen(line));
cmd.buffer[strlen(line)]=0xd;
cmdtail.count=strlen(line);
memcpy(cmdtail.buffer,line,strlen(line));
cmdtail.buffer[strlen(line)]=0xd;
/* Copy command line in stack block too */
MEM_BlockWrite(SegPhys(ss)+reg_sp+0x100,&cmd,128);
MEM_BlockWrite(SegPhys(ss)+reg_sp+0x100,&cmdtail,128);
/* Parse FCB (first two parameters) and put them into the current DOS_PSP */
Bit8u add;
FCB_Parsename(dos.psp(),0x5C,0x00,cmd.buffer,&add);
FCB_Parsename(dos.psp(),0x6C,0x00,&cmd.buffer[add],&add);
FCB_Parsename(dos.psp(),0x5C,0x00,cmdtail.buffer,&add);
FCB_Parsename(dos.psp(),0x6C,0x00,&cmdtail.buffer[add],&add);
block.exec.fcb1=RealMake(dos.psp(),0x5C);
block.exec.fcb2=RealMake(dos.psp(),0x6C);
/* Set the command line in the block and save it */
@ -473,9 +487,9 @@ bool DOS_Shell::Execute(char * name,char * args) {
static char * bat_ext=".BAT";
static char * com_ext=".COM";
static char * exe_ext=".EXE";
static const char * bat_ext=".BAT";
static const char * com_ext=".COM";
static const char * exe_ext=".EXE";
static char which_ret[DOS_PATHLENGTH+4];
char * DOS_Shell::Which(char * name) {