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/platform/version.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crates/shirabe/src/platform/version.rs') diff --git a/crates/shirabe/src/platform/version.rs b/crates/shirabe/src/platform/version.rs index baa029ef..b9573366 100644 --- a/crates/shirabe/src/platform/version.rs +++ b/crates/shirabe/src/platform/version.rs @@ -1,6 +1,6 @@ //! ref: composer/src/Composer/Platform/Version.php -use shirabe_php_shim::{CmpOp, php_regex, preg_match2, version_compare}; +use shirabe_php_shim::{CmpOp, php_regex, preg_match, version_compare}; pub struct Version; @@ -8,12 +8,11 @@ impl Version { pub fn parse_openssl(openssl_version: &str, is_fips: &mut bool) -> Option { *is_fips = false; - let matches = preg_match2( + let matches = preg_match( php_regex!( r"/^(?P[0-9.]+)(?P[a-z]{0,2})(?P(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)(?:-\w+)?(?: \(.+?\))?$/" ), openssl_version, - 0, )?; let version = matches.name("version").unwrap_or_default().to_string(); @@ -42,10 +41,9 @@ impl Version { } pub fn parse_libjpeg(libjpeg_version: &str) -> Option { - let matches = preg_match2( + let matches = preg_match( php_regex!(r"/^(?P\d+)(?P[a-z]*)$/"), libjpeg_version, - 0, )?; let major = matches.name("major").unwrap_or_default().to_string(); @@ -58,10 +56,9 @@ impl Version { } pub fn parse_zoneinfo_version(zoneinfo_version: &str) -> Option { - let matches = preg_match2( + let matches = preg_match( php_regex!(r"/^(?P\d{4})(?P[a-z]*)$/"), zoneinfo_version, - 0, )?; let year = matches.name("year").unwrap_or_default().to_string(); -- cgit v1.3.1-4-g156e