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

Fixed bug with read-until. #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixed bug with read-until. #107

wants to merge 2 commits into from

Conversation

malisper
Copy link

@hanshuebner
Copy link
Member

Please add a comment that describes the problem that your change fixes.
Thank you!

2015-07-24 16:36 GMT+02:00 Michael Malis notifications@github.com:

#106 #106

You can view, comment on, or merge this pull request online at:

#107
Commit Summary

  • Fixed bug with read-until.

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#107.

The KMP algorithm works by building a table which keeps track of which
characters in the search string can be skipped when a mismatch
occurs. This information is supposed to be maintained in the index of
the mismatch. Read-until had previously built the table incorrectly
and placed that information in the wrong place.
@malisper
Copy link
Author

I added that information to the commit.

@stassats
Copy link
Member

That causes a problem with

(with-input-from-string (*standard-input* "ababad123") 
   (url-rewrite::read-until "aba" :skip nil))

Index 3 out of bounds for (SIMPLE-VECTOR 3), should be nonnegative and <3.

When one of the strings passed to mismatch is a proper prefix of the
other, mismatch will return the last index tested in the first string
plus one. This means that when the first string is a proper prefix of
the second string mismatch will return the length of the first
string. To avoid this case, just test that the index of the mismatch
is less than the length of the string.
@malisper
Copy link
Author

Thanks @stassats. The source of that problem is a weird edge case with mismatch. I have added another commit that fixes that problem.

@gefjon
Copy link
Contributor

gefjon commented Jan 10, 2022

@malisper are you still interested in this PR?

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.

4 participants