Added support for reading environmental variables on compile time - $%envVarName%.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3205 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-11-25 06:25:31 +00:00
parent b6a98d86c3
commit 5e2948eda9

View file

@ -418,8 +418,8 @@ void CEXEBuild::ps_addtoline(const char *str, GrowBuf &linedata, StringList &his
#endif
{
// convert $\r, $\n to their literals
// preprocessor replace ${VAR} with whatever value
// note that if VAR does not exist, ${VAR} will go through unmodified
// preprocessor replace ${VAR} and $%VAR% with whatever value
// note that if VAR does not exist, ${VAR} or $%VAR% will go through unmodified
const char *in=str;
while (*in)
{
@ -488,6 +488,38 @@ void CEXEBuild::ps_addtoline(const char *str, GrowBuf &linedata, StringList &his
ps_addtoline(t,linedata,hist,true);
#else
ps_addtoline(t,linedata,hist);
#endif
hist.delbypos(hist.find((char*)defname.get(),0));
}
}
free(s);
}
else if (in[0] == '%')
{
char *s=strdup(in+1);
char *t=s;
while (*t)
{
if (*t == '%') break;
t=CharNext(t);
}
if (*t && t!=s)
{
*t=0;
// check for defines inside the define name - ${bla${blo}}
GrowBuf defname;
ps_addtoline(s,defname,hist);
defname.add("",1);
t=getenv((char*)defname.get());
if (t && hist.find((char*)defname.get(),0)<0)
{
in+=strlen(s)+2;
add=0;
hist.add((char*)defname.get(),0);
#ifdef NSIS_FIX_DEFINES_IN_STRINGS
ps_addtoline(t,linedata,hist,true);
#else
ps_addtoline(t,linedata,hist);
#endif
hist.delbypos(hist.find((char*)defname.get(),0));
}