* Added support for 0o octal radix prefix on number literals in the preprocessor

* The single parameter version of !if now also supports floats
* Preprocessor now warns when invalid floating point numbers are used in math operations


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6633 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2015-11-05 21:05:23 +00:00
parent ce249976f7
commit d7ac356d0e
4 changed files with 15 additions and 3 deletions

View file

@ -2,7 +2,9 @@
\S0{compcommands} Compiler Utility Commands
These commands are similar to the C preprocessor in terms of purpose and functionality. They allow file inclusion, conditional compilation, executable header packing, and processes execution during the build process. Note: none of these commands allow use of variables.
These commands are similar to the C preprocessor in terms of purpose and functionality. They allow file inclusion, conditional compilation, executable header packing, and processes execution during the build process. Note: None of these commands allow the use of variables.
Number literals support the \c{0b}, \c{0o}, \c{0n} and \c{0x} radix prefixes (base 2, 8, 10 and 16 respectively). Note: The deprecated plain \c{0} octal prefix is also supported in some places but its usage is discouraged.
\S1{include} !include

View file

@ -20,6 +20,12 @@ Released on ? ?th, 201?
\b !system and !execute now provide a empty StdIn pipe to work around bugs in some Windows utilities
\b Added support for 0o octal radix prefix on number literals in the preprocessor
\b The single parameter version of !if now also supports floats
\b Preprocessor now warns when invalid floating point numbers are used in math operations
\b MakeNSISW now uses WinInet when checking for updates
\S2{} Translations

View file

@ -90,8 +90,10 @@ double LineParser::gettoken_float(int token, int *success/*=0*/) const
TCHAR *t=m_tokens[token];
if (_T('-') == *t || _T('+') == *t) ++t;
*success=*t?1:0;
unsigned int dotcount = 0;
while (*t)
{
if (_T('.') == *t && ++dotcount > 1) *success=0;
if ((*t < _T('0') || *t > _T('9'))&&*t != _T('.')) *success=0;
t++;
}
@ -116,9 +118,10 @@ int LineParser::gettoken_int(int token, int *success/*=0*/) const
++p, ++neg;
if (_T('0') == p[0])
{
// Special support for 0n and 0y MASM style and 0b Python style radix prefix:
// Special support for 0n, 0y and 0t MASM style and 0b and 0o Python style radix prefix:
if (_T('n') == (p[1]|32)) parse=&p[2], base=10;
if (_T('b') == (p[1]|32) || _T('y') == (p[1]|32)) parse=&p[2], base=2;
if (_T('o') == (p[1]|32) || _T('t') == (p[1]|32)) parse=&p[2], base=8;
}
if (neg)
{
@ -143,6 +146,7 @@ double LineParser::gettoken_number(int token, int *success/*=0*/) const
if (_T('x') == (str[1]|32)) ++forceint;
if (_T('n') == (str[1]|32)) ++forceint;
if (_T('b') == (str[1]|32) || _T('y') == (str[1]|32)) ++forceint;
if (_T('o') == (str[1]|32) || _T('t') == (str[1]|32)) ++forceint;
}
return forceint ? gettoken_int(token,success) : gettoken_float(token,success);
}

View file

@ -517,7 +517,7 @@ parse_again:
logicneg++, line.eattoken();
if (line.getnumtokens() == 2)
istrue = line.gettoken_int(1);
istrue = line.gettoken_number(1) || line.gettoken_int(1);
else if (line.getnumtokens() == 3) {
if (!_tcsicmp(line.gettoken_str(1),_T("/fileexists"))) {