Added a somewhat modified version of patch 1240751 from cyberwalker to make SET aware of envirionment variables on the command line
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2306
This commit is contained in:
parent
b6fbe42e85
commit
8799eb0ffe
1 changed files with 24 additions and 3 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: shell_cmds.cpp,v 1.56 2005-08-10 19:53:09 c2woody Exp $ */
|
||||
/* $Id: shell_cmds.cpp,v 1.57 2005-09-10 14:15:37 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -531,13 +531,34 @@ void DOS_Shell::CMD_SET(char * args) {
|
|||
WriteOut("%s\n",line.c_str());
|
||||
} else {
|
||||
*p++=0;
|
||||
if (!SetEnv(args,p)) {
|
||||
/* parse p for envirionment variables */
|
||||
char parsed[CMD_MAXLINE];
|
||||
char* p_parsed = parsed;
|
||||
while(*p) {
|
||||
if(*p != '%') *p_parsed++ = *p++; //Just add it (most likely path)
|
||||
else if( *(p+1) == '%') {
|
||||
*p_parsed++ = '%'; p += 2; //%% => %
|
||||
} else {
|
||||
char * second = strchr(++p,'%');
|
||||
if(!second) continue; *second++ = 0;
|
||||
std::string temp;
|
||||
if (GetEnvStr(p,temp)) {
|
||||
std::string::size_type equals = temp.find('=');
|
||||
if (equals == std::string::npos) continue;
|
||||
strcpy(p_parsed,temp.substr(equals+1).c_str());
|
||||
p_parsed += strlen(p_parsed);
|
||||
}
|
||||
p = second;
|
||||
}
|
||||
}
|
||||
*p_parsed = 0;
|
||||
/* Try setting the variable */
|
||||
if (!SetEnv(args,parsed)) {
|
||||
WriteOut(MSG_Get("SHELL_CMD_SET_OUT_OF_SPACE"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DOS_Shell::CMD_IF(char * args) {
|
||||
StripSpaces(args);
|
||||
bool has_not=false;
|
||||
|
|
Loading…
Add table
Reference in a new issue