From 78157ab3ffeca37023381a422fccda2d4a0c64af Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 14 Jun 2026 04:01:45 +0900 Subject: refactor(pcre): drop strict-groups Preg variants Rust's type system already distinguishes participating from non-participating capture groups via Option, so the *StrictGroups methods add no safety here. Remove them and switch callers to the plain variants. --- .../shirabe/src/repository/platform_repository.rs | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'crates/shirabe/src/repository/platform_repository.rs') diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index d9954af..39e29fb 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -369,7 +369,7 @@ impl PlatformRepository { // AMQP protocol version => 0-9-1 let mut protocol_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^AMQP protocol version => (?.+)$/im", &info, Some(&mut protocol_matches), @@ -434,7 +434,7 @@ impl PlatformRepository { // SSL Version => OpenSSL/1.0.1t let mut ssl_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^SSL Version => (?[^/]+)/(?.+)$}im", &info, Some(&mut ssl_matches), @@ -506,7 +506,7 @@ impl PlatformRepository { // libSSH Version => libssh2/1.4.3 let mut ssh_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^libSSH Version => (?[^/]+)/(?.+?)(?:/.*)?$}im", &info, Some(&mut ssh_matches), @@ -533,7 +533,7 @@ impl PlatformRepository { // ZLib Version => 1.2.8 let mut zlib_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^ZLib Version => (?.+)$}im", &info, Some(&mut zlib_matches), @@ -558,7 +558,7 @@ impl PlatformRepository { // timelib version => 2018.03 let mut timelib_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^timelib version => (?.+)$/im", &info, Some(&mut timelib_matches), @@ -579,7 +579,7 @@ impl PlatformRepository { // Timezone Database => internal let mut zoneinfo_source_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^Timezone Database => (?internal|external)$/im", &info, Some(&mut zoneinfo_source_matches), @@ -591,11 +591,9 @@ impl PlatformRepository { .map(|s| s == "external") .unwrap_or(false); let mut zoneinfo_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( - "/^\"Olson\" Timezone Database Version => (?.+?)(?:\\.system)?$/im", - &info, - Some(&mut zoneinfo_matches), - ) + if Preg::is_match3("/^\"Olson\" Timezone Database Version => (?.+?)(?:\\.system)?$/im", + &info, + Some(&mut zoneinfo_matches),) .unwrap_or(false) { let zoneinfo_version = zoneinfo_matches @@ -671,7 +669,7 @@ impl PlatformRepository { let info = self.runtime.get_extension_info(name)?; let mut libjpeg_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^libJPEG Version => (?.+?)(?: compatible)?$/im", &info, Some(&mut libjpeg_matches), @@ -694,7 +692,7 @@ impl PlatformRepository { } let mut libpng_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^libPNG Version => (?.+)$/im", &info, Some(&mut libpng_matches), @@ -714,7 +712,7 @@ impl PlatformRepository { } let mut freetype_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^FreeType Version => (?.+)$/im", &info, Some(&mut freetype_matches), @@ -734,7 +732,7 @@ impl PlatformRepository { } let mut libxpm_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^libXpm Version => (?\\d+)$/im", &info, Some(&mut libxpm_matches), @@ -832,7 +830,7 @@ impl PlatformRepository { // ICU TZData version => 2019c let mut zoneinfo_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^ICU TZData version => (?.*)$/im", &info, Some(&mut zoneinfo_matches), @@ -951,13 +949,13 @@ impl PlatformRepository { let mut matches: IndexMap = IndexMap::new(); let mut vendor_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^Vendor Version => (?\\d+)$/im", &info, Some(&mut matches), ) .unwrap_or(false) - && Preg::is_match_strict_groups3( + && Preg::is_match3( "/^Vendor Name => (?.+)$/im", &info, Some(&mut vendor_matches), @@ -1106,7 +1104,7 @@ impl PlatformRepository { }; // OpenSSL 1.1.1g 21 Apr 2020 let mut matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^(?:OpenSSL|LibreSSL)?\\s*(?\\S+)}i", &openssl_text_str, Some(&mut matches), @@ -1149,7 +1147,7 @@ impl PlatformRepository { // PCRE Unicode Version => 12.1.0 let mut pcre_unicode_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^PCRE Unicode Version => (?.+)$/im", &info, Some(&mut pcre_unicode_matches), @@ -1173,7 +1171,7 @@ impl PlatformRepository { let info = self.runtime.get_extension_info(name)?; let mut matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^(?:Client API version|Version) => mysqlnd (?.+?) /mi", &info, Some(&mut matches), @@ -1197,7 +1195,7 @@ impl PlatformRepository { let info = self.runtime.get_extension_info(name)?; let mut libmongoc_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^libmongoc bundled version => (?.+)$/im", &info, Some(&mut libmongoc_matches), @@ -1217,7 +1215,7 @@ impl PlatformRepository { } let mut libbson_matches: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "/^libbson bundled version => (?.+)$/im", &info, Some(&mut libbson_matches), @@ -1737,7 +1735,7 @@ impl PlatformRepository { Err(_) => { extra_description = Some(format!(" (actual version: {})", pretty_version)); let mut m: IndexMap = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^(\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)}", &pretty_version, Some(&mut m), -- cgit v1.3.1