mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 06:45:39 +08:00
fix(xlswriter): convert K&R function declaration to ANSI C in bundled minizip
The bundled minizip in xlswriter (pinned at libxlsxwriter RELEASE_1.0.0) uses a K&R-style function declaration in mztools.c. Modern Clang on macOS (defaulting to C23) rejects this as a hard syntax error since K&R declarations were removed from the C23 standard. The upstream libxlsxwriter has already fixed this on their main branch. This patch applies the same fix during the build process. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -28,6 +29,18 @@ class xlswriter extends Extension
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
$patched = parent::patchBeforeMake();
|
||||
|
||||
// Fix K&R C function declaration in bundled minizip rejected by modern Clang (C23 default)
|
||||
$mztools = $this->source_dir . '/library/libxlsxwriter/third_party/minizip/mztools.c';
|
||||
if (file_exists($mztools)) {
|
||||
FileSystem::replaceFileStr(
|
||||
$mztools,
|
||||
"extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)\nconst char* file;\nconst char* fileOut;\nconst char* fileOutTmp;\nuLong* nRecovered;\nuLong* bytesRecovered;\n{",
|
||||
"extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered)\n{"
|
||||
);
|
||||
$patched = true;
|
||||
}
|
||||
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
// fix windows build with openssl extension duplicate symbol bug
|
||||
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
|
||||
|
||||
Reference in New Issue
Block a user