Skip to content

Commit 77d9591

Browse files
Revert "Fix wcpncpy() return value; add test." (#146752)
This reverts commit 988876c. Was intended to be a PR
1 parent 988876c commit 77d9591

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

libc/src/wchar/wcpncpy.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ LLVM_LIBC_FUNCTION(wchar_t *, wcpncpy,
2828
for (i = 0; i < n && s2[i] != '\0'; ++i)
2929
s1[i] = s2[i];
3030
// When n>strlen(src), n-strlen(src) \0 are appended.
31-
for (size_t j = i; j < n; ++j)
32-
s1[j] = L'\0';
33-
// ...but our result points to the first \0 (if any).
31+
for (; i < n; ++i)
32+
s1[i] = L'\0';
3433
return s1 + i;
3534
}
3635

libc/test/src/wchar/wcpncpy_test.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ TEST(LlvmLibcWCPNCpyTest, CopyTwoWithNull) {
7575
ASSERT_EQ(dest + 2, res);
7676
}
7777

78-
TEST(LlvmLibcWCPNCpyTest, CopyAndFill) {
79-
wchar_t dest[] = {L'a', L'b', L'c'};
80-
wchar_t *res = LIBC_NAMESPACE::wcpncpy(dest, L"x", 3);
81-
ASSERT_TRUE(dest[0] == L'x');
82-
ASSERT_TRUE(dest[1] == L'\0');
83-
ASSERT_TRUE(dest[2] == L'\0');
84-
ASSERT_EQ(dest + 1, res);
85-
}
86-
8778
#if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER)
8879
TEST(LlvmLibcWCPNCpyTest, NullptrCrash) {
8980
// Passing in a nullptr should crash the program.

0 commit comments

Comments
 (0)