aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/mhmake/src/build.cpp103
-rw-r--r--tools/mhmake/src/curdir.cpp2
-rw-r--r--tools/mhmake/src/fileinfo.cpp77
-rw-r--r--tools/mhmake/src/fileinfo.h24
-rw-r--r--tools/mhmake/src/functions.cpp20
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp42
-rw-r--r--tools/mhmake/src/mhmakeparser.y6
-rw-r--r--tools/mhmake/src/rule.cpp9
-rw-r--r--tools/mhmake/src/util.cpp33
-rw-r--r--tools/mhmake/src/util.h70
10 files changed, 218 insertions, 168 deletions
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index feae1eb25..97366d88a 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -305,7 +305,7 @@ string SearchCommand(const string &Command, const string &Extension="")
pExt=NULL;
else
pExt=Extension.c_str();
- if (SearchPath(NULL,Command.c_str(),pExt,MAX_PATH,FullCommand,NULL))
+ if (SearchPath(NULL,UnquoteFileName(Command).c_str(),pExt,MAX_PATH,FullCommand,NULL))
return FullCommand;
#ifdef WIN32
/* See if we have a path for python.exe in the registry */
@@ -570,13 +570,13 @@ exit:
{
if (pNewDest->Exists())
{
- cerr << pNewDest->GetFullFileName() << " exists and is not a directory.\n";
+ cerr << pNewDest->GetQuotedFullFileName() << " exists and is not a directory.\n";
Error = false;
goto exit;
}
if (-1==mkdir(pNewDest->GetFullFileName().c_str(),0777))
{
- cerr << "Error creating directory " << pNewDest->GetFullFileName() << endl;
+ cerr << "Error creating directory " << pNewDest->GetQuotedFullFileName() << endl;
Error = false;
goto exit;
}
@@ -816,7 +816,7 @@ static const string &GetPythonExe()
string FullCommand=SearchCommand(PYTHONEXE);
if (!FullCommand.empty())
{
- PythonExe="\""+FullCommand+"\" ";
+ PythonExe=QuoteFileName(FullCommand)+" ";
}
else
{
@@ -964,42 +964,20 @@ string mhmakefileparser::GetFullCommand(string Command)
{
s_Py2ExeInstalled=false;
cout << "\nWarning: cannot convert "<<FullCommand<<".\nCompilation will be faster by installing py2exe.\n\n";
- Command=GetPythonExe()+"\""+FullCommand+"\"";
+ Command=GetPythonExe()+QuoteFileName(FullCommand);
}
else
Command=ExeFullCommand;
}
else
#endif
- Command=GetPythonExe()+FullCommand;
+ Command=GetPythonExe()+QuoteFileName(FullCommand);
}
}
}
if (!Found)
{
- if (Command.find(" ")!=string::npos)
- {
- #ifdef WIN32
- Command=GetComspec()+"\""+Command+"\"";
- #else
- // In linux excape the spaces in commands
- const char *pTmp=Command.c_str();
- string NewCommand="";
- string Space="";
- string SpaceString="\\ ";
- while (*pTmp)
- {
- string Item;
- pTmp=NextItem(pTmp,Item);
- NewCommand+=Space;
- NewCommand+=Item;
- Space=SpaceString;
- }
- Command=GetComspec()+NewCommand;
- #endif
- }
- else
- Command=GetComspec()+Command;
+ Command=GetComspec()+QuoteFileName(Command);
}
m_CommandCache[OriCommand]=Command;
return Command;
@@ -1009,29 +987,25 @@ string mhmakefileparser::GetFullCommand(string Command)
bool OsExeCommand(const string &Command,const string &Params,bool IgnoreError,string *pOutput)
{
+ string FullCommandLine;
+ string ComSpec=GetComspec();
#ifdef WIN32
STARTUPINFO StartupInfo;
memset(&StartupInfo,0,sizeof(StartupInfo));
StartupInfo.cb=sizeof(STARTUPINFO);
PROCESS_INFORMATION ProcessInfo;
- string FullCommandLine;
- string ComSpec=GetComspec();
if (Command.substr(0,ComSpec.size())==ComSpec)
{
string tmpCommand=Command.substr(ComSpec.size(),Command.size());
FullCommandLine=ComSpec;
- if (tmpCommand.find(' ')!=string::npos)
- FullCommandLine+="\""+tmpCommand+"\""+Params;
- else
- FullCommandLine+=tmpCommand+Params;
+ FullCommandLine+=QuoteFileName(tmpCommand)+Params;
}
else
{
const string PythonExe=GetPythonExe();
- if (Command.find(' ')!=string::npos &&
- !(Command.substr(0,PythonExe.size())==PythonExe))
- FullCommandLine="\""+Command+"\""+Params;
+ if (!(Command.substr(0,PythonExe.size())==PythonExe))
+ FullCommandLine=QuoteFileName(Command)+Params;
else
FullCommandLine=Command+Params;
}
@@ -1139,10 +1113,20 @@ bool OsExeCommand(const string &Command,const string &Params,bool IgnoreError,st
CloseHandle(ProcessInfo.hProcess);
return true;
#else
- string FullCommandLine=Command+Params;
int pipeto[2]; /* pipe to feed the exec'ed program input */
int pipefrom[2]; /* pipe to get the exec'ed program output */
+ if (Command.substr(0,ComSpec.size())==ComSpec)
+ {
+ string tmpCommand=Command.substr(ComSpec.size(),Command.size());
+ FullCommandLine=ComSpec;
+ FullCommandLine+=QuoteFileName(tmpCommand)+Params;
+ }
+ else
+ {
+ FullCommandLine=Command+Params;
+ }
+
if (pOutput || g_Quiet)
{
pipe( pipeto );
@@ -1324,15 +1308,14 @@ bool mhmakefileparser::ExecuteCommand(string Command,string *pOutput)
StartCommandPos=1;
EndCommandPos=1;
while (pCom[EndCommandPos]!='"') EndCommandPos++;
- BeginParamPos=EndCommandPos+1;
}
else
{
StartCommandPos=0;
EndCommandPos=0;
- while (!strchr(" \t",pCom[EndCommandPos])) EndCommandPos++;
- BeginParamPos=EndCommandPos;
}
+ while (!strchr(" \t",pCom[EndCommandPos])) EndCommandPos++;
+ BeginParamPos=EndCommandPos;
string Params=Command.substr(BeginParamPos);
Command=Command.substr(StartCommandPos,EndCommandPos-StartCommandPos);
@@ -1430,7 +1413,7 @@ void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, const refptr
{
#ifdef _DEBUG
if (pRule&&g_pPrintDependencyCheck && DepDate.IsExistingFile() && TargetDate.IsExistingFile())
- cout<<"Going to build "<<Target->GetFullFileName()<<" because "<<(*pDepIt)->GetFullFileName()<<" is more recent\n";
+ cout<<"Going to build "<<Target->GetQuotedFullFileName()<<" because "<<(*pDepIt)->GetQuotedFullFileName()<<" is more recent\n";
#endif
MakeTarget=true;
}
@@ -1447,12 +1430,12 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
deque< refptr<fileinfo> >::const_iterator pFind=find(m_TargetStack.begin(),m_TargetStack.end(),Target);
if (pFind!=m_TargetStack.end())
{
- cout << "Circular dependency detected.\n"<<Target->GetFullFileName()<<" depending on itself.\n";
+ cout << "Circular dependency detected.\n"<<Target->GetQuotedFullFileName()<<" depending on itself.\n";
cout << "Dependency stack:\n";
deque< refptr<fileinfo> >::const_iterator pIt=m_TargetStack.begin();
while (pIt!=m_TargetStack.end())
{
- cout << " " << (*pIt)->GetFullFileName() << endl;
+ cout << " " << (*pIt)->GetQuotedFullFileName() << endl;
pIt++;
}
}
@@ -1471,7 +1454,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<" Already build "<<Target->GetFullFileName()<<" : "<<Target->GetDate()<<endl;
+ cout<<" Already build "<<Target->GetQuotedFullFileName()<<" : "<<Target->GetDate()<<endl;
}
#endif
return Target->GetDate();
@@ -1479,14 +1462,14 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
#ifdef _DEBUG
if (g_GenProjectTree)
- cout << Target->GetFullFileName() << endl;
+ cout << Target->GetQuotedFullFileName() << endl;
Indent++;
if (g_pPrintDependencyCheck)
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building dependencies of "<<Target->GetFullFileName()<<endl;
+ cout<<"Building dependencies of "<<Target->GetQuotedFullFileName()<<endl;
}
#endif
@@ -1535,7 +1518,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
{
- cout<<"Found implicit rule for "<<Target->GetFullFileName()<<endl;
+ cout<<"Found implicit rule for "<<Target->GetQuotedFullFileName()<<endl;
pRule->PrintCommands(Target);
}
#endif
@@ -1559,7 +1542,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
{
- cout<<"Found implicit rule for "<<Target->GetFullFileName()<<". Dependent "<<ResultIt->first->GetFullFileName()<<endl;
+ cout<<"Found implicit rule for "<<Target->GetQuotedFullFileName()<<". Dependent "<<ResultIt->first->GetQuotedFullFileName()<<endl;
pRule->PrintCommands(Target);
}
#endif
@@ -1567,7 +1550,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
{
#ifdef _DEBUG
if (pRule,g_pPrintDependencyCheck && DepDate.IsExistingFile() && TargetDate.IsExistingFile())
- cout<<"Going to build "<<Target->GetFullFileName()<<" because "<<ResultIt->first->GetFullFileName()<<" is more recent\n";
+ cout<<"Going to build "<<Target->GetQuotedFullFileName()<<" because "<<ResultIt->first->GetQuotedFullFileName()<<" is more recent\n";
#endif
MakeTarget=true;
}
@@ -1595,7 +1578,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building "<<Target->GetFullFileName()<<endl;
+ cout<<"Building "<<Target->GetQuotedFullFileName()<<endl;
}
#endif
if (!MakeTarget)
@@ -1608,11 +1591,11 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
if (!TargetDate.DoesExist())
{
if (!m_ImplicitSearch && !Target->IsPhony())
- cout<<"Building "<<Target->GetFullFileName()<<" because it does not exist yet\n";
+ cout<<"Building "<<Target->GetQuotedFullFileName()<<" because it does not exist yet\n";
}
else if (TargetDate.IsOlder(m_sBuildTime))
{
- cout<<"Building "<<Target->GetFullFileName()<<" because need to rebuild all (-a)\n";
+ cout<<"Building "<<Target->GetQuotedFullFileName()<<" because need to rebuild all (-a)\n";
}
}
#endif
@@ -1637,7 +1620,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
#else
if (!g_Quiet)
#endif
- cout << "Building " << Target->GetFullFileName()<<endl;
+ cout << "Building " << Target->GetQuotedFullFileName()<<endl;
}
curdir::ChangeCurDir(pMakefile->GetMakeDir());
@@ -1664,7 +1647,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
if (!pMakefile->ExecuteCommand(Command))
{
cerr << "Error running command: "<<Command<<endl;
- cerr << "Command defined in makefile: "<<GetMakeDir()->GetFullFileName()<<endl;
+ cerr << "Command defined in makefile: "<<GetMakeDir()->GetQuotedFullFileName()<<endl;
Target->SetCommandsMd5_32(0); /* Clear the md5 to make sure that the target is rebuild the next time mhmake is ran */
m_AutoDepsDirty=true; /* We need to update the autodeps file if the md5 has been changed */
throw(1);
@@ -1705,7 +1688,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
{
#ifdef _DEBUG
if (!g_GenProjectTree)
- cout << "Md5 is different for " << Target->GetFullFileName() << " Old:"<<hex<<Target->GetCommandsMd5_32()<<", New: "<<Md5_32<<". Commandline must have been changed so recompiling\n";
+ cout << "Md5 is different for " << Target->GetQuotedFullFileName() << " Old:"<<hex<<Target->GetCommandsMd5_32()<<", New: "<<Md5_32<<". Commandline must have been changed so recompiling\n";
#endif
MakeTarget=true;
}
@@ -1720,7 +1703,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
{
for (int i=0; i<Indent; i++)
cout<<" ";
- cout<<"Building "<<Target->GetFullFileName()<<" finished : "<< YoungestDate << endl;
+ cout<<"Building "<<Target->GetQuotedFullFileName()<<" finished : "<< YoungestDate << endl;
}
Indent--;
if (g_CheckCircularDeps)
@@ -1731,7 +1714,7 @@ mh_time_t mhmakefileparser::BuildTarget(const refptr<fileinfo> &Target,bool bChe
if (!m_ImplicitSearch && !Target->Exists() && !Target->IsPhony() && !g_DoNotExecute && !g_GenProjectTree)
{
// This is only a warning for phony messages
- cout<<"Warning: don't know how to make "<<Target->GetFullFileName()<<"\nMake the rule a phony rule to avoid this warning (but only do it when it is really phony).\n";;
+ cout<<"Warning: don't know how to make "<<Target->GetQuotedFullFileName()<<"\nMake the rule a phony rule to avoid this warning (but only do it when it is really phony).\n";;
}
#endif
Target->SetDate(YoungestDate); /* This is especially needed for phony targets in between real targets */
@@ -1746,7 +1729,7 @@ void mhmakefileparser::BuildIncludedMakefiles()
{
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout<<"Building include file "<<(*MakefileIt)->GetFullFileName()<<endl;
+ cout<<"Building include file "<<(*MakefileIt)->GetQuotedFullFileName()<<endl;
#endif
BuildTarget(*MakefileIt);
MakefileIt++;
diff --git a/tools/mhmake/src/curdir.cpp b/tools/mhmake/src/curdir.cpp
index bdaf444b5..68cf505e7 100644
--- a/tools/mhmake/src/curdir.cpp
+++ b/tools/mhmake/src/curdir.cpp
@@ -52,7 +52,7 @@ void curdir::ChangeCurDir(const refptr<fileinfo>&NewDir)
#endif
if (-1==chdir(NewDir->GetFullFileName().c_str()))
{
- cerr<<"Error changing to directory "<<NewDir->GetFullFileName()<<endl;
+ cerr<<"Error changing to directory "<<NewDir->GetQuotedFullFileName()<<endl;
throw(1);
}
m_pCurrentDir=NewDir;
diff --git a/tools/mhmake/src/fileinfo.cpp b/tools/mhmake/src/fileinfo.cpp
index 65b7d52a2..b79d51678 100644
--- a/tools/mhmake/src/fileinfo.cpp
+++ b/tools/mhmake/src/fileinfo.cpp
@@ -33,6 +33,51 @@ ZEROTIME g_ZeroTime;
#endif
///////////////////////////////////////////////////////////////////////////////
+string QuoteFileName(const string &Filename)
+{
+ string Ret(Filename);
+#if OSPATHSEP=='\\'
+ /* Put quotes around the string if there are spaces in it */
+ if (Ret.find_first_of(' ')!=string::npos && Ret[0]!='"')
+ {
+ Ret=g_QuoteString+Ret+g_QuoteString;
+ }
+#else
+ int Pos=0;
+ /* Escape the spaces with a backslash */
+ while ((Pos=Ret.find_first_of(' ',Pos))!=string::npos)
+ {
+ Ret=Ret.replace(Pos,1,"\\ ");
+ Pos+=2;
+ }
+#endif
+ return Ret;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+string UnquoteFileName(const string &Filename)
+{
+ int Pos=0;
+ string Name(Filename);
+#if OSPATHSEP=='\\'
+ /* Remove all the quotes from the filename */
+ while ((Pos=Name.find_first_of('"',Pos))!=string::npos)
+ {
+ Name=Name.replace(Pos,1,"");
+ }
+#else
+ /* Remove the escaped spaces */
+ while ((Pos=Name.find_first_of("\\",Pos))!=string::npos)
+ {
+ if (Name[Pos+1]==' ')
+ Name=Name.replace(Pos,2," ");
+ Pos+=1;
+ }
+#endif
+ return Name;
+}
+
+///////////////////////////////////////////////////////////////////////////////
refptr<fileinfo> fileinfo::GetDir() const
{
return GetAbsFileInfo(m_AbsFileName.substr(0,m_AbsFileName.find_last_of(OSPATHSEP)));
@@ -145,7 +190,7 @@ string fileinfo::GetPrerequisits() const
{
Ret+=g_SpaceString;
}
- Ret+=(*DepIt)->GetFullFileName();
+ Ret+=(*DepIt)->GetQuotedFullFileName();
}
Deps.insert(*DepIt);
DepIt++;
@@ -185,8 +230,8 @@ bool fileinfo::IsAutoDepExtention(void) const
///////////////////////////////////////////////////////////////////////////////
void fileinfo::DumpErrorMessageDuplicateRule(const refptr<rule>&pRule)
{
- cerr << m_AbsFileName << ": rule is defined multiple times\n";
- cerr << "First ("<<m_pRule->GetMakefile()->GetMakeDir()->GetFullFileName()<<") :\n";
+ cerr << GetQuotedFullFileName() << ": rule is defined multiple times\n";
+ cerr << "First ("<<m_pRule->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()<<") :\n";
vector<string>::const_iterator It=m_pRule->GetCommands().begin();
while (It!=m_pRule->GetCommands().end())
@@ -194,7 +239,7 @@ void fileinfo::DumpErrorMessageDuplicateRule(const refptr<rule>&pRule)
cerr << " " << m_pRule->GetMakefile()->ExpandExpression(*It) << endl;
It++;
}
- cerr << "Second ("<<pRule->GetMakefile()->GetMakeDir()->GetFullFileName()<<") :\n";
+ cerr << "Second ("<<pRule->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()<<") :\n";
It=pRule->GetCommands().begin();
while (It!=pRule->GetCommands().end())
{
@@ -205,7 +250,7 @@ void fileinfo::DumpErrorMessageDuplicateRule(const refptr<rule>&pRule)
#endif
///////////////////////////////////////////////////////////////////////////////
-static inline string &GetFullLowerPathName(string &Name)
+static inline string &NormalizePathName(string &Name)
{
const char *pPtr=Name.c_str();
const char *pBeg=pPtr;
@@ -258,7 +303,11 @@ static inline string &GetFullLowerPathName(string &Name)
}
else
{
+ #ifdef WIN32
*pWr++ = tolower(Char);
+ #else
+ *pWr++ = Char;
+ #endif
}
Char=*pPtr++;
}
@@ -272,8 +321,9 @@ static inline string &GetFullLowerPathName(string &Name)
///////////////////////////////////////////////////////////////////////////////
const refptr<fileinfo> &GetFileInfo(const string &NameIn,const refptr<fileinfo> &RelDir)
{
- string Name=NameIn;
+ string Name=UnquoteFileName(NameIn);
bool DoesExist=true;
+
//Only concatenate if szName is not already a full name
#ifdef WIN32
if (!Name.empty() && Name[1]!=':')
@@ -293,14 +343,7 @@ const refptr<fileinfo> &GetFileInfo(const string &NameIn,const refptr<fileinfo>
}
#endif
}
- const refptr<fileinfo> &Ret=GetAbsFileInfo(GetFullLowerPathName(Name));
- #ifdef _DEBUG
- if (Ret->GetFullFileName().find(' ')!=string::npos)
- {
- cerr << "Spaces are not allowed in filenames: "<< Ret->GetFullFileName() << endl;
- exit(1);
- }
- #endif
+ const refptr<fileinfo> &Ret=GetAbsFileInfo(NormalizePathName(Name));
if (!DoesExist)
Ret->SetNotExist();
return Ret;
@@ -313,14 +356,14 @@ void PrintFileInfos()
set<refptr<fileinfo>,less_refptrfileinfo>::iterator pIt=g_FileInfos.begin();
while (pIt!=g_FileInfos.end())
{
- cout<<(*pIt)->GetFullFileName()<<" :";
+ cout<<(*pIt)->GetQuotedFullFileName()<<" :";
if ((*pIt)->IsPhony())
cout<<" (phony)";
vector< refptr<fileinfo> > &Deps=(*pIt)->GetDeps();
vector< refptr<fileinfo> >::iterator pDepIt=Deps.begin();
while (pDepIt!=Deps.end())
{
- cout<<g_SpaceString<<(*pDepIt)->GetFullFileName();
+ cout<<g_SpaceString<<(*pDepIt)->GetQuotedFullFileName();
pDepIt++;
}
cout<<endl;
@@ -328,7 +371,7 @@ void PrintFileInfos()
refptr<rule> pRule=(*pIt)->GetRule();
if (pRule)
{
- cout<<g_SpaceString<<"Run in: "<<pRule->GetMakefile()->GetMakeDir()->GetFullFileName()<<endl;
+ cout<<g_SpaceString<<"Run in: "<<pRule->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()<<endl;
pRule->PrintCommands();
}
pIt++;
diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h
index c44041d30..227ba5e1f 100644
--- a/tools/mhmake/src/fileinfo.h
+++ b/tools/mhmake/src/fileinfo.h
@@ -53,6 +53,10 @@ extern bool g_PrintMultipleDefinedRules;
extern const string g_EmptyString;
extern const string g_SpaceString;
+extern const string g_QuoteString;
+
+string QuoteFileName(const string &Filename);
+string UnquoteFileName(const string &Filename);
#define TIMESAFETY 3
class mh_time
@@ -138,12 +142,12 @@ public:
{
m_IsPhony=false;
m_IsBuild=false;
- m_AbsFileName=AbsFileName;
+ m_AbsFileName=UnquoteFileName(AbsFileName);
InvalidateDate();
m_CommandsMd5_32=Md5_32;
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Initialising Md5 of "<<GetFullFileName().c_str()<<" to 0x"<<hex<<Md5_32<<endl;
+ cout << "Initialising Md5 of "<<GetQuotedFullFileName().c_str()<<" to 0x"<<hex<<Md5_32<<endl;
#endif
}
fileinfo(const string &AbsFileName)
@@ -153,7 +157,7 @@ public:
/* The following constructor is only used for name comparisons, and should only be used for that */
fileinfo(int Dummy,const string &AbsFileName)
{
- m_AbsFileName=AbsFileName;
+ m_AbsFileName=UnquoteFileName(AbsFileName);
}
fileinfo(const char *szFile)
@@ -171,9 +175,13 @@ public:
{
return m_AbsFileName;
}
+ string GetQuotedFullFileName(void) const
+ {
+ return QuoteFileName(m_AbsFileName);
+ }
void SetFullFileName(const string &strAbsName)
{
- m_AbsFileName=strAbsName;
+ m_AbsFileName=UnquoteFileName(strAbsName);
// If the last char is path sep strip it
if (!m_AbsFileName.empty() && m_AbsFileName[m_AbsFileName.length()-1]==OSPATHSEP)
m_AbsFileName.resize(m_AbsFileName.length()-1);
@@ -235,7 +243,7 @@ public:
if (&*Dep==this)
{
#ifdef _DEBUG
- cout << GetFullFileName()<<" is directly dependent on itself\n";
+ cout << GetQuotedFullFileName()<<" is directly dependent on itself\n";
#endif
return;
}
@@ -253,7 +261,7 @@ public:
if (&**It==this)
{
#ifdef _DEBUG
- cout << GetFullFileName()<<" is directly dependent on itself\n";
+ cout << GetQuotedFullFileName()<<" is directly dependent on itself\n";
#endif
}
else
@@ -268,7 +276,7 @@ public:
if (&*MainDep==this)
{
#ifdef _DEBUG
- cout << GetFullFileName()<<" is directly dependent on itself\n";
+ cout << GetQuotedFullFileName()<<" is directly dependent on itself\n";
#endif
return;
}
@@ -338,7 +346,7 @@ public:
{
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Setting Md5 of "<<GetFullFileName().c_str()<<" to 0x"<<hex<<Md5_32<<endl;
+ cout << "Setting Md5 of "<<GetQuotedFullFileName()<<" to 0x"<<hex<<Md5_32<<endl;
#endif
m_CommandsMd5_32=Md5_32;
}
diff --git a/tools/mhmake/src/functions.cpp b/tools/mhmake/src/functions.cpp
index 9564610f8..2d93f59cd 100644
--- a/tools/mhmake/src/functions.cpp
+++ b/tools/mhmake/src/functions.cpp
@@ -449,7 +449,7 @@ string mhmakefileparser::f_filesindirs(const string & Arg) const
{
first=false;
}
- Ret+=pFile->GetFullFileName();
+ Ret+=pFile->GetQuotedFullFileName();
}
return Ret;
@@ -460,7 +460,7 @@ string mhmakefileparser::f_fullname(const string & Arg) const
{
string File=TrimString(Arg);
refptr<fileinfo> pFile=GetFileInfo(File);
- return pFile->GetFullFileName();
+ return pFile->GetQuotedFullFileName();
}
///////////////////////////////////////////////////////////////////////////////
@@ -491,7 +491,7 @@ static string IterList(const string &List,string (*iterFunc)(const string &FileN
static string basename(const string &FileName,const string &)
{
string Ret=FileName.substr(0,FileName.find_last_of('.'));
- if (FileName[0]=='"')
+ if (FileName[0]=='"' && FileName.end()[-1]=='"')
Ret+=s_QuoteString;
return Ret;
}
@@ -513,7 +513,7 @@ static string notdir(const string &FileName,const string &)
else
{
string Ret=g_EmptyString;
- if (FileName[0]=='"')
+ if (FileName[0]=='"' && FileName.end()[-1]=='"')
Ret+=s_QuoteString;
Ret+=FileName.substr(Pos+1);
return Ret;
@@ -651,7 +651,7 @@ static string dir(const string &FileName,const string &)
{
string Ret=g_EmptyString;
Ret+=FileName.substr(0,Pos+1);
- if (FileName[0]=='"')
+ if (FileName[0]=='"' && FileName.end()[-1]=='"')
Ret+=s_QuoteString;
return Ret;
}
@@ -715,10 +715,8 @@ static string relpath(const string &FileName,const string &)
retPath+=OSPATHSEPSTR"..";
pCur++;
}
- if (!pPath)
- return retPath;
- else
- return retPath+OSPATHSEPSTR+pLast;
+ if (pPath)
+ retPath=retPath+OSPATHSEPSTR+pLast;
}
else
{
@@ -731,12 +729,12 @@ static string relpath(const string &FileName,const string &)
pCur++;
}
retPath+=pLast;
- return retPath;
}
+ return QuoteFileName(retPath);
}
///////////////////////////////////////////////////////////////////////////////
-// Make a path name relative to the curren directory
+// Make a path name relative to the current directory
string mhmakefileparser::f_relpath(const string & FileNames) const
{
return IterList(FileNames,relpath);
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index cbcb33648..f8304df3f 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -47,14 +47,14 @@ int mhmakefileparser::ParseFile(const refptr<fileinfo> &FileInfo,bool SetMakeDir
if (SetMakeDir)
{
m_MakeDir=curdir::GetCurDir();
- m_Variables[CURDIR]=m_MakeDir->GetFullFileName();
+ m_Variables[CURDIR]=m_MakeDir->GetQuotedFullFileName();
}
theLexer.m_InputFileName=FileInfo->GetFullFileName();
theLexer.m_pParser=(mhmakeparser*)this;
theLexer.yyin=::fopen(FileInfo->GetFullFileName().c_str(),"r");
if (!theLexer.yyin)
{
- cerr << "Error opening makefile: "<<FileInfo->GetFullFileName()<<endl;
+ cerr << "Error opening makefile: "<<FileInfo->GetQuotedFullFileName()<<endl;
return 1;
}
int Ret=yyparse();
@@ -236,6 +236,11 @@ string mhmakefileparser::ExpandMacro(const string &Expr) const
{ // We have a match for the regular expression ^([^ \\t:]+)([: \\t])[ \\t]*(.+)
if (Type==':')
{
+ #ifdef WIN32
+ bool IsFileName=false;
+ if (pVarEnd-pVar == 1 && (*pVar=='<' || *pVar =='@'))
+ IsFileName=true;
+ #endif
string ToSubst=ExpandExpression(ExpandVar(string(pVar,pVarEnd)));
const char *pSrc=pTmp;
const char *pStop=pSrc;
@@ -243,6 +248,10 @@ string mhmakefileparser::ExpandMacro(const string &Expr) const
const char *pTo=pStop+1;
string SrcStr(pSrc,pStop);
string ToStr(pTo);
+ #ifdef WIN32
+ if (IsFileName)
+ return QuoteFileName(Substitute(UnquoteFileName(ToSubst),SrcStr,ToStr));
+ #endif
return Substitute(ToSubst,SrcStr,ToStr);
}
else if (Type==' ' || Type == '\t')
@@ -302,9 +311,9 @@ string mhmakefileparser::ExpandVar(const string &Var) const
return "<No Dependencies defined.>";
}
#endif
- return m_RuleThatIsBuild->GetDeps()[0]->GetFullFileName();
+ return m_RuleThatIsBuild->GetDeps()[0]->GetQuotedFullFileName();
case '@': // return full target file name
- return m_RuleThatIsBuild->GetFullFileName();
+ return m_RuleThatIsBuild->GetQuotedFullFileName();
case '*': // return stem
return m_RuleThatIsBuild->GetRule()->GetStem();
case '^': // return all prerequisits
@@ -359,10 +368,6 @@ void SplitToItems(const string &String,vector< refptr<fileinfo> > &Items,refptr<
pTmp=NextItem(pTmp,Item);
if (!Item.empty())
{
- if (Item[0]=='"')
- {
- Item=Item.substr(1,Item.size()-2);
- }
Items.push_back(GetFileInfo(Item,Dir));
}
}
@@ -669,14 +674,14 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
#ifdef _DEBUG
if (!pIn)
{
- cerr << "Error opening autodep file "<<DepFile->GetFullFileName()<<endl;
+ cerr << "Error opening autodep file "<<DepFile->GetQuotedFullFileName()<<endl;
return;
}
#endif
fread(&m_EnvMd5_32,sizeof(m_EnvMd5_32),1,pIn);
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Reading Env Md5 from "<<DepFile->GetFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl;
+ cout << "Reading Env Md5 from "<<DepFile->GetQuotedFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl;
#endif
char UsedEnvVars[1024];
ReadStr(pIn,UsedEnvVars);
@@ -711,9 +716,9 @@ void mhmakefileparser::LoadAutoDepsFile(refptr<fileinfo> &DepFile)
{
#ifdef _DEBUG
if (!(*pPair.first)->CompareMd5_32(Md5_32) && !(*pPair.first)->CompareMd5_32(0))
- cout << "Warning: trying to set to different md5's for Target "<<(*pPair.first)->GetFullFileName()<<" Old: "<<hex<<(*pPair.first)->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl;
+ cout << "Warning: trying to set to different md5's for Target "<<(*pPair.first)->GetQuotedFullFileName()<<" Old: "<<hex<<(*pPair.first)->GetCommandsMd5_32()<<" New: "<<Md5_32<<endl;
if (g_PrintAdditionalInfo)
- cout << "Setting Md5 for Target "<<(*pPair.first)->GetFullFileName()<<" to "<<hex<<Md5_32<<endl;
+ cout << "Setting Md5 for Target "<<(*pPair.first)->GetQuotedFullFileName()<<" to "<<hex<<Md5_32<<endl;
#endif
(*pPair.first)->SetCommandsMd5_32(Md5_32); // If it was already there, just update the md5 value
}
@@ -753,18 +758,19 @@ void mhmakefileparser::SaveAutoDepsFile()
{
return;
}
+ refptr<fileinfo> pDepFile=GetFileInfo(DepFile);
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
cout<<"Saving automatic dependency file "<<DepFile<<endl;
#endif
- FILE *pOut=fopen(DepFile.c_str(),"wb");
+ FILE *pOut=fopen(pDepFile->GetFullFileName().c_str(),"wb");
if (!pOut)
{
/* Maybe it is because the directory does not exist, so try to create this first */
- MakeDirs(GetAbsFileInfo(DepFile.substr(0,DepFile.find_last_of(OSPATHSEP))));
- pOut=fopen(DepFile.c_str(),"wb");
+ MakeDirs(pDepFile->GetDir());
+ pOut=fopen(pDepFile->GetFullFileName().c_str(),"wb");
if (!pOut)
{
@@ -964,7 +970,7 @@ uint32 mhmakefileparser::CreateEnvMd5_32() const
string Val=GetFromEnv(Var,false);
transform(Var.begin(),Var.end(),Var.begin(),(int(__CDECL *)(int))toupper);
transform(Val.begin(),Val.end(),Val.begin(),(int(__CDECL *)(int))toupper);
- DBGOUT(cout << GetMakeDir()->GetFullFileName() << " -> Setting GetFromEnv var " << Var << " to " << Val << endl);
+ DBGOUT(cout << GetMakeDir()->GetQuotedFullFileName() << " -> Setting GetFromEnv var " << Var << " to " << Val << endl);
Variables[Var]=Val;
}
}
@@ -978,7 +984,7 @@ uint32 mhmakefileparser::CreateEnvMd5_32() const
transform(Var.begin(),Var.end(),Var.begin(),(int(__CDECL *)(int))toupper);
string Val=It->second;
transform(Val.begin(),Val.end(),Val.begin(),(int(__CDECL *)(int))toupper);
- DBGOUT(cout << GetMakeDir()->GetFullFileName() << " -> Setting Commandline var " << Var << " to " << Val << endl);
+ DBGOUT(cout << GetMakeDir()->GetQuotedFullFileName() << " -> Setting Commandline var " << Var << " to " << Val << endl);
Variables[Var]=Val;
}
It++;
@@ -987,7 +993,7 @@ uint32 mhmakefileparser::CreateEnvMd5_32() const
// Now create the md5 string
md5_starts( &ctx );
- DBGOUT(cout << "MD5 of " << m_MakeDir->GetFullFileName() << endl);
+ DBGOUT(cout << "MD5 of " << m_MakeDir->GetQuotedFullFileName() << endl);
map<string,string>::const_iterator VarIt=Variables.begin();
map<string,string>::const_iterator VarItEnd=Variables.end();
diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y
index 0a8985209..ee26dd92b 100644
--- a/tools/mhmake/src/mhmakeparser.y
+++ b/tools/mhmake/src/mhmakeparser.y
@@ -58,7 +58,7 @@ file : statements
{
if (m_pCurrentItems)
{
- PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetFullFileName().c_str()));
+ PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetQuotedFullFileName().c_str()));
AddRule();
}
}
@@ -92,7 +92,7 @@ includemak:
{
if (m_pCurrentItems)
{
- PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetFullFileName().c_str()));
+ PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetQuotedFullFileName().c_str()));
AddRule();
}
} INCLUDEMAK
@@ -102,7 +102,7 @@ ruledef: expression_nocolorequal rulecolon maybeemptyexpression
{
if (m_pCurrentItems)
{
- PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetFullFileName().c_str()));
+ PRINTF(("Adding rule : %s\n",(*m_pCurrentItems)[0]->GetQuotedFullFileName().c_str()));
AddRule();
}
diff --git a/tools/mhmake/src/rule.cpp b/tools/mhmake/src/rule.cpp
index e8bc1b6d6..7e71ba95f 100644
--- a/tools/mhmake/src/rule.cpp
+++ b/tools/mhmake/src/rule.cpp
@@ -30,6 +30,7 @@ refptr<rule> NullRule;
map< string, vector<pair<string,refptr<rule> > > > IMPLICITRULE::m_ImplicitRules;
makecommand g_MakeCommand; // Order is important since sm_Statics is using g_MakeCommand
+const string g_QuoteString("\""); // Order is important since sm_Statics is using g_QuoteString
loadedmakefile::loadedmakefile_statics loadedmakefile::sm_Statics;
///////////////////////////////////////////////////////////////////////////////
@@ -52,7 +53,7 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
cerr << "Implicit Rule '"<< DepName << "' defined twice with different commands\n";
else
cerr << "Implicit Rule '"<< DepName << "' defined twice with same commands\n";
- cerr << "Command 1: makedir = " << SecIt->second->GetMakefile()->GetMakeDir()->GetFullFileName()<< endl;
+ cerr << "Command 1: makedir = " << SecIt->second->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()<< endl;
vector<string>::const_iterator It;
if (bCommandsDifferent)
@@ -63,7 +64,7 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
cerr << " " << *It << endl;
}
}
- cerr << "Command 2: makedir = "<< Rule->GetMakefile()->GetMakeDir()->GetFullFileName()<< endl;
+ cerr << "Command 2: makedir = "<< Rule->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()<< endl;
if (bCommandsDifferent)
{
It=NewCommands.begin();
@@ -83,9 +84,9 @@ static bool FindDep(const string &DepName,vector<pair<string,refptr<rule> > >&Im
if (pOldMakefile->ExpandExpression(*OldIt)!=pNewMakefile->ExpandExpression(*NewIt))
{
cerr << "Implicit Rule '"<< DepName << "' defined twice with different commands\n";
- cerr << "Command 1: makedir = " << pOldMakefile->GetMakeDir()->GetFullFileName()<< endl;
+ cerr << "Command 1: makedir = " << pOldMakefile->GetMakeDir()->GetQuotedFullFileName()<< endl;
cerr << " " << pOldMakefile->ExpandExpression(*OldIt) << endl;
- cerr << "Command 2: makedir = "<< pNewMakefile->GetMakeDir()->GetFullFileName()<< endl;
+ cerr << "Command 2: makedir = "<< pNewMakefile->GetMakeDir()->GetQuotedFullFileName()<< endl;
cerr << " " << pNewMakefile->ExpandExpression(*NewIt) << endl;
throw(1);
}
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index be0e92281..608311e94 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -265,8 +265,9 @@ loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
const char *pEnv=getenv(MHMAKECONF);
if (pEnv)
{
- m_GlobalCommandLineVars[MHMAKECONF]=pEnv;
- m_MhMakeConf=GetFileInfo(pEnv);
+ string Env(QuoteFileName(pEnv));
+ m_GlobalCommandLineVars[MHMAKECONF]=Env;
+ m_MhMakeConf=GetFileInfo(Env);
// Get the revision of the working copy
// We do it with the svn info command
@@ -276,7 +277,7 @@ loadedmakefile::loadedmakefile_statics::loadedmakefile_statics()
try
{
string SvnCommand=SearchCommand("svn",EXEEXT);
- Ret=OsExeCommand(SvnCommand,string(" info ")+m_MhMakeConf->GetFullFileName(),false,&Output);
+ Ret=OsExeCommand(SvnCommand,string(" info ")+m_MhMakeConf->GetQuotedFullFileName(),false,&Output);
}
catch (int)
{
@@ -464,7 +465,7 @@ void loadedmakefile::LoadMakefile()
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Loading makefile "<<m_Makefile->GetFullFileName()<<endl;
+ cout << "Loading makefile "<<m_Makefile->GetQuotedFullFileName()<<endl;
#endif
m_pParser=refptr<mhmakeparser>(new mhmakeparser(m_CommandLineVars));
@@ -501,7 +502,7 @@ void loadedmakefile::LoadMakefile()
int result=m_pParser->ParseFile(BeforeMakefile,true);
if (result)
{
- printf("Error parsing %s\n",BeforeMakefile->GetFullFileName().c_str());
+ printf("Error parsing %s\n",BeforeMakefile->GetQuotedFullFileName().c_str());
throw(1);
}
m_pParser->UpdateDate(BeforeMakefile->GetDate());
@@ -514,7 +515,7 @@ void loadedmakefile::LoadMakefile()
throw(1);
}
DepFile=GetFileInfo(ObjDirName+OSPATHSEPSTR MAKEDEPFILE);
- m_pParser->SetVariable(AUTODEPFILE,DepFile->GetFullFileName().c_str());
+ m_pParser->SetVariable(AUTODEPFILE,DepFile->GetQuotedFullFileName());
}
else
{
@@ -536,7 +537,7 @@ void loadedmakefile::LoadMakefile()
sprintf(ID,"_%x",md5_finish32( &ctx));
DepFile=GetFileInfo(string(MAKEDEPFILE)+ID);
- m_pParser->SetVariable(AUTODEPFILE,DepFile->GetFullFileName().c_str());
+ m_pParser->SetVariable(AUTODEPFILE,DepFile->GetQuotedFullFileName());
}
if (DepFile->Exists())
@@ -546,24 +547,24 @@ void loadedmakefile::LoadMakefile()
int result=m_pParser->ParseFile(m_Makefile,true);
if (result)
{
- printf("Error parsing %s\n",m_Makefile->GetFullFileName().c_str());
+ printf("Error parsing %s\n",m_Makefile->GetQuotedFullFileName().c_str());
throw(1);
}
#ifdef _DEBUG
/* Check if the makefile has changed the AUTODEPFILE variable, if so generate a warning that a
* rebuild could happen for the rules defined for making included makefiles */
- if (m_pParser->ExpandVar(AUTODEPFILE)!=DepFile->GetFullFileName())
+ if (m_pParser->ExpandVar(AUTODEPFILE)!=DepFile->GetQuotedFullFileName())
{
- cout << "\n\nWARNING:\n makefile '"<< m_Makefile->GetFullFileName() <<"' re-defines AUTODEPFILE\n from '"<< DepFile->GetFullFileName() <<"'\n to '"<<
+ cout << "\n\nWARNING:\n makefile '"<< m_Makefile->GetQuotedFullFileName() <<"' re-defines AUTODEPFILE\n from '"<< DepFile->GetQuotedFullFileName() <<"'\n to '"<<
m_pParser->ExpandVar(AUTODEPFILE) << "'\n (may cause needless rebuilds when having rules for included makefiles!!!!!)\n\n\n";
}
if (g_PrintAdditionalInfo)
{
if (m_pParser->GetFirstTarget())
- cout<<"First target of "<<m_Makefile->GetFullFileName()<<" is "<<m_pParser->GetFirstTarget()->GetFullFileName()<<endl;
+ cout<<"First target of "<<m_Makefile->GetQuotedFullFileName()<<" is "<<m_pParser->GetFirstTarget()->GetQuotedFullFileName()<<endl;
else
- cout<<"No First target for "<<m_Makefile->GetFullFileName()<<endl;
+ cout<<"No First target for "<<m_Makefile->GetQuotedFullFileName()<<endl;
}
#endif
m_pParser->UpdateDate(m_Makefile->GetDate());
@@ -573,7 +574,7 @@ void loadedmakefile::LoadMakefile()
refptr<fileinfo> AfterMakefile=GetFileInfo(BaseAutoMak+".after",sm_Statics.m_MhMakeConf);
int result=m_pParser->ParseFile(AfterMakefile);
if (result) {
- printf("Error parsing %s\n",AfterMakefile->GetFullFileName().c_str());
+ printf("Error parsing %s\n",AfterMakefile->GetQuotedFullFileName().c_str());
throw(1);
}
m_pParser->UpdateDate(AfterMakefile->GetDate());
@@ -606,7 +607,7 @@ void loadedmakefile::LoadMakefile()
{
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
- cout << "Makefile already loaded: "<<Found->m_Makefile->GetFullFileName()<<endl;
+ cout << "Makefile already loaded: "<<Found->m_Makefile->GetQuotedFullFileName()<<endl;
#endif
}
else
@@ -625,7 +626,7 @@ void loadedmakefile::LoadMakefile()
{
#ifdef _DEBUG
if (!g_GenProjectTree)
- cout << "Rebuilding everything of "<< m_Makefile->GetFullFileName() <<" because environment and/or command-line variables have been changed.\n";
+ cout << "Rebuilding everything of "<< m_Makefile->GetQuotedFullFileName() <<" because environment and/or command-line variables have been changed.\n";
#endif
m_pParser->SetRebuildAll();
}
@@ -642,7 +643,7 @@ void DumpVarsAndRules()
{
for (i=0; i<80; i++) cout << "_";
cout << endl;
- cout << "Variables of makefile " << (*LoadMakIt)->m_Makefile->GetFullFileName() << endl;
+ cout << "Variables of makefile " << (*LoadMakIt)->m_Makefile->GetQuotedFullFileName() << endl;
for (i=0; i<80; i++) cout << "_";
cout << endl;
(*LoadMakIt)->m_pParser->PrintVariables(true);
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index 6d660fc94..5cd242d51 100644
--- a/tools/mhmake/src/util.h
+++ b/tools/mhmake/src/util.h
@@ -50,7 +50,7 @@
#define PLATFORM "linux"
#endif
-#define MHMAKEVER "1.3.22"
+#define MHMAKEVER "1.4.0"
#define MAKEDEPFILE ".makefile.dep"
@@ -73,39 +73,49 @@ inline const char *NextItem(const char *pTmp,string &Output, const char *pToks="
const char *pStart;
const char *pStop;
while (strchr(pToks,*pTmp)&&*pTmp) pTmp++;
- if (*pTmp=='"')
+ pStart=pTmp;
+ while (1)
{
- pStart=pTmp++;
- while (*pTmp && *pTmp!='"') pTmp++;
- if (*pTmp) pTmp++;
- pStop=pTmp;
- }
- else if (*pTmp=='\'')
- {
- pStart=pTmp++;
- while (*pTmp && *pTmp!='\'') pTmp++;
- if (*pTmp) pTmp++;
- pStop=pTmp;
- }
- else if (!*pTmp)
- {
- pStart=pStop=pTmp;
- }
- else
- {
- pStart=pTmp++;
- #if OSPATHSEP=='/'
- while (*pTmp)
+ if (*pTmp=='"')
+ {
+ pTmp++;
+ while (*pTmp && *pTmp!='"') pTmp++;
+ if (*pTmp) pTmp++;
+ pStop=pTmp;
+ if (!*pTmp || strchr(pToks,*pTmp))
+ break;
+ }
+ else if (*pTmp=='\'')
{
- if (!strchr(pToks,*pTmp) || (*(pTmp-1)=='\\'))
- pTmp++;
- else
+ pTmp++;
+ while (*pTmp && *pTmp!='\'') pTmp++;
+ if (*pTmp) pTmp++;
+ pStop=pTmp;
+ if (!*pTmp || strchr(pToks,*pTmp))
break;
}
- #else
- while (!strchr(pToks,*pTmp)) pTmp++;
- #endif
- pStop=pTmp;
+ else if (!*pTmp)
+ {
+ pStop=pTmp;
+ break;
+ }
+ else
+ {
+ pTmp++;
+ #if OSPATHSEP=='/'
+ while (*pTmp)
+ {
+ if (!strchr(pToks,*pTmp) || (*(pTmp-1)=='\\'))
+ pTmp++;
+ else
+ break;
+ }
+ #else
+ while (!strchr(pToks,*pTmp)) pTmp++;
+ #endif
+ pStop=pTmp;
+ break;
+ }
}
Output=string(pStart,pStop);
// skip trailing space