Fix riscv64 stpcpy().
We were copying the data fine, but the return value was one vector
length too far (but also not taking into account the actual number of
bytes in the last transfer).
Also move the stpcpy() tests to EXPECT_EQ() so we get all the details
of the failure at once.
Test: treehugger
Change-Id: I76bf02c8a31f40722acb7c9fd8e301d50e405bf8
diff --git a/libc/arch-riscv64/string/stpcpy_vext.S b/libc/arch-riscv64/string/stpcpy_vext.S
index 3096e76..e089938 100644
--- a/libc/arch-riscv64/string/stpcpy_vext.S
+++ b/libc/arch-riscv64/string/stpcpy_vext.S
@@ -83,8 +83,9 @@
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)