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

Fix StringReplace looping forever when replacing character when replacing same character as match #736

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

ASpoonPlaysGames
Copy link
Contributor

closes #407

Find the next replacement starting from the end of the last one, instead of from the start of the string

@ASpoonPlaysGames ASpoonPlaysGames added needs testing Changes from the PR still need to be tested needs code review Changes from PR still need to be reviewed in code labels Oct 5, 2023
@GeckoEidechse GeckoEidechse changed the title fix StringReplace looping forever Fix StringReplace looping forever Oct 7, 2023
@GeckoEidechse
Copy link
Member

What would be a good way to test this?

@ASpoonPlaysGames
Copy link
Contributor Author

What would be a good way to test this?

Try and replicate the linked issue. easiest way is with a script_ui command in the main menu:

script_ui printt( StringReplace("lol", "o", "o", true, false) ) will hang the game before this PR, and will print "lol" after

Copy link

@Jan200101 Jan200101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the given snippet and it does prevent an infinite loop.

@GeckoEidechse GeckoEidechse changed the title Fix StringReplace looping forever Fix StringReplace looping forever when replacing character when replacing same character as match Oct 7, 2023
@ASpoonPlaysGames ASpoonPlaysGames removed the needs testing Changes from the PR still need to be tested label Oct 7, 2023
Copy link
Contributor

@uniboi uniboi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

@GeckoEidechse GeckoEidechse removed the needs code review Changes from PR still need to be reviewed in code label Oct 11, 2023
@GeckoEidechse
Copy link
Member

Merging based on reviews

@GeckoEidechse GeckoEidechse merged commit 3714f23 into R2Northstar:main Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

StringReplace never exits when the replacement contains same character as match
4 participants