diff --git a/Docs/src/compiler.but b/Docs/src/compiler.but index dd69d215..8903efab 100644 --- a/Docs/src/compiler.but +++ b/Docs/src/compiler.but @@ -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 diff --git a/Docs/src/history.but b/Docs/src/history.but index 2f996a29..9745fc8e 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -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 diff --git a/Source/lineparse.cpp b/Source/lineparse.cpp index 3bda35cf..e9527dbf 100644 --- a/Source/lineparse.cpp +++ b/Source/lineparse.cpp @@ -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); } diff --git a/Source/script.cpp b/Source/script.cpp index 3a32eaec..0e311696 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -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"))) {