-
Notifications
You must be signed in to change notification settings - Fork 422
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
Binary search is used with incorrectly-sorted array #75
Comments
Nice find! If you find an easy fix, that would be awesome. Otherwise, I am in the process of rewriting the parser with the intention of fixing a bunch of little bugaboos like this. (Although I didn't realize this caused buggy behavior!) |
I have a fix, but I’m also tracking down another bug. Let we write up an issue. |
Awesome! I'm currently out, but I'll review as soon as I get home and get this merged. Thank you! |
The “dynamic” matching of
CharClass
uses a binary search withinchar
ranges, which relies on the input being sorted. The input is indeed sorted in its “natural” order, but the comparison function in case-insensitive mode uses a different order.This leads to incorrect results:
The above fails, because
_
in ASCII is between upper-case and lower-case letters. The comparison function maps the'a'..'a'
range to its upper case'A'..'A'
, which has a different order relative to'_'..'_'
.Compare with e.g. the code below, which succeeds.
The comparison function has a
FIXME
to move the case mapping outside of it and have theVec
of ranges be already mapped. I assume this was intended for performance, but I think it’ll also fix this issue. I’ll try it.The text was updated successfully, but these errors were encountered: