From e093b2be1c333e67c96aebb0a5291bea9ae3d6db Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 01:57:02 +0900 Subject: refactor(preg): drop the offset argument from preg_match Every call site but one passed offset 0. The remaining one, the UTF-8 chunking loop in Application, slices the subject instead: its pattern has no anchor or lookaround, so matching a suffix is equivalent to starting the search at that offset. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/show_command.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/command/show_command.rs') diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index e8072ca8..acb4f5c8 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -39,7 +39,7 @@ use indexmap::IndexMap; use shirabe_php_shim::{ CmpOp, DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, array_search, date_format_to_strftime, date_local, extension_loaded, impl_php_class, - in_array_loose, in_array_strict, php_regex, preg_match2, preg_quote, preg_replace, realpath, + in_array_loose, in_array_strict, php_regex, preg_match, preg_quote, preg_replace, realpath, strtolower, version_compare, }; use shirabe_semver::Semver; @@ -1373,10 +1373,9 @@ impl ShowCommand { if target_version.is_none() { if major_only - && let Some(groups) = preg_match2( + && let Some(groups) = preg_match( php_regex!(r"{^(?P(?:0\.)+)?(?P\d+)\.}"), &package.get_version(), - 0, ) { let zero_major = groups.name("zero_major").unwrap_or_default().to_string(); @@ -2342,7 +2341,7 @@ impl Command for ShowCommand { } let matches_filter = match &package_filter_regex { None => true, - Some(r) => preg_match2(r, &p.get_name(), 0).is_some(), + Some(r) => preg_match(r, &p.get_name()).is_some(), }; if matches_filter { let matches_list = match &package_list_filter { @@ -2421,7 +2420,7 @@ impl Command for ShowCommand { if show_latest && *show_version { for package_or_name in type_packages.values() { if let PackageOrName::Pkg(package) = package_or_name - && preg_match2(&ignored_packages_regex, &package.get_pretty_name(), 0) + && preg_match(&ignored_packages_regex, &package.get_pretty_name()) .is_none() { let latest = self.find_latest_package( @@ -2493,7 +2492,7 @@ impl Command for ShowCommand { package_is_up_to_date = package_is_up_to_date || (latest_package.is_none() && show_major_only); let package_is_ignored = - preg_match2(&ignored_packages_regex, &package.get_pretty_name(), 0) + preg_match(&ignored_packages_regex, &package.get_pretty_name()) .is_some(); if input.borrow().get_option("outdated")?.as_bool() == Some(true) && (package_is_up_to_date || package_is_ignored) -- cgit v1.3.1-4-g156e