Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toke.c: minor adjustment of #ifdef to stop confusing code editors #22774

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Nov 23, 2024

Quite possibly the stupidest PR I've ever had to raise. It makes no change to the compiled output behaviour. It isn't even a change for the benefit of human readers. This change is here purely to stop confusing static analysis and code editing tools.

Before this change, the two separate while statements would upset the code folding as parsed by tree-sitter-c (and likely many others, I haven't tested), into thinking this was two nested loops. Having failed to find the end of both of them before the end of the function, various confusions result, usually ending up in the entire rest of the file (and it's a long file) getting folded into one giant region. This likely causes various static analysis tools similarly to not see any of the subsequent functions in the file.

By adjusting the code so that just the condition part is inside the #ifdef, it means that code parsing tools have a much easier time working out the high-level structure of this file.

  • This set of changes does not require a perldelta entry.

Before this change, the two separate `while` statements would upset the
code folding as parsed by tree-sitter-c (and likely many others, I
haven't tested), into thinking this was two nested loops. Having failed
to find the end of both of them before the end of the function, various
confusions result, usually ending up in the entire rest of the file (and
it's a long file) getting folded into one giant region. This likely
causes various static analysis tools similarly to not see any of the
subsequent functions in the file.

By adjusting the code so that just the condition part is conditional on
the `#ifdef`, it means that code parsing tools have a much easier time
working out the high-level structure of this file.
@leonerd leonerd merged commit 63feb21 into Perl:blead Nov 23, 2024
34 checks passed
@leonerd leonerd deleted the fix-code-folding-in-toke.c branch November 23, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants