diff options
| -rw-r--r-- | crates/shirabe-pcre/src/preg.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe-php-shim/src/preg.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/tests/command/show_command_test.rs | 1 |
3 files changed, 7 insertions, 20 deletions
diff --git a/crates/shirabe-pcre/src/preg.rs b/crates/shirabe-pcre/src/preg.rs index 95697e83..a761608e 100644 --- a/crates/shirabe-pcre/src/preg.rs +++ b/crates/shirabe-pcre/src/preg.rs @@ -83,23 +83,13 @@ impl Preg { result } - pub fn match_all_with_offsets5( + fn match_all_with_offsets5( pattern: impl PregPattern, subject: &str, matches: Option<&mut IndexMap<CaptureKey, Vec<(String, usize)>>>, - flags: i64, - offset: usize, ) -> usize { - Self::check_set_order(flags); - let mut internal: IndexMap<CaptureKey, Vec<(Option<String>, i64)>> = IndexMap::new(); - let result = preg_match_all_offset_capture2( - pattern, - subject, - &mut internal, - flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, - offset, - ); + let result = preg_match_all_offset_capture2(pattern, subject, &mut internal); if let Some(out) = matches { *out = null_to_empty_offset_match_all(internal); @@ -263,7 +253,7 @@ impl Preg { subject: &str, matches: Option<&mut IndexMap<CaptureKey, Vec<(String, usize)>>>, ) -> bool { - Self::match_all_with_offsets5(pattern, subject, matches, 0, 0) > 0 + Self::match_all_with_offsets5(pattern, subject, matches) > 0 } fn check_offset_capture(flags: i64, use_function_name: &str) { diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs index 42a3ecec..40eb25fb 100644 --- a/crates/shirabe-php-shim/src/preg.rs +++ b/crates/shirabe-php-shim/src/preg.rs @@ -200,24 +200,20 @@ pub fn preg_match_all_offset_capture2( pattern: impl PregPattern, subject: &str, matches: &mut indexmap::IndexMap<CaptureKey, Vec<(Option<String>, i64)>>, - flags: i64, - offset: usize, ) -> usize { let __resolved = pattern.resolve(); let (re, _anchored) = __resolved.parts(); - let unmatched_as_null = flags & PREG_UNMATCHED_AS_NULL != 0; let group_count = re.captures_len(); let names: Vec<Option<&str>> = re.capture_names().collect(); let mut groups: Vec<Vec<(Option<String>, i64)>> = vec![Vec::new(); group_count]; let mut count = 0; - for caps in re.captures_iter(&subject[offset..]) { + for caps in re.captures_iter(subject) { count += 1; for (g, column) in groups.iter_mut().enumerate() { let entry = match caps.get(g) { - Some(m) => (Some(m.as_str().to_string()), (m.start() + offset) as i64), - None if unmatched_as_null => (None, -1), - None => (Some(String::new()), -1), + Some(m) => (Some(m.as_str().to_string()), m.start() as i64), + None => (None, -1), }; column.push(entry); } diff --git a/crates/shirabe/tests/command/show_command_test.rs b/crates/shirabe/tests/command/show_command_test.rs index 20dbf848..eb8176e9 100644 --- a/crates/shirabe/tests/command/show_command_test.rs +++ b/crates/shirabe/tests/command/show_command_test.rs @@ -187,6 +187,7 @@ outdated/patch 1.0.0 <highlight>! 1.0.1</highlight>", #[test] #[serial] +#[ignore = "see test_self()"] fn test_show_outdated_deps_sorting_by_age() { run_show_case( input(vec