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/event_dispatcher/event_dispatcher.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/event_dispatcher') diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 06ce21cc..9cb38599 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -29,7 +29,7 @@ use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_pop, array_push, array_search_in_vec, array_splice, file_exists, get_class, hash, implode, ini_get, is_array, - is_callable, is_object, is_string, krsort, php_regex, preg_match2, preg_quote, preg_replace, + is_callable, is_object, is_string, krsort, php_regex, preg_match, preg_quote, preg_replace, preg_replace_callback, realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, spl_object_hash, str_replace, strlen, strpos, strtoupper, substr, trim, @@ -922,10 +922,9 @@ try {{ .get_binaries(); if !possible_local_binaries.is_empty() { for local_exec in &possible_local_binaries { - if preg_match2( + if preg_match( format!("{{\\b{}$}}", preg_quote(&callable_str, None)), local_exec, - 0, ) .is_some() { @@ -967,7 +966,7 @@ try {{ // match somename (not in quote, and not a qualified path) and if it is not a valid path from CWD then try to find it // in $PATH. This allows support for `@php foo` where foo is a binary name found in PATH but not an actual relative path if let Some(m) = - preg_match2(php_regex!("{^[^\\'\"\\s/\\\\]+}"), &path_and_args, 0) + preg_match(php_regex!("{^[^\\'\"\\s/\\\\]+}"), &path_and_args) { let m0 = m.get(0).unwrap_or_default().to_string(); if !file_exists(&m0) { -- cgit v1.3.1-4-g156e