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

Line breaker: Fix variable assignation with cast #66

Merged
merged 3 commits into from
Sep 3, 2023
Merged

Line breaker: Fix variable assignation with cast #66

merged 3 commits into from
Sep 3, 2023

Conversation

younesaassila
Copy link
Contributor

The current regex doesn't take into account variable assignments with casting (e.g. (type)var = value;)

Implementing a regex to match all cases (e.g. (type)var, (type) var, (type)(var), (type)(var->value)->value) would probably result in an illegible regex.

I've modified the code to match any line like txt = txt. It checks that the equal sign is not within parens (like for while (var = value)) and that it isn't in a string.

I've added test cases and used it to format all files in my minishell project with great success.

Let me know if the code needs anything changed.

@cacharle cacharle merged commit 87676af into dawnbeen:master Sep 3, 2023
10 checks passed
@younesaassila younesaassila deleted the fix/line-breaker-variable-assignment branch September 3, 2023 10:10
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