From b6604e1395f003748fe40a44e1190470632a40ce Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 19:06:49 +0900 Subject: refactor(preg): import preg_*() instead of qualifying them Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-symfony-process/src/process.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'crates/shirabe-symfony-process') diff --git a/crates/shirabe-symfony-process/src/process.rs b/crates/shirabe-symfony-process/src/process.rs index 556238cf..5307e1ae 100644 --- a/crates/shirabe-symfony-process/src/process.rs +++ b/crates/shirabe-symfony-process/src/process.rs @@ -11,7 +11,10 @@ use crate::pipes::unix_pipes::UnixPipes; use crate::pipes::windows_pipes::WindowsPipes; use crate::process_utils::ProcessUtils; use indexmap::IndexMap; -use shirabe_php_shim::{CaptureKey, Descriptor, PhpMixed, PhpResource, php_regex}; +use shirabe_php_shim::{ + CaptureKey, Descriptor, PhpMixed, PhpResource, php_regex, preg_match, preg_replace, + preg_replace_callback, +}; use std::sync::OnceLock; /// A user-supplied callback invoked with the output type ("out"/"err") and a chunk of output. @@ -925,7 +928,7 @@ impl Process { let uid = shirabe_php_shim::uniqid("", true); let mut var_count = 0; let mut var_cache: IndexMap = IndexMap::new(); - let cmd = shirabe_php_shim::preg_replace_callback( + let cmd = preg_replace_callback( php_regex!( r#"/"(?:( [^"%!^]*+ @@ -963,7 +966,7 @@ impl Process { } value = format!( "\"{}\"", - shirabe_php_shim::preg_replace(php_regex!(r#"/(\\*)"/"#), "$1$1\\\"", &value) + preg_replace(php_regex!(r#"/(\\*)"/"#), "$1$1\\\"", &value) ); var_count += 1; let var = format!("{}{}", uid, var_count); @@ -985,11 +988,7 @@ impl Process { .map(|spec| { format!( "\"{}\"", - shirabe_php_shim::preg_replace( - php_regex!(r#"{(\\*+)"}"#), - "$1$1\\\"", - &spec, - ) + preg_replace(php_regex!(r#"{(\\*+)"}"#), "$1$1\\\"", &spec,) ) }) }) @@ -1044,14 +1043,14 @@ impl Process { if argument.contains('\0') { argument = argument.replace('\0', "?"); } - if !shirabe_php_shim::preg_match( + if !preg_match( php_regex!(r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#), &argument, &mut Vec::new(), ) { return argument; } - argument = shirabe_php_shim::preg_replace(php_regex!(r"/(\\+)$/"), "$1$1", &argument); + argument = preg_replace(php_regex!(r"/(\\+)$/"), "$1$1", &argument); let mut result = argument; for (from, to) in [ @@ -1071,7 +1070,7 @@ impl Process { commandline: &str, env: &IndexMap, ) -> anyhow::Result { - shirabe_php_shim::preg_replace_callback( + preg_replace_callback( php_regex!(r#"/"\$\{:([_a-zA-Z]+[_a-zA-Z0-9]*)\}"/"#), |matches: &IndexMap>| -> anyhow::Result { let key = matches -- cgit v1.3.1-4-g156e