mirror of
https://gitee.com/openharmony/third_party_rust_regex
synced 2025-04-12 15:43:16 +00:00

This fixes a bug in the parser where a regex like `(?x)[ / - ]` would fail to parse. In particular, since whitespace insensitive mode is enabled, this regex should be equivalent to `[/-]`, where the `-` is treated as a literal `-` instead of a range since it is the last character in the class. However, the parser did not account for whitespace insensitive mode, so it didn't see the `-` in `(?x)[ / - ]` as trailing, and therefore reported an unclosed character class (since the `]` was treated as part of the range). We fix that in this commit by accounting for whitespace insensitive mode, which we do by adding a `peek` method that skips over whitespace. Fixes #455