aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/build.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-01-23 16:43:22 +0000
committermarha <marha@users.sourceforge.net>2011-01-23 16:43:22 +0000
commit51181fb7f4d135d214974bb6611d51f21475eec8 (patch)
treee62cb1744a6b43d2d6991b329bba9e2a7143a674 /tools/mhmake/src/build.cpp
parent174c4371f04f7a77979614fb7f3633807bd428ec (diff)
parent8cd59857a99c534c560f58c931f5c2466d4c1f9b (diff)
downloadvcxsrv-51181fb7f4d135d214974bb6611d51f21475eec8.tar.gz
vcxsrv-51181fb7f4d135d214974bb6611d51f21475eec8.tar.bz2
vcxsrv-51181fb7f4d135d214974bb6611d51f21475eec8.zip
Solved problem when quotes and pipe characters on the command line in vista
Diffstat (limited to 'tools/mhmake/src/build.cpp')
-rw-r--r--tools/mhmake/src/build.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index 6d3c4afda..d1c4a32d1 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -711,7 +711,12 @@ static void CommandSep(const string &Command, int &EndPos, int &NextBegin)
{
EndPos=Command.find('&',NextBegin);
if (EndPos==string::npos || !EndPos)
+ {
+ // When there is only one command return that command, so we run %comspec% commands
+ // always via a temporary batch file. This is to avoid problems when quotes and pipe
+ // characters in parameters when using cmd /c
return;
+ }
EndPos--;
char C=Command[EndPos];
NextBegin=EndPos+2;
@@ -753,39 +758,34 @@ mh_pid_t mhmakefileparser::OsExeCommand(const string &Command, const string &Par
int NextBegin=0;
int EndPos=0;
CommandSep(ComspecCommandLine,EndPos,NextBegin);
- if (EndPos!=string::npos)
- {
- // We have multiple commands so create an temporary batch file
- FILE *pFile=(FILE*)1;
- char Filename[MAX_PATH];
- int Nr=1;
- while (1)
- {
- sprintf(Filename,"%s\\tmp%d.bat",m_MakeDir->GetFullFileName().c_str(),Nr);
- pFile=fopen(Filename,"r");
- if (!pFile)
- break;
- fclose(pFile);
- Nr++;
- }
- pFile=fopen(Filename,"w");
- fprintf(pFile,"@echo off\n");
- int PrevPos=0;
- while (EndPos!=string::npos)
- {
- string SubCommand=ComspecCommandLine.substr(PrevPos,EndPos-PrevPos+1);
- fprintf(pFile,"%s\n",SubCommand.c_str());
- PrevPos=NextBegin;
- CommandSep(ComspecCommandLine,EndPos,NextBegin);
- }
- string SubCommand=ComspecCommandLine.substr(PrevPos);
- fprintf(pFile,"%s\n",SubCommand.c_str());
+ // We have multiple commands so create an temporary batch file
+ FILE *pFile=(FILE*)1;
+ char Filename[MAX_PATH];
+ int Nr=1;
+ while (1)
+ {
+ sprintf(Filename,"%s\\tmp%d.bat",m_MakeDir->GetFullFileName().c_str(),Nr);
+ pFile=fopen(Filename,"r");
+ if (!pFile)
+ break;
fclose(pFile);
- FullCommandLine+=QuoteFileName(Filename);
- ((mhmakefileparser*)this)->m_FilesToRemoveAtEnd.push_back(string(Filename));
+ Nr++;
}
- else
- FullCommandLine+=ComspecCommandLine;
+ pFile=fopen(Filename,"w");
+ fprintf(pFile,"@echo off\n");
+ int PrevPos=0;
+ while (EndPos!=string::npos)
+ {
+ string SubCommand=ComspecCommandLine.substr(PrevPos,EndPos-PrevPos+1);
+ fprintf(pFile,"%s\n",SubCommand.c_str());
+ PrevPos=NextBegin;
+ CommandSep(ComspecCommandLine,EndPos,NextBegin);
+ }
+ string SubCommand=ComspecCommandLine.substr(PrevPos);
+ fprintf(pFile,"%s\n",SubCommand.c_str());
+ fclose(pFile);
+ FullCommandLine+=QuoteFileName(Filename);
+ ((mhmakefileparser*)this)->m_FilesToRemoveAtEnd.push_back(string(Filename));
}
else
{