From 880a5eaad9dcdfd31563385f11ba1f63d38cfd14 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 06:19:30 +0900 Subject: refactor(php-shim): use std::path::MAIN_SEPARATOR over a shim constant The shim's DIRECTORY_SEPARATOR was hardcoded to "/", so every ported `'\\' === DIRECTORY_SEPARATOR` check compared against a constant that does not track the target platform. std::path::MAIN_SEPARATOR and MAIN_SEPARATOR_STR carry the same meaning as PHP's constant and resolve per platform, so the Windows branches are selected on Windows targets. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/symfony/console/helper/question_helper.rs | 2 +- .../src/symfony/console/output/stream_output.rs | 3 +-- crates/shirabe-external-packages/src/symfony/console/terminal.rs | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console') diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs index 2091225d..f5242d9a 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs @@ -685,7 +685,7 @@ impl QuestionHelper { input_stream: &shirabe_php_shim::PhpResource, trimmable: bool, ) -> anyhow::Result> { - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let mut exe = format!( "{}/../Resources/bin/hiddeninput.exe", shirabe_php_shim::dir() diff --git a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs index 9140dbc8..8ee2f186 100644 --- a/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs +++ b/crates/shirabe-external-packages/src/symfony/console/output/stream_output.rs @@ -98,8 +98,7 @@ impl StreamOutput { return false; } - if "\\" == shirabe_php_shim::DIRECTORY_SEPARATOR - && shirabe_php_shim::sapi_windows_vt100_support(stream) + if std::path::MAIN_SEPARATOR == '\\' && shirabe_php_shim::sapi_windows_vt100_support(stream) { return true; } diff --git a/crates/shirabe-external-packages/src/symfony/console/terminal.rs b/crates/shirabe-external-packages/src/symfony/console/terminal.rs index 7fca27e8..353dffcb 100644 --- a/crates/shirabe-external-packages/src/symfony/console/terminal.rs +++ b/crates/shirabe-external-packages/src/symfony/console/terminal.rs @@ -69,7 +69,7 @@ impl Terminal { let result = shirabe_php_shim::shell_exec(&format!( "stty 2> {}", - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { "NUL" } else { "/dev/null" @@ -81,7 +81,7 @@ impl Terminal { } fn init_dimensions() { - if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + if std::path::MAIN_SEPARATOR == '\\' { let ansicon = shirabe_php_shim::getenv("ANSICON"); let mut matches: Vec> = Vec::new(); if let Some(ansicon) = &ansicon -- cgit v1.3.1-4-g156e