Include dirs (${NSISDIR}\Inclue is automatically one of them, use !AddIncludeDir to add more). Fixed a bug with SetStaticBkColor (-1)
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1958 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
92029c8558
commit
6896e04c79
5 changed files with 50 additions and 3 deletions
|
@ -198,10 +198,12 @@ CEXEBuild::CEXEBuild()
|
|||
// Coded by Robert Rainwater
|
||||
{
|
||||
char szNSISDir[NSIS_MAX_STRLEN],*fn2;
|
||||
GetModuleFileName(NULL,szNSISDir,sizeof(szNSISDir));
|
||||
GetModuleFileName(NULL,szNSISDir,sizeof(szNSISDir)-sizeof("\\Include"));
|
||||
fn2=strrchr(szNSISDir,'\\');
|
||||
if(fn2!=NULL) *fn2=0;
|
||||
definedlist.add("NSISDIR",(char*)szNSISDir);
|
||||
lstrcat(szNSISDir, "\\Include");
|
||||
include_dirs.add(szNSISDir,0);
|
||||
}
|
||||
|
||||
db_opt_save=db_comp_save=db_full_size=db_opt_save_u=db_comp_save_u=db_full_size_u=0;
|
||||
|
|
|
@ -194,6 +194,8 @@ class CEXEBuild {
|
|||
db_comp_save_u, db_full_size_u;
|
||||
int build_sections_req,build_sections_div;
|
||||
|
||||
StringList include_dirs;
|
||||
|
||||
StringList ns_func, ns_label; // function and label namespaces
|
||||
|
||||
int build_cursection_isfunc;
|
||||
|
|
|
@ -1663,20 +1663,56 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
SCRIPT_MSG("!system: returned %d\n",ret);
|
||||
}
|
||||
return PS_OK;
|
||||
case TOK_P_ADDINCLUDEDIR:
|
||||
include_dirs.add(line.gettoken_str(1),0);
|
||||
return PS_OK;
|
||||
case TOK_P_INCLUDE:
|
||||
{
|
||||
bool malloced=false;
|
||||
char *f=line.gettoken_str(1);
|
||||
SCRIPT_MSG("!include: \"%s\"\n",f);
|
||||
FILE *incfp=fopen(f,"rt");
|
||||
if (!incfp)
|
||||
{
|
||||
char *dir=include_dirs.get();
|
||||
unsigned int dirs=include_dirs.getnum();
|
||||
unsigned int size=lstrlen(f)+lstrlen(dir)+100;
|
||||
char *incfile=(char*)malloc(size);
|
||||
|
||||
for (unsigned int i=0; i<dirs; i++) {
|
||||
if (size < lstrlen(f)+lstrlen(dir))
|
||||
{
|
||||
free(incfile);
|
||||
size+=lstrlen(dir);
|
||||
incfile=(char*)malloc(size);
|
||||
}
|
||||
strcpy(incfile,dir);
|
||||
if (*f != '\\')
|
||||
strcat(incfile,"\\");
|
||||
strcat(incfile,f);
|
||||
incfp=fopen(incfile,"rt");
|
||||
if (!incfp)
|
||||
dir+=strlen(dir)+1;
|
||||
else
|
||||
{
|
||||
malloced=true;
|
||||
f=incfile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!malloced) free(incfile);
|
||||
}
|
||||
if (!incfp)
|
||||
{
|
||||
ERROR_MSG("!include: could not open file: \"%s\"\n",f);
|
||||
if (malloced) free(f);
|
||||
return PS_ERROR;
|
||||
}
|
||||
static int depth;
|
||||
if (depth >= MAX_INCLUDEDEPTH)
|
||||
{
|
||||
ERROR_MSG("parseScript: too many levels of includes (%d max).\n",MAX_INCLUDEDEPTH);
|
||||
if (malloced) free(f);
|
||||
return PS_ERROR;
|
||||
}
|
||||
depth++;
|
||||
|
@ -1689,9 +1725,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
if (r == PS_ENDIF) ERROR_MSG("!endif: stray !endif\n");
|
||||
if (IS_PS_ELSE(r)) ERROR_MSG("!else: stray !else\n");
|
||||
ERROR_MSG("!include: error in script: \"%s\" on line %d\n",f,lc);
|
||||
if (malloced) free(f);
|
||||
return PS_ERROR;
|
||||
}
|
||||
SCRIPT_MSG("!include: closed: \"%s\"\n",f);
|
||||
if (malloced) free(f);
|
||||
}
|
||||
return PS_OK;
|
||||
case TOK_P_CD:
|
||||
|
@ -2546,8 +2584,11 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
case TOK_SETSTATICBKCOLOR:
|
||||
ent.which=EW_SETWINDOWLONG;
|
||||
ent.offsets[0]=add_string(line.gettoken_str(1));
|
||||
ent.offsets[1]=add_string("-21"/*GWL_USERDATA*/);
|
||||
ent.offsets[2]=add_string(line.gettoken_str(2));
|
||||
char temp[64];
|
||||
wsprintf(temp, "%d", GWL_USERDATA);
|
||||
ent.offsets[1]=add_string(temp);
|
||||
wsprintf(temp, "%d", line.gettoken_int(2)+1);
|
||||
ent.offsets[2]=add_string(temp);
|
||||
SCRIPT_MSG("SetStaticBkColor: handle=%s color=%s\n",line.gettoken_str(1),line.gettoken_str(2));
|
||||
return add_entry(&ent);
|
||||
case TOK_SETWINDOWLONG:
|
||||
|
|
|
@ -174,6 +174,7 @@ static tokenType tokenlist[TOK__LAST] =
|
|||
{TOK_XPSTYLE, "XPStyle",1,0,"(on|off)"},
|
||||
{TOK_P_PACKEXEHEADER,"!packhdr",2,0,"temp_file_name command_line_to_compress_that_temp_file"},
|
||||
{TOK_P_SYSTEMEXEC,"!system",1,2,"command (<|>|<>|=|ignore) retval"},
|
||||
{TOK_P_ADDINCLUDEDIR,"!AddIncludeDir",1,0,"dir"},
|
||||
{TOK_P_INCLUDE,"!include",1,0,"filename.nsi"},
|
||||
{TOK_P_CD,"!cd",1,0,"absolute_or_relative_new_directory"},
|
||||
{TOK_P_IFDEF,"!ifdef",1,-1,"symbol [| symbol2 [& symbol3 [...]]]"},
|
||||
|
|
|
@ -65,6 +65,7 @@ enum
|
|||
TOK_P_UNDEF,
|
||||
TOK_P_PACKEXEHEADER,
|
||||
TOK_P_SYSTEMEXEC,
|
||||
TOK_P_ADDINCLUDEDIR,
|
||||
TOK_P_INCLUDE,
|
||||
TOK_P_CD,
|
||||
TOK_P_ECHO,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue