feat(libc): implement wcscat
This commit is contained in:
parent
e99a1b0aa9
commit
cd0e9dccd7
|
|
@ -392,6 +392,11 @@ char16_t* APS5_VABI wcscpy_nid_postfix(char16_t* dest, const char16_t* src) {
|
|||
return dest;
|
||||
}
|
||||
|
||||
char16_t* APS5_VABI wcscat_nid_postfix(char16_t* dest, const char16_t* src) {
|
||||
std::memcpy(dest + Length(dest), src, (Length(src) + 1) * sizeof(char16_t));
|
||||
return dest;
|
||||
}
|
||||
|
||||
char16_t* APS5_VABI wcsncpy_nid_postfix(char16_t* dest, const char16_t* src, size_t n) {
|
||||
size_t index = 0;
|
||||
for (; index < n && src[index] != 0; ++index) dest[index] = src[index];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ std::size_t APS5_VABI wcslen_nid_postfix(const char16_t* s);
|
|||
int APS5_VABI wcscmp_nid_postfix(const char16_t* s1, const char16_t* s2);
|
||||
int APS5_VABI wcsncmp_nid_postfix(const char16_t* s1, const char16_t* s2, std::size_t n);
|
||||
char16_t* APS5_VABI wcscpy_nid_postfix(char16_t* dest, const char16_t* src);
|
||||
char16_t* APS5_VABI wcscat_nid_postfix(char16_t* dest, const char16_t* src);
|
||||
char16_t* APS5_VABI wcsncpy_nid_postfix(char16_t* dest, const char16_t* src, std::size_t n);
|
||||
const char16_t* APS5_VABI wcschr_nid_postfix(const char16_t* s, char16_t c);
|
||||
const char16_t* APS5_VABI wcsrchr_nid_postfix(const char16_t* s, char16_t c);
|
||||
|
|
@ -69,6 +70,14 @@ int main() {
|
|||
require(wcscpy_nid_postfix(buffer, u"wide") == buffer);
|
||||
require(same(buffer, u"wide", 5) && buffer[5] == 0xaaaa);
|
||||
|
||||
char16_t concatenated[8];
|
||||
wmemset_nid_postfix(concatenated, 0xaaaa, 8);
|
||||
concatenated[0] = 0;
|
||||
require(wcscat_nid_postfix(concatenated, u"ab") == concatenated);
|
||||
require(wcscat_nid_postfix(concatenated, u"世") == concatenated);
|
||||
const char16_t expectedConcatenated[] = {u'a', u'b', u'世', 0, 0xaaaa};
|
||||
require(same(concatenated, expectedConcatenated, 5));
|
||||
|
||||
wmemset_nid_postfix(buffer, 0xaaaa, 8);
|
||||
require(wcsncpy_nid_postfix(buffer, u"ab", 5) == buffer);
|
||||
const char16_t padded[] = {u'a', u'b', 0, 0, 0, 0xaaaa};
|
||||
|
|
|
|||
Loading…
Reference in New Issue