1
0
Fork 0

Allow command /Cdir

Fix quoting so that command /c mount d "/tmp/a b" works
This breaks command /c "dir", but this doesn't work on real DOS either.
Let's hope everything still works.


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3728
This commit is contained in:
Peter Veenstra 2011-06-24 21:02:05 +00:00
parent 8abf23aa8d
commit 6fc206193e
3 changed files with 35 additions and 1 deletions

View file

@ -50,6 +50,7 @@ public:
bool FindCommand(unsigned int which,std::string & value);
bool FindStringBegin(char const * const begin,std::string & value, bool remove=false);
bool FindStringRemain(char const * const name,std::string & value);
bool FindStringRemainBegin(char const * const name,std::string & value);
bool GetStringRemain(std::string & value);
int GetParameterFromList(const char* const params[], std::vector<std::string> & output);
void FillVector(std::vector<std::string> & vector);

View file

@ -955,6 +955,39 @@ bool CommandLine::FindStringRemain(char const * const name,std::string & value)
return true;
}
/* Only used for parsing command.com /C
* Allowing /C dir and /Cdir
* Restoring quotes back into the commands so command /C mount d "/tmp/a b" works as intended
*/
bool CommandLine::FindStringRemainBegin(char const * const name,std::string & value) {
cmd_it it;value="";
if (!FindEntry(name,it)) {
size_t len = strlen(name);
for (it=cmds.begin();it!=cmds.end();it++) {
if (strncasecmp(name,(*it).c_str(),len)==0) {
std::string temp = ((*it).c_str() + len);
//Restore quotes for correct parsing in later stages
if(temp.find(" ") != std::string::npos)
value = std::string("\"") + temp + std::string("\"");
else
value = temp;
break;
}
}
if( it == cmds.end()) return false;
}
it++;
for (;it!=cmds.end();it++) {
value += " ";
std::string temp = (*it);
if(temp.find(" ") != std::string::npos)
value += std::string("\"") + temp + std::string("\"");
else
value += temp;
}
return true;
}
bool CommandLine::GetStringRemain(std::string & value) {
if(!cmds.size()) return false;

View file

@ -285,7 +285,7 @@ void DOS_Shell::RunInternal(void)
void DOS_Shell::Run(void) {
char input_line[CMD_MAXLINE] = {0};
std::string line;
if (cmd->FindStringRemain("/C",line)) {
if (cmd->FindStringRemainBegin("/C",line)) {
strcpy(input_line,line.c_str());
char* sep = strpbrk(input_line,"\r\n"); //GTA installer
if (sep) *sep = 0;