2003-11-25 16:08:38 +00:00
|
|
|
/*
|
|
|
|
|
* wchar.cpp
|
|
|
|
|
* stepmania
|
|
|
|
|
*
|
|
|
|
|
* Created by Steve Checkoway on Tue Nov 25 2003.
|
|
|
|
|
* Copyright (c) 2003 Steve Checkoway. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define _BSD_WCHAR_T_DEFINED_
|
|
|
|
|
#include <stddef.h>
|
2003-11-26 00:58:21 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
2003-11-25 16:08:38 +00:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#ifndef wcslen
|
2003-11-26 00:58:21 +00:00
|
|
|
size_t wcslen(const wchar_t *ws)
|
|
|
|
|
{
|
|
|
|
|
size_t n = 0;
|
|
|
|
|
|
|
|
|
|
while (*(ws++) != NULL)
|
|
|
|
|
++n;
|
|
|
|
|
return n;
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef wmemchr
|
2003-11-26 00:58:21 +00:00
|
|
|
wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i=0; i<n; ++i, ++ws)
|
|
|
|
|
if (*ws == wc)
|
|
|
|
|
return (wchar_t *)ws;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef wmemcmp
|
2003-11-26 00:58:21 +00:00
|
|
|
int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i=0; i<n; ++i, ++ws1, ++ws2)
|
|
|
|
|
if (*ws1 != *ws2)
|
|
|
|
|
return *ws1 - *ws2;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef wmemcpy
|
2003-11-26 00:58:21 +00:00
|
|
|
wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
|
|
|
|
{
|
|
|
|
|
return (wchar_t *)memcpy(ws1, ws2, n * sizeof(wchar_t));
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef wmemmove
|
2003-11-26 00:58:21 +00:00
|
|
|
wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n)
|
|
|
|
|
{
|
|
|
|
|
return (wchar_t *)memmove(ws1, ws2, n * sizeof(wchar_t));
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef wmemset
|
2003-11-26 00:58:21 +00:00
|
|
|
wchar_t *wmemset(wchar_t *ws , wchar_t wc, size_t n)
|
|
|
|
|
{
|
|
|
|
|
wchar_t *temp = ws;
|
|
|
|
|
for (unsigned i=0; i<n; ++i, ++temp)
|
|
|
|
|
*temp = wc;
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
2003-11-25 16:08:38 +00:00
|
|
|
#endif
|
|
|
|
|
}
|
2003-11-26 00:58:21 +00:00
|
|
|
|
|
|
|
|
#ifndef wstring
|
|
|
|
|
template class std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >;
|
|
|
|
|
#endif
|