Skip to content

Commit

Permalink
Updated regex to match ULL as well. reorganized test to make sure we …
Browse files Browse the repository at this point in the history
…test each variant
  • Loading branch information
bdbaddog committed Nov 5, 2024
1 parent a711d13 commit ce84dc6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 13 deletions.
1 change: 0 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
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.
Fixes Issue #4623

From Alex James:
- On Darwin, PermissionErrors are now handled while trying to access
Expand Down
2 changes: 0 additions & 2 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ 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.
Fixes Issue #4623

IMPROVEMENTS
------------
Expand Down
2 changes: 1 addition & 1 deletion SCons/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 79 additions & 9 deletions SCons/cppTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,60 @@
#include <file30-no>
#endif
#if 123456789UL || 0x13L
#include <file301-yes>
#if 123456789UL
#include <file301ul-yes>
#else
#include <file301-no>
#include <file301ul-no>
#endif
#if X1234UL || X1234L
#if 1234U
#include <file301u-yes>
#else
#include <file301u-no>
#endif
#if 1234L
#include <file301l-yes>
#else
#include <file301l-no>
#endif
#if 1234ULL
#include <file301ull-yes>
#else
#include <file301ull-no>
#endif
#define X1234UL 1
#if X1234UL
#include <file302-yes>
#else
#include <file302-no>
#endif
#define X1234U 1
#if X1234U
#include <file303-yes>
#else
#include <file303-no>
#endif
#define X1234L 1
#if X1234L
#include <file304-yes>
#else
#include <file304-no>
#endif
#define X1234ULL 1
#if X1234ULL
#include <file305-yes>
#else
#include <file305-no>
#endif
"""


Expand Down Expand Up @@ -486,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"""
Expand Down Expand Up @@ -594,8 +642,16 @@ class PreProcessorTestCase(cppAllTestCase):
('include', '<', 'file28-yes'),
('include', '"', 'file29-yes'),
('include', '<', 'file30-yes'),
('include', '<', 'file301-yes'),
('include', '<', 'file302-no'),

('include', '<', 'file301ul-yes'),
('include', '<', 'file301u-yes'),
('include', '<', 'file301l-yes'),
('include', '<', 'file301ull-yes'),

('include', '<', 'file302-yes'),
('include', '<', 'file303-yes'),
('include', '<', 'file304-yes'),
('include', '<', 'file305-yes'),

]

Expand Down Expand Up @@ -725,10 +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 = [
Expand Down

0 comments on commit ce84dc6

Please sign in to comment.