[libc-commits] [libc] [libc] Refactored internal wcrtomb function (PR #145923)
via libc-commits
libc-commits at lists.llvm.org
Thu Jun 26 09:38:02 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- libc/test/src/__support/wchar/wcrtomb_bounded_test.cpp libc/src/wchar/wcrtomb.cpp libc/src/wchar/wctomb.cpp libc/src/__support/wchar/wcrtomb_bounded.cpp libc/src/__support/wchar/wcrtomb_bounded.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/wchar/wctomb.cpp b/libc/src/wchar/wctomb.cpp
index 1f4babecf..2b2c67f4d 100644
--- a/libc/src/wchar/wctomb.cpp
+++ b/libc/src/wchar/wctomb.cpp
@@ -22,7 +22,8 @@ LLVM_LIBC_FUNCTION(int, wctomb, (char *s, wchar_t wc)) {
if (s == nullptr)
return 0;
- auto result = internal::wcrtomb_bounded(s, wc, &internal_mbstate, sizeof(wchar_t));
+ auto result =
+ internal::wcrtomb_bounded(s, wc, &internal_mbstate, sizeof(wchar_t));
if (!result.has_value()) { // invalid wide character
libc_errno = EILSEQ;
diff --git a/libc/test/src/__support/wchar/wcrtomb_bounded_test.cpp b/libc/test/src/__support/wchar/wcrtomb_bounded_test.cpp
index d191f4d3b..8ba5cfb11 100644
--- a/libc/test/src/__support/wchar/wcrtomb_bounded_test.cpp
+++ b/libc/test/src/__support/wchar/wcrtomb_bounded_test.cpp
@@ -6,13 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#include "hdr/types/wchar_t.h"
#include "hdr/errno_macros.h"
+#include "hdr/types/wchar_t.h"
#include "src/__support/wchar/mbstate.h"
#include "src/__support/wchar/wcrtomb_bounded.h"
#include "test/UnitTest/Test.h"
-// The majority of the following tests are the same as tests/src/wchar/wcrtomb_test.cpp
+// The majority of the following tests are the same as
+// tests/src/wchar/wcrtomb_test.cpp
TEST(LlvmLibcWCRToMBBoundedTest, OneByte) {
LIBC_NAMESPACE::internal::mbstate state;
@@ -103,13 +104,15 @@ TEST(LlvmLibcWCRToMBBoundedTest, ContinueConversion) {
char mb[5] = {'\x01', '\x01', '\x01', '\x01', '\x01'};
auto result = LIBC_NAMESPACE::internal::wcrtomb_bounded(mb, wc, &state, 1);
ASSERT_TRUE(result.has_value());
- ASSERT_EQ(result.value(), static_cast<size_t>(-1)); // conversion not completed
+ ASSERT_EQ(result.value(),
+ static_cast<size_t>(-1)); // conversion not completed
ASSERT_EQ(mb[0], '\xF0');
ASSERT_EQ(mb[1], '\x01');
result = LIBC_NAMESPACE::internal::wcrtomb_bounded(mb + 1, wc, &state, 2);
ASSERT_TRUE(result.has_value());
- ASSERT_EQ(result.value(), static_cast<size_t>(-1)); // conversion not completed
+ ASSERT_EQ(result.value(),
+ static_cast<size_t>(-1)); // conversion not completed
ASSERT_EQ(mb[0], '\xF0');
ASSERT_EQ(mb[1], '\x9F');
ASSERT_EQ(mb[2], '\xA4');
``````````
</details>
https://github.com/llvm/llvm-project/pull/145923
More information about the libc-commits
mailing list