[haiku-commits] haiku: hrev43641 - src/tests/system/libroot/posix src/system/libroot/posix/glibc/wcsmbs src/system/libroot/posix/glibc/string src/system/libroot/posix/wchar headers/posix

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 7 Jan 2012 22:03:59 +0100 (CET)

hrev43641 adds 6 changesets to branch 'master'
old head: 1b93a2e630c15d68443f288aa55bdd2d55f129f5
new head: 174676503b2c345653f73de4915e8b247961a81a

----------------------------------------------------------------------------

bd55dcb: Add our implementation for wcscoll() and wcsxfrm().
      
  * add Wcscoll() and Wcsxfrm() ICU locale backend
  * provide implementations of wcscoll() and wcsxfrm() that are using
    the respective methods of the locale backend
        

d796551: Cleanup: LocaleBackend.h is not a local header for wchar.

d8ef8ef: Add wcs_test, a testsuite for all wchar-related functions.

7efc2e3: Add our own implementations for all wchar.h functions.
      
  * add implementation for wcpcpy(), wcpncpy(), wcscasecmp(), wcscat(),
    wcschr(), wcscmp(), wcscpy(), wcscspn(), wcsdup(), wcslcat(),
    wcslcpy(), wcslen(), wcsncasecmp(), wcsncat(), wcsncmp(), wcsncpy(),
    wcsnlen(), wcspbrk(), wcsrchr(), wcsspn(), wcsstr(), wcstok(),
    wmemchr(), wmemcmp(), wmemcpy(), wmemmove(), wmemset
  * add implementations for GNU-extensions used by our glibc and some
    other programs/libs: wcschrnul(), wmempcpy()
  * add stub for wcsftime()

b7417fb: Switch wchar from glibc to our own implementations.

