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 find routines' api to default to last=-1 #19761

Merged
merged 2 commits into from
Jun 7, 2022
Merged

Conversation

ZoomRmc
Copy link
Contributor

@ZoomRmc ZoomRmc commented May 4, 2022

This PR changes the default for the last parameter of various find routines from 0 to -1. Previous default prevents limiting the search to the first character. This is a logic error introduced in #5196, as full text search was performed for 2 valid values of last: 0 and last.high(). This fix also makes the api consistent with rfind.

Adds an overload for initSkipTable which returns a newly initialized table. This encapsulates every single usage of a var-acting original func in this module.

@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented May 4, 2022

Ok, so this is a pale shadow of #18173. However, this PR is not an attempt of a complete overhaul of strutils API and focuses on immediate fix of a logical error and shouldn't break any reasonable code (besides likes of nimpylib).

If the fixing of last default is unacceptable, I can remove all the changes except the docstring fixes and rename the PR.

@ringabout
Copy link
Member

ringabout commented May 4, 2022

You can split it in two PRs with one focusing on fixing the doc.

One PR brings one change.

@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented May 5, 2022

You can split it in two PRs with one focusing on fixing the doc.

One PR brings one change.

I could, but it would be a bit easier to know beforehand which one will be declined ;)

@ghost
Copy link

ghost commented May 5, 2022

Ok, so this is a pale shadow of #18173. However, this PR is not an attempt of a complete overhaul of strutils API and focuses on immediate fix of a logical error and shouldn't break any reasonable code (besides likes of nimpylib).

If the fixing of last default is unacceptable, I can remove all the changes except the docstring fixes and rename the PR.

sorry for nimpylib, will fix it for this PR today

@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented May 5, 2022

You can split it in two PRs with one focusing on fixing the doc.

One PR brings one change.

Done. Doc fixes separated to #19765

This changes the default for the `last` parameter of various `find`
routines from `0` to `-1`. Previous default prevents limiting the search
to the first character. This is a logic error, as full text search was
performed for 2 *valid* values of `last`: `0` and `last.high()`.

Adds an overload for `initSkipTable` which returns a newly initialized
table. This encapsulates every single usage of a `var`-acting original
func in this module.
@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented May 8, 2022

Rebased on devel tip and squashed.

@ZoomRmc ZoomRmc marked this pull request as ready for review May 8, 2022 15:14
@ghost
Copy link

ghost commented May 9, 2022

FAIL: [26/39] polypbren c is unrelated, pylib test now passes fine.

@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented Jun 6, 2022

ping @Araq any reason this can't be merged?

@Araq Araq merged commit b024a45 into nim-lang:devel Jun 7, 2022
@ZoomRmc
Copy link
Contributor Author

ZoomRmc commented Jun 7, 2022

Thanks for the merge!

@ringabout
Copy link
Member

A changelog entry will be appreciated.

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.

3 participants