Skip to content

Commit

Permalink
Fix broken objecting # matching because of a regression in regex matc…
Browse files Browse the repository at this point in the history
…hing on [...]+ type patterns.
  • Loading branch information
rdaum committed Nov 5, 2023
1 parent be0c339 commit ea3d330
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/kernel/src/builtins/bf_list_sets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ fn perform_regex_match(
syntax.set_operators(
syntax
.operators()
.bitor(SyntaxOperator::SYNTAX_OPERATOR_QMARK_ZERO_ONE),
.bitor(SyntaxOperator::SYNTAX_OPERATOR_QMARK_ZERO_ONE)
.bitor(SyntaxOperator::SYNTAX_OPERATOR_PLUS_ONE_INF),
);
let regex = onig::Regex::with_options(translated_pattern.as_str(), options, &syntax)
.map_err(|_| E_INVARG)?;
Expand Down Expand Up @@ -504,6 +505,17 @@ mod tests {
assert_eq!(result, "edit");
}

#[test]
fn test_match_regression() {
let source = "2";
// In MOO this should yield (1,1). In Python re it's (0,1).
// 'twas returning None because + support got broken.
let (overall, _) = perform_regex_match("[0-9]+ *", source, false, false)
.unwrap()
.unwrap();
assert_eq!(overall, (1, 1));
}

#[test]
fn test_rmatch() {
let m = perform_regex_match("o*b", "foobar", false, true)
Expand Down

0 comments on commit ea3d330

Please sign in to comment.