-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[libc] Implement wcs to mbs family of functions #149421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
uzairnawaz
wants to merge
10
commits into
llvm:main
Choose a base branch
from
uzairnawaz:wcstombs-functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+958
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- libc/src/__support/wchar/wcsnrtombs.cpp libc/src/__support/wchar/wcsnrtombs.h libc/src/wchar/wcsnrtombs.cpp libc/src/wchar/wcsnrtombs.h libc/src/wchar/wcsrtombs.cpp libc/src/wchar/wcsrtombs.h libc/src/wchar/wcstombs.cpp libc/src/wchar/wcstombs.h libc/test/src/__support/wchar/wcsnrtombs_test.cpp libc/test/src/wchar/wcsnrtombs_test.cpp libc/test/src/wchar/wcsrtombs_test.cpp libc/test/src/wchar/wcstombs_test.cpp View the diff from clang-format here.diff --git a/libc/src/wchar/wcsnrtombs.h b/libc/src/wchar/wcsnrtombs.h
index 793d38366..aef87e9e6 100644
--- a/libc/src/wchar/wcsnrtombs.h
+++ b/libc/src/wchar/wcsnrtombs.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for wcsnrtombs -------------------------------===//
+//===-- Implementation header for wcsnrtombs
+//-------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,7 +17,8 @@
namespace LIBC_NAMESPACE_DECL {
-size_t wcsnrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t nwc, size_t len, mbstate_t* ps);
+size_t wcsnrtombs(char *__restrict s, const wchar_t **__restrict pwcs,
+ size_t nwc, size_t len, mbstate_t *ps);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wchar/wcsrtombs.h b/libc/src/wchar/wcsrtombs.h
index af69fccdb..6a426925e 100644
--- a/libc/src/wchar/wcsrtombs.h
+++ b/libc/src/wchar/wcsrtombs.h
@@ -1,4 +1,5 @@
-//===-- Implementation header for wcsrtombs --------------------------------===//
+//===-- Implementation header for wcsrtombs
+//--------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,7 +17,8 @@
namespace LIBC_NAMESPACE_DECL {
-size_t wcsrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t n, mbstate_t* ps);
+size_t wcsrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t n,
+ mbstate_t *ps);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/__support/wchar/wcsnrtombs_test.cpp b/libc/test/src/__support/wchar/wcsnrtombs_test.cpp
index 710fc4b56..d8f523c6d 100644
--- a/libc/test/src/__support/wchar/wcsnrtombs_test.cpp
+++ b/libc/test/src/__support/wchar/wcsnrtombs_test.cpp
@@ -110,7 +110,8 @@ TEST(LlvmLibcWcsnrtombs, SrcLimit) {
ASSERT_EQ(mbs[6], '\x91');
ASSERT_EQ(mbs[7], '\x01');
- res = LIBC_NAMESPACE::internal::wcsnrtombs(mbs + res.value(), &cur, 100, 11, &state);
+ res = LIBC_NAMESPACE::internal::wcsnrtombs(mbs + res.value(), &cur, 100, 11,
+ &state);
ASSERT_TRUE(res.has_value());
ASSERT_EQ(res.value(), static_cast<size_t>(3));
ASSERT_EQ(cur, nullptr);
diff --git a/libc/test/src/wchar/wcstombs_test.cpp b/libc/test/src/wchar/wcstombs_test.cpp
index 397ce0460..61e0873dc 100644
--- a/libc/test/src/wchar/wcstombs_test.cpp
+++ b/libc/test/src/wchar/wcstombs_test.cpp
@@ -79,7 +79,6 @@ TEST_F(LlvmLibcWcstombs, ErrnoTest) {
// n parameter ignored when dest is null
ASSERT_EQ(LIBC_NAMESPACE::wcstombs(mbs, src, 7), static_cast<size_t>(7));
ASSERT_ERRNO_SUCCESS();
- ASSERT_EQ(LIBC_NAMESPACE::wcstombs(mbs, src, 100),
- static_cast<size_t>(-1));
+ ASSERT_EQ(LIBC_NAMESPACE::wcstombs(mbs, src, 100), static_cast<size_t>(-1));
ASSERT_ERRNO_EQ(EILSEQ);
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented internal wcs to mbs internal function + tests
Impelemented wcs to mbs public functions