From 84cbcbfe42132bf757a43ab0ca4b964a6b85641c Mon Sep 17 00:00:00 2001 From: Denis Zubarev Date: Wed, 1 Apr 2026 12:45:55 +0300 Subject: [PATCH 1/2] fix iconv --- runtime-light/k2-platform/k2-api.h | 1 + runtime-light/stdlib/system/system-functions.cpp | 5 +++-- tests/phpt/dl/475_convert_to_win.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime-light/k2-platform/k2-api.h b/runtime-light/k2-platform/k2-api.h index 1bbf21333b..9eb8f2b445 100644 --- a/runtime-light/k2-platform/k2-api.h +++ b/runtime-light/k2-platform/k2-api.h @@ -36,6 +36,7 @@ inline constexpr size_t DEFAULT_MEMORY_ALIGN = 16; } // namespace k2_impl_ inline constexpr int32_t errno_ok = 0; +inline constexpr int32_t errno_e2big = E2BIG; inline constexpr int32_t errno_ebusy = EBUSY; inline constexpr int32_t errno_enodev = ENODEV; inline constexpr int32_t errno_einval = EINVAL; diff --git a/runtime-light/stdlib/system/system-functions.cpp b/runtime-light/stdlib/system/system-functions.cpp index 3b848c5389..48905718c9 100644 --- a/runtime-light/stdlib/system/system-functions.cpp +++ b/runtime-light/stdlib/system/system-functions.cpp @@ -28,8 +28,9 @@ Optional f$iconv(const string& input_encoding, const string& output_enco char* input_buf{const_cast(input_str.c_str())}; char* output_buf{output_str.buffer()}; size_t res{}; - if (k2::iconv(std::addressof(res), cd, std::addressof(input_buf), std::addressof(input_len), std::addressof(output_buf), std::addressof(output_len)) == - k2::errno_ok) { + if (auto iconv_result{ + k2::iconv(std::addressof(res), cd, std::addressof(input_buf), std::addressof(input_len), std::addressof(output_buf), std::addressof(output_len))}; + iconv_result == k2::errno_ok || iconv_result != k2::errno_e2big) { output_str.shrink(static_cast(output_buf - output_str.c_str())); return output_str; } diff --git a/tests/phpt/dl/475_convert_to_win.php b/tests/phpt/dl/475_convert_to_win.php index ac182bfa28..3437bbcb48 100644 --- a/tests/phpt/dl/475_convert_to_win.php +++ b/tests/phpt/dl/475_convert_to_win.php @@ -1,4 +1,4 @@ -@ok benchmark k2_skip +@ok benchmark Date: Wed, 1 Apr 2026 13:03:02 +0300 Subject: [PATCH 2/2] minor fix --- runtime-light/stdlib/system/system-functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime-light/stdlib/system/system-functions.cpp b/runtime-light/stdlib/system/system-functions.cpp index 48905718c9..428d3e9fe4 100644 --- a/runtime-light/stdlib/system/system-functions.cpp +++ b/runtime-light/stdlib/system/system-functions.cpp @@ -30,7 +30,7 @@ Optional f$iconv(const string& input_encoding, const string& output_enco size_t res{}; if (auto iconv_result{ k2::iconv(std::addressof(res), cd, std::addressof(input_buf), std::addressof(input_len), std::addressof(output_buf), std::addressof(output_len))}; - iconv_result == k2::errno_ok || iconv_result != k2::errno_e2big) { + iconv_result != k2::errno_e2big) { output_str.shrink(static_cast(output_buf - output_str.c_str())); return output_str; }