Added ${__COUNTER__} predefine

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6325 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-03-29 02:39:07 +00:00
parent 9fa3398dd9
commit fe8e4a36bf
3 changed files with 31 additions and 13 deletions

View file

@ -177,6 +177,10 @@ Passing push will cause \R{verbose}{!verbose} to push the current verbosity leve
You can use these standard predefines to automatically add the build time to the title of development versions, add the date to the version number, etc.
\S1{precounter} $\{__COUNTER__\}
Expands to a number (Starting at 0 and incrementing by 1 every time it is used)
\S1{prefile} $\{__FILE__\}
Current script name.

View file

@ -32,6 +32,8 @@ Released on ?, 2013
\b Added $\{NSIS_PACKEDVERSION\}, the NSIS version packed in a hex number (\W{http://sourceforge.net/support/tracker.php?aid=2680832}{patch #2680832})
\b Added $\{__COUNTER__\} predefine
\b Added UnsafeStrCpy instruction, it can write to special variables like $PLUGINSDIR
\b Plugins in $\{NSISDIR\}\\Plugins have to be reserved with \c{ReserveFile /plugin}

View file

@ -684,21 +684,33 @@ void CEXEBuild::ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hi
ps_addtoline(s,defname,hist);
defname.add(_T(""),sizeof(_T("")));
t=definedlist.find((TCHAR*)defname.get());
TCHAR unichar[4+1];
if (!t && _T('U')==s[0] && _T('+')==s[1])
TCHAR dyndefbuf[10+1];
if (!t)
{
TCHAR *n=s+2;
unsigned long utf32=_tcstoul(n,&t,16);
// We only want to accept "${U+HEXDIGITS}" and not "${U+ -HEXDIGITS }"
if (*t || _T('-')==*n || _T('+')==*n) t=0;
if (_T(' ')==*n || _T('\t')==*n) t=0; // TODO: _istspace()?
if (!utf32) t=0; // Don't allow "${U+0}"
if (t)
if (_T('_')==s[0] && _T('_')==s[1])
{
UINT32 codpts[]={utf32,UNICODE_REPLACEMENT_CHARACTER,'?'};
for(UINT i=0; i < COUNTOF(codpts); ++i)
if (WCFromCodePoint(unichar,COUNTOF(unichar),codpts[i])) break;
t=unichar;
if (!_tcscmp(s,_T("__COUNTER__")))
{
static unsigned long cntr=0;
_stprintf(dyndefbuf,_T("%lu"),cntr++);
t=dyndefbuf;
}
}
if (_T('U')==s[0] && _T('+')==s[1])
{
TCHAR *n=s+2;
unsigned long utf32=_tcstoul(n,&t,16);
// We only want to accept "${U+HEXDIGITS}" and not "${U+ -HEXDIGITS }"
if (*t || _T('-')==*n || _T('+')==*n) t=0;
if (_T(' ')==*n || _T('\t')==*n) t=0; // TODO: _istspace()?
if (!utf32) t=0; // Don't allow "${U+0}"
if (t)
{
UINT32 codpts[]={utf32,UNICODE_REPLACEMENT_CHARACTER,'?'};
for(UINT i=0; i < COUNTOF(codpts); ++i)
if (WCFromCodePoint(dyndefbuf,COUNTOF(dyndefbuf),codpts[i])) break;
t=dyndefbuf;
}
}
}
if (t && hist.find((TCHAR*)defname.get(),0)<0)