2008-06-11 08:54:46 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS CRT library
|
|
|
|
* LICENSE: LGPL - See COPYING in the top level directory
|
|
|
|
* FILE: lib/sdk/crt/string/wcs.c
|
|
|
|
* PURPOSE: wcs* CRT functions
|
|
|
|
* PROGRAMMERS: Wine team
|
|
|
|
* Ported to ReactOS by Aleksey Bragin (aleksey@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* msvcrt.dll wide-char functions
|
|
|
|
*
|
|
|
|
* Copyright 1999 Alexandre Julliard
|
|
|
|
* Copyright 2000 Jon Griffiths
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#include <precomp.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#ifndef _LIBCNT_
|
|
|
|
#include <internal/wine/msvcrt.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#undef sprintf
|
|
|
|
#undef wsprintf
|
2008-07-03 12:07:12 +00:00
|
|
|
#undef snprintf
|
2008-06-11 08:54:46 +00:00
|
|
|
#undef vsnprintf
|
|
|
|
#undef vprintf
|
|
|
|
#undef vwprintf
|
|
|
|
|
2011-02-10 11:35:05 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma function(_wcsset)
|
|
|
|
#endif
|
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
#ifndef _LIBCNT_
|
|
|
|
/*********************************************************************
|
|
|
|
* _wcsdup (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
wchar_t* CDECL _wcsdup( const wchar_t* str )
|
|
|
|
{
|
|
|
|
wchar_t* ret = NULL;
|
|
|
|
if (str)
|
|
|
|
{
|
2011-09-15 17:11:53 +00:00
|
|
|
size_t size = (strlenW(str) + 1) * sizeof(wchar_t);
|
2008-06-11 08:54:46 +00:00
|
|
|
ret = malloc( size );
|
|
|
|
if (ret) memcpy( ret, str, size );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
|
|
* _wcsicoll (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL _wcsicoll( const wchar_t* str1, const wchar_t* str2 )
|
|
|
|
{
|
|
|
|
/* FIXME: handle collates */
|
|
|
|
return strcmpiW( str1, str2 );
|
|
|
|
}
|
2008-06-23 03:57:50 +00:00
|
|
|
#endif
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnset (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
wchar_t* CDECL _wcsnset( wchar_t* str, wchar_t c, size_t n )
|
|
|
|
{
|
|
|
|
wchar_t* ret = str;
|
|
|
|
while ((n-- > 0) && *str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wcsrev (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
wchar_t* CDECL _wcsrev( wchar_t* str )
|
|
|
|
{
|
|
|
|
wchar_t* ret = str;
|
|
|
|
wchar_t* end = str + strlenW(str) - 1;
|
|
|
|
while (end > str)
|
|
|
|
{
|
|
|
|
wchar_t t = *end;
|
|
|
|
*end-- = *str;
|
|
|
|
*str++ = t;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2008-06-23 03:57:50 +00:00
|
|
|
#ifndef _LIBCNT_
|
2008-06-11 08:54:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsset (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
wchar_t* CDECL _wcsset( wchar_t* str, wchar_t c )
|
|
|
|
{
|
|
|
|
wchar_t* ret = str;
|
|
|
|
while (*str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-23 10:56:54 +00:00
|
|
|
/******************************************************************
|
|
|
|
* _wcsupr_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT CDECL _wcsupr_s( wchar_t* str, size_t n )
|
|
|
|
{
|
|
|
|
wchar_t* ptr = str;
|
|
|
|
|
|
|
|
if (!str || !n)
|
|
|
|
{
|
|
|
|
if (str) *str = '\0';
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_set_errno(EINVAL);
|
2009-12-23 10:56:54 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (n--)
|
|
|
|
{
|
|
|
|
if (!*ptr) return 0;
|
|
|
|
*ptr = toupperW(*ptr);
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MSDN claims that the function should return and set errno to
|
|
|
|
* ERANGE, which doesn't seem to be true based on the tests. */
|
|
|
|
*str = '\0';
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_set_errno(EINVAL);
|
2009-12-23 10:56:54 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstod (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
double CDECL wcstod(const wchar_t* lpszStr, wchar_t** end)
|
|
|
|
{
|
|
|
|
const wchar_t* str = lpszStr;
|
|
|
|
int negative = 0;
|
|
|
|
double ret = 0, divisor = 10.0;
|
|
|
|
|
|
|
|
TRACE("(%s,%p) semi-stub\n", debugstr_w(lpszStr), end);
|
|
|
|
|
|
|
|
/* FIXME:
|
|
|
|
* - Should set errno on failure
|
|
|
|
* - Should fail on overflow
|
|
|
|
* - Need to check which input formats are allowed
|
|
|
|
*/
|
|
|
|
while (isspaceW(*str))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
if (*str == '-')
|
|
|
|
{
|
|
|
|
negative = 1;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
ret = ret * 10.0 + (*str - '0');
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
if (*str == '.')
|
|
|
|
str++;
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
ret = ret + (*str - '0') / divisor;
|
|
|
|
divisor *= 10;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*str == 'E' || *str == 'e' || *str == 'D' || *str == 'd')
|
|
|
|
{
|
|
|
|
int negativeExponent = 0;
|
|
|
|
int exponent = 0;
|
|
|
|
if (*(++str) == '-')
|
|
|
|
{
|
|
|
|
negativeExponent = 1;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
exponent = exponent * 10 + (*str - '0');
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
if (exponent != 0)
|
|
|
|
{
|
|
|
|
if (negativeExponent)
|
|
|
|
ret = ret / pow(10.0, exponent);
|
|
|
|
else
|
|
|
|
ret = ret * pow(10.0, exponent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
ret = -ret;
|
|
|
|
|
|
|
|
if (end)
|
|
|
|
*end = (wchar_t*)str;
|
|
|
|
|
|
|
|
TRACE("returning %g\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2010-11-05 22:21:36 +00:00
|
|
|
#endif
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wcscoll (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL wcscoll( const wchar_t* str1, const wchar_t* str2 )
|
|
|
|
{
|
|
|
|
/* FIXME: handle collates */
|
|
|
|
return strcmpW( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcspbrk (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
wchar_t* CDECL wcspbrk( const wchar_t* str, const wchar_t* accept )
|
|
|
|
{
|
|
|
|
const wchar_t* p;
|
|
|
|
while (*str)
|
|
|
|
{
|
|
|
|
for (p = accept; *p; p++) if (*p == *str) return (wchar_t*)str;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
#ifndef _LIBCNT_
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2008-06-11 08:54:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wctomb (MSVCRT.@)
|
|
|
|
*/
|
2012-12-09 03:17:14 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wctomb (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL wctomb( char *dst, wchar_t ch )
|
2008-06-11 08:54:46 +00:00
|
|
|
{
|
2012-12-09 03:17:14 +00:00
|
|
|
BOOL error;
|
|
|
|
INT size;
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
size = WideCharToMultiByte(get_locinfo()->lc_codepage, 0, &ch, 1, dst, dst ? 6 : 0, NULL, &error);
|
|
|
|
if(!size || error) {
|
|
|
|
*_errno() = EINVAL;
|
|
|
|
return EOF;
|
2008-07-16 21:40:09 +00:00
|
|
|
}
|
2012-12-09 03:17:14 +00:00
|
|
|
return size;
|
2008-07-16 21:40:09 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wcsrtombs_l (INTERNAL)
|
|
|
|
*/
|
|
|
|
static size_t CDECL wcsrtombs_l(char *mbstr, const wchar_t **wcstr, size_t count, _locale_t locale)
|
2008-07-16 21:40:09 +00:00
|
|
|
{
|
2012-12-09 03:17:14 +00:00
|
|
|
MSVCRT_pthreadlocinfo locinfo;
|
|
|
|
size_t tmp = 0;
|
|
|
|
BOOL used_default;
|
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = ((MSVCRT__locale_t)locale)->locinfo;
|
|
|
|
|
|
|
|
if(!mbstr) {
|
|
|
|
tmp = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
|
|
|
*wcstr, -1, NULL, 0, NULL, &used_default)-1;
|
|
|
|
if(used_default)
|
|
|
|
return -1;
|
|
|
|
return tmp;
|
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
while(**wcstr) {
|
|
|
|
char buf[3];
|
|
|
|
size_t i, size;
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
|
|
|
*wcstr, 1, buf, 3, NULL, &used_default);
|
|
|
|
if(used_default)
|
|
|
|
return -1;
|
|
|
|
if(tmp+size > count)
|
|
|
|
return tmp;
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
for(i=0; i<size; i++)
|
|
|
|
mbstr[tmp++] = buf[i];
|
|
|
|
(*wcstr)++;
|
2008-07-16 21:40:09 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
if(tmp < count) {
|
|
|
|
mbstr[tmp] = '\0';
|
|
|
|
*wcstr = NULL;
|
2008-07-16 21:40:09 +00:00
|
|
|
}
|
2012-12-09 03:17:14 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstombs_l (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
size_t CDECL _wcstombs_l(char *mbstr, const wchar_t *wcstr, size_t count, _locale_t locale)
|
|
|
|
{
|
|
|
|
return wcsrtombs_l(mbstr, &wcstr, count, locale);
|
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
|
2012-12-09 03:17:14 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstombs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
size_t CDECL wcstombs(char *mbstr, const wchar_t *wcstr, size_t count)
|
|
|
|
{
|
|
|
|
return wcsrtombs_l(mbstr, &wcstr, count, NULL);
|
2008-06-11 08:54:46 +00:00
|
|
|
}
|
2008-07-16 21:40:09 +00:00
|
|
|
#endif
|
2008-06-11 08:54:46 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcscpy_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
|
|
|
|
{
|
2011-09-15 17:11:53 +00:00
|
|
|
size_t size = 0;
|
2008-06-11 08:54:46 +00:00
|
|
|
|
|
|
|
if(!wcDest || !numElement)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
wcDest[0] = 0;
|
|
|
|
|
|
|
|
if(!wcSrc)
|
|
|
|
{
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = strlenW(wcSrc) + 1;
|
|
|
|
|
|
|
|
if(size > numElement)
|
|
|
|
{
|
|
|
|
return ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-02-04 10:09:48 +00:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* wcsncpy_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL wcsncpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc,
|
|
|
|
size_t count )
|
|
|
|
{
|
|
|
|
size_t size = 0;
|
|
|
|
|
|
|
|
if (!wcDest || !numElement)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
wcDest[0] = 0;
|
|
|
|
|
|
|
|
if (!wcSrc)
|
|
|
|
{
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = min(strlenW(wcSrc), count);
|
|
|
|
|
|
|
|
if (size >= numElement)
|
|
|
|
{
|
|
|
|
return ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
|
|
|
|
wcDest[size] = '\0';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
/******************************************************************
|
|
|
|
* wcscat_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT CDECL wcscat_s(wchar_t* dst, size_t elem, const wchar_t* src)
|
|
|
|
{
|
|
|
|
wchar_t* ptr = dst;
|
|
|
|
|
|
|
|
if (!dst || elem == 0) return EINVAL;
|
|
|
|
if (!src)
|
|
|
|
{
|
|
|
|
dst[0] = '\0';
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* seek to end of dst string (or elem if no end of string is found */
|
|
|
|
while (ptr < dst + elem && *ptr != '\0') ptr++;
|
|
|
|
while (ptr < dst + elem)
|
|
|
|
{
|
|
|
|
if ((*ptr++ = *src++) == '\0') return 0;
|
|
|
|
}
|
|
|
|
/* not enough space */
|
|
|
|
dst[0] = '\0';
|
|
|
|
return ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcsncat_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT CDECL wcsncat_s(wchar_t *dst, size_t elem,
|
|
|
|
const wchar_t *src, size_t count)
|
|
|
|
{
|
|
|
|
size_t srclen;
|
|
|
|
wchar_t dststart;
|
|
|
|
INT ret = 0;
|
|
|
|
|
|
|
|
if (!MSVCRT_CHECK_PMT(dst != NULL) || !MSVCRT_CHECK_PMT(elem > 0))
|
|
|
|
{
|
|
|
|
#ifndef _LIBCNT_
|
|
|
|
_set_errno(EINVAL);
|
|
|
|
#endif
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (!MSVCRT_CHECK_PMT(src != NULL || count == 0))
|
|
|
|
return EINVAL;
|
|
|
|
if (count == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (dststart = 0; dststart < elem; dststart++)
|
|
|
|
{
|
|
|
|
if (dst[dststart] == '\0')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dststart == elem)
|
|
|
|
{
|
2014-05-10 20:38:26 +00:00
|
|
|
MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", EINVAL);
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == _TRUNCATE)
|
|
|
|
{
|
|
|
|
srclen = strlenW(src);
|
|
|
|
if (srclen >= (elem - dststart))
|
|
|
|
{
|
|
|
|
srclen = elem - dststart - 1;
|
|
|
|
ret = STRUNCATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
srclen = min(strlenW(src), count);
|
|
|
|
if (srclen < (elem - dststart))
|
|
|
|
{
|
|
|
|
memcpy(&dst[dststart], src, srclen*sizeof(wchar_t));
|
|
|
|
dst[dststart+srclen] = '\0';
|
|
|
|
return ret;
|
|
|
|
}
|
2014-05-10 20:38:26 +00:00
|
|
|
MSVCRT_INVALID_PMT("dst[elem] is too small", ERANGE);
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
dst[0] = '\0';
|
|
|
|
return ERANGE;
|
|
|
|
}
|
2009-02-04 10:09:48 +00:00
|
|
|
|