Merge "Fix riscv64 stpcpy()." into main am: f971dc6b4a
am: f2f9d64a0a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2806858 Change-Id: Ib9b4cddded5f2dbd51ebfc4e51af3102de77bf62 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7aec3e086e
2 changed files with 16 additions and 14 deletions
|
@ -83,8 +83,9 @@ L(stpcpy_loop):
|
|||
add pDstPtr, pDstPtr, iCurrentVL
|
||||
bltz iActiveElemPos, L(stpcpy_loop)
|
||||
|
||||
// stpcpy() returns a pointer to the '\0', not the byte after it.
|
||||
addi pDstPtr, pDstPtr, -1
|
||||
// stpcpy() returns a pointer to the '\0' in the destination.
|
||||
sub pDstPtr, pDstPtr, iCurrentVL
|
||||
add pDstPtr, pDstPtr, iActiveElemPos
|
||||
ret
|
||||
END(stpcpy_vext)
|
||||
|
||||
|
|
|
@ -319,33 +319,34 @@ TEST(STRING_TEST, strcpy4) {
|
|||
// one byte target with "\0" source
|
||||
TEST(STRING_TEST, stpcpy2) {
|
||||
char buf[1];
|
||||
memset(buf, 'A', sizeof(buf));
|
||||
char* orig = strdup("");
|
||||
ASSERT_EQ(buf, stpcpy(buf, orig));
|
||||
ASSERT_EQ('\0', buf[0]);
|
||||
EXPECT_EQ(buf, stpcpy(buf, orig));
|
||||
EXPECT_EQ('\0', buf[0]);
|
||||
free(orig);
|
||||
}
|
||||
|
||||
// multibyte target where we under fill target
|
||||
TEST(STRING_TEST, stpcpy3) {
|
||||
char buf[10];
|
||||
char* orig = strdup("12345");
|
||||
memset(buf, 'A', sizeof(buf));
|
||||
ASSERT_EQ(buf+strlen(orig), stpcpy(buf, orig));
|
||||
ASSERT_STREQ("12345", buf);
|
||||
ASSERT_EQ('A', buf[6]);
|
||||
ASSERT_EQ('A', buf[7]);
|
||||
ASSERT_EQ('A', buf[8]);
|
||||
ASSERT_EQ('A', buf[9]);
|
||||
char* orig = strdup("12345");
|
||||
EXPECT_EQ(buf+strlen(orig), stpcpy(buf, orig));
|
||||
EXPECT_STREQ("12345", buf);
|
||||
EXPECT_EQ('A', buf[6]);
|
||||
EXPECT_EQ('A', buf[7]);
|
||||
EXPECT_EQ('A', buf[8]);
|
||||
EXPECT_EQ('A', buf[9]);
|
||||
free(orig);
|
||||
}
|
||||
|
||||
// multibyte target where we fill target exactly
|
||||
TEST(STRING_TEST, stpcpy4) {
|
||||
char buf[10];
|
||||
char* orig = strdup("123456789");
|
||||
memset(buf, 'A', sizeof(buf));
|
||||
ASSERT_EQ(buf+strlen(orig), stpcpy(buf, orig));
|
||||
ASSERT_STREQ("123456789", buf);
|
||||
char* orig = strdup("123456789");
|
||||
EXPECT_EQ(buf+strlen(orig), stpcpy(buf, orig));
|
||||
EXPECT_STREQ("123456789", buf);
|
||||
free(orig);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue