diff --git a/Docs/src/attributes.but b/Docs/src/attributes.but
index 3a8c55a0..e5566d42 100644
--- a/Docs/src/attributes.but
+++ b/Docs/src/attributes.but
@@ -230,12 +230,14 @@ Valid values for flag are "smooth" (smooth the progress bar) or "colored" (color
\S2{ainsttype} InstType
-\c install_type_name | /NOCUSTOM | /CUSTOMSTRING=str | /COMPONENTSONLYONCUSTOM
+\c install_type_name [index_output] | /NOCUSTOM | /CUSTOMSTRING=str | /COMPONENTSONLYONCUSTOM
-Adds an install type to the install type list, or disables the custom install type. There can be as many as 32 types, each one specifying the name of the install type. If the name is prefixed with 'un.' it is an uninstaller install type. The name can contain variables which will be processed at runtime before the components page shows. Another way of changing the \R{ainsttype}{InstType} name during runtime is the \R{sinsttypesettext}{InstTypeSetText} command. The difference is that with \R{sinsttypesettext}{InstTypeSetText} you are saving your precious user variables. The first type is the default (generally 'Typical'). If the /NOCUSTOM switch is specified, then the "custom" install type is disabled, and the user has to choose one of the pre-defined install types. Alternatively, if the /CUSTOMSTRING switch is specified, the parameter will override the "Custom" install type text. Alternatively, if the /COMPONENTSONLYONCUSTOM flag is specified, the component list will only be shown if the "Custom" install type is selected.
+Adds an install type to the install type list, or disables the custom install type. There can be as many as \#{NSIS_MAX_INST_TYPES}32 types, each one specifying the name of the install type. If the name is prefixed with 'un.' it is an uninstaller install type. The name can contain variables which will be processed at runtime before the components page shows. Another way of changing the \R{ainsttype}{InstType} name during runtime is the \R{sinsttypesettext}{InstTypeSetText} command. The difference is that with \R{sinsttypesettext}{InstTypeSetText} you are saving your precious user variables. The first type is the default (generally 'Typical' or 'Full'). If the /NOCUSTOM switch is specified, then the "custom" install type is disabled, and the user has to choose one of the pre-defined install types. Alternatively, if the /CUSTOMSTRING switch is specified, the parameter will override the "Custom" install type text. Alternatively, if the /COMPONENTSONLYONCUSTOM flag is specified, the component list will only be shown if the "Custom" install type is selected.
Accepts variables for type names. If variables are used, they must be initialized before the components page is created.
+\R{ssectioninsttype}{SectionInstType} is used to bind \cw{Section}s to install types.
+
\S2{alicensebkcolor} LicenseBkColor
\c color | \\/gray\\ | /windows
diff --git a/Docs/src/history.but b/Docs/src/history.but
index 5bce35b9..150f0013 100644
--- a/Docs/src/history.but
+++ b/Docs/src/history.but
@@ -34,6 +34,8 @@ ANSI targets are deprecated, consider moving to Unicode.
\b StrFunc.nsh now supports a "using" idiom to help with forward-declaration of functions (\W{http://sf.net/p/nsis/bugs/1229}{bug #1229})
+\b Added \R{ssectioninsttype}{SectionInstType}
+
\b Zero uninitialized data in icon group (\W{http://sf.net/p/nsis/bugs/1230}{bug #1230})
\b Automatically doubles ampersands in the name attribute
diff --git a/Docs/src/sections.but b/Docs/src/sections.but
index 3d1fa141..9ed19443 100644
--- a/Docs/src/sections.but
+++ b/Docs/src/sections.but
@@ -71,22 +71,30 @@ To access the section index, curly brackets must be used and the code must be lo
This command closes the current open section.
+\S2{ssectioninsttype} SectionInstType
+
+\c insttype_index [insttype_index [...]] [RO]
+
+This command specifies which install types (see \R{ainsttype}{InstType}) the current section defaults to the enabled state in. Multiple \cw{SectionInstType} commands can be specified (they are combined). If you specify RO as a parameter, then the section will be read-only, meaning the user won't be able to change its state.
+
+\c InstType "Full" IT_FULL
+\c InstType "Minimal" IT_MIN
+\c
+\c Section "Help"
+\c SectionInstType ${IT_FULL} ${IT_MIN}
+\c SectionEnd
+\c
+\c Section "Bonus content"
+\c SectionInstType ${IT_FULL}
+\c SectionEnd
+
\S2{ssectionin} SectionIn
-\c insttype_index [insttype_index] [RO]
+\c insttype_index [insttype_index [...]] [RO]
-This command specifies which install types (see \R{ainsttype}{InstType}) the current section defaults to the enabled state in. Multiple \R{ssectionin}{SectionIn} commands can be specified (they are combined). If you specify RO as a parameter, then the section will be read-only, meaning the user won't be able to change its state. The first install type defined using \R{ainsttype}{InstType} is indexed 1, the next 2 and so on.
+Works like \cw{SectionInstType} except that the first install type defined using \R{ainsttype}{InstType} is indexed 1, the next 2 and so on.
-\c InstType "full"
-\c InstType "minimal"
-\c
-\c Section "a section"
-\c SectionIn 1 2
-\c SectionEnd
-\c
-\c Section "another section"
-\c SectionIn 1
-\c SectionEnd
+\# DEPRECATED
\S2{ssectiongroup} SectionGroup
diff --git a/Source/lineparse.cpp b/Source/lineparse.cpp
index aa43a9c3..0f5637cd 100644
--- a/Source/lineparse.cpp
+++ b/Source/lineparse.cpp
@@ -199,7 +199,7 @@ int LineParser::gettoken_binstrdata(int token, char*buffer, int bufcap) const
TCHAR* LineParser::gettoken_str(int token) const
{
token+=m_eat;
- if (token < 0 || token >= m_nt) return (TCHAR*) _T("");
+ if (token < 0 || token >= m_nt) return const_cast(_T(""));
return m_tokens[token];
}
diff --git a/Source/script.cpp b/Source/script.cpp
index 7f008d06..a27f233d 100644
--- a/Source/script.cpp
+++ b/Source/script.cpp
@@ -1462,12 +1462,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
}
else
{
- TCHAR *itname = line.gettoken_str(1);
-
- if (!_tcsnicmp(itname, _T("un."), 3)) {
- set_uninstall_mode(1);
- itname += 3;
- }
+ const TCHAR *itname = line.gettoken_str(1), *defname = line.gettoken_str(2), setdef = *defname, *eqstr = setdef ? _T("=") : _T("");
+ if (!_tcsnicmp(itname, _T("un."), 3)) set_uninstall_mode(1), itname += 3;
for (x = 0; x < NSIS_MAX_INST_TYPES && cur_header->install_types[x]; x++);
if (x == NSIS_MAX_INST_TYPES)
@@ -1478,7 +1474,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
else
{
cur_header->install_types[x] = add_string(itname);
- SCRIPT_MSG(_T("InstType: %") NPRIs _T("%d=\"%") NPRIs _T("\"\n"), uninstall_mode ? _T("(uninstall) ") : _T(""), x+1, itname);
+ if (setdef) definedlist.set_si32(defname, x);
+ SCRIPT_MSG(_T("InstType: %") NPRIs _T("\"%") NPRIs _T("\" (%") NPRIs _T("%") NPRIs _T("%d)\n"), uninstall_mode ? _T("(uninstall) ") : _T(""), itname, defname, eqstr, x);
}
set_uninstall_mode(0);
@@ -2674,12 +2671,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_SECTIONEND:
SCRIPT_MSG(_T("SectionEnd\n"));
return section_end();
- case TOK_SECTIONIN:
+ case TOK_SECTIONINSTTYPE: // 0 based
+ case TOK_SECTIONIN: // Legacy 1 based instruction
{
- SCRIPT_MSG(_T("SectionIn: "));
- for (int wt = 1; wt < line.getnumtokens(); wt++)
+ int zerobased = which_token == TOK_SECTIONINSTTYPE, itid, succ;
+ const TCHAR *cmdname = get_commandtoken_name(which_token);
+ SCRIPT_MSG(_T("%") NPRIs _T(": "), cmdname);
+ for (int ti = 0; ++ti < line.getnumtokens();)
{
- TCHAR *p=line.gettoken_str(wt);
+ const TCHAR *p = line.gettoken_str(ti);
if (!_tcsicmp(p, _T("RO")))
{
if (section_add_flags(SF_RO) != PS_OK) return PS_ERROR;
@@ -2687,22 +2687,17 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
}
else
{
- int x=_ttoi(p)-1;
- if (x >= 0 && x < NSIS_MAX_INST_TYPES)
+ itid = line.gettoken_int(ti, &succ) - (zerobased ? 0 : 1);
+ if (succ && itid >= 0 && itid < NSIS_MAX_INST_TYPES)
{
- if (section_add_install_type(1<> >>>)"),TP_CODE},
{TOK_INTPTROP,_T("IntPtrOp"),3,1,_T("$(user_var: result) val1 OP [val2]"),TP_CODE},
{TOK_INTCMP,_T("IntCmp"),3,2,_T("val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]"),TP_CODE},
@@ -171,6 +171,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_RMDIR,_T("RMDir"),1,2,_T("[/r] [/REBOOTOK] directory_name"),TP_CODE},
{TOK_SECTION,_T("Section"),0,3,_T("[/o] [-][un.][section_name] [section index output]"),TP_GLOBAL},
{TOK_SECTIONEND,_T("SectionEnd"),0,0,_T(""),TP_SEC},
+{TOK_SECTIONINSTTYPE,_T("SectionInstType"),1,-1,_T("InstTypeIdx [InstTypeIdx [...]]"),TP_SEC},
{TOK_SECTIONIN,_T("SectionIn"),1,-1,_T("InstTypeIdx [InstTypeIdx [...]]"),TP_SEC},
{TOK_SUBSECTION,_T("SubSection"),1,2,_T("deprecated - use SectionGroup"),TP_GLOBAL},
{TOK_SECTIONGROUP,_T("SectionGroup"),1,2,_T("[/e] [un.]section_group_name [section index output]"),TP_GLOBAL},
diff --git a/Source/tokens.h b/Source/tokens.h
index e7964388..b7ec04b3 100644
--- a/Source/tokens.h
+++ b/Source/tokens.h
@@ -148,6 +148,7 @@ enum
// section/function stuff
TOK_SECTION,
TOK_SECTIONEND,
+ TOK_SECTIONINSTTYPE,
TOK_SECTIONIN,
TOK_SECTIONGROUP,
TOK_SECTIONGROUPEND,