From 2e13be2a7aded02e93f802ab58d9619fb3e28030 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 21 Oct 2025 13:54:34 +0200 Subject: [PATCH 1/3] prevent libedit from building strlcat/strlcpy, no idea why their soure code doesn't prevent this correctly itself --- src/SPC/builder/unix/library/libedit.php | 17 ++++++++++++++--- src/SPC/store/SourcePatcher.php | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/libedit.php b/src/SPC/builder/unix/library/libedit.php index e436ee8b..39e14bf7 100644 --- a/src/SPC/builder/unix/library/libedit.php +++ b/src/SPC/builder/unix/library/libedit.php @@ -4,16 +4,27 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; trait libedit { protected function build(): void { - UnixAutoconfExecutor::create($this) + $make = UnixAutoconfExecutor::create($this) ->appendEnv(['CFLAGS' => '-D__STDC_ISO_10646__=201103L']) - ->configure() - ->make(); + ->configure(); + + foreach (['strlcpy', 'strlcat', 'fgetln'] as $symbol) { + $usymbol = strtoupper($symbol); + FileSystem::replaceFileLineContainsString( + $this->source_dir . '/config.h', + "/* #undef HAVE_{$usymbol} */", + "/* #undef HAVE_{$usymbol} */\n#define {$symbol} libedit_{$symbol}" + ); + } + + $make->make(); $this->patchPkgconfPrefix(['libedit.pc']); } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c08204f5..c7738e92 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -44,7 +44,7 @@ class SourcePatcher } foreach ($builder->getLibs() as $lib) { if ($lib->patchBeforeBuildconf() === true) { - logger()->info("Library [{$lib->getName()}]patched before buildconf"); + logger()->info("Library [{$lib->getName()}] patched before buildconf"); } } // patch windows php 8.1 bug From 4e393886aa1835ddcb58346c5c6736d802d8e891 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 21 Oct 2025 14:23:55 +0200 Subject: [PATCH 2/3] no idea why our source has that uncommented --- src/SPC/builder/unix/library/libedit.php | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SPC/builder/unix/library/libedit.php b/src/SPC/builder/unix/library/libedit.php index 39e14bf7..f2bcd6e5 100644 --- a/src/SPC/builder/unix/library/libedit.php +++ b/src/SPC/builder/unix/library/libedit.php @@ -9,22 +9,22 @@ use SPC\util\executor\UnixAutoconfExecutor; trait libedit { + public function patchBeforeBuild(): bool + { + FileSystem::replaceFileStr( + $this->source_dir . '/src/sys.h', + '//#define strl', + '#define strl' + ); + return true; + } + protected function build(): void { - $make = UnixAutoconfExecutor::create($this) + UnixAutoconfExecutor::create($this) ->appendEnv(['CFLAGS' => '-D__STDC_ISO_10646__=201103L']) - ->configure(); - - foreach (['strlcpy', 'strlcat', 'fgetln'] as $symbol) { - $usymbol = strtoupper($symbol); - FileSystem::replaceFileLineContainsString( - $this->source_dir . '/config.h', - "/* #undef HAVE_{$usymbol} */", - "/* #undef HAVE_{$usymbol} */\n#define {$symbol} libedit_{$symbol}" - ); - } - - $make->make(); + ->configure() + ->make(); $this->patchPkgconfPrefix(['libedit.pc']); } } From 96592bce3ef5b02cffd3d8282c254f920a2bd609 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 21 Oct 2025 14:26:44 +0200 Subject: [PATCH 3/3] fix --- src/SPC/builder/unix/library/libedit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/libedit.php b/src/SPC/builder/unix/library/libedit.php index f2bcd6e5..2de9077f 100644 --- a/src/SPC/builder/unix/library/libedit.php +++ b/src/SPC/builder/unix/library/libedit.php @@ -11,9 +11,9 @@ trait libedit { public function patchBeforeBuild(): bool { - FileSystem::replaceFileStr( + FileSystem::replaceFileRegex( $this->source_dir . '/src/sys.h', - '//#define strl', + '|//#define\s+strl|', '#define strl' ); return true;