aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe-pcre/src/preg.rs21
-rw-r--r--crates/shirabe-php-shim/src/preg.rs11
2 files changed, 7 insertions, 25 deletions
diff --git a/crates/shirabe-pcre/src/preg.rs b/crates/shirabe-pcre/src/preg.rs
index e197c874..95697e83 100644
--- a/crates/shirabe-pcre/src/preg.rs
+++ b/crates/shirabe-pcre/src/preg.rs
@@ -57,7 +57,7 @@ impl Preg {
}
pub fn match_all(pattern: impl PregPattern, subject: &str) -> usize {
- Self::match_all5(pattern, subject, None, 0, 0)
+ Self::match_all5(pattern, subject, None)
}
pub fn match_all3(
@@ -65,27 +65,16 @@ impl Preg {
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
) -> usize {
- Self::match_all5(pattern, subject, matches, 0, 0)
+ Self::match_all5(pattern, subject, matches)
}
- pub fn match_all5(
+ fn match_all5(
pattern: impl PregPattern,
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
- flags: i64,
- offset: usize,
) -> usize {
- Self::check_offset_capture(flags, "matchAllWithOffsets");
- Self::check_set_order(flags);
-
let mut internal: IndexMap<CaptureKey, Vec<Option<String>>> = IndexMap::new();
- let result = preg_match_all2(
- pattern,
- subject,
- &mut internal,
- flags | PREG_UNMATCHED_AS_NULL,
- offset,
- );
+ let result = preg_match_all2(pattern, subject, &mut internal);
if let Some(out) = matches {
*out = null_to_empty_match_all(internal);
@@ -266,7 +255,7 @@ impl Preg {
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
) -> bool {
- Self::match_all5(pattern, subject, matches, 0, 0) > 0
+ Self::match_all5(pattern, subject, matches) > 0
}
pub fn is_match_all_with_offsets3(
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs
index 727fc149..42a3ecec 100644
--- a/crates/shirabe-php-shim/src/preg.rs
+++ b/crates/shirabe-php-shim/src/preg.rs
@@ -122,27 +122,20 @@ pub fn preg_match_all2(
pattern: impl PregPattern,
subject: &str,
matches: &mut indexmap::IndexMap<CaptureKey, Vec<Option<String>>>,
- 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();
// PREG_PATTERN_ORDER: one column per group, one row per match occurrence.
let mut groups: Vec<Vec<Option<String>>> = 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 value = caps.get(g).map(|m| m.as_str().to_string());
- column.push(if unmatched_as_null {
- value
- } else {
- Some(value.unwrap_or_default())
- });
+ column.push(value);
}
}