1746765: Drop now unneeded glibc wchar-files (plus others).

                                    [ Oliver Tappe <zooey@xxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

89 files changed, 5021 insertions(+), 3413 deletions(-)
headers/posix/wchar.h                              |  163 +-
headers/private/libroot/locale/ICUCollateData.h    |    4 +
headers/private/libroot/locale/ICULocaleBackend.h  |    4 +
headers/private/libroot/locale/LocaleBackend.h     |    4 +
headers/private/libroot/wchar_private.h            |  116 +-
src/system/libroot/add-ons/icu/ICUCollateData.cpp  |   72 +-
.../libroot/add-ons/icu/ICULocaleBackend.cpp       |   19 +
.../libroot/add-ons/icu/ICUTimeConversion.cpp      |    2 -
src/system/libroot/posix/glibc/string/strcoll.c    |  556 ---
src/system/libroot/posix/glibc/string/strxfrm.c    |  466 --
src/system/libroot/posix/glibc/wcsmbs/Jamfile      |   30 -
src/system/libroot/posix/glibc/wcsmbs/Makefile     |   68 -
src/system/libroot/posix/glibc/wcsmbs/wchar.h      |  303 --
src/system/libroot/posix/glibc/wcsmbs/wcpcpy.c     |   47 -
src/system/libroot/posix/glibc/wcsmbs/wcpncpy.c    |   89 -
src/system/libroot/posix/glibc/wcsmbs/wcscasecmp.c |   73 -
.../libroot/posix/glibc/wcsmbs/wcscasecmp_l.c      |   24 -
src/system/libroot/posix/glibc/wcsmbs/wcscat.c     |   51 -
src/system/libroot/posix/glibc/wcsmbs/wcschr.c     |   35 -
src/system/libroot/posix/glibc/wcsmbs/wcschrnul.c  |   36 -
src/system/libroot/posix/glibc/wcsmbs/wcscmp.c     |   44 -
src/system/libroot/posix/glibc/wcsmbs/wcscoll.c    |   41 -
src/system/libroot/posix/glibc/wcsmbs/wcscoll_l.c  |   23 -
src/system/libroot/posix/glibc/wcsmbs/wcscpy.c     |   59 -
src/system/libroot/posix/glibc/wcsmbs/wcscspn.c    |   39 -
src/system/libroot/posix/glibc/wcsmbs/wcsdup.c     |   37 -
src/system/libroot/posix/glibc/wcsmbs/wcslen.c     |   43 -
.../libroot/posix/glibc/wcsmbs/wcsmbs-tst1.c       |   59 -
src/system/libroot/posix/glibc/wcsmbs/wcsncase.c   |   76 -
src/system/libroot/posix/glibc/wcsmbs/wcsncase_l.c |   24 -
src/system/libroot/posix/glibc/wcsmbs/wcsncat.c    |   80 -
src/system/libroot/posix/glibc/wcsmbs/wcsncmp.c    |   71 -
src/system/libroot/posix/glibc/wcsmbs/wcsncpy.c    |   86 -
src/system/libroot/posix/glibc/wcsmbs/wcsnlen.c    |   45 -
src/system/libroot/posix/glibc/wcsmbs/wcspbrk.c    |   37 -
src/system/libroot/posix/glibc/wcsmbs/wcsrchr.c    |   37 -
src/system/libroot/posix/glibc/wcsmbs/wcsspn.c     |   47 -
src/system/libroot/posix/glibc/wcsmbs/wcsstr.c     |  100 -
src/system/libroot/posix/glibc/wcsmbs/wcstod_l.c   |   35 -
src/system/libroot/posix/glibc/wcsmbs/wcstof_l.c   |   35 -
src/system/libroot/posix/glibc/wcsmbs/wcstok.c     |   66 -
src/system/libroot/posix/glibc/wcsmbs/wcstold_l.c  |   56 -
src/system/libroot/posix/glibc/wcsmbs/wcsxfrm.c    |   38 -
src/system/libroot/posix/glibc/wcsmbs/wcsxfrm_l.c  |   23 -
src/system/libroot/posix/glibc/wcsmbs/wmemchr.c    |   63 -
src/system/libroot/posix/glibc/wcsmbs/wmemcmp.c    |   84 -
src/system/libroot/posix/glibc/wcsmbs/wmemcpy.c    |   32 -
src/system/libroot/posix/glibc/wcsmbs/wmemmove.c   |   32 -
src/system/libroot/posix/glibc/wcsmbs/wmempcpy.c   |   33 -
src/system/libroot/posix/glibc/wcsmbs/wmemset.c    |   56 -
src/system/libroot/posix/wchar/Jamfile             |   32 +
src/system/libroot/posix/wchar/mbrtowc.cpp         |    2 +-
src/system/libroot/posix/wchar/mbsrtowcs.cpp       |    7 +-
src/system/libroot/posix/wchar/wcpcpy.c            |   20 +
src/system/libroot/posix/wchar/wcpncpy.c           |   27 +
src/system/libroot/posix/wchar/wcrtomb.cpp         |    2 +-
src/system/libroot/posix/wchar/wcscasecmp.c        |   29 +
src/system/libroot/posix/wchar/wcscat.c            |   23 +
src/system/libroot/posix/wchar/wcschr.c            |   23 +
src/system/libroot/posix/wchar/wcschrnul.c         |   19 +
src/system/libroot/posix/wchar/wcscmp.c            |   27 +
src/system/libroot/posix/wchar/wcscoll.cpp         |   32 +
src/system/libroot/posix/wchar/wcscpy.c            |   21 +
src/system/libroot/posix/wchar/wcscspn.c           |   25 +
src/system/libroot/posix/wchar/wcsdup.c            |   34 +
src/system/libroot/posix/wchar/wcsftime.cpp        |   20 +
src/system/libroot/posix/wchar/wcslcat.c           |   41 +
src/system/libroot/posix/wchar/wcslcpy.c           |   27 +
src/system/libroot/posix/wchar/wcslen.c            |   21 +
src/system/libroot/posix/wchar/wcsncasecmp.c       |   29 +
src/system/libroot/posix/wchar/wcsncat.c           |   25 +
src/system/libroot/posix/wchar/wcsncmp.c           |   27 +
src/system/libroot/posix/wchar/wcsncpy.c           |   25 +
src/system/libroot/posix/wchar/wcsnlen.c           |   21 +
src/system/libroot/posix/wchar/wcspbrk.c           |   24 +
src/system/libroot/posix/wchar/wcsrchr.c           |   22 +
src/system/libroot/posix/wchar/wcsrtombs.cpp       |    8 +-
src/system/libroot/posix/wchar/wcsspn.c            |   28 +
src/system/libroot/posix/wchar/wcsstr.c            |   29 +
src/system/libroot/posix/wchar/wcstok.c            |   40 +
src/system/libroot/posix/wchar/wcsxfrm.cpp         |   34 +
src/system/libroot/posix/wchar/wmemchr.c           |   22 +
src/system/libroot/posix/wchar/wmemcmp.c           |   25 +
src/system/libroot/posix/wchar/wmemcpy.c           |   18 +
src/system/libroot/posix/wchar/wmemmove.c          |   18 +
src/system/libroot/posix/wchar/wmempcpy.c          |   20 +
src/system/libroot/posix/wchar/wmemset.c           |   20 +
src/tests/system/libroot/posix/Jamfile             |    1 +
src/tests/system/libroot/posix/wcs_test.cpp        | 3903 ++++++++++++++++

############################################################################

Commit:      bd55dcbefbf303b990bbc118370f2325fe064cc2
URL:         http://cgit.haiku-os.org/haiku/commit/?id=bd55dcb
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 20:47:31 2012 UTC

Add our implementation for wcscoll() and wcsxfrm().
    
* add Wcscoll() and Wcsxfrm() ICU locale backend
* provide implementations of wcscoll() and wcsxfrm() that are using
  the respective methods of the locale backend
        

----------------------------------------------------------------------------

diff --git a/headers/private/libroot/locale/ICUCollateData.h 
b/headers/private/libroot/locale/ICUCollateData.h
index 3b6707e..7d73267 100644
--- a/headers/private/libroot/locale/ICUCollateData.h
+++ b/headers/private/libroot/locale/ICUCollateData.h
@@ -29,6 +29,10 @@ public:
                        status_t                        Strcoll(const char* a, 
const char* b, int& out);
                        status_t                        Strxfrm(char* out, 
const char* in, size_t size,
                                                                        size_t& 
outSize);
+                       status_t                        Wcscoll(const wchar_t* 
a, const wchar_t* b,
+                                                                       int& 
out);
+                       status_t                        Wcsxfrm(wchar_t* out, 
const wchar_t* in,
+                                                                       size_t 
size, size_t& outSize);
 
 private:
                        status_t                        _ToUnicodeString(const 
char* in,
diff --git a/headers/private/libroot/locale/ICULocaleBackend.h 
b/headers/private/libroot/locale/ICULocaleBackend.h
index 4d18db3..4b9f22d 100644
--- a/headers/private/libroot/locale/ICULocaleBackend.h
+++ b/headers/private/libroot/locale/ICULocaleBackend.h
@@ -61,6 +61,10 @@ public:
        virtual status_t                        Strcoll(const char* a, const 
char* b, int& out);
        virtual status_t                        Strxfrm(char* out, const char* 
in, size_t size,
                                                                        size_t& 
outSize);
+       virtual status_t                        Wcscoll(const wchar_t* a, const 
wchar_t* b,
+                                                                       int& 
out);
+       virtual status_t                        Wcsxfrm(wchar_t* out, const 
wchar_t* in,
+                                                                       size_t 
size, size_t& outSize);
 
        virtual status_t                        TZSet(const char* timeZoneID, 
const char* tz);
        virtual status_t                        Localtime(const time_t* inTime,
diff --git a/headers/private/libroot/locale/LocaleBackend.h 
b/headers/private/libroot/locale/LocaleBackend.h
index 8f5fdc8..670253c 100644
--- a/headers/private/libroot/locale/LocaleBackend.h
+++ b/headers/private/libroot/locale/LocaleBackend.h
@@ -144,6 +144,10 @@ public:
                                                                        int& 
out) = 0;
        virtual status_t                        Strxfrm(char* out, const char* 
in, size_t size,
                                                                        size_t& 
outSize) = 0;
+       virtual status_t                        Wcscoll(const wchar_t* a, const 
wchar_t* b,
+                                                                       int& 
out) = 0;
+       virtual status_t                        Wcsxfrm(wchar_t* out, const 
wchar_t* in,
+                                                                       size_t 
size, size_t& outSize) = 0;
 
        virtual status_t                        TZSet(const char* timeZoneID,
                                                                        const 
char* tz) = 0;
diff --git a/src/system/libroot/add-ons/icu/ICUCollateData.cpp 
b/src/system/libroot/add-ons/icu/ICUCollateData.cpp
index 70e88e4..d2ab5d5 100644
--- a/src/system/libroot/add-ons/icu/ICUCollateData.cpp
+++ b/src/system/libroot/add-ons/icu/ICUCollateData.cpp
@@ -7,9 +7,12 @@
 #include "ICUCollateData.h"
 
 #include <string.h>
+#include <wchar.h>
 
 #include <unicode/unistr.h>
 
+#include <AutoDeleter.h>
+
 
 namespace BPrivate {
 namespace Libroot {
@@ -63,7 +66,7 @@ ICUCollateData::SetToPosix()
 status_t
 ICUCollateData::Strcoll(const char* a, const char* b, int& result)
 {
-       if (strcmp(fPosixLocaleName, "POSIX") == 0) {
+       if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) {
                // handle POSIX here as the collator ICU uses for that 
(english) is
                // incompatible in too many ways
                result = strcmp(a, b);
@@ -109,7 +112,7 @@ ICUCollateData::Strcoll(const char* a, const char* b, int& 
result)
 status_t
 ICUCollateData::Strxfrm(char* out, const char* in, size_t size, size_t& 
outSize)
 {
-       if (strcmp(fPosixLocaleName, "POSIX") == 0) {
+       if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) {
                // handle POSIX here as the collator ICU uses for that 
(english) is
                // incompatible in too many ways
                outSize = strlcpy(out, in, size);
@@ -125,13 +128,40 @@ ICUCollateData::Strxfrm(char* out, const char* in, size_t 
size, size_t& outSize)
                return B_OK;
        }
 
-       UErrorCode icuStatus = U_ZERO_ERROR;
-
        UnicodeString unicodeIn;
        if (_ToUnicodeString(in, unicodeIn) != B_OK)
                return B_BAD_VALUE;
 
        outSize = fCollator->getSortKey(unicodeIn, (uint8_t*)out, size);
+
+       return B_OK;
+}
+
+
+status_t
+ICUCollateData::Wcscoll(const wchar_t* a, const wchar_t* b, int& result)
+{
+       if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) {
+               // handle POSIX here as the collator ICU uses for that 
(english) is
+               // incompatible in too many ways
+               result = wcscmp(a, b);
+               for (const wchar_t* aIter = a; *aIter != 0; ++aIter) {
+                       if (*aIter > 127)
+                               return B_BAD_VALUE;
+               }
+               for (const wchar_t* bIter = b; *bIter != 0; ++bIter) {
+                       if (*bIter > 127)
+                               return B_BAD_VALUE;
+               }
+               return B_OK;
+       }
+
+       UnicodeString unicodeA = UnicodeString::fromUTF32((UChar32*)a, -1);
+       UnicodeString unicodeB = UnicodeString::fromUTF32((UChar32*)b, -1);
+
+       UErrorCode icuStatus = U_ZERO_ERROR;
+       result = fCollator->compare(unicodeA, unicodeB, icuStatus);
+
        if (!U_SUCCESS(icuStatus))
                return B_BAD_VALUE;
 
@@ -140,6 +170,40 @@ ICUCollateData::Strxfrm(char* out, const char* in, size_t 
size, size_t& outSize)
 
 
 status_t
+ICUCollateData::Wcsxfrm(wchar_t* out, const wchar_t* in, size_t size,
+       size_t& outSize)
+{
+       if (in == NULL) {
+               outSize = 0;
+               return B_OK;
+       }
+
+       if (fCollator == NULL || strcmp(fPosixLocaleName, "POSIX") == 0) {
+               // handle POSIX here as the collator ICU uses for that 
(english) is
+               // incompatible in too many ways
+               outSize = wcslcpy(out, in, size);
+               for (const wchar_t* inIter = in; *inIter != 0; ++inIter) {
+                       if (*inIter > 127)
+                               return B_BAD_VALUE;
+               }
+               return B_OK;
+       }
+
+       UnicodeString unicodeIn = UnicodeString::fromUTF32((UChar32*)in, -1);
+       size_t requiredSize = fCollator->getSortKey(unicodeIn, NULL, 0);
+
+       uint8_t* buffer = (uint8_t*)out;
+       outSize = fCollator->getSortKey(unicodeIn, buffer, requiredSize);
+
+       // convert 1-byte characters to 4-byte wide characters:
+       for (size_t i = 0; i < outSize; ++i)
+               out[outSize - 1 - i] = buffer[outSize - 1 - i];
+
+       return B_OK;
+}
+
+
+status_t
 ICUCollateData::_ToUnicodeString(const char* in, UnicodeString& out)
 {
        out.remove();
diff --git a/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp 
b/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp
index 89d6f14..ca90785 100644
--- a/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp
+++ b/src/system/libroot/add-ons/icu/ICULocaleBackend.cpp
@@ -295,6 +295,25 @@ ICULocaleBackend::Strxfrm(char* out, const char* in, 
size_t size,
 
 
 status_t
+ICULocaleBackend::Wcscoll(const wchar_t* a, const wchar_t* b, int& result)
+{
+       ErrnoMaintainer errnoMaintainer;
+
+       return fCollateData.Wcscoll(a, b, result);
+}
+
+
+status_t
+ICULocaleBackend::Wcsxfrm(wchar_t* out, const wchar_t* in, size_t size,
+       size_t& outSize)
+{
+       ErrnoMaintainer errnoMaintainer;
+
+       return fCollateData.Wcsxfrm(out, in, size, outSize);
+}
+
+
+status_t
 ICULocaleBackend::TZSet(const char* timeZoneID, const char* tz)
 {
        ErrnoMaintainer errnoMaintainer;
diff --git a/src/system/libroot/add-ons/icu/ICUTimeConversion.cpp 
b/src/system/libroot/add-ons/icu/ICUTimeConversion.cpp
index a676033..64a3db8 100644
--- a/src/system/libroot/add-ons/icu/ICUTimeConversion.cpp
+++ b/src/system/libroot/add-ons/icu/ICUTimeConversion.cpp
@@ -11,8 +11,6 @@
 
 #include <unicode/gregocal.h>
 
-#include <AutoDeleter.h>
-
 
 namespace BPrivate {
 namespace Libroot {
diff --git a/src/system/libroot/posix/wchar/wcscoll.cpp 
b/src/system/libroot/posix/wchar/wcscoll.cpp
new file mode 100644
index 0000000..0623efe
--- /dev/null
+++ b/src/system/libroot/posix/wchar/wcscoll.cpp
@@ -0,0 +1,32 @@
+/*
+** Copyright 2011, Oliver Tappe, zooey@xxxxxxxxxxxxxxxx All rights reserved.
+** Distributed under the terms of the Haiku License.
+*/
+
+#include <errno_private.h>
+#include <LocaleBackend.h>
+#include <wchar_private.h>
+
+
+using BPrivate::Libroot::gLocaleBackend;
+
+
+extern "C" int
+__wcscoll(const wchar_t* wcs1, const wchar_t* wcs2)
+{
+       if (gLocaleBackend != NULL) {
+               int result = 0;
+               status_t status = gLocaleBackend->Wcscoll(wcs1, wcs2, result);
+
+               if (status != B_OK)
+                       __set_errno(EINVAL);
+
+               return result;
+       }
+
+       return wcscmp(wcs1, wcs2);
+}
+
+
+extern "C"
+B_DEFINE_WEAK_ALIAS(__wcscoll, wcscoll);
diff --git a/src/system/libroot/posix/wchar/wcsxfrm.cpp 
b/src/system/libroot/posix/wchar/wcsxfrm.cpp
new file mode 100644
index 0000000..5843349
--- /dev/null
+++ b/src/system/libroot/posix/wchar/wcsxfrm.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Oliver Tappe, zooey@xxxxxxxxxxxxxxxx
+ * All rights reserved. Distributed under the terms of the MIT license.
+ */
+
+#include <errno.h>
+
+#include <errno_private.h>
+#include <LocaleBackend.h>
+#include <wchar_private.h>
+
+
+using BPrivate::Libroot::gLocaleBackend;
+
+
+extern "C" size_t
+__wcsxfrm(wchar_t* dest, const wchar_t* src, size_t destSize)
+{
+       if (gLocaleBackend != NULL) {
+               size_t outSize = 0;
+               status_t status = gLocaleBackend->Wcsxfrm(dest, src, destSize, 
outSize);
+
+               if (status != B_OK)
+                       __set_errno(EINVAL);
+
+               return outSize;
+       }
+
+       return wcslcpy(dest, src, destSize);
+}
+
+
+extern "C"
+B_DEFINE_WEAK_ALIAS(__wcsxfrm, wcsxfrm);

############################################################################

Commit:      d7965519f2ecef3d7653e3531a39ec3cf62951ef
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d796551
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 20:48:39 2012 UTC

Cleanup: LocaleBackend.h is not a local header for wchar.

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/wchar/mbrtowc.cpp 
b/src/system/libroot/posix/wchar/mbrtowc.cpp
index f79712c..df27894 100644
--- a/src/system/libroot/posix/wchar/mbrtowc.cpp
+++ b/src/system/libroot/posix/wchar/mbrtowc.cpp
@@ -8,7 +8,7 @@
 #include <wchar.h>
 
 #include <errno_private.h>
-#include "LocaleBackend.h"
+#include <LocaleBackend.h>
 
 
 //#define TRACE_MBRTOWC
diff --git a/src/system/libroot/posix/wchar/mbsrtowcs.cpp 
b/src/system/libroot/posix/wchar/mbsrtowcs.cpp
index 63bda43..09d5b13 100644
--- a/src/system/libroot/posix/wchar/mbsrtowcs.cpp
+++ b/src/system/libroot/posix/wchar/mbsrtowcs.cpp
@@ -8,7 +8,7 @@
 #include <wchar.h>
 
 #include <errno_private.h>
-#include "LocaleBackend.h"
+#include <LocaleBackend.h>
 
 
 //#define TRACE_MBSRTOWCS
@@ -101,9 +101,8 @@ __mbsnrtowcs(wchar_t* dst, const char** src, size_t nmc, 
size_t len,
 }
 
 
-// deactivated, as mbsnrtowcs() isn't publically available yet.
-//extern "C"
-//B_DEFINE_WEAK_ALIAS(__mbsnrtowcs, mbsnrtowcs);
+extern "C"
+B_DEFINE_WEAK_ALIAS(__mbsnrtowcs, mbsnrtowcs);
 
 
 extern "C" size_t
diff --git a/src/system/libroot/posix/wchar/wcrtomb.cpp 
b/src/system/libroot/posix/wchar/wcrtomb.cpp
index 1837868..59f669e 100644
--- a/src/system/libroot/posix/wchar/wcrtomb.cpp
+++ b/src/system/libroot/posix/wchar/wcrtomb.cpp
@@ -8,7 +8,7 @@
 #include <wchar.h>
 
 #include <errno_private.h>
-#include "LocaleBackend.h"
+#include <LocaleBackend.h>
 
 
 //#define TRACE_WCRTOMB
diff --git a/src/system/libroot/posix/wchar/wcsrtombs.cpp 
b/src/system/libroot/posix/wchar/wcsrtombs.cpp
index cccd254..69e38de 100644
--- a/src/system/libroot/posix/wchar/wcsrtombs.cpp
+++ b/src/system/libroot/posix/wchar/wcsrtombs.cpp
@@ -8,10 +8,9 @@
 #include <wchar.h>
 
 #include <errno_private.h>
+#include <LocaleBackend.h>
 #include <wchar_private.h>
 
-#include "LocaleBackend.h"
-
 
 //#define TRACE_WCSRTOMBS
 #ifdef TRACE_WCSRTOMBS
@@ -103,9 +102,8 @@ __wcsnrtombs(char* dst, const wchar_t** src, size_t nwc, 
size_t len,
 }
 
 
-// deactivated, as wcsnrtombs() isn't publically available yet.
-//extern "C"
-//B_DEFINE_WEAK_ALIAS(__wcsnrtombs, wcsnrtombs);
+extern "C"
+B_DEFINE_WEAK_ALIAS(__wcsnrtombs, wcsnrtombs);
 
 
 extern "C" size_t

############################################################################

Commit:      d8ef8ef48b222b074f0ba0714776d17410d2b805
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d8ef8ef
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 20:59:28 2012 UTC

Add wcs_test, a testsuite for all wchar-related functions.

----------------------------------------------------------------------------

diff --git a/src/tests/system/libroot/posix/Jamfile 
b/src/tests/system/libroot/posix/Jamfile
index 7674db1..21561df 100644
--- a/src/tests/system/libroot/posix/Jamfile
+++ b/src/tests/system/libroot/posix/Jamfile
@@ -63,6 +63,7 @@ SimpleTest tst-wprintf2 : tst-wprintf2.c ;
 SimpleTest tst-wscanf : tst-wscanf.c ;
 SimpleTest test_wcfuncs : test_wcfuncs.c ;
 SimpleTest test_wctype : test_wctype.c ;
+SimpleTest wcs_test : wcs_test.cpp ;
 
 
 # Tell Jam where to find these sources
diff --git a/src/tests/system/libroot/posix/wcs_test.cpp 
b/src/tests/system/libroot/posix/wcs_test.cpp
new file mode 100644
index 0000000..1b97c18
--- /dev/null
+++ b/src/tests/system/libroot/posix/wcs_test.cpp
@@ -0,0 +1,3903 @@
+/*
+ * Copyright 2011, Oliver Tappe, zooey@xxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ */
+
+#define __USE_GNU
+       // for wmempcpy() and wcschrnul()
+
+#include <errno.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <wchar.h>
+
+
+static int sign (int a)
+{
+       if (a < 0)
+               return -1;
+       if (a > 0)
+               return 1;
+       return 0;
+}
+
+
+// #pragma mark - wcslen 
-------------------------------------------------------
+
+
+void
+test_wcslen()
+{
+       printf("wcslen()/wcsnlen()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* string = L"";
+               size_t result = wcslen(string);
+               size_t expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu 
(expected %lu),"
+                                       " errno = %x (expected %x)\n", string, 
result, expected,
+                               errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"test";
+               size_t result = wcslen(string);
+               size_t expected = 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu 
(expected %lu),"
+                                       " errno = %x (expected %x)\n", string, 
result, expected,
+                               errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"t\xE4st";
+               size_t result = wcslen(string);
+               size_t expected = 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu 
(expected %lu),"
+                                       " errno = %x (expected %x)\n", string, 
result, expected,
+                               errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"te\x00st";
+               size_t result = wcslen(string);
+               size_t expected = 2;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcslen(\"%ls\") = %lu 
(expected %lu),"
+                                       " errno = %x (expected %x)\n", string, 
result, expected,
+                               errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"test";
+               size_t result = wcsnlen(string, 0);
+               size_t expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsnlen(\"%ls\", 0) = %lu 
"
+                                       "(expected %lu), errno = %x (expected 
%x)\n",
+                               string, result, expected, errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"test";
+               size_t result = wcsnlen(string, 4);
+               size_t expected = 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsnlen(\"%ls\", 4) = %lu 
"
+                                       "(expected %lu), errno = %x (expected 
%x)\n",
+                               string, result, expected, errno, 0);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"test";
+               size_t result = wcsnlen(string, 6);
+               size_t expected = 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsnlen(\"%ls\", 6) = %lu 
"
+                                       "(expected %lu), errno = %x (expected 
%x)\n",
+                               string, result, expected, errno, 0);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcscmp 
-------------------------------------------------------
+
+
+void
+test_wcscmp()
+{
+       printf("wcscmp()/wcsncmp()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* a = L"";
+               const wchar_t* b = L"";
+               int result = sign(wcscmp(a, b));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"a";
+               const wchar_t* b = L"b";
+               int result = sign(wcscmp(a, b));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"b";
+               const wchar_t* b = L"a";
+               int result = sign(wcscmp(a, b));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"a";
+               const wchar_t* b = L"A";
+               int result = sign(wcscmp(a, b));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst";
+               const wchar_t* b = L"täst";
+               int result = sign(wcscmp(a, b));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst";
+               const wchar_t* b = L"täst ";
+               int result = sign(wcscmp(a, b));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täSt";
+               const wchar_t* b = L"täs";
+               int result = sign(wcscmp(a, b));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscmp(\"%ls\", \"%ls\") 
= %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst1";
+               const wchar_t* b = L"täst0";
+               int result = sign(wcsncmp(a, b, 0));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 
0) = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst1";
+               const wchar_t* b = L"täst0";
+               int result = sign(wcsncmp(a, b, 4));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 
4) = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst1";
+               const wchar_t* b = L"täst0";
+               int result = sign(wcsncmp(a, b, 5));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 
5) = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täs";
+               const wchar_t* b = L"täst123";
+               int result = sign(wcsncmp(a, b, (size_t)-1));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncmp(\"%ls\", \"%ls\", 
-1) = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcscasecmp 
---------------------------------------------------
+
+
+void
+test_wcscasecmp()
+{
+       printf("wcscasecmp()/wcsncasecmp()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* a = L"";
+               const wchar_t* b = L"";
+               int result = sign(wcscasecmp(a, b));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"a";
+               const wchar_t* b = L"b";
+               int result = sign(wcscasecmp(a, b));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"B";
+               const wchar_t* b = L"a";
+               int result = sign(wcscasecmp(a, b));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"a";
+               const wchar_t* b = L"A";
+               int result = sign(wcscasecmp(a, b));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"TÄST";
+               const wchar_t* b = L"täst";
+               int result = sign(wcscasecmp(a, b));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"tÄst";
+               const wchar_t* b = L"täst ";
+               int result = sign(wcscasecmp(a, b));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"TäSt";
+               const wchar_t* b = L"täs";
+               int result = sign(wcscasecmp(a, b));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasecmp(\"%ls\", 
\"%ls\") = %d "
+                                       "(expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"tÄst1";
+               const wchar_t* b = L"täst0";
+               int result = sign(wcsncasecmp(a, b, 0));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcscasencmp(\"%ls\", 
\"%ls\", 0) = %d"
+                                       " (expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täst1";
+               const wchar_t* b = L"täSt0";
+               int result = sign(wcsncasecmp(a, b, 4));
+               int expected = 0;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", 
\"%ls\", 4) = %d"
+                                       " (expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täsT1";
+               const wchar_t* b = L"täst0";
+               int result = sign(wcsncasecmp(a, b, 5));
+               int expected = 1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", 
\"%ls\", 5) = %d"
+                                       " (expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* a = L"täs";
+               const wchar_t* b = L"täSt123";
+               int result = sign(wcsncasecmp(a, b, (size_t)-1));
+               int expected = -1;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsncasecmp(\"%ls\", 
\"%ls\", -1) = "
+                                       "%d (expected %d), errno = %x (expected 
0)\n", a, b, result,
+                               expected, errno);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcschr 
-------------------------------------------------------
+
+
+void
+test_wcschr()
+{
+       printf("wcschr()/wcschrnul()/wcsrchr()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"sometext";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = string + 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L's';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'S';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcschr(string, ch);
+               const wchar_t* expected = string + 14;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"sometext";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string + wcslen(string);
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string + 4;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L's';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'S';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string + wcslen(string);
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcschrnul(string, ch);
+               const wchar_t* expected = string + 14;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcschrnul(\"%ls\", '%lc') 
= %p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"sometext";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L' ';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = string + 9;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L's';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = string;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'S';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = NULL;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"some more text";
+               const wchar_t ch = L'\0';
+               const wchar_t* result = wcsrchr(string, ch);
+               const wchar_t* expected = string + 14;
+               if (result != expected || errno != 0) {
+                       printf("\tPROBLEM: result for wcsrchr(\"%ls\", '%lc') = 
%p "
+                                       "(expected %p), errno = %x (expected 
0)\n", string, ch,
+                               result, expected, errno);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcsdup 
-------------------------------------------------------
+
+
+void
+test_wcsdup()
+{
+       printf("wcsdup()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+#ifdef __HAIKU__
+       {
+               const wchar_t* string = NULL;
+               wchar_t* result = wcsdup(string);
+               if (result != NULL || errno != 0) {
+                       printf("\tPROBLEM: result for wcsdup(%p) = \"%ls\", 
errno = %x"
+                                       " (expected 0)\n", string, result, 
errno);
+                       problemCount++;
+               }
+       }
+#endif
+
+       {
+               const wchar_t* string = L"";
+               wchar_t* result = wcsdup(string);
+               if (result == NULL || wcscmp(result, string) != 0 || errno != 
0) {
+                       printf("\tPROBLEM: result for wcsdup(\"%ls\") = 
\"%ls\", errno = %x"
+                                       " (expected 0)\n", string, result, 
errno);
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* string = L"tÄstdata with some charäcters";
+               wchar_t* result = wcsdup(string);
+               if (result == NULL || wcscmp(result, string) != 0 || errno != 
0) {
+                       printf("\tPROBLEM: result for wcsdup(\"%ls\") = 
\"%ls\", errno = %x"
+                                       " (expected 0)\n", string, result, 
errno);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcscpy 
-------------------------------------------------------
+
+
+void
+test_wcscpy()
+{
+       printf("wcscpy()/wcsncpy()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* source = L"";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcscpy(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 0) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
0\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L'\0') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[1] != L'X') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"test";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcscpy(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'X') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcscpy(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'X') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"te\x00st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcscpy(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 2) {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
2\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L'\0') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[3] != L'X') {
+                       printf("\tPROBLEM: wcscpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcsncpy(destination, source, 0);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L'X') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 0) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcsncpy(destination, source, 2);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L'X') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 2) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcsncpy(destination, source, 4);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'X') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 4) -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcsncpy(destination, source, 8);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'\0') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[6] != L'\0') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[6]=%x, expected %x\n", 
source, destination[6],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[7] != L'\0') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[7]=%x, expected %x\n", 
source, destination[7],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[8] != L'X') {
+                       printf("\tPROBLEM: wcsncpy(destination, \"%ls\", 8) -> "
+                                       "destination[8]=%x, expected %x\n", 
source, destination[8],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcpcpy 
-------------------------------------------------------
+
+
+void
+test_wcpcpy()
+{
+       printf("wcpcpy()/wcpncpy()\n");
+
+       int problemCount = 0;
+       errno = 0;
+
+       {
+               const wchar_t* source = L"";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpcpy(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 0) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
0\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L'\0') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[1] != L'X') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"test";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpcpy(destination, source);
+               if (result != destination + 4) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 4);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'X') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpcpy(destination, source);
+               if (result != destination + 4) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 4);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'X') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"te\x00st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpcpy(destination, source);
+               if (result != destination + 2) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 2);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 2) {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
2\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L'\0') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[3] != L'X') {
+                       printf("\tPROBLEM: wcpcpy(destination, \"%ls\") -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpncpy(destination, source, 0);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L'X') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 0) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpncpy(destination, source, 2);
+               if (result != destination + 2) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 2);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L'X') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 2) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpncpy(destination, source, 4);
+               if (result != destination + 4) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 4);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'X') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 4) -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               const wchar_t* source = L"t\xE4st";
+               wchar_t destination[] = L"XXXXXXXXXXXXXXXX";
+               wchar_t* result = wcpncpy(destination, source, 8);
+               if (result != destination + 4) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> 
result=%p, "
+                                       "expected %p\n", source, result, 
destination + 4);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> 
errno=%d, "
+                                       "expected 0\n", source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[0]=%x, expected %x\n", 
source, destination[0],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'\xE4') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[1]=%x, expected %x\n", 
source, destination[1],
+                               L'\xE4');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[2]=%x, expected %x\n", 
source, destination[2],
+                               L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[3]=%x, expected %x\n", 
source, destination[3],
+                               L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[4]=%x, expected %x\n", 
source, destination[4],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'\0') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[5]=%x, expected %x\n", 
source, destination[5],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[6] != L'\0') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[6]=%x, expected %x\n", 
source, destination[6],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[7] != L'\0') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[7]=%x, expected %x\n", 
source, destination[7],
+                               L'\0');
+                       problemCount++;
+               }
+               if (destination[8] != L'X') {
+                       printf("\tPROBLEM: wcpncpy(destination, \"%ls\", 8) -> "
+                                       "destination[8]=%x, expected %x\n", 
source, destination[8],
+                               L'X');
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcscat 
-------------------------------------------------------
+
+
+void
+test_wcscat()
+{
+       printf("wcscat()/wcsncat()\n");
+
+       int problemCount = 0;
+       errno = 0;
+       wchar_t destination[] = L"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+       destination[0] = L'\0';
+       wchar_t backup[33];
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"";
+               wchar_t* result = wcscat(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 0) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
0\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L'\0') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[0]=%x, "
+                                       "expected %x\n", backup, source, 
destination[0], L'\0');
+                       problemCount++;
+               }
+               if (destination[1] != L'X') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[1]=%x, "
+                                       "expected %x\n", backup, source, 
destination[1], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"test";
+               wchar_t* result = wcscat(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[0]=%x, "
+                                       "expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[1]=%x, "
+                                       "expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[2]=%x, "
+                                       "expected %x\n", backup, source, 
destination[2], L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[3]=%x, "
+                                       "expected %x\n", backup, source, 
destination[3], L't');
+                       problemCount++;
+               }
+               if (destination[4] != L'\0') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[4]=%x, "
+                                       "expected %x\n", backup, source, 
destination[4], L'\0');
+                       problemCount++;
+               }
+               if (destination[5] != L'X') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[5]=%x, "
+                                       "expected %x\n", backup, source, 
destination[5], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"t\xE4st";
+               wchar_t* result = wcscat(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 8) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
8\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[0]=%x, "
+                                       "expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[1]=%x, "
+                                       "expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[2]=%x, "
+                                       "expected %x\n", backup, source, 
destination[2], L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[3]=%x, "
+                                       "expected %x\n", backup, source, 
destination[3], L't');
+                       problemCount++;
+               }
+               if (destination[4] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[4]=%x, "
+                                       "expected %x\n", backup, source, 
destination[4], L't');
+                       problemCount++;
+               }
+               if (destination[5] != L'\xE4') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[5]=%x, "
+                                       "expected %x\n", backup, source, 
destination[5], L'\xE4');
+                       problemCount++;
+               }
+               if (destination[6] != L's') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[6]=%x, "
+                                       "expected %x\n", backup, source, 
destination[6], L's');
+                       problemCount++;
+               }
+               if (destination[7] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[7]=%x, "
+                                       "expected %x\n", backup, source, 
destination[7], L't');
+                       problemCount++;
+               }
+               if (destination[8] != L'\0') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[8]=%x, "
+                                       "expected %x\n", backup, source, 
destination[8], L'\0');
+                       problemCount++;
+               }
+               if (destination[9] != L'X') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[9]=%x, "
+                                       "expected %x\n", backup, source, 
destination[9], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"te\x00st";
+               wchar_t* result = wcscat(destination, source);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 10) {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> "
+                                       "wcslen(destination)=%lu, expected 
10\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[0]=%x, "
+                                       "expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[1]=%x, "
+                                       "expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[2]=%x, "
+                                       "expected %x\n", backup, source, 
destination[2], L's');
+                       problemCount++;
+               }
+               if (destination[3] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[3]=%x, "
+                                       "expected %x\n", backup, source, 
destination[3], L't');
+                       problemCount++;
+               }
+               if (destination[4] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[4]=%x, "
+                                       "expected %x\n", backup, source, 
destination[4], L't');
+                       problemCount++;
+               }
+               if (destination[5] != L'\xE4') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[5]=%x, "
+                                       "expected %x\n", backup, source, 
destination[5], L'\xE4');
+                       problemCount++;
+               }
+               if (destination[6] != L's') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[6]=%x, "
+                                       "expected %x\n", backup, source, 
destination[6], L's');
+                       problemCount++;
+               }
+               if (destination[7] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[7]=%x, "
+                                       "expected %x\n", backup, source, 
destination[7], L't');
+                       problemCount++;
+               }
+               if (destination[8] != L't') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[8]=%x, "
+                                       "expected %x\n", backup, source, 
destination[8], L't');
+                       problemCount++;
+               }
+               if (destination[9] != L'e') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[9]=%x, "
+                                       "expected %x\n", backup, source, 
destination[9], L'e');
+                       problemCount++;
+               }
+               if (destination[10] != L'\0') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[10]=%x, "
+                                       "expected %x\n", backup, source, 
destination[10], L'\0');
+                       problemCount++;
+               }
+               if (destination[11] != L'X') {
+                       printf("\tPROBLEM: wcscat(\"%ls\", \"%ls\") -> 
destination[11]=%x, "
+                                       "expected %x\n", backup, source, 
destination[11], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(destination, L"some");
+               wcscpy(backup, destination);
+               const wchar_t* source = L" other text";
+               wchar_t* result = wcsncat(destination, source, 0);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (wcscmp(destination, L"some") != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 0) -> 
\"%ls\"\n",
+                               backup, source, destination);
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(destination, L"some");
+               wcscpy(backup, destination);
+               const wchar_t* source = L" other text";
+               wchar_t* result = wcsncat(destination, source, 6);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 10) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> "
+                                       "wcslen(destination)=%lu, expected 
10\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (wcscmp(destination, L"some other") != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 6) -> 
\"%ls\"\n",
+                               backup, source, destination);
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(destination, L"some");
+               wcscpy(backup, destination);
+               const wchar_t* source = L" other text";
+               wchar_t* result = wcsncat(destination, source, 20);
+               if (result != destination) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> 
result=%p, "
+                                       "expected %p\n", backup, source, 
result, destination);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 15) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> "
+                                       "wcslen(destination)=%lu, expected 
15\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (wcscmp(destination, L"some other text") != 0) {
+                       printf("\tPROBLEM: wcsncat(\"%ls\", \"%ls\", 20) -> 
\"%ls\"\n",
+                               backup, source, destination);
+                       problemCount++;
+               }
+       }
+
+       if (problemCount)
+               printf("\t%d problem(s) found!\n", problemCount);
+       else
+               printf("\tall fine\n");
+}
+
+
+// #pragma mark - wcslcat 
------------------------------------------------------
+
+
+#ifdef __HAIKU__
+
+void
+test_wcslcat()
+{
+       printf("wcslcat()\n");
+
+       int problemCount = 0;
+       errno = 0;
+       wchar_t destination[] = L"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+       wchar_t backup[33];
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"";
+               size_t result = wcslcat(destination, source, 0);
+               size_t expectedResult = 0;
+               if (result != expectedResult) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> 
result=%ld, "
+                                       "expected %ld\n", backup, source, 
result, expectedResult);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 32) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> "
+                                       "wcslen(destination)=%lu, expected 
32\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L'X') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 0) -> 
destination[0]="
+                                       "%x, expected %x\n", backup, source, 
destination[0], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               destination[0] = L'\0';
+               wcscpy(backup, destination);
+               const wchar_t* source = L"";
+               size_t result = wcslcat(destination, source, 32);
+               size_t expectedResult = 0;
+               if (result != expectedResult) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> 
result=%ld, "
+                                       "expected %ld\n", backup, source, 
result, expectedResult);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> "
+                                       "wcslen(destination)=%lu, expected 
0\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L'\0') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> 
destination[0]="
+                                       "%x, expected %x\n", backup, source, 
destination[0], L'\0');
+                       problemCount++;
+               }
+               if (destination[1] != L'X') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 32) -> 
destination[1]="
+                                       "%x, expected %x\n", backup, source, 
destination[1], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"test";
+               size_t result = wcslcat(destination, source, 3);
+               size_t expectedResult = 4;
+               if (result != expectedResult) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
result=%ld, "
+                                       "expected %ld\n", backup, source, 
result, expectedResult);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 2) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> "
+                                       "wcslen(destination)=%lu, expected 
2\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
destination[0]="
+                                       "%x, expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
destination[1]="
+                                       "%x, expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L'\0') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
destination[2]="
+                                       "%x, expected %x\n", backup, source, 
destination[2], L'\0');
+                       problemCount++;
+               }
+               if (destination[3] != L'X') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 3) -> 
destination[3]="
+                                       "%x, expected %x\n", backup, source, 
destination[3], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"st";
+               size_t result = wcslcat(destination, source, 4);
+               size_t expectedResult = 4;
+               if (result != expectedResult) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
result=%ld, "
+                                       "expected %ld\n", backup, source, 
result, expectedResult);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 3) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> "
+                                       "wcslen(destination)=%lu, expected 
3\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
destination[0]="
+                                       "%x, expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
destination[1]="
+                                       "%x, expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }
+               if (destination[2] != L's') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
destination[2]="
+                                       "%x, expected %x\n", backup, source, 
destination[2], L's');
+                       problemCount++;
+               }
+               if (destination[3] != L'\0') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
destination[3]="
+                                       "%x, expected %x\n", backup, source, 
destination[3], L'\0');
+                       problemCount++;
+               }
+               if (destination[4] != L'X') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 4) -> 
destination[4]="
+                                       "%x, expected %x\n", backup, source, 
destination[4], L'X');
+                       problemCount++;
+               }
+       }
+
+       {
+               wcscpy(backup, destination);
+               const wchar_t* source = L"t";
+               size_t result = wcslcat(destination, source, 5);
+               size_t expectedResult = 4;
+               if (result != expectedResult) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> 
result=%ld, "
+                                       "expected %ld\n", backup, source, 
result, expectedResult);
+                       problemCount++;
+               }
+               if (errno != 0) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> 
errno=%d, "
+                                       "expected 0\n", backup, source, errno);
+                       problemCount++;
+               }
+               if (wcslen(destination) != 4) {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> "
+                                       "wcslen(destination)=%lu, expected 
4\n", backup, source,
+                               wcslen(destination));
+                       problemCount++;
+               }
+               if (destination[0] != L't') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> 
destination[0]="
+                                       "%x, expected %x\n", backup, source, 
destination[0], L't');
+                       problemCount++;
+               }
+               if (destination[1] != L'e') {
+                       printf("\tPROBLEM: wcslcat(\"%ls\", \"%ls\", 5) -> 
destination[1]="
+                                       "%x, expected %x\n", backup, source, 
destination[1], L'e');
+                       problemCount++;
+               }

