aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/src/mhmakefileparser.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-02-19 17:09:40 +0000
committermarha <marha@users.sourceforge.net>2010-02-19 17:09:40 +0000
commit68504d1066c26aa26b73d5be549d7a95d6afd8ed (patch)
treeaec0dd1ce863c0bf082b7b90e09dfd510bb2714d /tools/mhmake/src/mhmakefileparser.cpp
parente99c3e5c94628984d5f1f38b38ce3ed0363e3935 (diff)
downloadvcxsrv-68504d1066c26aa26b73d5be549d7a95d6afd8ed.tar.gz
vcxsrv-68504d1066c26aa26b73d5be549d7a95d6afd8ed.tar.bz2
vcxsrv-68504d1066c26aa26b73d5be549d7a95d6afd8ed.zip
Linux compilation is ok again.
Diffstat (limited to 'tools/mhmake/src/mhmakefileparser.cpp')
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index 76e43f475..e9d50a704 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -415,12 +415,21 @@ void mhmakefileparser::PrintVariables(bool Expand) const
if (m_pEnv)
{
cout << "Environment overruled:\n";
+#ifdef WIN32
char *pEnv=m_pEnv;
while (*pEnv)
{
cout<<pEnv<<endl;
pEnv+=strlen(pEnv)+1;
}
+#else
+ char **pEnv=m_pEnv;
+ while (*pEnv)
+ {
+ cout<<*pEnv<<endl;
+ pEnv++;
+ }
+#endif
}
}
#endif
@@ -871,6 +880,7 @@ bool mhmakefileparser::SkipHeaderFile(const string &FileName)
///////////////////////////////////////////////////////////////////////////////
void mhmakefileparser::SetExport(const string &Var, const string &Val)
{
+#ifdef WIN32
if (!m_pEnv)
{
/* Environment not created yet, so create one */
@@ -930,6 +940,57 @@ void mhmakefileparser::SetExport(const string &Var, const string &Val)
*pEnv++='\0';
*pEnv++='\0';
m_EnvLen+=Extra;
+#else
+ if (!m_pEnv)
+ {
+ /* Environment not created yet, so create one */
+ char **pEnv=environ;
+ char **pEnd=pEnv;
+ int Len=1;
+ while (*pEnd)
+ {
+ Len++;
+ pEnd++;
+ }
+ m_EnvLen=Len;
+ m_pEnv=(char**)malloc(Len*sizeof(pEnv));
+ int i=0;
+ while (*pEnv)
+ {
+ m_pEnv[i]=strdup(*pEnv);
+ i++;
+ pEnv++;
+ }
+ m_pEnv[i]=NULL;
+ }
+ /* First check if the variable is in the environment, if so replace it */
+ char **pEnv=m_pEnv;
+ while (*pEnv)
+ {
+ const char *pVar=Var.c_str();
+ char *pStart=*pEnv;
+ char *pTmp=pStart;
+ while (*pTmp!='=' && *pTmp==*pVar)
+ {
+ pTmp++; pVar++;
+ }
+ if (*pTmp=='=' && !*pVar)
+ {
+ free(*pEnv);
+ *pEnv=strdup((Var+"="+Val).c_str());
+ break;
+ }
+ pEnv++;
+ }
+ if (!*pEnv)
+ {
+ // Add it at the end of the list
+ m_pEnv=(char**)realloc(m_pEnv,(m_EnvLen+1)*sizeof(*pEnv));
+ m_pEnv[m_EnvLen-1]=strdup((Var+"="+Val).c_str());
+ m_pEnv[m_EnvLen++]=NULL;
+ }
+
+#endif
}
///////////////////////////////////////////////////////////////////////////////