aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/mhmakefileparser.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-01-19 20:29:24 +0000
committermarha <marha@users.sourceforge.net>2011-01-19 20:29:24 +0000
commitcbe6ed88f01b654241301539d8fa3f6111a0a6de (patch)
tree0fe25b7083dc4cc0c3e162fe18e9d427fcb712a5 /tools/mhmake/src/mhmakefileparser.cpp
parentcdc60fdcddbe5666aac11af34c6c030d4a670b99 (diff)
downloadvcxsrv-cbe6ed88f01b654241301539d8fa3f6111a0a6de.tar.gz
vcxsrv-cbe6ed88f01b654241301539d8fa3f6111a0a6de.tar.bz2
vcxsrv-cbe6ed88f01b654241301539d8fa3f6111a0a6de.zip
Use bison instead of bison++
The += operator should also take the environment variables into account Solved problem when & in redirect operator on command line Solved syntax error when SPACE was follewed by SPACE Removed kdevelop3 project files Enable debug info in debug build on linux Added support for foreach function Fixed dependency problem for implicit rules with extra dependencies Increased gnu make compatibility: allow implicit rules without commands Solved wrong error message when it cannot build a target in mhmake_dbg On windows: when checking the extension of a command: make sure a / does not cause a wrong decision Added safety against recursive implicit rules. Fixed wrong check on failure to open makefiles. Make sure no message is printed when -include is used flex and bison generated files: make sure the #line statements have the correct line numbers for the debugger after having added one line in the beginning of the file after running the flex/bison. Make sure that the variable defined just before an error or message/info macro is defined when the message is generated. mhmake_dbg: print error message when a target cannot be build because the directory of the target does not exist (and no rule is defined for it) Reformatted message/info macro output Also print makefile and line number when using error and message macro Solved crash in mhmake_dbg when -C is specified on the command line Solved problem in macro expansion when 2 patsubst inside each other addprefix should not give an error when done on an empty string Use comspec when echo is followed by a pipe character (piping is not supported by the echo internal command of mhmake) Solved possible stack curruption (there was little chance that this was occuring)
Diffstat (limited to 'tools/mhmake/src/mhmakefileparser.cpp')
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp67
1 files changed, 42 insertions, 25 deletions
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index f281bc7dd..cf41b3c1c 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -29,19 +29,6 @@
commandqueue mhmakefileparser::sm_CommandQueue;
///////////////////////////////////////////////////////////////////////////////
-int mhmakefileparser::yylex(void)
-{
- m_yyloc=m_ptheLexer->lineno();
- return m_ptheLexer->yylex(m_theTokenValue);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-void mhmakefileparser::yyerror(const char *m)
-{
- cerr << this->m_ptheLexer->m_InputFileName<< " ("<<m_yyloc<<"): "<<m<<endl;
-}
-
-///////////////////////////////////////////////////////////////////////////////
int mhmakefileparser::ParseFile(const fileinfo *pFileInfo, const fileinfo *pMakeDir)
{
if (pMakeDir)
@@ -60,8 +47,8 @@ int mhmakefileparser::ParseFile(const fileinfo *pFileInfo, const fileinfo *pMake
mhmakeFlexLexer theLexer(&yyin);
m_ptheLexer=&theLexer;
theLexer.m_InputFileName=pFileInfo->GetFullFileName();
- theLexer.m_pParser=(mhmakeparser*)this;
- int Ret=yyparse();
+ theLexer.m_pParser=this;
+ int Ret=parse();
return Ret;
}
@@ -92,10 +79,15 @@ static inline size_t SkipUntilQuote(const string &Expr,size_t i,char Char)
static inline size_t SkipMakeExpr(const string &Expr,size_t i)
{
char Char=Expr[i++];
- if (Char!='(')
+ char EndChar;
+ if (Char=='(')
+ EndChar=')';
+ else if (Char=='{')
+ EndChar='}';
+ else
return i;
Char=Expr[i++];
- while (Char!=')')
+ while (Char!=EndChar)
{
if (Char=='$')
{
@@ -103,7 +95,7 @@ static inline size_t SkipMakeExpr(const string &Expr,size_t i)
}
#ifdef _DEBUG
if (i>=Expr.length())
- throw(string(") not found in ")+Expr);
+ throw(string(1,EndChar)+" not found in "+Expr);
#endif
Char=Expr[i++];
}
@@ -570,11 +562,11 @@ void mhmakefileparser::GetAutoDeps(const fileinfo *pFirstDep, deps_t &Autodeps)
{
if (Ret=='#')
{
- fscanf(pIn,"%*[ \t]");
- Ret=fscanf(pIn,"include %1[\"<]%254[^>\"]%*[\">]",&Type,IncludeList);
+ Ret=fscanf(pIn,"%*[ \t]");
+ Ret=fscanf(pIn,"include %1[\"<]%254[^>\"]%*[\">]",(char*)&Type,IncludeList);
}
else
- Ret=fscanf(pIn,"import %1[\"<]%254[^>\"]%*[\">]",&Type,IncludeList);
+ Ret=fscanf(pIn,"import %1[\"<]%254[^>\"]%*[\">]",(char*)&Type,IncludeList);
if (Ret==2)
{
bFound=true;
@@ -744,14 +736,17 @@ void mhmakefileparser::LoadAutoDepsFile(fileinfo *pDepFile)
m_AutoDepFileLoaded=pDepFile;
FILE *pIn=fopen(pDepFile->GetFullFileName().c_str(),"rb");
-#ifdef _DEBUG
if (!pIn)
{
cerr << "Error opening autodep file "<<pDepFile->GetQuotedFullFileName()<<endl;
return;
}
-#endif
- fread(&m_EnvMd5_32,sizeof(m_EnvMd5_32),1,pIn);
+ if (1!=fread(&m_EnvMd5_32,sizeof(m_EnvMd5_32),1,pIn))
+ {
+ cerr << "Wrong format of autodep file "<<pDepFile->GetQuotedFullFileName()<<endl;
+ fclose(pIn);
+ return;
+ }
#ifdef _DEBUG
if (g_PrintAdditionalInfo)
cout << "Reading Env Md5 from "<<pDepFile->GetQuotedFullFileName()<<": "<<hex<<m_EnvMd5_32<<endl;
@@ -1358,7 +1353,12 @@ string mhmakefileparser::ResolveExpression(const string &InExpr,string &Rest) co
switch (Expr[i])
{
case '!':
- if (Expr[i+1]!='=')
+ if (i==Expr.length()-1)
+ {
+ i++; // to break out of the loop
+ Ret=s_TrueString; /* the input was ! which means true */
+ }
+ else if (Expr[i+1]!='=')
{
Ret=ResolveExpression(Expr.substr(i+1),Expr);
Ret = Ret.empty() || Ret==s_FalseString ? s_TrueString : g_EmptyString;
@@ -1371,6 +1371,12 @@ string mhmakefileparser::ResolveExpression(const string &InExpr,string &Rest) co
}
break;
case '&':
+ #ifdef _DEBUG
+ if (i==Expr.length()-1)
+ {
+ throw(string("Error in expression near ")+Expr[i]+": "+InExpr);
+ } else
+ #endif
if (Expr[i+1]!='&')
{
Ret+=Expr[i++];
@@ -1382,6 +1388,12 @@ string mhmakefileparser::ResolveExpression(const string &InExpr,string &Rest) co
}
break;
case '|':
+ #ifdef _DEBUG
+ if (i==Expr.length()-1)
+ {
+ throw(string("Error in expression near ")+Expr[i]+": "+InExpr);
+ } else
+ #endif
if (Expr[i+1]!='|')
{
Ret+=Expr[i++];
@@ -1420,6 +1432,11 @@ string mhmakefileparser::ResolveExpression(const string &InExpr,string &Rest) co
}
break;
case '=':
+ if (i==Expr.length()-1)
+ {
+ i++; // To break out of the loop
+ }
+ else
if (Expr[i+1]!='=')
{
Ret+=Expr[i++];