aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-14 04:01:45 +0900
committernsfisis <nsfisis@gmail.com>2026-06-14 04:02:58 +0900
commit78157ab3ffeca37023381a422fccda2d4a0c64af (patch)
tree11664aae5e585742647d4c0374495acd77b1aedb /crates
parent7f00f9e7f9be826863716a5a52c141eb913d03bb (diff)
downloadphp-shirabe-78157ab3ffeca37023381a422fccda2d4a0c64af.tar.gz
php-shirabe-78157ab3ffeca37023381a422fccda2d4a0c64af.tar.zst
php-shirabe-78157ab3ffeca37023381a422fccda2d4a0c64af.zip
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.
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs2
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_cleaner.rs3
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_parser.rs2
-rw-r--r--crates/shirabe-external-packages/src/composer/pcre/mod.rs1
-rw-r--r--crates/shirabe-external-packages/src/composer/pcre/preg.rs153
-rw-r--r--crates/shirabe-external-packages/src/composer/pcre/unexpected_null_match_exception.rs29
-rw-r--r--crates/shirabe/src/command/archive_command.rs2
-rw-r--r--crates/shirabe/src/command/config_command.rs2
-rw-r--r--crates/shirabe/src/command/create_project_command.rs2
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs2
-rw-r--r--crates/shirabe/src/command/init_command.rs6
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs2
-rw-r--r--crates/shirabe/src/dependency_resolver/problem.rs2
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs6
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs27
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs8
-rw-r--r--crates/shirabe/src/event_dispatcher/event_dispatcher.rs8
-rw-r--r--crates/shirabe/src/installer/binary_installer.rs2
-rw-r--r--crates/shirabe/src/json/json_file.rs3
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs4
-rw-r--r--crates/shirabe/src/package/loader/root_package_loader.rs8
-rw-r--r--crates/shirabe/src/package/locker.rs2
-rw-r--r--crates/shirabe/src/package/version/version_guesser.rs17
-rw-r--r--crates/shirabe/src/platform/version.rs12
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs2
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs46
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs2
-rw-r--r--crates/shirabe/src/repository/vcs/git_driver.rs8
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs31
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs9
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs20
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs32
-rw-r--r--crates/shirabe/src/util/filesystem.rs2
-rw-r--r--crates/shirabe/src/util/git.rs30
-rw-r--r--crates/shirabe/src/util/github.rs4
-rw-r--r--crates/shirabe/src/util/http_downloader.rs2
-rw-r--r--crates/shirabe/src/util/process_executor.rs3
-rw-r--r--crates/shirabe/src/util/remote_filesystem.rs4
39 files changed, 123 insertions, 381 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs
index 391bee9..ba59b33 100644
--- a/crates/shirabe-class-map-generator/src/class_map_generator.rs
+++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs
@@ -381,7 +381,7 @@ impl ClassMapGenerator {
// extract a prefix being a protocol://, protocol:, protocol://drive: or simply drive:
let mut r#match: indexmap::IndexMap<_, _> = indexmap![];
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix",
&path,
Some(&mut r#match),
diff --git a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
index 5505b7d..2b53307 100644
--- a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
@@ -268,7 +268,6 @@ impl PhpFileCleaner {
}
fn r#match(&self, regex: &str, r#match: Option<&mut IndexMap<CaptureKey, String>>) -> bool {
- Preg::is_match_strict_groups5(regex, &self.contents, r#match, 0, self.index)
- .unwrap_or(false)
+ Preg::is_match5(regex, &self.contents, r#match, 0, self.index).unwrap_or(false)
}
}
diff --git a/crates/shirabe-class-map-generator/src/php_file_parser.rs b/crates/shirabe-class-map-generator/src/php_file_parser.rs
index 84fb418..a086d78 100644
--- a/crates/shirabe-class-map-generator/src/php_file_parser.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs
@@ -68,7 +68,7 @@ impl PhpFileParser {
// return early if there is no chance of matching anything in this file
let pattern = format!("{{\\b(?:class|interface|trait{})\\s}}i", extra_types);
- let max_matches = Preg::match_all_strict_groups(&pattern, &contents)?;
+ let max_matches = Preg::match_all(&pattern, &contents)?;
if max_matches == 0 {
return Ok(vec![]);
}
diff --git a/crates/shirabe-external-packages/src/composer/pcre/mod.rs b/crates/shirabe-external-packages/src/composer/pcre/mod.rs
index 41def3b..5d1a373 100644
--- a/crates/shirabe-external-packages/src/composer/pcre/mod.rs
+++ b/crates/shirabe-external-packages/src/composer/pcre/mod.rs
@@ -1,5 +1,4 @@
pub mod pcre_exception;
pub mod preg;
-pub mod unexpected_null_match_exception;
pub use preg::*;
diff --git a/crates/shirabe-external-packages/src/composer/pcre/preg.rs b/crates/shirabe-external-packages/src/composer/pcre/preg.rs
index 6af67c4..4c0c2bf 100644
--- a/crates/shirabe-external-packages/src/composer/pcre/preg.rs
+++ b/crates/shirabe-external-packages/src/composer/pcre/preg.rs
@@ -1,7 +1,6 @@
//! ref: composer/vendor/composer/pcre/src/Preg.php
use super::pcre_exception::PcreException;
-use super::unexpected_null_match_exception::UnexpectedNullMatchException;
use indexmap::IndexMap;
pub const PREG_PATTERN_ORDER: i64 = 1;
@@ -51,39 +50,8 @@ impl Preg {
Ok(result == 1)
}
- pub fn match_strict_groups3(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, String>>,
- ) -> anyhow::Result<bool> {
- Self::match_strict_groups5(pattern, subject, matches, 0, 0)
- }
-
- pub fn match_strict_groups5(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, String>>,
- flags: i64,
- offset: usize,
- ) -> anyhow::Result<bool> {
- Self::check_offset_capture(flags, "matchWithOffsets");
-
- let mut internal: IndexMap<CaptureKey, Option<String>> = IndexMap::new();
- let result = preg_match(
- pattern,
- subject,
- Some(&mut internal),
- flags | PREG_UNMATCHED_AS_NULL,
- offset,
- )
- .ok_or_else(|| PcreException::from_function("preg_match", pattern))?;
-
- let enforced = Self::enforce_non_null_matches(pattern, internal, "match")?;
- if let Some(out) = matches {
- *out = enforced;
- }
-
- Ok(result == 1)
+ pub fn match_all(pattern: &str, subject: &str) -> anyhow::Result<usize> {
+ Self::match_all5(pattern, subject, None, 0, 0)
}
pub fn match_all3(
@@ -121,38 +89,6 @@ impl Preg {
Ok(result as usize)
}
- pub fn match_all_strict_groups(pattern: &str, subject: &str) -> anyhow::Result<usize> {
- Self::match_all_strict_groups5(pattern, subject, None, 0, 0)
- }
-
- pub fn match_all_strict_groups5(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
- flags: i64,
- offset: usize,
- ) -> anyhow::Result<usize> {
- Self::check_offset_capture(flags, "matchAllWithOffsets");
- Self::check_set_order(flags);
-
- let mut internal: IndexMap<CaptureKey, Vec<Option<String>>> = IndexMap::new();
- let result = preg_match_all(
- pattern,
- subject,
- Some(&mut internal),
- flags | PREG_UNMATCHED_AS_NULL,
- offset,
- )
- .ok_or_else(|| PcreException::from_function("preg_match_all", pattern))?;
-
- let enforced = Self::enforce_non_null_match_all(pattern, internal, "matchAll")?;
- if let Some(out) = matches {
- *out = enforced;
- }
-
- Ok(result as usize)
- }
-
pub fn match_all_with_offsets5(
pattern: &str,
subject: &str,
@@ -315,24 +251,6 @@ impl Preg {
Ok(result == 1)
}
- pub fn is_match_strict_groups3(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, String>>,
- ) -> anyhow::Result<bool> {
- Self::match_strict_groups5(pattern, subject, matches, 0, 0)
- }
-
- pub fn is_match_strict_groups5(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, String>>,
- flags: i64,
- offset: usize,
- ) -> anyhow::Result<bool> {
- Self::match_strict_groups5(pattern, subject, matches, flags, offset)
- }
-
pub fn is_match_with_indexed_captures(
pattern: &str,
subject: &str,
@@ -376,14 +294,6 @@ impl Preg {
Ok(Self::match_all5(pattern, subject, matches, 0, 0)? > 0)
}
- pub fn is_match_all_strict_groups3(
- pattern: &str,
- subject: &str,
- matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
- ) -> anyhow::Result<bool> {
- Ok(Self::match_all_strict_groups5(pattern, subject, matches, 0, 0)? > 0)
- }
-
pub fn is_match_all_with_offsets3(
pattern: &str,
subject: &str,
@@ -406,65 +316,6 @@ impl Preg {
"PREG_SET_ORDER is not supported as it changes the type of $matches"
);
}
-
- fn enforce_non_null_matches(
- pattern: &str,
- matches: IndexMap<CaptureKey, Option<String>>,
- variant_method: &str,
- ) -> anyhow::Result<IndexMap<CaptureKey, String>> {
- let mut result = IndexMap::new();
- for (group, m) in matches {
- match m {
- None => {
- return Err(UnexpectedNullMatchException::new(format!(
- "Pattern \"{}\" had an unexpected unmatched group \"{}\", make sure the pattern always matches or use {}() instead.",
- pattern,
- capture_key_to_string(&group),
- variant_method
- ))
- .into());
- }
- Some(value) => {
- result.insert(group, value);
- }
- }
- }
- Ok(result)
- }
-
- fn enforce_non_null_match_all(
- pattern: &str,
- matches: IndexMap<CaptureKey, Vec<Option<String>>>,
- variant_method: &str,
- ) -> anyhow::Result<IndexMap<CaptureKey, Vec<String>>> {
- let mut result = IndexMap::new();
- for (group, group_matches) in matches {
- let mut converted = Vec::with_capacity(group_matches.len());
- for m in group_matches {
- match m {
- None => {
- return Err(UnexpectedNullMatchException::new(format!(
- "Pattern \"{}\" had an unexpected unmatched group \"{}\", make sure the pattern always matches or use {}() instead.",
- pattern,
- capture_key_to_string(&group),
- variant_method
- ))
- .into());
- }
- Some(value) => converted.push(value),
- }
- }
- result.insert(group, converted);
- }
- Ok(result)
- }
-}
-
-fn capture_key_to_string(key: &CaptureKey) -> String {
- match key {
- CaptureKey::ByIndex(index) => index.to_string(),
- CaptureKey::ByName(name) => name.clone(),
- }
}
// Drops `null` (unmatched) groups, mirroring how the public `string`-valued
diff --git a/crates/shirabe-external-packages/src/composer/pcre/unexpected_null_match_exception.rs b/crates/shirabe-external-packages/src/composer/pcre/unexpected_null_match_exception.rs
deleted file mode 100644
index 513870c..0000000
--- a/crates/shirabe-external-packages/src/composer/pcre/unexpected_null_match_exception.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-//! ref: composer/vendor/composer/pcre/src/UnexpectedNullMatchException.php
-
-use super::pcre_exception::PcreException;
-
-#[derive(Debug)]
-pub struct UnexpectedNullMatchException(pub PcreException);
-
-impl UnexpectedNullMatchException {
- pub fn new(message: String) -> UnexpectedNullMatchException {
- UnexpectedNullMatchException(PcreException(shirabe_php_shim::RuntimeException {
- message,
- code: 0,
- }))
- }
-
- pub fn from_function(_function: &str, _pattern: &str) -> UnexpectedNullMatchException {
- panic!(
- "fromFunction should not be called on UnexpectedNullMatchException, use PcreException"
- );
- }
-}
-
-impl std::fmt::Display for UnexpectedNullMatchException {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "{}", self.0)
- }
-}
-
-impl std::error::Error for UnexpectedNullMatchException {}
diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs
index f657ef4..71d353e 100644
--- a/crates/shirabe/src/command/archive_command.rs
+++ b/crates/shirabe/src/command/archive_command.rs
@@ -280,7 +280,7 @@ impl ArchiveCommand {
if let Some(version_str) = &version {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(
+ if Preg::match3(
r"{@(stable|RC|beta|alpha|dev)$}i",
version_str,
Some(&mut matches),
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 2bcb681..e55b92e 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -703,7 +703,7 @@ impl ConfigCommand {
// handle repositories
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^repos?(?:itories)?\\.(.+)/",
&setting_key,
Some(&mut matches),
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index 247941b..aa4245d 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -692,7 +692,7 @@ impl CreateProjectCommand {
stability = Some("stable".to_string());
} else if {
let mut matched: IndexMap<CaptureKey, String> = IndexMap::new();
- let ok = Preg::is_match_strict_groups3(
+ let ok = Preg::is_match3(
&format!(
"{{^[^,\\s]*?@({})$}}i",
implode(
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index aa75ad7..6c37459 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -1178,7 +1178,7 @@ impl DiagnoseCommand {
let phpinfo_str = ob_get_clean();
let mut phpinfo_match: IndexMap<CaptureKey, String> = IndexMap::new();
if phpinfo_str.is_some()
- && Preg::is_match_strict_groups3(
+ && Preg::is_match3(
"{Configure Command(?: *</td><td class=\"v\">| *=> *)(.*?)(?:</td>|$)}m",
phpinfo_str.as_ref().unwrap(),
Some(&mut phpinfo_match),
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index 205494c..d7af222 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -928,7 +928,7 @@ impl InitCommand {
/// @return array{name: string, email: string|null}
fn parse_author_string(&self, author: &str) -> Result<IndexMap<String, Option<String>>> {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r#"/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’\"()]+)(?:\s+<(?P<email>.+?)>)?$/u"#,
author,
Some(&mut m),
@@ -1022,9 +1022,7 @@ impl InitCommand {
{
self.git_config = Some(IndexMap::new());
let mut m: IndexMap<CaptureKey, Vec<String>> = IndexMap::new();
- if Preg::is_match_all_strict_groups3(r"{^([^=]+)=(.*)$}m", &output, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match_all3(r"{^([^=]+)=(.*)$}m", &output, Some(&mut m)).unwrap_or(false) {
let keys: Vec<String> = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let values: Vec<String> =
m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index 2fe856c..917a716 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -375,7 +375,7 @@ pub trait PackageDiscoveryTrait {
}
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}",
&selection,
Some(&mut m),
diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs
index be2b0ad..b8fa03f 100644
--- a/crates/shirabe/src/dependency_resolver/problem.rs
+++ b/crates/shirabe/src/dependency_resolver/problem.rs
@@ -231,7 +231,7 @@ impl Problem {
),
true,
) {
- Preg::is_match_strict_groups3(
+ Preg::is_match3(
r"{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}",
&message,
Some(&mut m),
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index b7145b6..fd2246a 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -99,7 +99,7 @@ impl GitDownloader {
let mut refs = trim(&output, None);
let mut head_match: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(r"{^([a-f0-9]+) HEAD$}mi", &refs, Some(&mut head_match))
+ if !Preg::is_match3(r"{^([a-f0-9]+) HEAD$}mi", &refs, Some(&mut head_match))
.unwrap_or(false)
{
// could not match the HEAD for some reason
@@ -111,7 +111,7 @@ impl GitDownloader {
.unwrap_or_default();
let mut branches_match: IndexMap<CaptureKey, Vec<String>> = IndexMap::new();
- if !Preg::is_match_all_strict_groups3(
+ if !Preg::is_match_all3(
&format!("{{^{} refs/heads/(.+)$}}mi", preg_quote(&head_ref, None)),
&refs,
Some(&mut branches_match),
@@ -138,7 +138,7 @@ impl GitDownloader {
// try to find matching branch names in remote repos
for candidate in &candidate_branches {
let mut m: IndexMap<CaptureKey, Vec<String>> = IndexMap::new();
- if Preg::is_match_all_strict_groups3(
+ if Preg::is_match_all3(
&format!(
"{{^[a-f0-9]+ refs/remotes/((?:[^/]+)/{})$}}mi",
preg_quote(candidate, None)
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index 95f25f8..e66d3ae 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -399,20 +399,19 @@ impl VcsDownloader for SvnDownloader {
let url_pattern = "#<url>(.*)</url>#";
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- let base_url = if Preg::match_strict_groups3(url_pattern, &output, Some(&mut matches))
- .unwrap_or(false)
- {
- matches
- .get(&CaptureKey::ByIndex(1))
- .cloned()
- .unwrap_or_default()
- } else {
- return Err(RuntimeException {
- message: format!("Unable to determine svn url for path {}", path),
- code: 0,
- }
- .into());
- };
+ let base_url =
+ if Preg::match3(url_pattern, &output, Some(&mut matches)).unwrap_or(false) {
+ matches
+ .get(&CaptureKey::ByIndex(1))
+ .cloned()
+ .unwrap_or_default()
+ } else {
+ return Err(RuntimeException {
+ message: format!("Unable to determine svn url for path {}", path),
+ code: 0,
+ }
+ .into());
+ };
// strip paths from references and only keep the actual revision
let from_revision =
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index c5c2526..0613c15 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -116,12 +116,8 @@ impl ZipDownloader {
== 0
{
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"^\s*7-Zip(?:\s\[64\])?\s([0-9.]+)",
- &output,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"^\s*7-Zip(?:\s\[64\])?\s([0-9.]+)", &output, Some(&mut m))
+ .unwrap_or(false)
{
let m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
if version_compare(&m1, "21.01", "<") {
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
index f0ef82f..8d3ac4b 100644
--- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
+++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
@@ -689,12 +689,8 @@ impl EventDispatcher {
// 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
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- "{^[^\\'\"\\s/\\\\]+}",
- &path_and_args,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3("{^[^\\'\"\\s/\\\\]+}", &path_and_args, Some(&mut m))
+ .unwrap_or(false)
{
let m0 =
m.get(&CaptureKey::ByIndex(0)).cloned().unwrap_or_default();
diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs
index 539201f..778a8a0 100644
--- a/crates/shirabe/src/installer/binary_installer.rs
+++ b/crates/shirabe/src/installer/binary_installer.rs
@@ -173,7 +173,7 @@ impl BinaryInstaller {
let line = fgets(handle.clone()).unwrap_or_default();
fclose(handle);
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m",
&line,
Some(&mut m),
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs
index cf92a77..f06a0b9 100644
--- a/crates/shirabe/src/json/json_file.rs
+++ b/crates/shirabe/src/json/json_file.rs
@@ -575,8 +575,7 @@ impl JsonFile {
pub fn detect_indenting(json: Option<&str>) -> String {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r##"#^([ \t]+)"#m"##, json.unwrap_or(""), Some(&mut m))
- .unwrap_or(false)
+ if Preg::is_match3(r##"#^([ \t]+)"#m"##, json.unwrap_or(""), Some(&mut m)).unwrap_or(false)
{
return m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
}
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs
index 0fd2053..63b9cae 100644
--- a/crates/shirabe/src/json/json_manipulator.rs
+++ b/crates/shirabe/src/json/json_manipulator.rs
@@ -134,7 +134,7 @@ impl JsonManipulator {
)?;
} else {
let mut groups: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"#^\\s*\\{\\s*\\S+.*?(\\s*\\}\\s*)$#s",
&links,
Some(&mut groups),
@@ -1583,7 +1583,7 @@ impl JsonManipulator {
// check that we are not leaving a dangling comma on the previous line if the last line was removed
let mut start = matches.get("start").cloned().unwrap_or_default();
let end = matches.get("end").cloned().unwrap_or_default();
- if Preg::is_match_strict_groups3("#,\\s*$#", &start, None).unwrap_or(false)
+ if Preg::is_match3("#,\\s*$#", &start, None).unwrap_or(false)
&& Preg::is_match3("#^\\}$#", &end, None).unwrap_or(false)
{
start = rtrim(
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs
index 04ae470..476f6bd 100644
--- a/crates/shirabe/src/package/loader/root_package_loader.rs
+++ b/crates/shirabe/src/package/loader/root_package_loader.rs
@@ -274,7 +274,7 @@ impl RootPackageLoader {
) -> Vec<IndexMap<String, String>> {
for (req_name, req_version) in requires {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *,)",
req_version,
Some(&mut m),
@@ -349,9 +349,7 @@ impl RootPackageLoader {
let mut matched = false;
for constraint in &constraints {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(&pattern, constraint, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(&pattern, constraint, Some(&mut m)).unwrap_or(false) {
let name = strtolower(req_name);
let m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let normalized_m1 = VersionParser::normalize_stability(&m1).unwrap_or_default();
@@ -399,7 +397,7 @@ impl RootPackageLoader {
let req_version =
Preg::replace(r"^([^,\s@]+) as .+$", "$1", req_version).unwrap_or_default();
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r"^[^,\s@]+?#([a-f0-9]+)$", &req_version, Some(&mut m))
+ if Preg::is_match3(r"^[^,\s@]+?#([a-f0-9]+)$", &req_version, Some(&mut m))
.unwrap_or(false)
{
if VersionParser::parse_stability(&req_version) == "dev" {
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index c61d807..8c84b4e 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -895,7 +895,7 @@ impl Locker {
path.as_deref(),
)? {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^\s*(\d+)\s*}",
output.as_string().unwrap_or(""),
Some(&mut m),
diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs
index da67d56..562d141 100644
--- a/crates/shirabe/src/package/version/version_guesser.rs
+++ b/crates/shirabe/src/package/version/version_guesser.rs
@@ -210,11 +210,9 @@ impl VersionGuesser {
for branch in self.process.borrow().split_lines(&output) {
if !branch.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}",
- &branch,
- Some(&mut m),
- )
+ if Preg::is_match3(r"{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}",
+ &branch,
+ Some(&mut m),)
.unwrap_or(false)
{
let g1 = m
@@ -245,11 +243,10 @@ impl VersionGuesser {
if !branch.is_empty() && {
let mut tmp: IndexMap<CaptureKey, String> = IndexMap::new();
- !Preg::is_match_strict_groups3(r"{^ *.+/HEAD }", &branch, Some(&mut tmp))
- .unwrap_or(false)
+ !Preg::is_match3(r"{^ *.+/HEAD }", &branch, Some(&mut tmp)).unwrap_or(false)
} {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}",
&branch,
Some(&mut m),
@@ -761,9 +758,7 @@ impl VersionGuesser {
}
};
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r"{^(\d+(?:\.\d+)*)-dev$}i", &version, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^(\d+(?:\.\d+)*)-dev$}i", &version, Some(&mut m)).unwrap_or(false) {
return Ok(format!(
"{}.x-dev",
m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default()
diff --git a/crates/shirabe/src/platform/version.rs b/crates/shirabe/src/platform/version.rs
index e602f15..f1d2b87 100644
--- a/crates/shirabe/src/platform/version.rs
+++ b/crates/shirabe/src/platform/version.rs
@@ -11,11 +11,9 @@ impl Version {
*is_fips = false;
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::match_strict_groups3(
- r"^(?P<version>[0-9.]+)(?P<patch>[a-z]{0,2})(?P<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)(?:-\w+)?(?: \(.+?\))?$",
- openssl_version,
- Some(&mut matches),
- )
+ if !Preg::match3(r"^(?P<version>[0-9.]+)(?P<patch>[a-z]{0,2})(?P<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)(?:-\w+)?(?: \(.+?\))?$",
+ openssl_version,
+ Some(&mut matches),)
.unwrap_or(false)
{
return None;
@@ -57,7 +55,7 @@ impl Version {
pub fn parse_libjpeg(libjpeg_version: &str) -> Option<String> {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::match_strict_groups3(
+ if !Preg::match3(
r"^(?P<major>\d+)(?P<minor>[a-z]*)$",
libjpeg_version,
Some(&mut matches),
@@ -84,7 +82,7 @@ impl Version {
pub fn parse_zoneinfo_version(zoneinfo_version: &str) -> Option<String> {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::match_strict_groups3(
+ if !Preg::match3(
r"^(?P<year>\d{4})(?P<revision>[a-z]*)$",
zoneinfo_version,
Some(&mut matches),
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index f07eb73..5994968 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -792,7 +792,7 @@ impl ComposerRepository {
if self.has_providers()? || self.lazy_providers_url.is_some() {
// optimize search for "^foo/bar" where at least "^foo/" is present by loading this directly from the listUrl if present
let mut match_groups: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i",
&query,
Some(&mut match_groups),
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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^AMQP protocol version => (?<version>.+)$/im",
&info,
Some(&mut protocol_matches),
@@ -434,7 +434,7 @@ impl PlatformRepository {
// SSL Version => OpenSSL/1.0.1t
let mut ssl_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im",
&info,
Some(&mut ssl_matches),
@@ -506,7 +506,7 @@ impl PlatformRepository {
// libSSH Version => libssh2/1.4.3
let mut ssh_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im",
&info,
Some(&mut ssh_matches),
@@ -533,7 +533,7 @@ impl PlatformRepository {
// ZLib Version => 1.2.8
let mut zlib_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^ZLib Version => (?<version>.+)$}im",
&info,
Some(&mut zlib_matches),
@@ -558,7 +558,7 @@ impl PlatformRepository {
// timelib version => 2018.03
let mut timelib_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^timelib version => (?<version>.+)$/im",
&info,
Some(&mut timelib_matches),
@@ -579,7 +579,7 @@ impl PlatformRepository {
// Timezone Database => internal
let mut zoneinfo_source_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^Timezone Database => (?<source>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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- "/^\"Olson\" Timezone Database Version => (?<version>.+?)(?:\\.system)?$/im",
- &info,
- Some(&mut zoneinfo_matches),
- )
+ if Preg::is_match3("/^\"Olson\" Timezone Database Version => (?<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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im",
&info,
Some(&mut libjpeg_matches),
@@ -694,7 +692,7 @@ impl PlatformRepository {
}
let mut libpng_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^libPNG Version => (?<version>.+)$/im",
&info,
Some(&mut libpng_matches),
@@ -714,7 +712,7 @@ impl PlatformRepository {
}
let mut freetype_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^FreeType Version => (?<version>.+)$/im",
&info,
Some(&mut freetype_matches),
@@ -734,7 +732,7 @@ impl PlatformRepository {
}
let mut libxpm_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^libXpm Version => (?<versionId>\\d+)$/im",
&info,
Some(&mut libxpm_matches),
@@ -832,7 +830,7 @@ impl PlatformRepository {
// ICU TZData version => 2019c
let mut zoneinfo_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^ICU TZData version => (?<version>.*)$/im",
&info,
Some(&mut zoneinfo_matches),
@@ -951,13 +949,13 @@ impl PlatformRepository {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
let mut vendor_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^Vendor Version => (?<versionId>\\d+)$/im",
&info,
Some(&mut matches),
)
.unwrap_or(false)
- && Preg::is_match_strict_groups3(
+ && Preg::is_match3(
"/^Vendor Name => (?<vendor>.+)$/im",
&info,
Some(&mut vendor_matches),
@@ -1106,7 +1104,7 @@ impl PlatformRepository {
};
// OpenSSL 1.1.1g 21 Apr 2020
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^(?:OpenSSL|LibreSSL)?\\s*(?<version>\\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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^PCRE Unicode Version => (?<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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi",
&info,
Some(&mut matches),
@@ -1197,7 +1195,7 @@ impl PlatformRepository {
let info = self.runtime.get_extension_info(name)?;
let mut libmongoc_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^libmongoc bundled version => (?<version>.+)$/im",
&info,
Some(&mut libmongoc_matches),
@@ -1217,7 +1215,7 @@ impl PlatformRepository {
}
let mut libbson_matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"/^libbson bundled version => (?<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<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^(\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)}",
&pretty_version,
Some(&mut m),
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 73975cd..82794a4 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -605,9 +605,7 @@ impl ForgejoDriver {
let links = explode(",", &header);
for link in links {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(r#"{<(.+?)>; *rel="next"}"#, &link, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::match3(r#"{<(.+?)>; *rel="next"}"#, &link, Some(&mut m)).unwrap_or(false) {
if let Some(url) = m.get(&CaptureKey::ByIndex(1)) {
return Some(url.clone());
}
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index 9c285e0..674f849 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -87,7 +87,7 @@ impl GitBitbucketDriver {
/// @inheritDoc
pub fn initialize(&mut self) -> Result<()> {
let mut m: indexmap::IndexMap<CaptureKey, String> = indexmap::IndexMap::new();
- if !Preg::is_match_strict_groups3(
+ if !Preg::is_match3(
r"#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i",
&self.inner.url,
Some(&mut m),
diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs
index 7f8c206..10353f3 100644
--- a/crates/shirabe/src/repository/vcs/git_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_driver.rs
@@ -215,9 +215,7 @@ impl GitDriver {
for branch in &branches {
if !branch.is_empty() {
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(r"{^\* +(\S+)}", branch, Some(&mut caps))
- .unwrap_or(false)
- {
+ if Preg::match3(r"{^\* +(\S+)}", branch, Some(&mut caps)).unwrap_or(false) {
if let Some(name) = caps.get(&CaptureKey::ByIndex(1)) {
self.root_identifier = Some(name.clone());
break;
@@ -336,7 +334,7 @@ impl GitDriver {
for tag in self.inner.process.borrow().split_lines(&output) {
if !tag.is_empty() {
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(
+ if Preg::match3(
r"{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}",
&tag,
Some(&mut caps),
@@ -381,7 +379,7 @@ impl GitDriver {
&& !Preg::is_match(r"{^ *[^/]+/HEAD }", &branch).unwrap_or(false)
{
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(
+ if Preg::match3(
r"{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}",
&branch,
Some(&mut caps),
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 5fb3439..64ed4d3 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -74,7 +74,7 @@ impl GitHubDriver {
pub fn initialize(&mut self) -> Result<()> {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(
+ if !Preg::is_match3(
r"#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#",
&self.inner.url,
Some(&mut match_),
@@ -504,9 +504,7 @@ impl GitHubDriver {
for line in Preg::split(r"{\r?\n}", &funding).unwrap_or_default() {
let line = trim(&line, None);
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r"{^(\w+)\s*:\s*(.+)$}", &line, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r"{^(\w+)\s*:\s*(.+)$}", &line, Some(&mut m)).unwrap_or(false) {
let g1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let g2 = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
if g2 == "[" {
@@ -514,8 +512,7 @@ impl GitHubDriver {
continue;
}
let mut m2: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r"{^\[(.*?)\](?:\s*#.*)?$}", &g2, Some(&mut m2))
- .unwrap_or(false)
+ if Preg::is_match3(r"{^\[(.*?)\](?:\s*#.*)?$}", &g2, Some(&mut m2)).unwrap_or(false)
{
let inner = m2.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
for item in array_map(
@@ -530,12 +527,8 @@ impl GitHubDriver {
);
result.push(entry);
}
- } else if Preg::is_match_strict_groups3(
- r"{^([^#].*?)(?:\s+#.*)?$}",
- &g2,
- Some(&mut m2),
- )
- .unwrap_or(false)
+ } else if Preg::is_match3(r"{^([^#].*?)(?:\s+#.*)?$}", &g2, Some(&mut m2))
+ .unwrap_or(false)
{
let mut entry = IndexMap::new();
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
@@ -549,15 +542,13 @@ impl GitHubDriver {
result.push(entry);
}
key = None;
- } else if Preg::is_match_strict_groups3(r"{^(\w+)\s*:\s*#\s*$}", &line, Some(&mut m))
- .unwrap_or(false)
+ } else if Preg::is_match3(r"{^(\w+)\s*:\s*#\s*$}", &line, Some(&mut m)).unwrap_or(false)
{
key = Some(m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default());
} else if key.is_some() && {
let mut tmp: IndexMap<CaptureKey, String> = IndexMap::new();
- Preg::is_match_strict_groups3(r"{^-\s*(.+)(?:\s+#.*)?$}", &line, Some(&mut m))
- .unwrap_or(false)
- || Preg::is_match_strict_groups3(r"{^(.+),(?:\s*#.*)?$}", &line, Some(&mut tmp))
+ Preg::is_match3(r"{^-\s*(.+)(?:\s+#.*)?$}", &line, Some(&mut m)).unwrap_or(false)
+ || Preg::is_match3(r"{^(.+),(?:\s*#.*)?$}", &line, Some(&mut tmp))
.unwrap_or(false)
&& {
m = tmp;
@@ -961,7 +952,7 @@ impl GitHubDriver {
_deep: bool,
) -> anyhow::Result<bool> {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(
+ if !Preg::is_match3(
r"#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#",
url,
Some(&mut matches),
@@ -1329,9 +1320,7 @@ impl GitHubDriver {
let links = explode(",", &header);
for link in &links {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut m)).unwrap_or(false) {
return Some(m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default());
}
}
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index bc47db8..a123a24 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -84,9 +84,7 @@ impl GitLabDriver {
/// SSH urls use https by default. Set "secure-http": false on the repository config to use http instead.
pub fn initialize(&mut self) -> Result<()> {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(Self::URL_REGEX, &self.inner.url, Some(&mut match_))
- .unwrap_or(false)
- {
+ if !Preg::is_match3(Self::URL_REGEX, &self.inner.url, Some(&mut match_)).unwrap_or(false) {
return Err(InvalidArgumentException {
message: format!(
"The GitLab repository URL {} is invalid. It must be the HTTP URL of a GitLab project.",
@@ -989,8 +987,7 @@ impl GitLabDriver {
_deep: bool,
) -> anyhow::Result<bool> {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(Self::URL_REGEX, url, Some(&mut match_)).unwrap_or(false)
- {
+ if !Preg::is_match3(Self::URL_REGEX, url, Some(&mut match_)).unwrap_or(false) {
return Ok(false);
}
@@ -1058,7 +1055,7 @@ impl GitLabDriver {
let links = explode(",", &header);
for link in &links {
let mut match_: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut match_))
+ if Preg::is_match3(r#"{<(.+?)>; *rel="next"}"#, link, Some(&mut match_))
.unwrap_or(false)
{
return Some(
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index f637437..c76f496 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -244,9 +244,7 @@ impl HgDriver {
for tag in self.inner.process.borrow().split_lines(&output) {
if !tag.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(r"^([^\s]+)\s+\d+:(.*)$", &tag, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::match3(r"^([^\s]+)\s+\d+:(.*)$", &tag, Some(&mut m)).unwrap_or(false) {
tags.insert(
m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(),
m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default(),
@@ -276,12 +274,8 @@ impl HgDriver {
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(
- r"^([^\s]+)\s+\d+:([a-f0-9]+)",
- &branch,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::match3(r"^([^\s]+)\s+\d+:([a-f0-9]+)", &branch, Some(&mut m))
+ .unwrap_or(false)
{
let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
if !name.starts_with('-') {
@@ -303,12 +297,8 @@ impl HgDriver {
for branch in self.inner.process.borrow().split_lines(&output) {
if !branch.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(
- r"^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$",
- &branch,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::match3(r"^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$", &branch, Some(&mut m))
+ .unwrap_or(false)
{
let name = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
if !name.starts_with('-') {
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 911e982..71d8499 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -322,12 +322,8 @@ impl SvnDriver {
for line in self.inner.process.borrow().split_lines(&output) {
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^Last Changed Date: ([^(]+)}",
- &line,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"{^Last Changed Date: ([^(]+)}", &line, Some(&mut m))
+ .unwrap_or(false)
{
let date_str = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
return Ok(shirabe_php_shim::date_create::<Utc>(date_str.trim())
@@ -358,12 +354,8 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^\s*(\S+).*?(\S+)\s*$}",
- &line,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
+ .unwrap_or(false)
{
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
@@ -413,12 +405,8 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^\s*(\S+).*?(\S+)\s*$}",
- &line,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
+ .unwrap_or(false)
{
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
@@ -459,12 +447,8 @@ impl SvnDriver {
let line = trim(&line, None);
if !line.is_empty() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^\s*(\S+).*?(\S+)\s*$}",
- &line,
- Some(&mut m),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"{^\s*(\S+).*?(\S+)\s*$}", &line, Some(&mut m))
+ .unwrap_or(false)
{
let rev: i64 = m
.get(&CaptureKey::ByIndex(1))
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index f693598..15f970d 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -701,7 +701,7 @@ impl Filesystem {
shirabe_external_packages::composer::pcre::CaptureKey,
String,
> = indexmap::IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
"{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix",
&path,
Some(&mut prefix_match),
diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs
index d9cfdfd..35f4940 100644
--- a/crates/shirabe/src/util/git.rs
+++ b/crates/shirabe/src/util/git.rs
@@ -227,7 +227,7 @@ impl Git {
cwd.map(|s| s.to_string()),
);
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im",
&output,
Some(&mut m),
@@ -251,7 +251,7 @@ impl Git {
// public github, autoswitch protocols
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
&format!(
"{{^(?:https?|git)://{}/(.*)}}",
Self::get_github_domains_regex(&*self.config.borrow())
@@ -361,7 +361,7 @@ impl Git {
// private github repository without ssh key access, try https with auth
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- let github_matched = Preg::is_match_strict_groups3(
+ let github_matched = Preg::is_match3(
&format!(
"{{^git@{}:(.+?)\\.git$}}i",
Self::get_github_domains_regex(&*self.config.borrow())
@@ -370,7 +370,7 @@ impl Git {
Some(&mut m),
)
.unwrap_or(false)
- || Preg::is_match_strict_groups3(
+ || Preg::is_match3(
&format!(
"{{^https?://{}/(.*?)(?:\\.git)?$}}i",
Self::get_github_domains_regex(&*self.config.borrow())
@@ -430,13 +430,13 @@ impl Git {
error_msg = self.process.borrow().get_error_output().to_string();
}
} else if {
- let bb_matched = Preg::is_match_strict_groups3(
+ let bb_matched = Preg::is_match3(
r"{^(https?)://(bitbucket\.org)/(.*?)(?:\.git)?$}i",
url,
Some(&mut m),
)
.unwrap_or(false)
- || Preg::is_match_strict_groups3(
+ || Preg::is_match3(
r"{^(git)@(bitbucket\.org):(.+?\.git)$}i",
url,
Some(&mut m),
@@ -582,7 +582,7 @@ impl Git {
error_msg = self.process.borrow().get_error_output().to_string();
} else if {
- let gl_matched = Preg::is_match_strict_groups3(
+ let gl_matched = Preg::is_match3(
&format!(
"{{^(git)@{}:(.+?\\.git)$}}i",
Self::get_gitlab_domains_regex(&*self.config.borrow())
@@ -591,7 +591,7 @@ impl Git {
Some(&mut m),
)
.unwrap_or(false)
- || Preg::is_match_strict_groups3(
+ || Preg::is_match3(
&format!(
"{{^(https?)://{}/(.*)}}i",
Self::get_gitlab_domains_regex(&*self.config.borrow())
@@ -1117,9 +1117,7 @@ impl Git {
/// @return array<int, string>|null
fn get_authentication_failure(&self, url: &str) -> Option<IndexMap<CaptureKey, String>> {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if !Preg::is_match_strict_groups3(r"{^(https?://)([^/]+)(.*)$}i", url, Some(&mut m))
- .unwrap_or(false)
- {
+ if !Preg::is_match3(r"{^(https?://)([^/]+)(.*)$}i", url, Some(&mut m)).unwrap_or(false) {
return None;
}
@@ -1204,12 +1202,8 @@ impl Git {
.split_lines(output_mixed.as_string().unwrap_or(""));
for line in lines {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
- r"{^\s*HEAD branch:\s(.+)\s*$}m",
- &line,
- Some(&mut matches),
- )
- .unwrap_or(false)
+ if Preg::is_match3(r"{^\s*HEAD branch:\s(.+)\s*$}m", &line, Some(&mut matches))
+ .unwrap_or(false)
{
return Ok(Some(
matches
@@ -1347,7 +1341,7 @@ impl Git {
);
if exit_code == 0 {
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"/^git version (\d+(?:\.\d+)+)/m",
&output,
Some(&mut matches),
diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs
index 26544cb..1cd78c1 100644
--- a/crates/shirabe/src/util/github.rs
+++ b/crates/shirabe/src/util/github.rs
@@ -333,9 +333,7 @@ impl GitHub {
continue;
}
let mut caps: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::match_strict_groups3(r"{\burl=(?P<url>[^\s;]+)}", header, Some(&mut caps))
- .unwrap_or(false)
- {
+ if Preg::match3(r"{\burl=(?P<url>[^\s;]+)}", header, Some(&mut caps)).unwrap_or(false) {
return caps.get(&CaptureKey::ByName("url".to_string())).cloned();
}
}
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index 434dedb..b1da08f 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -310,7 +310,7 @@ impl HttpDownloader {
// capture username/password from URL if there is one
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(
+ if Preg::is_match3(
r"{^https?://([^:/]+):([^@/]+)@([^/]+)}i",
&request.url,
Some(&mut m),
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 75b40cb..a681f2c 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -206,8 +206,7 @@ impl ProcessExecutor {
let mut command_str = command.as_string().unwrap_or("").to_string();
if Platform::is_windows() {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3(r"{^([^:/\\]++) }", &command_str, Some(&mut m))
- .unwrap_or(false)
+ if Preg::is_match3(r"{^([^:/\\]++) }", &command_str, Some(&mut m)).unwrap_or(false)
{
let m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
command_str = substr_replace(
diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs
index c510d7c..a75f947 100644
--- a/crates/shirabe/src/util/remote_filesystem.rs
+++ b/crates/shirabe/src/util/remote_filesystem.rs
@@ -145,9 +145,7 @@ impl RemoteFilesystem {
let mut value: Option<i64> = None;
for header in headers {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
- if Preg::is_match_strict_groups3("{^HTTP/\\S+ (\\d+)}i", header, Some(&mut m))
- .unwrap_or(false)
- {
+ if Preg::is_match3("{^HTTP/\\S+ (\\d+)}i", header, Some(&mut m)).unwrap_or(false) {
value = m
.get(&CaptureKey::ByIndex(1))
.and_then(|s| s.parse().ok())