diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
| commit | e093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch) | |
| tree | 0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/platform/version.rs | |
| parent | 050c56ef263d90d862ef565bc1762909110e02eb (diff) | |
| download | php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/platform/version.rs')
| -rw-r--r-- | crates/shirabe/src/platform/version.rs | 11 |
1 files changed, 4 insertions, 7 deletions
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<String> { *is_fips = false; - let matches = preg_match2( + let matches = preg_match( php_regex!( r"/^(?P<version>[0-9.]+)(?P<patch>[a-z]{0,2})(?P<suffix>(?:-?(?: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<String> { - let matches = preg_match2( + let matches = preg_match( php_regex!(r"/^(?P<major>\d+)(?P<minor>[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<String> { - let matches = preg_match2( + let matches = preg_match( php_regex!(r"/^(?P<year>\d{4})(?P<revision>[a-z]*)$/"), zoneinfo_version, - 0, )?; let year = matches.name("year").unwrap_or_default().to_string(); |
