From 5d3d56e060abbd2aea0958bf661185dc85198520 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 18 May 2005 17:29:09 +0000 Subject: [PATCH] add patch/bug 1203382 from Chris Thielen. Fixes problems with batchfiles using %0 Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2210 --- src/shell/shell_batch.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/shell/shell_batch.cpp b/src/shell/shell_batch.cpp index 086afed7..d708d66b 100644 --- a/src/shell/shell_batch.cpp +++ b/src/shell/shell_batch.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_batch.cpp,v 1.16 2005-03-25 09:02:43 qbix79 Exp $ */ +/* $Id: shell_batch.cpp,v 1.17 2005-05-18 17:29:09 qbix79 Exp $ */ #include #include @@ -28,7 +28,7 @@ BatchFile::BatchFile(DOS_Shell * host,char * name, char * cmd_line) { prev=host->bf; echo=host->echo; shell=host; - cmd=new CommandLine(0,cmd_line); + cmd=new CommandLine(name,cmd_line); if (!DOS_OpenFile(name,128,&file_handle)) { //TODO Come up with something better E_Exit("SHELL:Can't open BatchFile"); @@ -70,12 +70,19 @@ emptyline: env_write=env_name; if (*cmd_read=='%') { cmd_read++; - if (cmd_read[0]=='%') { + if (cmd_read[0] == '%') { cmd_read++; *cmd_write++='%'; } - size_t len=strspn(cmd_read,"0123456789"); - if (len) { + if (cmd_read[0] == '0') { /* Handle %0 */ + const char *file_name = cmd->GetFileName(); + cmd_read++; + strcpy(cmd_write,file_name); + cmd_write+=strlen(file_name); + continue; + } + size_t len=strspn(cmd_read,"123456789"); + if (len) { /* Handle %1 %2 .. %9 */ memcpy(env_name,cmd_read,len); env_name[len]=0;cmd_read+=len; len=atoi(env_name);