[ *** diff truncated: 1785 lines dropped *** ]


############################################################################

Commit:      7efc2e3a0e70a9fd3c07470dc20e99bbb71628d5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7efc2e3
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 21:01:40 2012 UTC

Add our own implementations for all wchar.h functions.
    
* add implementation for wcpcpy(), wcpncpy(), wcscasecmp(), wcscat(),
  wcschr(), wcscmp(), wcscpy(), wcscspn(), wcsdup(), wcslcat(),
  wcslcpy(), wcslen(), wcsncasecmp(), wcsncat(), wcsncmp(), wcsncpy(),
  wcsnlen(), wcspbrk(), wcsrchr(), wcsspn(), wcsstr(), wcstok(),
  wmemchr(), wmemcmp(), wmemcpy(), wmemmove(), wmemset
* add implementations for GNU-extensions used by our glibc and some
  other programs/libs: wcschrnul(), wmempcpy()
* add stub for wcsftime()

----------------------------------------------------------------------------

############################################################################

Commit:      b7417fbec1977006971f93c91a288138a9462e5a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b7417fb
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 21:02:48 2012 UTC

Switch wchar from glibc to our own implementations.

----------------------------------------------------------------------------

############################################################################

Revision:    hrev43641
Commit:      174676503b2c345653f73de4915e8b247961a81a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1746765
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Sat Jan  7 21:03:24 2012 UTC

Drop now unneeded glibc wchar-files (plus others).

----------------------------------------------------------------------------


Other related posts:

  • » [haiku-commits] haiku: hrev43641 - src/tests/system/libroot/posix src/system/libroot/posix/glibc/wcsmbs src/system/libroot/posix/glibc/string src/system/libroot/posix/wchar headers/posix - zooey