Skip to content

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 [email protected]:

#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