Whole file
terryyin/lizard
The author described this change as “fix(clike): stop C++ raw string literals from swallowing following code”. It counts as a record because the checks below fail on the code as it stood at 82c8e7a1f and pass on bfaa1b122, with nothing else changed between the two runs.
Projectterryyin/lizard
Fix saved2026-06-01
Sharing licenceMIT · LICENSE.txt
Change size+9 −4
What the code was meant to do, written into the code itself as a save note
fix(clike): stop C++ raw string literals from swallowing following code
The change
| 32 | 32 | ||
| 33 | 33 | @staticmethod | |
| 34 | 34 | def generate_tokens(source_code, addition='', token_class=None): | |
| 35 | - | # Add pattern for C++ raw string literals R"delimiter(content)delimiter" | |
| 36 | - | # The delimiter can be empty or up to 16 chars (excluding parentheses, backslash, whitespace) | |
| 37 | - | # Using a simplified pattern that handles most cases | |
| 38 | - | addition = r"|R\"[^(\\]*\((?:[^)]|\)[^\"])*\)[^(\\]*\"" + \ | |
| 35 | + | # C++ raw string literals: R"(...)" with an optional encoding prefix | |
| 36 | + | # (u8/u/U/L). Match the empty-delimiter form and stop at the first ')"' | |
| 37 | + | # terminator: a ')' only continues the body when it is not followed by a | |
| 38 | + | # double quote. The pattern added for #451 used a closing class of | |
| 39 | + | # [^(\\]* which also matched '"', so it ran past the terminator and | |
| 40 | + | # swallowed the following code (issue #478). Custom delimiters such as | |
| 41 | + | # R"tag(...)tag" without an embedded '"' are handled by the normal | |
| 42 | + | # string-literal rule that follows in the token pattern. | |
| 43 | + | addition = r"|(?:u8|u|U|L)?R\"\((?:[^)]|\)(?!\"))*\)\"" + \ | |
| 39 | 44 | r"|(?:\d*\.\d+(?:[eE][-+]?\d+)?)" + \ | |
| 40 | 45 | r"|(?:\d+\.(?:\d+)?(?:[eE][-+]?\d+)?)" + \ | |
| 41 | 46 | addition |
The check that tells the two apart
fail→pass·test/test_languages/testCAndCPP.py::Test_cpp_raw_string_literals::test_raw_string_brace_init_keeps_following_function
fail→pass·test/test_languages/testCAndCPP.py::Test_cpp_raw_string_literals::test_raw_string_eq_init_keeps_function_bounds
Check file test/test_languages/testCAndCPP.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it82c8e7a1f170b07b8e30774883d75338f4b23408
Broken version dated2026-05-26
Modulelizard_languages.clike
Units changedCLikeReader
Fingerprintcdb7a7b44910eb6c
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in terryyin/lizard
- 2026-08-08fix(java): do not report control structures as methods
- 2026-07-02HalsteadClassifier
- 2026-07-02fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields
- 2026-06-15fix(golike): register generic functions with [...] type params
- 2026-06-15fix(java): enhance parsing of generic and qualified type names in anonymous classes
- 2026-06-11fix(script): stop a '#' comment continuing past a trailing backslash (#317)