You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Binary search is used with incorrectly-sorted array #75
The “dynamic” matching of CharClassuses a binary search within char 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.
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 '_'..'_'.
The comparison function has a FIXME to move the case mapping outside of it and have the Vec 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.
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!)
Activity
BurntSushi commentedon Apr 19, 2015
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!)
SimonSapin commentedon Apr 19, 2015
I have a fix, but I’m also tracking down another bug. Let we write up an issue.
Fix rust-lang#75: map char ranges for case-insensitivity at parse time.
SimonSapin commentedon Apr 19, 2015
#75 is that issue. #78 has fixes for both and #55.
BurntSushi commentedon Apr 19, 2015
Awesome! I'm currently out, but I'll review as soon as I get home and get this merged. Thank you!