diff --git a/CHANGES.txt b/CHANGES.txt index c53fce328..819a1554d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Added error handling when creating MS VC detection debug log file specified by SCONS_MSCOMMON_DEBUG + From William Deegan: + - Fix SConsCPPConditionalScanner to properly handle #ifdefs with non number prefixing numbers followed by UL or L. + Previously it was removing the L or UL when that should only have been done when a only numbers preceded them. + From Alex James: - On Darwin, PermissionErrors are now handled while trying to access /etc/paths.d. This may occur if SCons is invoked in a sandboxed diff --git a/RELEASE.txt b/RELEASE.txt index baa9d1dbf..a200fb44f 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -69,6 +69,9 @@ FIXES - Skip running a few validation tests if the user is root and the test is not designed to work for the root user. +- Fix SConsCPPConditionalScanner to properly handle ifdefs with non number prefixing numbers followed by UL or L. + Previously it was removing the L or UL when that should only have been done when a only numbers preceded them. + IMPROVEMENTS ------------ diff --git a/SCons/cpp.py b/SCons/cpp.py index 1093ae2ac..bde60bd01 100644 --- a/SCons/cpp.py +++ b/SCons/cpp.py @@ -152,7 +152,7 @@ def Cleanup_CPP_Expressions(ts): [r'defined\s+(\w+)', '"\\1" in __dict__'], [r'defined\s*\((\w+)\)', '"\\1" in __dict__'], [r'(0x[0-9A-Fa-f]+)(?:L|UL)?', '\\1'], - [r'(\d+)(?:L|UL)?', '\\1'], + [r'^(\d+)(?:L|ULL|UL|U)?', '\\1'], ] # Replace the string representations of the regular expressions in the diff --git a/SCons/cppTests.py b/SCons/cppTests.py index 85f01b781..e3b1723be 100644 --- a/SCons/cppTests.py +++ b/SCons/cppTests.py @@ -236,11 +236,60 @@ #include #endif -#if 123456789UL || 0x13L -#include +#if 123456789UL +#include #else -#include +#include #endif + +#if 1234U +#include +#else +#include +#endif + +#if 1234L +#include +#else +#include +#endif + +#if 1234ULL +#include +#else +#include +#endif + +#define X1234UL 1 +#if X1234UL +#include +#else +#include +#endif + +#define X1234U 1 +#if X1234U +#include +#else +#include +#endif + +#define X1234L 1 +#if X1234L +#include +#else +#include +#endif + +#define X1234ULL 1 +#if X1234ULL +#include +#else +#include +#endif + + + """ @@ -480,7 +529,12 @@ def test_expression(self) -> None: """Test #if with arithmetic expressions""" expect = self.expression_expect result = self.cpp.process_contents(expression_input) - assert expect == result, (expect, result) + if expect != result: + for e,r in zip(expect, result): + if e != r: + print("XXXX->",end="") + print(f"{e}: {r}") + assert expect == result, f"\nexpect:{expect}\nresult:{result}" def test_undef(self) -> None: """Test #undef handling""" @@ -588,7 +642,17 @@ class PreProcessorTestCase(cppAllTestCase): ('include', '<', 'file28-yes'), ('include', '"', 'file29-yes'), ('include', '<', 'file30-yes'), - ('include', '<', 'file301-yes'), + + ('include', '<', 'file301ul-yes'), + ('include', '<', 'file301u-yes'), + ('include', '<', 'file301l-yes'), + ('include', '<', 'file301ull-yes'), + + ('include', '<', 'file302-yes'), + ('include', '<', 'file303-yes'), + ('include', '<', 'file304-yes'), + ('include', '<', 'file305-yes'), + ] undef_expect = [ @@ -717,8 +781,24 @@ class DumbPreProcessorTestCase(cppAllTestCase): ('include', '"', 'file29-yes'), ('include', '<', 'file30-yes'), ('include', '<', 'file30-no'), - ('include', '<', 'file301-yes'), - ('include', '<', 'file301-no'), + + ('include', '<', 'file301ul-yes'), + ('include', '<', 'file301ul-no'), + ('include', '<', 'file301u-yes'), + ('include', '<', 'file301u-no'), + ('include', '<', 'file301l-yes'), + ('include', '<', 'file301l-no'), + ('include', '<', 'file301ull-yes'), + ('include', '<', 'file301ull-no'), + + ('include', '<', 'file302-yes'), + ('include', '<', 'file302-no'), + ('include', '<', 'file303-yes'), + ('include', '<', 'file303-no'), + ('include', '<', 'file304-yes'), + ('include', '<', 'file304-no'), + ('include', '<', 'file305-yes'), + ('include', '<', 'file305-no'), ] undef_expect = [