diff --git a/Docs/src/compiler.but b/Docs/src/compiler.but index 0c75073f..ac88ded3 100644 --- a/Docs/src/compiler.but +++ b/Docs/src/compiler.but @@ -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. diff --git a/Docs/src/history.but b/Docs/src/history.but index cdfeef77..875f8fc6 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -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} diff --git a/Source/script.cpp b/Source/script.cpp index 8bc639ae..0a648597 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -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)