diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 3c940289..0471dd65 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -23,6 +23,6 @@ class imagick extends Extension $static .= ' -l:libstdc++.a'; $shared = str_replace('-lstdc++', '', $shared); } - return [deduplicate_spaces($static), deduplicate_spaces($shared)]; + return [clean_spaces($static), clean_spaces($shared)]; } } diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index cf2b4ce4..c3bb83cc 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -98,9 +98,9 @@ class SPCConfigUtil $libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs); } return [ - 'cflags' => deduplicate_spaces(getenv('CFLAGS') . ' ' . $cflags), - 'ldflags' => deduplicate_spaces(getenv('LDFLAGS') . ' ' . $ldflags), - 'libs' => deduplicate_spaces(getenv('LIBS') . ' ' . $libs), + 'cflags' => clean_spaces(getenv('CFLAGS') . ' ' . $cflags), + 'ldflags' => clean_spaces(getenv('LDFLAGS') . ' ' . $ldflags), + 'libs' => clean_spaces(getenv('LIBS') . ' ' . $libs), ]; } @@ -117,9 +117,9 @@ class SPCConfigUtil } return [ - 'cflags' => deduplicate_spaces(getenv('CFLAGS') . ' ' . $cflags), - 'ldflags' => deduplicate_spaces(getenv('LDFLAGS') . ' ' . $ldflags), - 'libs' => deduplicate_spaces($allLibs), + 'cflags' => clean_spaces(getenv('CFLAGS') . ' ' . $cflags), + 'ldflags' => clean_spaces(getenv('LDFLAGS') . ' ' . $ldflags), + 'libs' => clean_spaces($allLibs), ]; } diff --git a/src/globals/functions.php b/src/globals/functions.php index 1ad115fc..2fef0d7f 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -244,10 +244,12 @@ function get_pack_replace(): array } /** - * @param $string - * @return string without double spaces + * Remove duplicate spaces from a string. + * + * @param string $string Input string that may contain unnecessary spaces (e.g., " -la -lb"). + * @return string The trimmed string with only single spaces (e.g., "-la -lb"). */ -function deduplicate_spaces($string): string +function clean_spaces(string $string): string { return trim(preg_replace('/\s+/', ' ', $string)); }