# HG changeset patch # User dewyatt # Date 1280868730 14400 # Node ID e2f4e31b41fcccdcb8b76f20997dcb8b4efcd581 # Parent 140be68391850f163e97e22689a743804deb7906 Added SDL_wcslcpy and SDL_wcslcat. diff -r 140be6839185 -r e2f4e31b41fc include/SDL_stdinc.h --- a/include/SDL_stdinc.h Sun Jul 25 13:17:31 2010 -0400 +++ b/include/SDL_stdinc.h Tue Aug 03 16:52:10 2010 -0400 @@ -470,6 +470,19 @@ extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string); #endif +#ifdef HAVE_WCSLCPY +#define SDL_wcslcpy wcslcpy +#else +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen); +#endif + +#ifdef HAVE_WCSLCAT +#define SDL_wcslcat wcslcat +#else +extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen); +#endif + + #ifdef HAVE_STRLCPY #define SDL_strlcpy strlcpy #else diff -r 140be6839185 -r e2f4e31b41fc src/stdlib/SDL_string.c --- a/src/stdlib/SDL_string.c Sun Jul 25 13:17:31 2010 -0400 +++ b/src/stdlib/SDL_string.c Tue Aug 03 16:52:10 2010 -0400 @@ -363,6 +363,33 @@ } #endif +#ifndef HAVE_WCSLCPY +size_t +SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen) +{ + size_t srclen = SDL_wcslen(src); + if (maxlen > 0) { + size_t len = SDL_min(srclen, maxlen - 1); + SDL_memcpy(dst, src, len * sizeof(wchar_t)); + dst[len] = '\0'; + } + return srclen; +} +#endif + +#ifndef HAVE_WCSLCAT +size_t +SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen) +{ + size_t dstlen = SDL_wcslen(dst); + size_t srclen = SDL_wcslen(src); + if (dstlen < maxlen) { + SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen); + } + return dstlen + srclen; +} +#endif + #ifndef HAVE_STRLCPY size_t SDL_strlcpy(char *dst, const char *src, size_t maxlen)