From c7aa10384a2548167466b4c61f9eff29ed8611f6 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 17 Aug 2026 07:13:02 +0900 Subject: refactor(preg): report unmatched groups as null throughout The shim carried two reporting modes for the preg_* $matches maps: PHP's default (trailing unmatched groups dropped, interior ones ""), and the PREG_UNMATCHED_AS_NULL form, picked by calling a *_unmatched_as_null() variant. The regex crate hands out Option, which maps onto the null form directly, and no caller distinguished a dropped group from a null one -- preg_match() and preg_match_all2() already reported nulls unconditionally. Keep only the null form; the shim API no longer mirrors PHP's flag set, which is intended. Preg::is_match_with_indexed_captures() modelled PHP's "unset" as a truncated Vec, and now returns Vec>. That is what Composer actually does: Preg::isMatch() always sets PREG_UNMATCHED_AS_NULL, and its callers test groups with `!== null`. preg_match_all(), preg_match_all_set_order() and preg_split_delim_capture() still hand back Vec and keep the "" form. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/repository/vcs/svn_driver.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/repository') diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 297e8f33..db8c43f0 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -260,10 +260,10 @@ impl SvnDriver { let (path, rev) = if let Some(m) = Preg::is_match_with_indexed_captures(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier) { - if m.get(2).is_some() { + if m[2].is_some() { ( - m.get(1).cloned().unwrap_or_default(), - m.get(2).cloned().unwrap_or_default(), + m[1].clone().unwrap_or_default(), + m[2].clone().unwrap_or_default(), ) } else { (identifier.clone(), String::new()) @@ -300,10 +300,10 @@ impl SvnDriver { let (path, rev) = if let Some(m) = Preg::is_match_with_indexed_captures(php_regex!(r"{^(.+?)(@\d+)?/$}"), &identifier) { - if m.get(2).is_some() { + if m[2].is_some() { ( - m.get(1).cloned().unwrap_or_default(), - m.get(2).cloned().unwrap_or_default(), + m[1].clone().unwrap_or_default(), + m[2].clone().unwrap_or_default(), ) } else { (identifier.clone(), String::new()) -- cgit v1.3.1-4-g156e