2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll wide-char functions
|
|
|
|
*
|
|
|
|
* Copyright 1999 Alexandre Julliard
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2010-04-26 12:33:38 +02:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
#define _NO_CRT_STDIO_INLINE
|
2001-01-22 03:21:54 +01:00
|
|
|
#include <limits.h>
|
2020-11-26 19:19:05 +01:00
|
|
|
#include <locale.h>
|
2004-04-08 21:48:19 +02:00
|
|
|
#include <math.h>
|
2005-02-14 21:53:42 +01:00
|
|
|
#include <assert.h>
|
2020-12-03 19:10:54 +01:00
|
|
|
#include <wchar.h>
|
2020-11-26 19:19:01 +01:00
|
|
|
#include <wctype.h>
|
2001-01-11 00:59:25 +01:00
|
|
|
#include "msvcrt.h"
|
|
|
|
#include "winnls.h"
|
2011-04-20 14:42:16 +02:00
|
|
|
#include "wtypes.h"
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2020-07-14 15:33:33 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
enum { LEN_DEFAULT, LEN_SHORT, LEN_LONG } IntegerLength;
|
|
|
|
BOOLEAN IntegerDouble, IntegerNative, LeftAlign, Alternate, PadZero;
|
|
|
|
BOOLEAN WideString, NaturalString;
|
|
|
|
int FieldLength, Precision;
|
|
|
|
char Sign, Format;
|
|
|
|
} pf_flags;
|
|
|
|
|
2011-04-27 20:09:00 +02:00
|
|
|
static BOOL n_format_enabled = TRUE;
|
|
|
|
|
2011-04-20 14:42:16 +02:00
|
|
|
#include "printf.h"
|
|
|
|
#define PRINTF_WIDE
|
|
|
|
#include "printf.h"
|
|
|
|
#undef PRINTF_WIDE
|
2001-01-22 03:21:54 +01:00
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#if _MSVCR_VER>=80
|
|
|
|
|
2014-04-21 14:32:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_printf_count_output (MSVCR80.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _get_printf_count_output( void )
|
2011-04-27 20:09:00 +02:00
|
|
|
{
|
|
|
|
return n_format_enabled ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2014-04-21 14:32:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _set_printf_count_output (MSVCR80.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _set_printf_count_output( int enable )
|
2011-04-27 20:09:00 +02:00
|
|
|
{
|
|
|
|
BOOL old = n_format_enabled;
|
2012-08-08 21:25:57 +02:00
|
|
|
n_format_enabled = enable != 0;
|
2011-04-27 20:09:00 +02:00
|
|
|
return old ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2018-01-07 06:05:31 +01:00
|
|
|
#endif /* _MSVCR_VER>=80 */
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsdup (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsdup( const wchar_t* str )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ret = NULL;
|
2001-01-11 00:59:25 +01:00
|
|
|
if (str)
|
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
int size = (wcslen(str) + 1) * sizeof(wchar_t);
|
2020-12-01 13:51:32 +01:00
|
|
|
ret = malloc( size );
|
2001-01-11 00:59:25 +01:00
|
|
|
if (ret) memcpy( ret, str, size );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-14 20:22:53 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _towlower_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wint_t CDECL _towlower_l(wint_t c, _locale_t locale)
|
2020-07-14 20:22:53 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t ret;
|
2020-07-14 20:22:53 +02:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_CTYPE]) {
|
2020-07-14 20:22:53 +02:00
|
|
|
if(c >= 'A' && c <= 'Z')
|
|
|
|
return c + 'a' - 'A';
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!LCMapStringW(locinfo->lc_handle[LC_CTYPE], LCMAP_LOWERCASE, &c, 1, &ret, 1))
|
2020-07-16 14:46:42 +02:00
|
|
|
return c;
|
|
|
|
return ret;
|
2020-07-14 20:22:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* towlower (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wint_t CDECL towlower(wint_t c)
|
2020-07-14 20:22:53 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _towlower_l(c, NULL);
|
2020-07-14 20:22:53 +02:00
|
|
|
}
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsicmp_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
|
2013-06-25 16:14:23 +02:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_tstruct tmp = {0};
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t c1, c2;
|
2020-07-14 20:22:53 +02:00
|
|
|
|
2013-06-25 16:14:23 +02:00
|
|
|
if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
|
2020-12-04 15:50:17 +01:00
|
|
|
return _NLSCMPERROR;
|
2013-06-25 16:14:23 +02:00
|
|
|
|
2020-11-10 16:58:44 +01:00
|
|
|
if(!locale)
|
|
|
|
locale = get_current_locale_noalloc(&tmp);
|
|
|
|
|
2020-07-14 20:22:53 +02:00
|
|
|
do
|
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
c1 = _towlower_l(*str1++, locale);
|
|
|
|
c2 = _towlower_l(*str2++, locale);
|
2020-07-14 20:22:53 +02:00
|
|
|
} while(c1 && (c1 == c2));
|
2020-11-10 16:58:44 +01:00
|
|
|
|
|
|
|
free_locale_noalloc(&tmp);
|
2020-07-14 20:22:53 +02:00
|
|
|
return c1 - c2;
|
2013-06-25 16:14:23 +02:00
|
|
|
}
|
|
|
|
|
2020-11-26 19:19:01 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* towctrans (MSVCR120.@)
|
|
|
|
*/
|
|
|
|
wint_t CDECL towctrans(wint_t c, wctrans_t category)
|
|
|
|
{
|
|
|
|
if(category == 1)
|
2020-12-03 19:10:54 +01:00
|
|
|
return _towupper_l(c, NULL);
|
|
|
|
return _towlower_l(c, NULL);
|
2020-11-26 19:19:01 +01:00
|
|
|
}
|
|
|
|
|
2013-03-27 16:11:06 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsicmp (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsicmp( const wchar_t* str1, const wchar_t* str2 )
|
2013-03-27 16:11:06 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsicmp_l(str1, str2, NULL);
|
2013-03-27 16:11:06 +01:00
|
|
|
}
|
|
|
|
|
2014-09-04 21:17:26 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnicmp_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsnicmp_l(const wchar_t *str1, const wchar_t *str2,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t n, _locale_t locale)
|
2014-09-04 21:17:26 +02:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_tstruct tmp = {0};
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t c1, c2;
|
2020-07-14 20:23:26 +02:00
|
|
|
|
|
|
|
if (!n)
|
2020-11-10 16:58:44 +01:00
|
|
|
return 0;
|
2020-07-14 20:23:26 +02:00
|
|
|
|
|
|
|
if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
|
2020-12-04 15:50:17 +01:00
|
|
|
return _NLSCMPERROR;
|
2020-07-14 20:23:26 +02:00
|
|
|
|
2020-11-10 16:58:44 +01:00
|
|
|
if(!locale)
|
|
|
|
locale = get_current_locale_noalloc(&tmp);
|
|
|
|
|
2020-07-14 20:23:26 +02:00
|
|
|
do
|
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
c1 = _towlower_l(*str1++, locale);
|
|
|
|
c2 = _towlower_l(*str2++, locale);
|
2020-07-14 20:23:26 +02:00
|
|
|
} while(--n && c1 && (c1 == c2));
|
2020-11-10 16:58:44 +01:00
|
|
|
|
|
|
|
free_locale_noalloc(&tmp);
|
2020-07-14 20:23:26 +02:00
|
|
|
return c1 - c2;
|
2014-09-04 21:17:26 +02:00
|
|
|
}
|
|
|
|
|
2013-09-12 12:50:19 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnicmp (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsnicmp(const wchar_t *str1, const wchar_t *str2, size_t n)
|
2013-09-12 12:50:19 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsnicmp_l(str1, str2, n, NULL);
|
2013-09-12 12:50:19 +02:00
|
|
|
}
|
|
|
|
|
2013-03-30 15:59:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsicoll_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsicoll_l(const wchar_t* str1, const wchar_t* str2, _locale_t locale)
|
2013-03-30 15:59:02 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2013-03-30 15:59:02 +01:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_COLLATE])
|
2020-07-14 20:22:49 +02:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t c1, c2;
|
2020-07-14 20:22:49 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c1 = *str1++;
|
|
|
|
if (c1 >= 'A' && c1 <= 'Z')
|
|
|
|
c1 += 'a' - 'A';
|
|
|
|
|
|
|
|
c2 = *str2++;
|
|
|
|
if (c2 >= 'A' && c2 <= 'Z')
|
|
|
|
c2 += 'a' - 'A';
|
|
|
|
} while(c1 && (c1 == c2));
|
|
|
|
return c1 - c2;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
return CompareStringW(locinfo->lc_handle[LC_COLLATE], NORM_IGNORECASE,
|
2013-03-30 15:59:02 +01:00
|
|
|
str1, -1, str2, -1)-CSTR_EQUAL;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsicoll (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsicoll( const wchar_t* str1, const wchar_t* str2 )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsicoll_l(str1, str2, NULL);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2013-03-30 17:00:30 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnicoll_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsnicoll_l(const wchar_t* str1, const wchar_t* str2,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, _locale_t locale)
|
2013-03-30 17:00:30 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2013-03-30 17:00:30 +01:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_COLLATE])
|
2020-07-14 20:23:20 +02:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t c1, c2;
|
2020-07-14 20:23:20 +02:00
|
|
|
|
|
|
|
if (!count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
c1 = *str1++;
|
|
|
|
if (c1 >= 'A' && c1 <= 'Z')
|
|
|
|
c1 += 'a' - 'A';
|
|
|
|
|
|
|
|
c2 = *str2++;
|
|
|
|
if (c2 >= 'A' && c2 <= 'Z')
|
|
|
|
c2 += 'a' - 'A';
|
|
|
|
} while(--count && c1 && (c1 == c2));
|
|
|
|
return c1 - c2;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
return CompareStringW(locinfo->lc_handle[LC_COLLATE], NORM_IGNORECASE,
|
2020-12-03 19:10:54 +01:00
|
|
|
str1, wcsnlen(str1, count),
|
|
|
|
str2, wcsnlen(str2, count))-CSTR_EQUAL;
|
2013-03-30 17:00:30 +01:00
|
|
|
}
|
|
|
|
|
2010-12-03 18:12:23 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnicoll (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsnicoll( const wchar_t* str1, const wchar_t* str2, size_t count )
|
2010-12-03 18:12:23 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsnicoll_l(str1, str2, count, NULL);
|
2010-12-03 18:12:23 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsnset (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsnset( wchar_t* str, wchar_t c, size_t n )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ret = str;
|
2001-01-11 00:59:25 +01:00
|
|
|
while ((n-- > 0) && *str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-04-01 19:57:07 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsnset_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsnset_s( wchar_t *str, size_t size, wchar_t c, size_t count )
|
2019-04-01 19:57:07 +02:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t i;
|
2019-04-01 19:57:07 +02:00
|
|
|
|
|
|
|
if(!str && !size && !count) return 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
if(!MSVCRT_CHECK_PMT(str != NULL)) return EINVAL;
|
|
|
|
if(!MSVCRT_CHECK_PMT(size > 0)) return EINVAL;
|
2019-04-01 19:57:07 +02:00
|
|
|
|
|
|
|
for(i=0; i<size-1 && i<count; i++) {
|
|
|
|
if(!str[i]) return 0;
|
|
|
|
str[i] = c;
|
|
|
|
}
|
|
|
|
for(; i<size; i++)
|
|
|
|
if(!str[i]) return 0;
|
|
|
|
|
|
|
|
str[0] = 0;
|
2020-12-01 13:51:23 +01:00
|
|
|
_invalid_parameter(NULL, NULL, NULL, 0, 0);
|
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2019-04-01 19:57:07 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsrev (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsrev( wchar_t* str )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ret = str;
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* end = str + wcslen(str) - 1;
|
2001-01-11 00:59:25 +01:00
|
|
|
while (end > str)
|
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t t = *end;
|
2001-01-11 00:59:25 +01:00
|
|
|
*end-- = *str;
|
|
|
|
*str++ = t;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-23 17:44:28 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsset_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsset_s( wchar_t *str, size_t n, wchar_t c )
|
2014-12-23 17:44:28 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t *p = str;
|
2014-12-23 17:44:28 +01:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if(!MSVCRT_CHECK_PMT(str != NULL)) return EINVAL;
|
|
|
|
if(!MSVCRT_CHECK_PMT(n)) return EINVAL;
|
2014-12-23 17:44:28 +01:00
|
|
|
|
|
|
|
while(*p && --n) *p++ = c;
|
|
|
|
if(!n) {
|
|
|
|
str[0] = 0;
|
2020-12-01 13:51:23 +01:00
|
|
|
_invalid_parameter(NULL, NULL, NULL, 0, 0);
|
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2014-12-23 17:44:28 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsset (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsset( wchar_t* str, wchar_t c )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ret = str;
|
2001-01-11 00:59:25 +01:00
|
|
|
while (*str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-11-16 02:09:17 +01:00
|
|
|
/******************************************************************
|
2011-03-05 00:28:28 +01:00
|
|
|
* _wcsupr_s_l (MSVCRT.@)
|
2009-11-16 02:09:17 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsupr_s_l( wchar_t* str, size_t n, _locale_t locale )
|
2009-11-16 02:09:17 +01:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_tstruct tmp = {0};
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ptr = str;
|
2009-11-16 02:09:17 +01:00
|
|
|
|
|
|
|
if (!str || !n)
|
|
|
|
{
|
|
|
|
if (str) *str = '\0';
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2009-11-16 02:09:17 +01:00
|
|
|
}
|
|
|
|
|
2020-11-10 16:58:57 +01:00
|
|
|
if(!locale)
|
|
|
|
locale = get_current_locale_noalloc(&tmp);
|
|
|
|
|
2009-11-16 02:09:17 +01:00
|
|
|
while (n--)
|
|
|
|
{
|
2020-11-10 16:58:57 +01:00
|
|
|
if (!*ptr)
|
|
|
|
{
|
|
|
|
free_locale_noalloc(&tmp);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-12-03 19:10:54 +01:00
|
|
|
*ptr = _towupper_l(*ptr, locale);
|
2009-11-16 02:09:17 +01:00
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
2020-11-10 16:58:57 +01:00
|
|
|
free_locale_noalloc(&tmp);
|
|
|
|
|
2009-11-16 02:09:17 +01:00
|
|
|
/* 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';
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2009-11-16 02:09:17 +01:00
|
|
|
}
|
|
|
|
|
2011-03-05 00:28:28 +01:00
|
|
|
/******************************************************************
|
|
|
|
* _wcsupr_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _wcsupr_s( wchar_t* str, size_t n )
|
2011-03-05 00:28:28 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsupr_s_l( str, n, NULL );
|
2011-03-05 00:28:28 +01:00
|
|
|
}
|
|
|
|
|
2014-04-29 14:49:38 +02:00
|
|
|
/******************************************************************
|
|
|
|
* _wcsupr_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsupr_l( wchar_t *str, _locale_t locale )
|
2014-04-29 14:49:38 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
_wcsupr_s_l( str, -1, locale);
|
2014-04-29 14:49:38 +02:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2018-10-17 15:22:56 +02:00
|
|
|
/******************************************************************
|
|
|
|
* _wcsupr (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcsupr( wchar_t *str )
|
2018-10-17 15:22:56 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsupr_l(str, NULL);
|
2018-10-17 15:22:56 +02:00
|
|
|
}
|
|
|
|
|
2011-03-04 23:59:08 +01:00
|
|
|
/******************************************************************
|
2014-05-22 12:58:50 +02:00
|
|
|
* _wcslwr_s_l (MSVCRT.@)
|
2011-03-04 23:59:08 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcslwr_s_l( wchar_t* str, size_t n, _locale_t locale )
|
2011-03-04 23:59:08 +01:00
|
|
|
{
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_tstruct tmp = {0};
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ptr = str;
|
2011-03-04 23:59:08 +01:00
|
|
|
|
|
|
|
if (!str || !n)
|
|
|
|
{
|
|
|
|
if (str) *str = '\0';
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2011-03-04 23:59:08 +01:00
|
|
|
}
|
|
|
|
|
2020-11-10 16:58:44 +01:00
|
|
|
if(!locale)
|
|
|
|
locale = get_current_locale_noalloc(&tmp);
|
|
|
|
|
2011-03-04 23:59:08 +01:00
|
|
|
while (n--)
|
|
|
|
{
|
2020-11-10 16:58:44 +01:00
|
|
|
if (!*ptr)
|
|
|
|
{
|
|
|
|
free_locale_noalloc(&tmp);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-12-03 19:10:54 +01:00
|
|
|
*ptr = _towlower_l(*ptr, locale);
|
2011-03-04 23:59:08 +01:00
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
2020-11-10 16:58:44 +01:00
|
|
|
free_locale_noalloc(&tmp);
|
|
|
|
|
2011-03-04 23:59:08 +01:00
|
|
|
/* 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';
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EINVAL;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2011-03-04 23:59:08 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 12:58:50 +02:00
|
|
|
/******************************************************************
|
|
|
|
* _wcslwr_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcslwr_s( wchar_t* str, size_t n )
|
2014-05-22 12:58:50 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcslwr_s_l(str, n, NULL);
|
2014-05-22 12:58:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* _wcslwr_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcslwr_l( wchar_t* str, _locale_t locale )
|
2014-05-22 12:58:50 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
_wcslwr_s_l(str, -1, locale);
|
2014-05-27 11:02:42 +02:00
|
|
|
return str;
|
2014-05-22 12:58:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* _wcslwr (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL _wcslwr( wchar_t* str )
|
2014-05-22 12:58:50 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
_wcslwr_s_l(str, -1, NULL);
|
2014-05-27 11:02:42 +02:00
|
|
|
return str;
|
2014-05-22 12:58:50 +02:00
|
|
|
}
|
|
|
|
|
2020-07-14 20:23:02 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcsncmp (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t n)
|
2020-07-14 20:23:02 +02:00
|
|
|
{
|
|
|
|
if (!n)
|
|
|
|
return 0;
|
|
|
|
while(--n && *str1 && (*str1 == *str2))
|
|
|
|
{
|
|
|
|
str1++;
|
|
|
|
str2++;
|
|
|
|
}
|
|
|
|
return *str1 - *str2;
|
|
|
|
}
|
|
|
|
|
2013-03-29 10:12:53 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsncoll_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsncoll_l(const wchar_t* str1, const wchar_t* str2,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, _locale_t locale)
|
2013-03-29 10:12:53 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2013-03-29 10:12:53 +01:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_COLLATE])
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsncmp(str1, str2, count);
|
2020-11-30 14:37:48 +01:00
|
|
|
return CompareStringW(locinfo->lc_handle[LC_COLLATE], 0,
|
2020-12-03 19:10:54 +01:00
|
|
|
str1, wcsnlen(str1, count),
|
|
|
|
str2, wcsnlen(str2, count))-CSTR_EQUAL;
|
2013-03-29 10:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wcsncoll (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcsncoll(const wchar_t* str1, const wchar_t* str2, size_t count)
|
2013-03-29 10:12:53 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsncoll_l(str1, str2, count, NULL);
|
2013-03-29 10:12:53 +01:00
|
|
|
}
|
|
|
|
|
2020-11-27 14:16:49 +01:00
|
|
|
static wchar_t strtod_wstr_get(void *ctx)
|
2019-12-19 18:37:13 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t **p = ctx;
|
2020-11-30 14:37:05 +01:00
|
|
|
if (!**p) return WEOF;
|
2020-01-01 00:00:11 +01:00
|
|
|
return *(*p)++;
|
|
|
|
}
|
2019-12-19 18:37:13 +01:00
|
|
|
|
2020-01-01 00:00:11 +01:00
|
|
|
static void strtod_wstr_unget(void *ctx)
|
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t **p = ctx;
|
2020-01-01 00:00:11 +01:00
|
|
|
(*p)--;
|
2019-12-19 18:37:13 +01:00
|
|
|
}
|
|
|
|
|
2010-04-26 12:33:38 +02:00
|
|
|
/*********************************************************************
|
2013-03-28 12:56:38 +01:00
|
|
|
* _wcstod_l (MSVCRT.@)
|
2010-04-26 12:33:38 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
double CDECL _wcstod_l(const wchar_t* str, wchar_t** end,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale)
|
2010-04-26 12:33:38 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *beg, *p;
|
2020-07-23 15:38:28 +02:00
|
|
|
struct fpnum fp;
|
2010-04-26 12:33:38 +02:00
|
|
|
double ret;
|
2020-07-23 15:38:28 +02:00
|
|
|
int err;
|
2010-04-26 12:33:38 +02:00
|
|
|
|
2020-01-01 00:00:11 +01:00
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL)) {
|
|
|
|
if (end) *end = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
2010-04-26 12:33:38 +02:00
|
|
|
|
2020-01-01 00:00:11 +01:00
|
|
|
if (!locale)
|
2011-05-24 17:22:32 +02:00
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
2010-04-26 12:33:38 +02:00
|
|
|
|
|
|
|
p = str;
|
2020-12-03 19:10:54 +01:00
|
|
|
while(_iswspace_l(*p, locale))
|
2010-04-26 12:33:38 +02:00
|
|
|
p++;
|
2020-01-01 00:00:11 +01:00
|
|
|
beg = p;
|
2010-04-26 12:33:38 +02:00
|
|
|
|
2020-07-23 15:38:40 +02:00
|
|
|
fp = fpnum_parse(strtod_wstr_get, strtod_wstr_unget, &p, locinfo, FALSE);
|
2020-11-27 14:16:49 +01:00
|
|
|
if (end) *end = (p == beg ? (wchar_t*)str : (wchar_t*)p);
|
2020-07-23 15:38:28 +02:00
|
|
|
|
|
|
|
err = fpnum_double(&fp, &ret);
|
2020-12-01 13:51:23 +01:00
|
|
|
if(err) *_errno() = err;
|
2010-04-26 12:33:38 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-27 08:42:46 +02:00
|
|
|
/*********************************************************************
|
2011-04-27 20:08:41 +02:00
|
|
|
* wcsrtombs_l (INTERNAL)
|
2010-04-27 08:42:46 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
static size_t wcsrtombs_l(char *mbstr, const wchar_t **wcstr,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, _locale_t locale)
|
2010-04-27 08:42:46 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t tmp = 0;
|
2020-10-19 19:35:31 +02:00
|
|
|
BOOL used_default = FALSE;
|
|
|
|
BOOL *pused_default;
|
2010-04-27 08:42:46 +02:00
|
|
|
|
|
|
|
if(!locale)
|
2011-05-24 17:22:32 +02:00
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2016-06-14 11:57:20 +02:00
|
|
|
if(!locinfo->lc_codepage) {
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t i;
|
2016-06-14 11:57:20 +02:00
|
|
|
|
|
|
|
if(!mbstr)
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcslen(*wcstr);
|
2016-06-14 11:57:20 +02:00
|
|
|
|
|
|
|
for(i=0; i<count; i++) {
|
|
|
|
if((*wcstr)[i] > 255) {
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2016-06-14 11:57:20 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mbstr[i] = (*wcstr)[i];
|
|
|
|
if(!(*wcstr)[i]) break;
|
|
|
|
}
|
2021-03-02 12:09:32 +01:00
|
|
|
|
|
|
|
if(i < count) *wcstr = NULL;
|
|
|
|
else *wcstr += i;
|
2016-06-14 11:57:20 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2020-10-19 19:35:31 +02:00
|
|
|
pused_default = (locinfo->lc_codepage != CP_UTF8 ? &used_default : NULL);
|
|
|
|
|
2011-07-28 12:28:38 +02:00
|
|
|
if(!mbstr) {
|
|
|
|
tmp = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
2020-10-19 19:35:31 +02:00
|
|
|
*wcstr, -1, NULL, 0, NULL, pused_default);
|
2013-09-24 15:51:48 +02:00
|
|
|
if(!tmp || used_default) {
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2011-07-28 12:28:38 +02:00
|
|
|
return -1;
|
2013-09-24 15:51:48 +02:00
|
|
|
}
|
2020-02-03 21:06:10 +01:00
|
|
|
return tmp-1;
|
2011-07-28 12:28:38 +02:00
|
|
|
}
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2011-04-27 20:08:41 +02:00
|
|
|
while(**wcstr) {
|
2010-05-24 10:03:55 +02:00
|
|
|
char buf[3];
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t i, size;
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2011-05-24 17:22:32 +02:00
|
|
|
size = WideCharToMultiByte(locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
|
2020-10-19 19:35:31 +02:00
|
|
|
*wcstr, 1, buf, 3, NULL, pused_default);
|
2013-09-24 15:51:48 +02:00
|
|
|
if(!size || used_default) {
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2010-05-24 10:03:55 +02:00
|
|
|
return -1;
|
2013-09-24 15:51:48 +02:00
|
|
|
}
|
2010-05-24 10:03:55 +02:00
|
|
|
if(tmp+size > count)
|
|
|
|
return tmp;
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2010-05-24 10:03:55 +02:00
|
|
|
for(i=0; i<size; i++)
|
|
|
|
mbstr[tmp++] = buf[i];
|
2011-04-27 20:08:41 +02:00
|
|
|
(*wcstr)++;
|
2010-05-24 10:03:55 +02:00
|
|
|
}
|
2010-05-06 14:27:57 +02:00
|
|
|
|
2011-04-27 20:08:41 +02:00
|
|
|
if(tmp < count) {
|
2010-05-24 10:03:55 +02:00
|
|
|
mbstr[tmp] = '\0';
|
2011-04-27 20:08:41 +02:00
|
|
|
*wcstr = NULL;
|
|
|
|
}
|
2010-05-06 14:27:57 +02:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2011-04-27 20:08:41 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstombs_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL _wcstombs_l(char *mbstr, const wchar_t *wcstr,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, _locale_t locale)
|
2011-04-27 20:08:41 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_l(mbstr, &wcstr, count, locale);
|
2011-04-27 20:08:41 +02:00
|
|
|
}
|
|
|
|
|
2010-05-06 14:27:57 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstombs (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcstombs(char *mbstr, const wchar_t *wcstr,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count)
|
2010-05-06 14:27:57 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_l(mbstr, &wcstr, count, NULL);
|
2010-05-06 14:27:57 +02:00
|
|
|
}
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2010-05-06 14:27:57 +02:00
|
|
|
/*********************************************************************
|
2011-04-27 20:08:41 +02:00
|
|
|
* wcsrtombs (MSVCRT.@)
|
2010-05-06 14:27:57 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcsrtombs(char *mbstr, const wchar_t **wcstr,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, mbstate_t *mbstate)
|
2011-04-27 20:08:41 +02:00
|
|
|
{
|
|
|
|
if(mbstate)
|
|
|
|
*mbstate = 0;
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_l(mbstr, wcstr, count, NULL);
|
2011-04-27 20:08:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2020-12-03 19:10:54 +01:00
|
|
|
* wcsrtombs_s_l (INTERNAL)
|
2011-04-27 20:08:41 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
static int wcsrtombs_s_l(size_t *ret, char *mbstr, size_t size,
|
2020-11-27 14:17:05 +01:00
|
|
|
const wchar_t **wcstr, size_t count, _locale_t locale)
|
2010-05-06 14:27:57 +02:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t conv;
|
2020-02-03 21:14:11 +01:00
|
|
|
int err;
|
2010-05-06 14:27:57 +02:00
|
|
|
|
2011-04-27 20:08:41 +02:00
|
|
|
if(!mbstr && !size && wcstr) {
|
2020-12-03 19:10:54 +01:00
|
|
|
conv = wcsrtombs_l(NULL, wcstr, 0, locale);
|
2010-05-06 14:27:57 +02:00
|
|
|
if(ret)
|
2011-03-30 15:45:04 +02:00
|
|
|
*ret = conv+1;
|
2020-02-03 21:14:11 +01:00
|
|
|
if(conv == -1)
|
2020-12-01 13:51:23 +01:00
|
|
|
return *_errno();
|
2010-05-06 14:27:57 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if (!MSVCRT_CHECK_PMT(mbstr != NULL)) return EINVAL;
|
2012-07-26 11:05:32 +02:00
|
|
|
if (size) mbstr[0] = '\0';
|
2020-11-30 14:37:27 +01:00
|
|
|
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(*wcstr != NULL)) return EINVAL;
|
2010-04-27 08:42:46 +02:00
|
|
|
|
2020-12-04 15:50:17 +01:00
|
|
|
if(count==_TRUNCATE || size<count)
|
2010-05-06 14:27:57 +02:00
|
|
|
conv = size;
|
|
|
|
else
|
|
|
|
conv = count;
|
|
|
|
|
2020-02-03 21:14:11 +01:00
|
|
|
err = 0;
|
2020-12-03 19:10:54 +01:00
|
|
|
conv = wcsrtombs_l(mbstr, wcstr, conv, locale);
|
2013-09-24 15:51:48 +02:00
|
|
|
if(conv == -1) {
|
2020-02-03 21:14:11 +01:00
|
|
|
conv = 0;
|
2013-09-24 15:51:48 +02:00
|
|
|
if(size)
|
|
|
|
mbstr[0] = '\0';
|
2020-12-01 13:51:23 +01:00
|
|
|
err = *_errno();
|
2013-09-24 15:51:48 +02:00
|
|
|
}else if(conv < size)
|
2010-05-06 14:27:57 +02:00
|
|
|
mbstr[conv++] = '\0';
|
2020-12-04 15:50:17 +01:00
|
|
|
else if(conv==size && (count==_TRUNCATE || mbstr[conv-1]=='\0')) {
|
2010-05-06 14:27:57 +02:00
|
|
|
mbstr[conv-1] = '\0';
|
2020-12-04 15:50:17 +01:00
|
|
|
if(count==_TRUNCATE)
|
2020-11-30 14:37:27 +01:00
|
|
|
err = STRUNCATE;
|
2020-02-03 21:14:11 +01:00
|
|
|
}else {
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("mbstr[size] is too small", ERANGE);
|
2020-02-03 21:14:11 +01:00
|
|
|
conv = 0;
|
2010-05-06 14:27:57 +02:00
|
|
|
if(size)
|
|
|
|
mbstr[0] = '\0';
|
2020-11-30 14:37:27 +01:00
|
|
|
err = ERANGE;
|
2010-04-27 08:42:46 +02:00
|
|
|
}
|
|
|
|
|
2010-05-06 14:27:57 +02:00
|
|
|
if(ret)
|
|
|
|
*ret = conv;
|
2020-02-03 21:14:11 +01:00
|
|
|
return err;
|
2010-04-27 08:42:46 +02:00
|
|
|
}
|
|
|
|
|
2011-04-27 20:08:41 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstombs_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcstombs_s_l(size_t *ret, char *mbstr, size_t size,
|
2020-11-27 14:17:05 +01:00
|
|
|
const wchar_t *wcstr, size_t count, _locale_t locale)
|
2011-04-27 20:08:41 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_s_l(ret, mbstr, size, &wcstr,count, locale);
|
2011-04-27 20:08:41 +02:00
|
|
|
}
|
|
|
|
|
2010-04-27 08:42:46 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstombs_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wcstombs_s(size_t *ret, char *mbstr, size_t size,
|
2020-11-27 14:17:05 +01:00
|
|
|
const wchar_t *wcstr, size_t count)
|
2010-04-27 08:42:46 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_s_l(ret, mbstr, size, &wcstr, count, NULL);
|
2011-04-27 20:08:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcsrtombs_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wcsrtombs_s(size_t *ret, char *mbstr, size_t size,
|
2020-11-27 14:17:05 +01:00
|
|
|
const wchar_t **wcstr, size_t count, mbstate_t *mbstate)
|
2011-04-27 20:08:41 +02:00
|
|
|
{
|
|
|
|
if(mbstate)
|
|
|
|
*mbstate = 0;
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcsrtombs_s_l(ret, mbstr, size, wcstr, count, NULL);
|
2010-04-27 08:42:46 +02:00
|
|
|
}
|
|
|
|
|
2003-09-24 00:50:30 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstod (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
double CDECL wcstod(const wchar_t* lpszStr, wchar_t** end)
|
2003-09-24 00:50:30 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstod_l(lpszStr, end, NULL);
|
2010-04-26 12:33:49 +02:00
|
|
|
}
|
2003-09-24 00:50:30 +02:00
|
|
|
|
2010-04-26 12:33:49 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtof (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
double CDECL _wtof(const wchar_t *str)
|
2010-04-26 12:33:49 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstod_l(str, NULL, NULL);
|
2003-09-24 00:50:30 +02:00
|
|
|
}
|
|
|
|
|
2010-04-26 12:33:49 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtof_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
double CDECL _wtof_l(const wchar_t *str, _locale_t locale)
|
2010-04-26 12:33:49 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstod_l(str, NULL, locale);
|
2010-04-26 12:33:49 +02:00
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=120
|
|
|
|
|
2016-02-18 16:10:06 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstof_l (MSVCR120.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
float CDECL _wcstof_l( const wchar_t *str, wchar_t **end, _locale_t locale )
|
2016-02-18 16:10:06 +01:00
|
|
|
{
|
2021-07-28 16:43:19 +02:00
|
|
|
double ret = _wcstod_l(str, end, locale);
|
|
|
|
if (ret && isfinite(ret)) {
|
|
|
|
float f = ret;
|
|
|
|
if (!f || !isfinite(f))
|
|
|
|
*_errno() = ERANGE;
|
|
|
|
}
|
|
|
|
return ret;
|
2016-02-18 16:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcstof (MSVCR120.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
float CDECL wcstof( const wchar_t *str, wchar_t **end )
|
2016-02-18 16:10:06 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstof_l(str, end, NULL);
|
2016-02-18 16:10:06 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif /* _MSVCR_VER>=120 */
|
|
|
|
|
2011-04-20 14:42:26 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* arg_clbk_valist (INTERNAL)
|
|
|
|
*/
|
|
|
|
printf_arg arg_clbk_valist(void *ctx, int arg_pos, int type, __ms_va_list *valist)
|
|
|
|
{
|
|
|
|
printf_arg ret;
|
|
|
|
|
|
|
|
if(type == VT_I8)
|
|
|
|
ret.get_longlong = va_arg(*valist, LONGLONG);
|
|
|
|
else if(type == VT_INT)
|
|
|
|
ret.get_int = va_arg(*valist, int);
|
|
|
|
else if(type == VT_R8)
|
|
|
|
ret.get_double = va_arg(*valist, double);
|
|
|
|
else if(type == VT_PTR)
|
|
|
|
ret.get_ptr = va_arg(*valist, void*);
|
|
|
|
else {
|
|
|
|
ERR("Incorrect type\n");
|
|
|
|
ret.get_int = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-04-27 12:09:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* arg_clbk_positional (INTERNAL)
|
|
|
|
*/
|
2017-10-13 20:23:29 +02:00
|
|
|
printf_arg arg_clbk_positional(void *ctx, int pos, int type, __ms_va_list *valist)
|
2011-04-27 12:09:01 +02:00
|
|
|
{
|
|
|
|
printf_arg *args = ctx;
|
|
|
|
return args[pos];
|
|
|
|
}
|
|
|
|
|
2020-11-19 13:28:52 +01:00
|
|
|
#if _MSVCR_VER < 140
|
|
|
|
|
2010-04-19 10:57:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-11-19 13:28:52 +01:00
|
|
|
int CDECL _vsnprintf( char *str, size_t len, const char *format, __ms_va_list valist )
|
2010-04-19 10:57:40 +02:00
|
|
|
{
|
2011-04-20 14:42:48 +02:00
|
|
|
static const char nullbyte = '\0';
|
|
|
|
struct _str_ctx_a ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, NULL, 0,
|
2011-05-11 15:39:07 +02:00
|
|
|
arg_clbk_valist, NULL, &valist);
|
2011-04-20 14:42:48 +02:00
|
|
|
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
|
|
|
return ret;
|
2010-04-19 10:57:40 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 13:28:52 +01:00
|
|
|
#else
|
2017-12-28 18:46:54 +01:00
|
|
|
|
2015-10-27 22:42:15 +01:00
|
|
|
static int puts_clbk_str_c99_a(void *ctx, int len, const char *str)
|
|
|
|
{
|
|
|
|
struct _str_ctx_a *out = ctx;
|
|
|
|
|
|
|
|
if(!out->buf)
|
|
|
|
return len;
|
|
|
|
|
2015-11-03 19:40:35 +01:00
|
|
|
if(out->len < len) {
|
2019-10-10 23:39:35 +02:00
|
|
|
memmove(out->buf, str, out->len);
|
2015-11-03 19:40:35 +01:00
|
|
|
out->buf += out->len;
|
|
|
|
out->len = 0;
|
2015-10-27 22:42:15 +01:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2019-10-10 23:39:35 +02:00
|
|
|
memmove(out->buf, str, len);
|
2015-10-27 22:42:15 +01:00
|
|
|
out->buf += len;
|
|
|
|
out->len -= len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vsprintf (UCRTBASE.@)
|
2015-10-27 22:42:15 +01:00
|
|
|
*/
|
2020-11-19 13:28:52 +01:00
|
|
|
int CDECL __stdio_common_vsprintf( unsigned __int64 options, char *str, size_t len, const char *format,
|
|
|
|
_locale_t locale, __ms_va_list valist )
|
2015-10-27 22:42:15 +01:00
|
|
|
{
|
|
|
|
static const char nullbyte = '\0';
|
|
|
|
struct _str_ctx_a ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:38 +01:00
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
2015-10-27 22:42:15 +01:00
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2015-11-03 19:40:35 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_c99_a,
|
2020-11-26 19:19:18 +01:00
|
|
|
&ctx, format, (_locale_t)locale, options & UCRTBASE_PRINTF_MASK, arg_clbk_valist, NULL, &valist);
|
2015-10-27 22:42:15 +01:00
|
|
|
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
2015-11-03 19:40:35 +01:00
|
|
|
|
2017-11-17 11:39:39 +01:00
|
|
|
if(!str)
|
|
|
|
return ret;
|
2020-11-30 14:37:33 +01:00
|
|
|
if(options & _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
2015-11-03 19:40:35 +01:00
|
|
|
return ret>len ? -1 : ret;
|
|
|
|
if(ret>=len) {
|
|
|
|
if(len) str[len-1] = 0;
|
2020-11-30 14:37:33 +01:00
|
|
|
if(options & _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR)
|
2020-05-18 14:15:34 +02:00
|
|
|
return ret;
|
|
|
|
return len > 0 ? -2 : -1;
|
2015-11-03 19:40:35 +01:00
|
|
|
}
|
2015-10-27 22:42:15 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif /* _MSVCR_VER>=140 */
|
|
|
|
|
2010-04-19 10:57:40 +02:00
|
|
|
/*********************************************************************
|
2013-12-09 10:51:54 +01:00
|
|
|
* _vsnprintf_l (MSVCRT.@)
|
2010-04-19 10:57:40 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnprintf_l( char *str, size_t len, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2010-04-19 10:57:40 +02:00
|
|
|
{
|
2011-04-20 14:42:48 +02:00
|
|
|
static const char nullbyte = '\0';
|
|
|
|
struct _str_ctx_a ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, 0,
|
2011-05-11 15:39:07 +02:00
|
|
|
arg_clbk_valist, NULL, &valist);
|
2011-04-20 14:42:48 +02:00
|
|
|
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
|
|
|
return ret;
|
2010-04-19 10:57:40 +02:00
|
|
|
}
|
|
|
|
|
2013-12-09 10:51:54 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsprintf_l( char *str, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2013-12-09 10:51:54 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_l(str, INT_MAX, format, locale, valist);
|
2013-12-09 10:51:54 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 12:57:19 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _sprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _sprintf_l(char *str, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2013-12-09 12:57:19 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_l(str, INT_MAX, format, locale, valist);
|
2013-12-09 12:57:19 +01:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
static int CDECL vsnprintf_s_l_opt( char *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const char *format, DWORD options,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2010-04-19 10:57:40 +02:00
|
|
|
{
|
2011-04-20 14:42:48 +02:00
|
|
|
static const char nullbyte = '\0';
|
|
|
|
struct _str_ctx_a ctx;
|
2010-04-19 10:57:40 +02:00
|
|
|
int len, ret;
|
|
|
|
|
|
|
|
if(sizeOfBuffer<count+1 || count==-1)
|
|
|
|
len = sizeOfBuffer;
|
|
|
|
else
|
|
|
|
len = count+1;
|
|
|
|
|
2011-04-20 14:42:48 +02:00
|
|
|
ctx.len = len;
|
|
|
|
ctx.buf = str;
|
2015-11-03 19:40:38 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options,
|
2011-05-11 15:39:07 +02:00
|
|
|
arg_clbk_valist, NULL, &valist);
|
2011-04-20 14:42:48 +02:00
|
|
|
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
2010-04-19 10:57:40 +02:00
|
|
|
|
|
|
|
if(ret<0 || ret==len) {
|
2020-12-04 15:50:17 +01:00
|
|
|
if(count!=_TRUNCATE && count>sizeOfBuffer) {
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
|
2010-04-19 10:57:40 +02:00
|
|
|
memset(str, 0, sizeOfBuffer);
|
|
|
|
} else
|
|
|
|
str[len-1] = '\0';
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
static int vsnwprintf_s_l_opt( wchar_t *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const wchar_t *format, DWORD options,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2016-07-28 21:21:49 +02:00
|
|
|
{
|
|
|
|
struct _str_ctx_w ctx;
|
|
|
|
int len, ret;
|
|
|
|
|
|
|
|
len = sizeOfBuffer;
|
|
|
|
if(count!=-1 && len>count+1)
|
|
|
|
len = count+1;
|
|
|
|
|
|
|
|
ctx.len = len;
|
|
|
|
ctx.buf = str;
|
|
|
|
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options,
|
|
|
|
arg_clbk_valist, NULL, &valist);
|
2020-11-27 14:16:53 +01:00
|
|
|
puts_clbk_str_w(&ctx, 1, L"");
|
2016-07-28 21:21:49 +02:00
|
|
|
|
|
|
|
if(ret<0 || ret==len) {
|
2020-12-04 15:50:17 +01:00
|
|
|
if(count!=_TRUNCATE && count>sizeOfBuffer) {
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
|
2020-11-27 14:16:49 +01:00
|
|
|
memset(str, 0, sizeOfBuffer*sizeof(wchar_t));
|
2016-07-28 21:21:49 +02:00
|
|
|
} else
|
|
|
|
str[len-1] = '\0';
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-03 19:40:38 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnprintf_s_l( char *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2015-11-03 19:40:38 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnprintf_s_l_opt(str, sizeOfBuffer, count, format, 0, locale, valist);
|
2015-11-03 19:40:38 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 12:57:19 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsprintf_s_l( char *str, size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2013-12-09 12:57:19 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_s_l(str, INT_MAX, count, format, locale, valist);
|
2013-12-09 12:57:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _sprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _sprintf_s_l( char *str, size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2013-12-09 12:57:19 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_s_l(str, INT_MAX, count, format, locale, valist);
|
2013-12-09 12:57:19 +01:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-04-19 10:57:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnprintf_s( char *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const char *format, __ms_va_list valist )
|
2010-04-19 10:57:40 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_s_l(str,sizeOfBuffer, count, format, NULL, valist);
|
2010-04-19 10:57:40 +02:00
|
|
|
}
|
|
|
|
|
2020-09-15 17:40:08 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf_c_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnprintf_c_l(char *str, size_t len, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2020-09-15 17:40:08 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnprintf_s_l_opt(str, len, len, format, 0, locale, valist);
|
2020-09-15 17:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf_c (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnprintf_c(char *str, size_t len,
|
2020-09-15 17:40:08 +02:00
|
|
|
const char *format, __ms_va_list valist)
|
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_c_l(str, len, format, NULL, valist);
|
2020-09-15 17:40:08 +02:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=140
|
|
|
|
|
2015-10-27 22:42:15 +01:00
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vsnprintf_s (UCRTBASE.@)
|
2015-10-27 22:42:15 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vsnprintf_s( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
char *str, size_t sizeOfBuffer, size_t count,
|
2020-11-26 19:19:18 +01:00
|
|
|
const char *format, _locale_t locale, __ms_va_list valist )
|
2015-10-27 22:42:15 +01:00
|
|
|
{
|
2015-11-03 19:40:38 +01:00
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnprintf_s_l_opt(str, sizeOfBuffer, count, format, options & UCRTBASE_PRINTF_MASK, locale, valist);
|
2015-10-27 22:42:15 +01:00
|
|
|
}
|
|
|
|
|
2016-07-28 21:21:49 +02:00
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vsnwprintf_s (UCRTBASE.@)
|
2016-07-28 21:21:49 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vsnwprintf_s( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
wchar_t *str, size_t sizeOfBuffer, size_t count,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, __ms_va_list valist )
|
2016-07-28 21:21:49 +02:00
|
|
|
{
|
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnwprintf_s_l_opt(str, sizeOfBuffer, count, format, options & UCRTBASE_PRINTF_MASK, locale, valist);
|
2016-07-28 21:21:49 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 13:18:03 +02:00
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vswprintf_s (UCRTBASE.@)
|
2016-08-02 13:18:03 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vswprintf_s( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
wchar_t *str, size_t count, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2016-08-02 13:18:03 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return __stdio_common_vsnwprintf_s(options, str, INT_MAX, count, format, locale, valist);
|
2016-08-02 13:18:03 +02:00
|
|
|
}
|
|
|
|
|
2015-10-27 22:42:15 +01:00
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vsprintf_s (UCRTBASE.@)
|
2015-10-27 22:42:15 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vsprintf_s( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
char *str, size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2015-10-27 22:42:15 +01:00
|
|
|
{
|
2015-11-03 19:40:38 +01:00
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnprintf_s_l_opt(str, INT_MAX, count, format, options & UCRTBASE_PRINTF_MASK, locale, valist);
|
2015-10-27 22:42:15 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif /* _MSVCR_VER>=140 */
|
|
|
|
|
2006-11-14 12:29:18 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* vsprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL vsprintf( char *str, const char *format, __ms_va_list valist)
|
2006-11-14 12:29:18 +01:00
|
|
|
{
|
2020-11-19 13:28:52 +01:00
|
|
|
return vsnprintf(str, INT_MAX, format, valist);
|
2006-11-14 12:29:18 +01:00
|
|
|
}
|
|
|
|
|
2010-01-10 22:37:31 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* vsprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL vsprintf_s( char *str, size_t num, const char *format, __ms_va_list valist)
|
2010-01-10 22:37:31 +01:00
|
|
|
{
|
2020-11-19 13:28:52 +01:00
|
|
|
return vsnprintf(str, num, format, valist);
|
2010-01-10 22:37:31 +01:00
|
|
|
}
|
|
|
|
|
2009-03-26 12:45:59 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vscprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscprintf( const char *format, __ms_va_list valist )
|
2009-03-26 12:45:59 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_l( NULL, INT_MAX, format, NULL, valist );
|
2009-03-26 12:45:59 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 22:55:30 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vscprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscprintf_l(const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2018-11-16 22:55:30 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnprintf_l(NULL, INT_MAX, format, locale, valist);
|
2018-11-16 22:55:30 +01:00
|
|
|
}
|
|
|
|
|
2015-01-20 13:43:09 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vscprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscprintf_p_l(const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list args)
|
2015-01-20 13:43:09 +01:00
|
|
|
{
|
2020-12-01 13:52:05 +01:00
|
|
|
printf_arg args_ctx[_ARGMAX+1];
|
2015-01-20 13:43:09 +01:00
|
|
|
struct _str_ctx_a puts_ctx = {INT_MAX, NULL};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(args_ctx, 0, sizeof(args_ctx));
|
|
|
|
|
|
|
|
ret = create_positional_ctx_a(args_ctx, format, args);
|
|
|
|
if(ret < 0) {
|
2020-12-01 13:51:23 +01:00
|
|
|
_invalid_parameter(NULL, NULL, NULL, 0, 0);
|
|
|
|
*_errno() = EINVAL;
|
2015-01-20 13:43:09 +01:00
|
|
|
return ret;
|
|
|
|
} else if(ret == 0) {
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
|
|
|
MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
2015-01-20 13:43:09 +01:00
|
|
|
arg_clbk_valist, NULL, &args);
|
|
|
|
} else {
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
|
|
|
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER,
|
2015-01-20 13:43:09 +01:00
|
|
|
arg_clbk_positional, args_ctx, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vscprintf_p (MSVCR80.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscprintf_p(const char *format, __ms_va_list argptr)
|
2015-01-20 13:43:09 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vscprintf_p_l(format, NULL, argptr);
|
2015-01-20 13:43:09 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:30:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf(char *str, size_t len, const char *format, ...)
|
2006-01-14 17:30:02 +01:00
|
|
|
{
|
|
|
|
int retval;
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-11-19 13:28:52 +01:00
|
|
|
retval = vsnprintf(str, len, format, valist);
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_end(valist);
|
2006-01-14 17:30:02 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2014-10-30 14:08:26 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf_l(char *str, size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2014-10-30 14:08:26 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
2020-09-16 18:42:00 +02:00
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_l(str, count, format, locale, valist);
|
2014-10-30 14:08:26 +01:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2020-09-16 18:41:54 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf_c_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf_c_l(char *str, size_t count, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2020-09-16 18:41:54 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_c_l(str, count, format, locale, valist);
|
2020-09-16 18:41:54 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf_c (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf_c(char *str, size_t count, const char *format, ...)
|
2020-09-16 18:41:54 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_c(str, count, format, valist);
|
2020-09-16 18:41:54 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2020-09-16 18:42:07 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf_s_l(char *str, size_t len, size_t count,
|
2020-11-26 19:19:18 +01:00
|
|
|
const char *format, _locale_t locale, ...)
|
2020-09-16 18:42:07 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_s_l(str, len, count, format, locale, valist);
|
2020-09-16 18:42:07 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-06-10 21:12:20 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snprintf_s(char *str, size_t len, size_t count,
|
2010-06-10 21:12:20 +02:00
|
|
|
const char *format, ...)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnprintf_s_l(str, len, count, format, NULL, valist);
|
2010-06-10 21:12:20 +02:00
|
|
|
__ms_va_end(valist);
|
2010-08-27 01:46:25 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _scprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _scprintf(const char *format, ...)
|
2010-08-27 01:46:25 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vscprintf(format, valist);
|
2010-08-27 01:46:25 +02:00
|
|
|
__ms_va_end(valist);
|
2010-06-10 21:12:20 +02:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-04-19 10:57:50 +02:00
|
|
|
/*********************************************************************
|
2010-06-06 16:19:14 +02:00
|
|
|
* _vsnwprintf (MSVCRT.@)
|
2010-04-19 10:57:50 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnwprintf(wchar_t *str, size_t len,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, __ms_va_list valist)
|
2010-04-19 10:57:50 +02:00
|
|
|
{
|
2011-04-20 14:42:48 +02:00
|
|
|
struct _str_ctx_w ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, 0,
|
2011-05-11 15:39:07 +02:00
|
|
|
arg_clbk_valist, NULL, &valist);
|
2020-11-27 14:16:53 +01:00
|
|
|
puts_clbk_str_w(&ctx, 1, L"");
|
2011-04-20 14:42:48 +02:00
|
|
|
return ret;
|
2010-04-19 10:57:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2010-06-06 16:19:14 +02:00
|
|
|
* _vsnwprintf_l (MSVCRT.@)
|
2010-04-19 10:57:50 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnwprintf_l(wchar_t *str, size_t len, const wchar_t *format,
|
2020-11-27 14:17:05 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2010-04-19 10:57:50 +02:00
|
|
|
{
|
2011-04-20 14:42:48 +02:00
|
|
|
struct _str_ctx_w ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_w(puts_clbk_str_w, &ctx, format, locale, 0,
|
2011-05-11 15:39:07 +02:00
|
|
|
arg_clbk_valist, NULL, &valist);
|
2020-11-27 14:16:53 +01:00
|
|
|
puts_clbk_str_w(&ctx, 1, L"");
|
2011-04-20 14:42:48 +02:00
|
|
|
return ret;
|
2010-04-19 10:57:50 +02:00
|
|
|
}
|
|
|
|
|
2020-09-15 17:40:08 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vswprintf_c_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_c_l(wchar_t *str, size_t len, const wchar_t *format,
|
2020-11-27 14:17:05 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2020-09-15 17:40:08 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnwprintf_s_l_opt(str, len, len, format, 0, locale, valist);
|
2020-09-15 17:40:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vswprintf_c (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_c(wchar_t *str, size_t len,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, __ms_va_list valist)
|
2020-09-15 17:40:08 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vswprintf_c_l(str, len, format, NULL, valist);
|
2020-09-15 17:40:08 +02:00
|
|
|
}
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
static int vswprintf_p_l_opt(wchar_t *buffer, size_t length,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, DWORD options, _locale_t locale, __ms_va_list args)
|
2011-08-01 16:08:06 +02:00
|
|
|
{
|
2020-12-01 13:52:05 +01:00
|
|
|
printf_arg args_ctx[_ARGMAX+1];
|
2011-08-01 16:08:06 +02:00
|
|
|
struct _str_ctx_w puts_ctx = {length, buffer};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(args_ctx, 0, sizeof(args_ctx));
|
|
|
|
|
|
|
|
ret = create_positional_ctx_w(args_ctx, format, args);
|
|
|
|
if(ret < 0) {
|
2020-12-01 13:51:23 +01:00
|
|
|
_invalid_parameter(NULL, NULL, NULL, 0, 0);
|
|
|
|
*_errno() = EINVAL;
|
2011-08-01 16:08:06 +02:00
|
|
|
return ret;
|
|
|
|
} else if(ret == 0)
|
2016-08-03 06:23:09 +02:00
|
|
|
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale, MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options,
|
2011-08-01 16:08:06 +02:00
|
|
|
arg_clbk_valist, NULL, &args);
|
|
|
|
else
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_w(puts_clbk_str_w, &puts_ctx, format, locale,
|
2016-08-03 06:23:09 +02:00
|
|
|
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options,
|
2011-08-01 16:08:06 +02:00
|
|
|
arg_clbk_positional, args_ctx, NULL);
|
|
|
|
|
2020-11-27 14:16:53 +01:00
|
|
|
puts_clbk_str_w(&puts_ctx, 1, L"");
|
2011-08-01 16:08:06 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-08-03 06:23:09 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vswprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_p_l(wchar_t *buffer, size_t length,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, __ms_va_list args)
|
2016-08-03 06:23:09 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vswprintf_p_l_opt(buffer, length, format, 0, locale, args);
|
2016-08-03 06:23:09 +02:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=80
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2017-12-28 18:46:54 +01:00
|
|
|
* _vswprintf_p (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_p(wchar_t *buffer, size_t length,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, __ms_va_list args)
|
2014-04-16 16:15:21 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vswprintf_p_l_opt(buffer, length, format, 0, NULL, args);
|
2014-04-16 16:15:21 +02:00
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|
2014-04-16 16:15:21 +02:00
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=140
|
2016-08-03 06:23:09 +02:00
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vswprintf_p (UCRTBASE.@)
|
2016-08-03 06:23:09 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vswprintf_p( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
wchar_t *str, size_t count, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2016-08-03 06:23:09 +02:00
|
|
|
{
|
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2020-12-03 19:10:54 +01:00
|
|
|
return vswprintf_p_l_opt(str, count, format, options & UCRTBASE_PRINTF_MASK, locale, valist);
|
2016-08-03 06:23:09 +02:00
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|
2016-08-03 06:23:09 +02:00
|
|
|
|
2010-04-19 10:57:50 +02:00
|
|
|
/*********************************************************************
|
2010-06-06 16:19:14 +02:00
|
|
|
* _vsnwprintf_s_l (MSVCRT.@)
|
2010-04-19 10:57:50 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnwprintf_s_l( wchar_t *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist)
|
2010-04-19 10:57:50 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsnwprintf_s_l_opt(str, sizeOfBuffer, count, format, 0, locale, valist);
|
2010-04-19 10:57:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2010-06-06 16:19:14 +02:00
|
|
|
* _vsnwprintf_s (MSVCRT.@)
|
2010-04-19 10:57:50 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsnwprintf_s(wchar_t *str, size_t sizeOfBuffer,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count, const wchar_t *format, __ms_va_list valist)
|
2010-04-19 10:57:50 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf_s_l(str, sizeOfBuffer, count,
|
2010-04-19 10:57:50 +02:00
|
|
|
format, NULL, valist);
|
2005-02-14 21:53:42 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:30:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snwprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snwprintf( wchar_t *str, size_t len, const wchar_t *format, ...)
|
2006-01-14 17:30:02 +01:00
|
|
|
{
|
|
|
|
int retval;
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnwprintf(str, len, format, valist);
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_end(valist);
|
2006-01-14 17:30:02 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-01-06 22:09:37 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snwprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snwprintf_l( wchar_t *str, size_t len, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2012-01-06 22:09:37 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnwprintf_l(str, len, format, locale, valist);
|
2012-01-06 22:09:37 +01:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-06-10 21:28:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _snwprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snwprintf_s( wchar_t *str, size_t len, size_t count,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, ...)
|
2010-06-10 21:28:01 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnwprintf_s_l(str, len, count, format, NULL, valist);
|
2010-06-10 21:28:01 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2013-09-19 10:31:07 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _snwprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _snwprintf_s_l( wchar_t *str, size_t len, size_t count,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, ... )
|
2013-09-19 10:31:07 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vsnwprintf_s_l(str, len, count, format, locale, valist);
|
2013-09-19 10:31:07 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=140
|
|
|
|
|
2020-11-27 14:16:49 +01:00
|
|
|
static int puts_clbk_str_c99_w(void *ctx, int len, const wchar_t *str)
|
2015-10-27 22:42:15 +01:00
|
|
|
{
|
|
|
|
struct _str_ctx_w *out = ctx;
|
|
|
|
|
|
|
|
if(!out->buf)
|
|
|
|
return len;
|
|
|
|
|
2015-11-03 19:40:35 +01:00
|
|
|
if(out->len < len) {
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(out->buf, str, out->len*sizeof(wchar_t));
|
2015-11-03 19:40:35 +01:00
|
|
|
out->buf += out->len;
|
|
|
|
out->len = 0;
|
2015-10-27 22:42:15 +01:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(out->buf, str, len*sizeof(wchar_t));
|
2015-10-27 22:42:15 +01:00
|
|
|
out->buf += len;
|
|
|
|
out->len -= len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2017-09-04 20:06:56 +02:00
|
|
|
* __stdio_common_vswprintf (UCRTBASE.@)
|
2015-10-27 22:42:15 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vswprintf( unsigned __int64 options,
|
2020-11-27 14:17:05 +01:00
|
|
|
wchar_t *str, size_t len, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list valist )
|
2015-10-27 22:42:15 +01:00
|
|
|
{
|
|
|
|
struct _str_ctx_w ctx = {len, str};
|
|
|
|
int ret;
|
|
|
|
|
2015-11-03 19:40:38 +01:00
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
2015-10-27 22:42:15 +01:00
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2015-11-03 19:40:35 +01:00
|
|
|
ret = pf_printf_w(puts_clbk_str_c99_w,
|
2015-11-03 19:40:38 +01:00
|
|
|
&ctx, format, locale, options & UCRTBASE_PRINTF_MASK, arg_clbk_valist, NULL, &valist);
|
2020-11-27 14:16:53 +01:00
|
|
|
puts_clbk_str_w(&ctx, 1, L"");
|
2015-11-03 19:40:35 +01:00
|
|
|
|
2017-11-17 11:39:39 +01:00
|
|
|
if(!str)
|
|
|
|
return ret;
|
2020-11-30 14:37:33 +01:00
|
|
|
if(options & _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION)
|
2015-11-03 19:40:35 +01:00
|
|
|
return ret>len ? -1 : ret;
|
|
|
|
if(ret>=len) {
|
|
|
|
if(len) str[len-1] = 0;
|
2020-11-30 14:37:33 +01:00
|
|
|
if(options & _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR)
|
2020-05-18 14:15:34 +02:00
|
|
|
return ret;
|
|
|
|
return len > 0 ? -2 : -1;
|
2015-11-03 19:40:35 +01:00
|
|
|
}
|
2015-10-27 22:42:15 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif /* _MSVCR_VER>=140 */
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* sprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV sprintf( char *str, const char *format, ... )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_list ap;
|
2004-06-02 02:35:09 +02:00
|
|
|
int r;
|
|
|
|
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_start( ap, format );
|
2020-11-19 13:28:52 +01:00
|
|
|
r = vsnprintf( str, INT_MAX, format, ap );
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_end( ap );
|
2004-06-02 02:35:09 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-01-10 22:40:40 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* sprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV sprintf_s( char *str, size_t num, const char *format, ... )
|
2010-01-10 22:40:40 +01:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start( ap, format );
|
2020-11-19 13:28:52 +01:00
|
|
|
r = vsnprintf( str, num, format, ap );
|
2010-01-10 22:40:40 +01:00
|
|
|
__ms_va_end( ap );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-06-10 21:54:30 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _scwprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _scwprintf( const wchar_t *format, ... )
|
2010-06-10 21:54:30 +02:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start( ap, format );
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsnwprintf( NULL, INT_MAX, format, ap );
|
2010-06-10 21:54:30 +02:00
|
|
|
__ms_va_end( ap );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2005-02-14 21:53:42 +01:00
|
|
|
* swprintf (MSVCRT.@)
|
2001-01-22 03:21:54 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _swprintf( wchar_t *str, const wchar_t *format, ... )
|
2001-01-22 03:21:54 +01:00
|
|
|
{
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_list ap;
|
2005-02-14 21:53:42 +01:00
|
|
|
int r;
|
|
|
|
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_start( ap, format );
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsnwprintf( str, INT_MAX, format, ap );
|
2009-01-02 21:43:58 +01:00
|
|
|
__ms_va_end( ap );
|
2005-02-14 21:53:42 +01:00
|
|
|
return r;
|
2001-01-22 03:21:54 +01:00
|
|
|
}
|
|
|
|
|
2010-04-20 21:39:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* swprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV swprintf_s(wchar_t *str, size_t numberOfElements,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, ... )
|
2010-04-20 21:39:01 +02:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(ap, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsnwprintf_s(str, numberOfElements, INT_MAX, format, ap);
|
2010-04-20 21:39:01 +02:00
|
|
|
__ms_va_end(ap);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-08-01 13:55:39 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _swprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _swprintf_s_l(wchar_t *str, size_t numberOfElements,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, ... )
|
2013-08-01 13:55:39 +02:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(ap, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsnwprintf_s_l(str, numberOfElements, INT_MAX, format, locale, ap);
|
2013-08-01 13:55:39 +02:00
|
|
|
__ms_va_end(ap);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2020-09-16 18:41:54 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _swprintf_c_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _swprintf_c_l(wchar_t *str, size_t len,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, ... )
|
2020-09-16 18:41:54 +02:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(ap, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vswprintf_c_l(str, len, format, locale, ap);
|
2020-09-16 18:41:54 +02:00
|
|
|
__ms_va_end(ap);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _swprintf_c (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _swprintf_c(wchar_t *str, size_t len,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, ... )
|
2020-09-16 18:41:54 +02:00
|
|
|
{
|
|
|
|
__ms_va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(ap, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vswprintf_c(str, len, format, ap);
|
2020-09-16 18:41:54 +02:00
|
|
|
__ms_va_end(ap);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2001-01-22 03:21:54 +01:00
|
|
|
/*********************************************************************
|
2011-07-29 15:10:10 +02:00
|
|
|
* _vswprintf (MSVCRT.@)
|
2001-01-22 03:21:54 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf( wchar_t* str, const wchar_t* format, __ms_va_list args )
|
2001-01-22 03:21:54 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf( str, INT_MAX, format, args );
|
2001-01-22 03:21:54 +01:00
|
|
|
}
|
|
|
|
|
2011-07-29 15:10:10 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vswprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_l( wchar_t* str, const wchar_t* format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list args )
|
2011-07-29 15:10:10 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf_l( str, INT_MAX, format, locale, args );
|
2011-07-29 15:10:10 +02:00
|
|
|
}
|
|
|
|
|
2009-03-26 12:45:59 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vscwprintf (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscwprintf( const wchar_t *format, __ms_va_list args )
|
2009-03-26 12:45:59 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf( NULL, INT_MAX, format, args );
|
2009-03-26 12:45:59 +01:00
|
|
|
}
|
|
|
|
|
2011-08-01 16:08:06 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vscwprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscwprintf_l( const wchar_t *format, _locale_t locale, __ms_va_list args )
|
2011-08-01 16:08:06 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf_l( NULL, INT_MAX, format, locale, args );
|
2011-08-01 16:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vscwprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscwprintf_p_l( const wchar_t *format, _locale_t locale, __ms_va_list args )
|
2011-08-01 16:08:06 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vswprintf_p_l_opt( NULL, INT_MAX, format, 0, locale, args );
|
2011-08-01 16:08:06 +02:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=80
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2017-12-28 18:46:54 +01:00
|
|
|
* _vscwprintf_p (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vscwprintf_p(const wchar_t *format, __ms_va_list args)
|
2014-04-16 16:15:21 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vswprintf_p_l_opt(NULL, INT_MAX, format, 0, NULL, args);
|
2014-04-16 16:15:21 +02:00
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|
2014-04-16 16:15:21 +02:00
|
|
|
|
2008-10-18 13:59:47 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* vswprintf_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL vswprintf_s(wchar_t* str, size_t numberOfElements,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t* format, __ms_va_list args)
|
2008-10-18 13:59:47 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf_s(str, numberOfElements, INT_MAX, format, args );
|
2010-04-19 10:58:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vswprintf_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vswprintf_s_l(wchar_t* str, size_t numberOfElements,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t* format, _locale_t locale, __ms_va_list args)
|
2010-04-19 10:58:00 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsnwprintf_s_l(str, numberOfElements, INT_MAX,
|
2010-06-07 03:54:14 +02:00
|
|
|
format, locale, args );
|
2008-10-18 13:59:47 +02:00
|
|
|
}
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
static int vsprintf_p_l_opt(char *buffer, size_t length, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
DWORD options, _locale_t locale, __ms_va_list args)
|
2011-04-27 12:09:01 +02:00
|
|
|
{
|
|
|
|
static const char nullbyte = '\0';
|
2020-12-01 13:52:05 +01:00
|
|
|
printf_arg args_ctx[_ARGMAX+1];
|
2011-04-27 12:09:01 +02:00
|
|
|
struct _str_ctx_a puts_ctx = {length, buffer};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(args_ctx, 0, sizeof(args_ctx));
|
|
|
|
|
|
|
|
ret = create_positional_ctx_a(args_ctx, format, args);
|
|
|
|
if(ret < 0) {
|
2020-12-01 13:51:23 +01:00
|
|
|
_invalid_parameter(NULL, NULL, NULL, 0, 0);
|
|
|
|
*_errno() = EINVAL;
|
2011-04-27 12:09:01 +02:00
|
|
|
return ret;
|
|
|
|
} else if(ret == 0)
|
2017-10-13 20:11:24 +02:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
|
|
|
MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options, arg_clbk_valist, NULL, &args);
|
2011-04-27 12:09:01 +02:00
|
|
|
else
|
2015-11-03 19:40:36 +01:00
|
|
|
ret = pf_printf_a(puts_clbk_str_a, &puts_ctx, format, locale,
|
2017-10-13 20:11:24 +02:00
|
|
|
MSVCRT_PRINTF_POSITIONAL_PARAMS | MSVCRT_PRINTF_INVOKE_INVALID_PARAM_HANDLER | options,
|
2011-04-27 12:09:01 +02:00
|
|
|
arg_clbk_positional, args_ctx, NULL);
|
|
|
|
|
|
|
|
puts_clbk_str_a(&puts_ctx, 1, &nullbyte);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-10-13 20:11:24 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsprintf_p_l(char *buffer, size_t length, const char *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, __ms_va_list args)
|
2017-10-13 20:11:24 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsprintf_p_l_opt(buffer, length, format, 0, locale, args);
|
2017-10-13 20:11:24 +02:00
|
|
|
}
|
|
|
|
|
2011-04-27 12:09:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsprintf_p (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _vsprintf_p(char *buffer, size_t length,
|
2011-04-27 12:09:01 +02:00
|
|
|
const char *format, __ms_va_list args)
|
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _vsprintf_p_l(buffer, length, format, NULL, args);
|
2011-04-27 12:09:01 +02:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=140
|
2017-10-13 20:11:24 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __stdio_common_vsprintf_p (UCRTBASE.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL __stdio_common_vsprintf_p(unsigned __int64 options, char *buffer, size_t length,
|
2020-11-26 19:19:18 +01:00
|
|
|
const char *format, _locale_t locale, __ms_va_list args)
|
2017-10-13 20:11:24 +02:00
|
|
|
{
|
|
|
|
if (options & ~UCRTBASE_PRINTF_MASK)
|
|
|
|
FIXME("options %s not handled\n", wine_dbgstr_longlong(options));
|
2020-12-03 19:10:54 +01:00
|
|
|
return vsprintf_p_l_opt(buffer, length, format, options & UCRTBASE_PRINTF_MASK, locale, args);
|
2017-10-13 20:11:24 +02:00
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|
2017-10-13 20:11:24 +02:00
|
|
|
|
2011-04-27 12:09:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _sprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _sprintf_p_l(char *buffer, size_t length,
|
2020-11-26 19:19:18 +01:00
|
|
|
const char *format, _locale_t locale, ...)
|
2011-04-27 12:09:01 +02:00
|
|
|
{
|
|
|
|
__ms_va_list valist;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsprintf_p_l(buffer, length, format, locale, valist);
|
2011-04-27 12:09:01 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-05-29 21:08:33 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* __swprintf_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV __swprintf_l( wchar_t *str, const wchar_t *format,
|
2020-11-26 19:19:18 +01:00
|
|
|
_locale_t locale, ...)
|
2015-05-29 21:08:33 +02:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
__ms_va_list valist;
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
retval = _vswprintf_l(str, format, locale, valist);
|
2015-05-29 21:08:33 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=80
|
2014-04-16 16:15:21 +02:00
|
|
|
/*********************************************************************
|
2017-12-28 18:46:54 +01:00
|
|
|
* _sprintf_p (MSVCR80.@)
|
2014-04-16 16:15:21 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _sprintf_p(char *buffer, size_t length, const char *format, ...)
|
2014-04-16 16:15:21 +02:00
|
|
|
{
|
|
|
|
__ms_va_list valist;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(valist, format);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = _vsprintf_p_l(buffer, length, format, NULL, valist);
|
2014-04-16 16:15:21 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif
|
2014-04-16 16:15:21 +02:00
|
|
|
|
2011-04-27 12:09:01 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _swprintf_p_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int WINAPIV _swprintf_p_l(wchar_t *buffer, size_t length,
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *format, _locale_t locale, ...)
|
2011-04-27 12:09:01 +02:00
|
|
|
{
|
|
|
|
__ms_va_list valist;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
__ms_va_start(valist, locale);
|
2020-12-03 19:10:54 +01:00
|
|
|
r = vswprintf_p_l_opt(buffer, length, format, 0, locale, valist);
|
2011-04-27 12:09:01 +02:00
|
|
|
__ms_va_end(valist);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2020-07-14 20:22:45 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcscmp (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wcscmp(const wchar_t *str1, const wchar_t *str2)
|
2020-07-14 20:22:45 +02:00
|
|
|
{
|
|
|
|
while (*str1 && (*str1 == *str2))
|
|
|
|
{
|
|
|
|
str1++;
|
|
|
|
str2++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*str1 < *str2)
|
|
|
|
return -1;
|
|
|
|
if (*str1 > *str2)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-30 15:34:31 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcscoll_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wcscoll_l(const wchar_t* str1, const wchar_t* str2, _locale_t locale)
|
2013-03-30 15:34:31 +01:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2013-03-30 15:34:31 +01:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_COLLATE])
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcscmp(str1, str2);
|
2020-11-30 14:37:48 +01:00
|
|
|
return CompareStringW(locinfo->lc_handle[LC_COLLATE], 0, str1, -1, str2, -1)-CSTR_EQUAL;
|
2013-03-30 15:34:31 +01:00
|
|
|
}
|
|
|
|
|
2001-01-22 03:21:54 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcscoll (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wcscoll( const wchar_t* str1, const wchar_t* str2 )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcscoll_l(str1, str2, NULL);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* wcspbrk (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL wcspbrk( const wchar_t* str, const wchar_t* accept )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t* p;
|
2012-12-17 23:12:14 +01:00
|
|
|
|
|
|
|
while (*str)
|
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
for (p = accept; *p; p++) if (*p == *str) return (wchar_t*)str;
|
2012-12-17 23:12:14 +01:00
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return NULL;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2006-01-14 17:24:49 +01:00
|
|
|
/*********************************************************************
|
2010-11-02 22:03:59 +01:00
|
|
|
* wcstok_s (MSVCRT.@)
|
2006-01-14 17:24:49 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t * CDECL wcstok_s( wchar_t *str, const wchar_t *delim,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **next_token )
|
2006-01-14 17:24:49 +01:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t *ret;
|
2006-01-14 17:24:49 +01:00
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(delim != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(next_token != NULL)) return NULL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL || *next_token != NULL)) return NULL;
|
|
|
|
|
2010-11-02 22:03:59 +01:00
|
|
|
if (!str) str = *next_token;
|
2006-01-14 17:24:49 +01:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
while (*str && wcschr( delim, *str )) str++;
|
2021-05-25 15:59:46 +02:00
|
|
|
if (!*str) ret = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = str++;
|
|
|
|
while (*str && !wcschr( delim, *str )) str++;
|
|
|
|
if (*str) *str++ = 0;
|
|
|
|
}
|
2010-11-02 22:03:59 +01:00
|
|
|
*next_token = str;
|
2006-01-14 17:24:49 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-02 22:03:59 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstok (MSVCRT.@)
|
|
|
|
*/
|
2020-01-24 06:51:22 +01:00
|
|
|
#if _MSVCR_VER>=140
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t * CDECL wcstok( wchar_t *str, const wchar_t *delim, wchar_t **ctx )
|
2020-01-24 06:51:22 +01:00
|
|
|
{
|
|
|
|
if (!ctx)
|
|
|
|
ctx = &msvcrt_get_thread_data()->wcstok_next;
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcstok_s(str, delim, ctx);
|
2020-01-24 06:51:22 +01:00
|
|
|
}
|
|
|
|
#else
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t * CDECL wcstok( wchar_t *str, const wchar_t *delim )
|
2010-11-02 22:03:59 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wcstok_s(str, delim, &msvcrt_get_thread_data()->wcstok_next);
|
2010-11-02 22:03:59 +01:00
|
|
|
}
|
2020-01-24 06:51:22 +01:00
|
|
|
#endif
|
2006-01-14 17:24:49 +01:00
|
|
|
|
2013-07-25 10:14:33 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wctomb_s_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wctomb_s_l(int *len, char *mbchar, size_t size,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t wch, _locale_t locale)
|
2013-07-25 10:14:33 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-10-19 19:35:41 +02:00
|
|
|
BOOL error = FALSE;
|
|
|
|
BOOL *perror;
|
2013-07-25 10:14:33 +02:00
|
|
|
int mblen;
|
|
|
|
|
|
|
|
if(!mbchar && size>0) {
|
|
|
|
if(len)
|
|
|
|
*len = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(len)
|
|
|
|
*len = -1;
|
|
|
|
|
|
|
|
if(!MSVCRT_CHECK_PMT(size <= INT_MAX))
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2013-07-25 10:14:33 +02:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
|
|
|
if(!locinfo->lc_codepage) {
|
|
|
|
if(wch > 0xff) {
|
|
|
|
if(mbchar && size>0)
|
|
|
|
memset(mbchar, 0, size);
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EILSEQ;
|
2013-07-25 10:14:33 +02:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if(!MSVCRT_CHECK_PMT_ERR(size >= 1, ERANGE))
|
|
|
|
return ERANGE;
|
2013-07-25 10:14:33 +02:00
|
|
|
|
|
|
|
*mbchar = wch;
|
|
|
|
if(len)
|
|
|
|
*len = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-19 19:35:41 +02:00
|
|
|
perror = (locinfo->lc_codepage != CP_UTF8 ? &error : NULL);
|
|
|
|
mblen = WideCharToMultiByte(locinfo->lc_codepage, 0, &wch, 1, mbchar, size, NULL, perror);
|
2013-07-25 10:14:33 +02:00
|
|
|
if(!mblen || error) {
|
|
|
|
if(!mblen && GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
|
|
|
|
if(mbchar && size>0)
|
|
|
|
memset(mbchar, 0, size);
|
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("insufficient buffer size", ERANGE);
|
|
|
|
return ERANGE;
|
2013-07-25 10:14:33 +02:00
|
|
|
}
|
|
|
|
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EILSEQ;
|
2013-07-25 10:14:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(len)
|
|
|
|
*len = mblen;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wctomb_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL wctomb_s(int *len, char *mbchar, size_t size, wchar_t wch)
|
2013-07-25 10:14:33 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wctomb_s_l(len, mbchar, size, wch, NULL);
|
2013-07-25 10:14:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wctomb_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _wctomb_l(char *dst, wchar_t ch, _locale_t locale)
|
2013-07-25 10:14:33 +02:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
_wctomb_s_l(&len, dst, dst ? MB_LEN_MAX : 0, ch, locale);
|
2013-07-25 10:14:33 +02:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wctomb (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wctomb( char *dst, wchar_t ch )
|
2013-07-25 10:14:33 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wctomb_l(dst, ch, NULL);
|
2013-07-25 10:14:33 +02:00
|
|
|
}
|
|
|
|
|
2011-04-05 23:47:22 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wctob (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wctob( wint_t wchar )
|
2011-04-05 23:47:22 +02:00
|
|
|
{
|
|
|
|
char out;
|
2020-10-19 19:35:50 +02:00
|
|
|
BOOL error = FALSE;
|
|
|
|
BOOL *perror;
|
2011-11-30 14:34:13 +01:00
|
|
|
UINT codepage = get_locinfo()->lc_codepage;
|
|
|
|
|
2020-10-19 19:35:50 +02:00
|
|
|
perror = (codepage != CP_UTF8 ? &error : NULL);
|
|
|
|
|
2011-11-30 14:34:13 +01:00
|
|
|
if(!codepage) {
|
|
|
|
if (wchar < 0xff)
|
|
|
|
return (signed char)wchar;
|
|
|
|
else
|
2020-11-30 14:37:09 +01:00
|
|
|
return EOF;
|
2020-10-19 19:35:50 +02:00
|
|
|
} else if(WideCharToMultiByte( codepage, 0, &wchar, 1, &out, 1, NULL, perror ) && !error)
|
2011-04-05 23:47:22 +02:00
|
|
|
return (INT)out;
|
2020-11-30 14:37:09 +01:00
|
|
|
return EOF;
|
2011-04-05 23:47:22 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 19:09:09 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcrtomb_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wcrtomb_s(size_t *len, char *mbchar,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t size, wchar_t wch, mbstate_t *s)
|
2019-09-30 19:09:09 +02:00
|
|
|
{
|
|
|
|
int ilen, ret;
|
|
|
|
|
|
|
|
if (s) *s = 0;
|
2020-12-03 19:10:54 +01:00
|
|
|
ret = wctomb_s(&ilen, mbchar, size, wch);
|
2019-09-30 19:09:09 +02:00
|
|
|
if (len) *len = ilen;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-29 22:49:42 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcrtomb (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcrtomb( char *dst, wchar_t ch, mbstate_t *s)
|
2012-11-29 22:49:42 +01:00
|
|
|
{
|
|
|
|
if(s)
|
|
|
|
*s = 0;
|
2020-12-03 19:10:54 +01:00
|
|
|
return wctomb(dst, ch);
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2020-07-15 14:05:40 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _iswctype_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswctype_l( wchar_t wc, wctype_t type, _locale_t locale )
|
2020-07-15 14:05:40 +02:00
|
|
|
{
|
2020-07-21 12:21:20 +02:00
|
|
|
WORD ct;
|
|
|
|
|
2020-11-30 14:37:05 +01:00
|
|
|
if (wc == WEOF) return 0;
|
2020-07-21 12:21:20 +02:00
|
|
|
if (wc < 256) return MSVCRT__pwctype[wc] & type;
|
|
|
|
|
|
|
|
if (!GetStringTypeW(CT_CTYPE1, &wc, 1, &ct))
|
|
|
|
{
|
|
|
|
ERR("GetStringTypeW failed for %x\n", wc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ct & type;
|
2020-07-15 14:05:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iswctype (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswctype( wchar_t wc, wctype_t type )
|
2020-07-15 14:05:40 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, type, NULL );
|
2020-07-15 14:05:40 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:46 +02:00
|
|
|
* _iswalnum_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswalnum_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _ALPHA | _DIGIT, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 07:31:54 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:46 +02:00
|
|
|
* iswalnum (MSVCRT.@)
|
2018-11-16 07:31:54 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswalnum( wchar_t wc )
|
2018-11-16 07:31:54 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswalnum_l( wc, NULL );
|
2018-11-16 07:31:54 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:50 +02:00
|
|
|
* iswalpha_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswalpha_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _ALPHA, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 10:24:44 +02:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:50 +02:00
|
|
|
* iswalpha (MSVCRT.@)
|
2010-04-08 10:24:44 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswalpha( wchar_t wc )
|
2010-04-08 10:24:44 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswalpha_l( wc, NULL );
|
2010-04-08 10:24:44 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:54 +02:00
|
|
|
* _iswcntrl_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswcntrl_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _CONTROL, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 07:31:55 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:54 +02:00
|
|
|
* iswcntrl (MSVCRT.@)
|
2018-11-16 07:31:55 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswcntrl( wchar_t wc )
|
2018-11-16 07:31:55 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswcntrl_l( wc, NULL );
|
2018-11-16 07:31:55 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:57 +02:00
|
|
|
* _iswdigit_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswdigit_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _DIGIT, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2011-10-06 20:14:23 +02:00
|
|
|
/*********************************************************************
|
2020-07-15 14:05:57 +02:00
|
|
|
* iswdigit (MSVCRT.@)
|
2011-10-06 20:14:23 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswdigit( wchar_t wc )
|
2011-10-06 20:14:23 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswdigit_l( wc, NULL );
|
2011-10-06 20:14:23 +02:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:00 +02:00
|
|
|
* _iswgraph_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswgraph_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _ALPHA | _DIGIT | _PUNCT, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 07:31:53 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:00 +02:00
|
|
|
* iswgraph (MSVCRT.@)
|
2018-11-16 07:31:53 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswgraph( wchar_t wc )
|
2018-11-16 07:31:53 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswgraph_l( wc, NULL );
|
2018-11-16 07:31:53 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:06 +02:00
|
|
|
* _iswlower_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswlower_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _LOWER, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-15 06:14:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:06 +02:00
|
|
|
* iswlower (MSVCRT.@)
|
2018-11-15 06:14:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswlower( wchar_t wc )
|
2018-11-15 06:14:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswlower_l( wc, NULL );
|
2018-11-15 06:14:25 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:10 +02:00
|
|
|
* _iswprint_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswprint_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _ALPHA | _BLANK | _DIGIT | _PUNCT, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-16 07:31:56 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:10 +02:00
|
|
|
* iswprint (MSVCRT.@)
|
2018-11-16 07:31:56 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswprint( wchar_t wc )
|
2018-11-16 07:31:56 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswprint_l( wc, NULL );
|
2018-11-16 07:31:56 +01:00
|
|
|
}
|
|
|
|
|
2015-01-23 17:51:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _iswpunct_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswpunct_l( wchar_t wc, _locale_t locale )
|
2015-01-23 17:51:02 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _PUNCT, locale );
|
2015-01-23 17:51:02 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswpunct (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswpunct( wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswpunct_l( wc, NULL );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-23 17:50:55 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _iswspace_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswspace_l( wchar_t wc, _locale_t locale )
|
2015-01-23 17:50:55 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _SPACE, locale );
|
2015-01-23 17:50:55 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswspace (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswspace( wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswspace_l( wc, NULL );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2020-07-15 14:06:29 +02:00
|
|
|
* _iswupper_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswupper_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _UPPER, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-15 06:14:26 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:29 +02:00
|
|
|
* iswupper (MSVCRT.@)
|
2018-11-15 06:14:26 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswupper( wchar_t wc )
|
2018-11-15 06:14:26 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswupper_l( wc, NULL );
|
2018-11-15 06:14:26 +01:00
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:34 +02:00
|
|
|
* _iswxdigit_l (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int CDECL _iswxdigit_l( wchar_t wc, _locale_t locale )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswctype_l( wc, _HEX, locale );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2018-11-16 07:31:57 +01:00
|
|
|
/*********************************************************************
|
2020-07-15 14:06:34 +02:00
|
|
|
* iswxdigit (MSVCRT.@)
|
2018-11-16 07:31:57 +01:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswxdigit( wchar_t wc )
|
2018-11-16 07:31:57 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _iswxdigit_l( wc, NULL );
|
2018-11-16 07:31:57 +01:00
|
|
|
}
|
|
|
|
|
2017-04-03 22:25:26 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _iswblank_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL _iswblank_l( wchar_t wc, _locale_t locale )
|
2017-04-03 22:25:26 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wc == '\t' || _iswctype_l( wc, _BLANK, locale );
|
2017-04-03 22:25:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iswblank (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL iswblank( wchar_t wc )
|
2017-04-03 22:25:26 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return wc == '\t' || _iswctype_l( wc, _BLANK, NULL );
|
2017-04-03 22:25:26 +02:00
|
|
|
}
|
|
|
|
|
2008-02-27 09:58:04 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcscpy_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
|
2008-02-27 09:58:04 +01:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t size = 0;
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if(!MSVCRT_CHECK_PMT(wcDest)) return EINVAL;
|
|
|
|
if(!MSVCRT_CHECK_PMT(numElement)) return EINVAL;
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2019-06-24 05:49:34 +02:00
|
|
|
if(!MSVCRT_CHECK_PMT(wcSrc))
|
|
|
|
{
|
|
|
|
wcDest[0] = 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2019-06-24 05:49:34 +02:00
|
|
|
}
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
size = wcslen(wcSrc) + 1;
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if(!MSVCRT_CHECK_PMT_ERR(size <= numElement, ERANGE))
|
2019-06-24 05:49:34 +02:00
|
|
|
{
|
|
|
|
wcDest[0] = 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
return ERANGE;
|
2019-06-24 05:49:34 +02:00
|
|
|
}
|
2008-02-27 09:58:04 +01:00
|
|
|
|
2019-06-24 05:49:34 +02:00
|
|
|
memmove( wcDest, wcSrc, size*sizeof(WCHAR) );
|
2008-02-27 09:58:04 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-02 22:00:34 +02:00
|
|
|
|
2020-07-21 12:21:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* wcscpy (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* __cdecl wcscpy( wchar_t *dst, const wchar_t *src )
|
2020-07-21 12:21:33 +02:00
|
|
|
{
|
|
|
|
WCHAR *p = dst;
|
|
|
|
while ((*p++ = *src++));
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2013-03-27 16:13:08 +01:00
|
|
|
/******************************************************************
|
|
|
|
* wcsncpy (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* __cdecl wcsncpy( wchar_t* s1, const wchar_t *s2, size_t n )
|
2013-03-27 16:13:08 +01:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t i;
|
2013-03-27 16:13:08 +01:00
|
|
|
|
|
|
|
for(i=0; i<n; i++)
|
|
|
|
if(!(s1[i] = s2[i])) break;
|
|
|
|
for(; i<n; i++)
|
|
|
|
s1[i] = 0;
|
|
|
|
return s1;
|
|
|
|
}
|
|
|
|
|
2008-10-02 22:00:34 +02:00
|
|
|
/******************************************************************
|
|
|
|
* wcsncpy_s (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wcsncpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t count )
|
2008-10-02 22:00:34 +02:00
|
|
|
{
|
2012-04-24 18:44:07 +02:00
|
|
|
WCHAR *p = wcDest;
|
2020-12-04 15:50:17 +01:00
|
|
|
BOOL truncate = (count == _TRUNCATE);
|
2012-04-24 18:44:07 +02:00
|
|
|
|
|
|
|
if(!wcDest && !numElement && !count)
|
|
|
|
return 0;
|
2008-10-02 22:00:34 +02:00
|
|
|
|
|
|
|
if (!wcDest || !numElement)
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2008-10-02 22:00:34 +02:00
|
|
|
|
|
|
|
if (!wcSrc)
|
|
|
|
{
|
2012-04-24 18:44:07 +02:00
|
|
|
*wcDest = 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
return count ? EINVAL : 0;
|
2008-10-02 22:00:34 +02:00
|
|
|
}
|
|
|
|
|
2012-04-24 18:44:07 +02:00
|
|
|
while (numElement && count && *wcSrc)
|
2012-04-12 16:19:31 +02:00
|
|
|
{
|
2012-04-24 18:44:07 +02:00
|
|
|
*p++ = *wcSrc++;
|
|
|
|
numElement--;
|
|
|
|
count--;
|
2012-04-12 16:19:31 +02:00
|
|
|
}
|
2012-04-24 18:44:07 +02:00
|
|
|
if (!numElement && truncate)
|
2008-10-02 22:00:34 +02:00
|
|
|
{
|
2012-04-24 18:44:07 +02:00
|
|
|
*(p-1) = 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
return STRUNCATE;
|
2012-04-24 18:44:07 +02:00
|
|
|
}
|
|
|
|
else if (!numElement)
|
|
|
|
{
|
|
|
|
*wcDest = 0;
|
2020-11-30 14:37:27 +01:00
|
|
|
return ERANGE;
|
2008-10-02 22:00:34 +02:00
|
|
|
}
|
|
|
|
|
2012-04-24 18:44:07 +02:00
|
|
|
*p = 0;
|
|
|
|
return 0;
|
2008-10-02 22:00:34 +02:00
|
|
|
}
|
2008-10-12 13:34:16 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* wcscat_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wcscat_s(wchar_t* dst, size_t elem, const wchar_t* src)
|
2008-10-12 13:34:16 +02:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t* ptr = dst;
|
2008-10-12 13:34:16 +02:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if (!dst || elem == 0) return EINVAL;
|
2008-10-12 13:34:16 +02:00
|
|
|
if (!src)
|
|
|
|
{
|
|
|
|
dst[0] = '\0';
|
2020-11-30 14:37:27 +01:00
|
|
|
return EINVAL;
|
2008-10-12 13:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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';
|
2020-11-30 14:37:27 +01:00
|
|
|
return ERANGE;
|
2010-10-18 14:06:16 +02:00
|
|
|
}
|
|
|
|
|
2020-07-21 12:21:39 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* wcscat (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* __cdecl wcscat( wchar_t *dst, const wchar_t *src )
|
2020-07-21 12:21:39 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
wcscpy( dst + wcslen(dst), src );
|
2020-07-21 12:21:39 +02:00
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:06:16 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcsncat_s (MSVCRT.@)
|
|
|
|
*
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
INT CDECL wcsncat_s(wchar_t *dst, size_t elem,
|
2020-11-27 14:17:05 +01:00
|
|
|
const wchar_t *src, size_t count)
|
2010-10-18 14:06:16 +02:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t srclen;
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t dststart;
|
2010-10-19 07:24:52 +02:00
|
|
|
INT ret = 0;
|
2010-10-18 14:06:16 +02:00
|
|
|
|
2020-11-30 14:37:27 +01:00
|
|
|
if (!MSVCRT_CHECK_PMT(dst != NULL)) return EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(elem > 0)) return EINVAL;
|
|
|
|
if (!MSVCRT_CHECK_PMT(src != NULL || count == 0)) return EINVAL;
|
2012-07-26 11:05:32 +02:00
|
|
|
|
2010-10-19 07:24:52 +02:00
|
|
|
if (count == 0)
|
|
|
|
return 0;
|
2010-10-18 14:06:16 +02:00
|
|
|
|
2010-10-19 07:24:52 +02:00
|
|
|
for (dststart = 0; dststart < elem; dststart++)
|
2010-10-18 14:06:16 +02:00
|
|
|
{
|
2010-10-19 07:24:52 +02:00
|
|
|
if (dst[dststart] == '\0')
|
2010-10-18 14:06:16 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dststart == elem)
|
2010-11-15 22:00:10 +01:00
|
|
|
{
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("dst[elem] is not NULL terminated\n", EINVAL);
|
|
|
|
return EINVAL;
|
2010-11-15 22:00:10 +01:00
|
|
|
}
|
2010-10-18 14:06:16 +02:00
|
|
|
|
2020-12-04 15:50:17 +01:00
|
|
|
if (count == _TRUNCATE)
|
2010-10-18 14:06:16 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
srclen = wcslen(src);
|
2010-10-19 07:24:52 +02:00
|
|
|
if (srclen >= (elem - dststart))
|
2010-10-18 14:06:16 +02:00
|
|
|
{
|
2010-10-19 07:24:52 +02:00
|
|
|
srclen = elem - dststart - 1;
|
2020-11-30 14:37:27 +01:00
|
|
|
ret = STRUNCATE;
|
2010-10-18 14:06:16 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-19 07:24:52 +02:00
|
|
|
else
|
2020-12-03 19:10:54 +01:00
|
|
|
srclen = min(wcslen(src), count);
|
2010-10-18 14:06:16 +02:00
|
|
|
if (srclen < (elem - dststart))
|
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
memcpy(&dst[dststart], src, srclen*sizeof(wchar_t));
|
2011-03-30 15:45:21 +02:00
|
|
|
dst[dststart+srclen] = '\0';
|
2010-10-19 07:24:52 +02:00
|
|
|
return ret;
|
2010-10-18 14:06:16 +02:00
|
|
|
}
|
2020-11-30 14:37:27 +01:00
|
|
|
MSVCRT_INVALID_PMT("dst[elem] is too small", ERANGE);
|
2010-10-18 14:06:16 +02:00
|
|
|
dst[0] = '\0';
|
2020-11-30 14:37:27 +01:00
|
|
|
return ERANGE;
|
2008-10-12 13:34:16 +02:00
|
|
|
}
|
2010-04-27 08:42:32 +02:00
|
|
|
|
2017-01-25 16:02:24 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wctoint (INTERNAL)
|
|
|
|
*/
|
|
|
|
static int wctoint(WCHAR c, int base)
|
|
|
|
{
|
|
|
|
int v = -1;
|
|
|
|
if ('0' <= c && c <= '9')
|
|
|
|
v = c - '0';
|
|
|
|
else if ('A' <= c && c <= 'Z')
|
|
|
|
v = c - 'A' + 10;
|
|
|
|
else if ('a' <= c && c <= 'z')
|
|
|
|
v = c - 'a' + 10;
|
2017-01-25 16:02:25 +01:00
|
|
|
else {
|
|
|
|
/* NOTE: wine_fold_string(MAP_FOLDDIGITS) supports too many things. */
|
|
|
|
/* Unicode points that contain digits 0-9; keep this sorted! */
|
|
|
|
static const WCHAR zeros[] = {
|
|
|
|
0x660, 0x6f0, 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xc66, 0xce6,
|
|
|
|
0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10
|
|
|
|
};
|
|
|
|
int i;
|
2018-07-26 00:05:52 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(zeros) && c >= zeros[i]; ++i) {
|
2017-01-25 16:02:25 +01:00
|
|
|
if (zeros[i] <= c && c <= zeros[i] + 9) {
|
|
|
|
v = c - zeros[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-25 16:02:24 +01:00
|
|
|
return v < base ? v : -1;
|
|
|
|
}
|
|
|
|
|
2010-04-27 08:42:32 +02:00
|
|
|
/*********************************************************************
|
2010-06-06 16:19:14 +02:00
|
|
|
* _wcstoi64_l (MSVCRT.@)
|
2010-04-27 08:42:32 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 CDECL _wcstoi64_l(const wchar_t *nptr,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **endptr, int base, _locale_t locale)
|
2010-04-27 08:42:32 +02:00
|
|
|
{
|
2017-01-25 16:02:26 +01:00
|
|
|
BOOL negative = FALSE, empty = TRUE;
|
2010-04-27 08:42:32 +02:00
|
|
|
__int64 ret = 0;
|
|
|
|
|
|
|
|
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
|
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
|
|
|
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
|
|
|
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
2017-01-25 16:02:26 +01:00
|
|
|
if(endptr)
|
2020-11-27 14:16:49 +01:00
|
|
|
*endptr = (wchar_t*)nptr;
|
2017-01-25 16:02:26 +01:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
while(_iswspace_l(*nptr, locale)) nptr++;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
if(*nptr == '-') {
|
|
|
|
negative = TRUE;
|
|
|
|
nptr++;
|
|
|
|
} else if(*nptr == '+')
|
|
|
|
nptr++;
|
|
|
|
|
2020-07-16 14:47:03 +02:00
|
|
|
if((base==0 || base==16) && wctoint(*nptr, 1)==0 && (nptr[1]=='x' || nptr[1]=='X')) {
|
2010-04-27 08:42:32 +02:00
|
|
|
base = 16;
|
|
|
|
nptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(base == 0) {
|
2017-01-25 16:02:24 +01:00
|
|
|
if(wctoint(*nptr, 1)==0)
|
2010-04-27 08:42:32 +02:00
|
|
|
base = 8;
|
|
|
|
else
|
|
|
|
base = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(*nptr) {
|
2017-01-25 16:02:24 +01:00
|
|
|
int v = wctoint(*nptr, base);
|
|
|
|
if(v<0)
|
|
|
|
break;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
if(negative)
|
|
|
|
v = -v;
|
|
|
|
|
|
|
|
nptr++;
|
2017-01-25 16:02:26 +01:00
|
|
|
empty = FALSE;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
2020-11-27 14:17:01 +01:00
|
|
|
if(!negative && (ret>I64_MAX/base || ret*base>I64_MAX-v)) {
|
|
|
|
ret = I64_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2020-11-27 14:17:01 +01:00
|
|
|
} else if(negative && (ret<I64_MIN/base || ret*base<I64_MIN-v)) {
|
|
|
|
ret = I64_MIN;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2010-04-27 08:42:32 +02:00
|
|
|
} else
|
|
|
|
ret = ret*base + v;
|
|
|
|
}
|
|
|
|
|
2017-01-25 16:02:26 +01:00
|
|
|
if(endptr && !empty)
|
2020-11-27 14:16:49 +01:00
|
|
|
*endptr = (wchar_t*)nptr;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2010-04-28 17:44:51 +02:00
|
|
|
* _wcstoi64 (MSVCRT.@)
|
2010-04-27 08:42:32 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 CDECL _wcstoi64(const wchar_t *nptr,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **endptr, int base)
|
2010-04-27 08:42:32 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstoi64_l(nptr, endptr, base, NULL);
|
2010-04-27 08:42:32 +02:00
|
|
|
}
|
|
|
|
|
2013-07-28 09:43:59 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstol_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_long CDECL _wcstol_l(const wchar_t *s,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **end, int base, _locale_t locale)
|
2013-07-28 09:43:59 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 ret = _wcstoi64_l(s, end, base, locale);
|
2013-07-28 09:43:59 +02:00
|
|
|
|
2020-11-27 14:17:01 +01:00
|
|
|
if(ret > LONG_MAX) {
|
|
|
|
ret = LONG_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2020-11-27 14:17:01 +01:00
|
|
|
}else if(ret < LONG_MIN) {
|
|
|
|
ret = LONG_MIN;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2013-07-28 09:43:59 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-10-17 15:23:22 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstol (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_long CDECL wcstol(const wchar_t *s,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **end, int base)
|
2018-10-17 15:23:22 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstol_l(s, end, base, NULL);
|
2018-10-17 15:23:22 +02:00
|
|
|
}
|
|
|
|
|
2012-12-12 11:16:05 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtoi_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int __cdecl _wtoi_l(const wchar_t *str, _locale_t locale)
|
2012-12-12 11:16:05 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 ret = _wcstoi64_l(str, NULL, 10, locale);
|
2012-12-12 11:16:05 +01:00
|
|
|
|
|
|
|
if(ret > INT_MAX) {
|
|
|
|
ret = INT_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2012-12-12 11:16:05 +01:00
|
|
|
} else if(ret < INT_MIN) {
|
|
|
|
ret = INT_MIN;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2012-12-12 11:16:05 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-27 16:11:23 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtoi (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
int __cdecl _wtoi(const wchar_t *str)
|
2013-03-27 16:11:23 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wtoi_l(str, NULL);
|
2013-03-27 16:11:23 +01:00
|
|
|
}
|
|
|
|
|
2013-03-27 16:11:32 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtol_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_long __cdecl _wtol_l(const wchar_t *str, _locale_t locale)
|
2013-03-27 16:11:32 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 ret = _wcstoi64_l(str, NULL, 10, locale);
|
2013-03-27 16:11:32 +01:00
|
|
|
|
2020-11-27 14:17:01 +01:00
|
|
|
if(ret > LONG_MAX) {
|
|
|
|
ret = LONG_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2020-11-27 14:17:01 +01:00
|
|
|
} else if(ret < LONG_MIN) {
|
|
|
|
ret = LONG_MIN;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2013-03-27 16:11:32 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wtol (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_long __cdecl _wtol(const wchar_t *str)
|
2013-03-27 16:11:32 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wtol_l(str, NULL);
|
2013-03-27 16:11:32 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#if _MSVCR_VER>=120
|
|
|
|
|
2016-02-09 14:29:07 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wtoll_l (MSVCR120.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 __cdecl _wtoll_l(const wchar_t *str, _locale_t locale)
|
2016-02-09 14:29:07 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstoi64_l(str, NULL, 10, locale);
|
2016-02-09 14:29:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wtoll (MSVCR120.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 __cdecl _wtoll(const wchar_t *str)
|
2016-02-09 14:29:07 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wtoll_l(str, NULL);
|
2016-02-09 14:29:07 +01:00
|
|
|
}
|
|
|
|
|
2017-12-28 18:46:54 +01:00
|
|
|
#endif /* _MSVCR_VER>=120 */
|
|
|
|
|
2010-04-27 08:42:32 +02:00
|
|
|
/*********************************************************************
|
2010-04-28 17:44:51 +02:00
|
|
|
* _wcstoui64_l (MSVCRT.@)
|
2010-04-27 08:42:32 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
unsigned __int64 CDECL _wcstoui64_l(const wchar_t *nptr,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **endptr, int base, _locale_t locale)
|
2010-04-27 08:42:32 +02:00
|
|
|
{
|
2017-01-25 16:02:26 +01:00
|
|
|
BOOL negative = FALSE, empty = TRUE;
|
2010-04-27 08:42:32 +02:00
|
|
|
unsigned __int64 ret = 0;
|
|
|
|
|
|
|
|
TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale);
|
|
|
|
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
|
|
|
|
if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
|
|
|
|
if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
2017-01-25 16:02:26 +01:00
|
|
|
if(endptr)
|
2020-11-27 14:16:49 +01:00
|
|
|
*endptr = (wchar_t*)nptr;
|
2017-01-25 16:02:26 +01:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
while(_iswspace_l(*nptr, locale)) nptr++;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
if(*nptr == '-') {
|
|
|
|
negative = TRUE;
|
|
|
|
nptr++;
|
|
|
|
} else if(*nptr == '+')
|
|
|
|
nptr++;
|
|
|
|
|
2020-07-16 14:47:03 +02:00
|
|
|
if((base==0 || base==16) && wctoint(*nptr, 1)==0 && (nptr[1]=='x' || nptr[1]=='X')) {
|
2010-04-27 08:42:32 +02:00
|
|
|
base = 16;
|
|
|
|
nptr += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(base == 0) {
|
2017-01-25 16:02:24 +01:00
|
|
|
if(wctoint(*nptr, 1)==0)
|
2010-04-27 08:42:32 +02:00
|
|
|
base = 8;
|
|
|
|
else
|
|
|
|
base = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(*nptr) {
|
2017-01-25 16:02:24 +01:00
|
|
|
int v = wctoint(*nptr, base);
|
|
|
|
if(v<0)
|
|
|
|
break;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
nptr++;
|
2017-01-25 16:02:26 +01:00
|
|
|
empty = FALSE;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
2020-11-27 14:17:01 +01:00
|
|
|
if(ret>UI64_MAX/base || ret*base>UI64_MAX-v) {
|
|
|
|
ret = UI64_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2010-04-27 08:42:32 +02:00
|
|
|
} else
|
|
|
|
ret = ret*base + v;
|
|
|
|
}
|
|
|
|
|
2017-01-25 16:02:26 +01:00
|
|
|
if(endptr && !empty)
|
2020-11-27 14:16:49 +01:00
|
|
|
*endptr = (wchar_t*)nptr;
|
2010-04-27 08:42:32 +02:00
|
|
|
|
|
|
|
return negative ? -ret : ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2010-04-28 17:44:51 +02:00
|
|
|
* _wcstoui64 (MSVCRT.@)
|
2010-04-27 08:42:32 +02:00
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
unsigned __int64 CDECL _wcstoui64(const wchar_t *nptr,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **endptr, int base)
|
2010-04-27 08:42:32 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstoui64_l(nptr, endptr, base, NULL);
|
2010-04-27 08:42:32 +02:00
|
|
|
}
|
2010-09-29 09:57:52 +02:00
|
|
|
|
2013-03-27 16:13:21 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcstoul_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_ulong __cdecl _wcstoul_l(const wchar_t *s,
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t **end, int base, _locale_t locale)
|
2013-03-27 16:13:21 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 ret = _wcstoi64_l(s, end, base, locale);
|
2013-03-27 16:13:21 +01:00
|
|
|
|
2020-11-27 14:17:01 +01:00
|
|
|
if(ret > ULONG_MAX) {
|
|
|
|
ret = ULONG_MAX;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2020-11-27 14:17:01 +01:00
|
|
|
}else if(ret < -(__int64)ULONG_MAX) {
|
2019-12-17 15:27:31 +01:00
|
|
|
ret = 1;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2013-03-27 16:13:21 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcstoul (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__msvcrt_ulong __cdecl wcstoul(const wchar_t *s, wchar_t **end, int base)
|
2013-03-27 16:13:21 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcstoul_l(s, end, base, NULL);
|
2013-03-27 16:13:21 +01:00
|
|
|
}
|
|
|
|
|
2010-09-29 09:57:52 +02:00
|
|
|
/******************************************************************
|
|
|
|
* wcsnlen (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcsnlen(const wchar_t *s, size_t maxlen)
|
2010-09-29 09:57:52 +02:00
|
|
|
{
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t i;
|
2010-09-29 09:57:52 +02:00
|
|
|
|
|
|
|
for (i = 0; i < maxlen; i++)
|
|
|
|
if (!s[i]) break;
|
|
|
|
return i;
|
|
|
|
}
|
2011-05-12 11:36:56 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _towupper_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wint_t CDECL _towupper_l(wint_t c, _locale_t locale)
|
2011-05-12 11:36:56 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2020-11-27 14:16:49 +01:00
|
|
|
wchar_t ret;
|
2019-01-28 12:08:19 +01:00
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_CTYPE]) {
|
2019-01-28 12:08:19 +01:00
|
|
|
if(c >= 'a' && c <= 'z')
|
|
|
|
return c + 'A' - 'a';
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!LCMapStringW(locinfo->lc_handle[LC_CTYPE], LCMAP_UPPERCASE, &c, 1, &ret, 1))
|
2020-07-16 14:47:10 +02:00
|
|
|
return c;
|
|
|
|
return ret;
|
2011-05-12 11:36:56 +02:00
|
|
|
}
|
|
|
|
|
2013-03-27 16:12:52 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* towupper (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wint_t CDECL towupper(wint_t c)
|
2013-03-27 16:12:52 +01:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _towupper_l(c, NULL);
|
2013-03-27 16:12:52 +01:00
|
|
|
}
|
|
|
|
|
2013-09-17 14:46:17 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcschr (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL wcschr(const wchar_t *str, wchar_t ch)
|
2013-09-17 14:46:17 +02:00
|
|
|
{
|
2020-07-21 12:21:45 +02:00
|
|
|
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
|
|
|
return NULL;
|
2013-09-17 14:46:17 +02:00
|
|
|
}
|
2013-09-17 14:46:30 +02:00
|
|
|
|
2018-10-17 15:23:08 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcsrchr (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL wcsrchr(const wchar_t *str, wchar_t ch)
|
2018-10-17 15:23:08 +02:00
|
|
|
{
|
2020-07-21 12:21:51 +02:00
|
|
|
WCHAR *ret = NULL;
|
|
|
|
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
|
|
|
return ret;
|
2018-10-17 15:23:08 +02:00
|
|
|
}
|
|
|
|
|
2013-09-17 14:46:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* wcslen (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcslen(const wchar_t *str)
|
2013-09-17 14:46:30 +02:00
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *s = str;
|
2020-07-21 12:21:27 +02:00
|
|
|
while (*s) s++;
|
|
|
|
return s - str;
|
2013-09-17 14:46:30 +02:00
|
|
|
}
|
2013-09-17 14:46:42 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcsstr (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
wchar_t* CDECL wcsstr(const wchar_t *str, const wchar_t *sub)
|
2013-09-17 14:46:42 +02:00
|
|
|
{
|
2020-07-15 14:05:36 +02:00
|
|
|
while(*str)
|
|
|
|
{
|
2020-11-27 14:16:49 +01:00
|
|
|
const wchar_t *p1 = str, *p2 = sub;
|
2020-07-15 14:05:36 +02:00
|
|
|
while(*p1 && *p2 && *p1 == *p2)
|
|
|
|
{
|
|
|
|
p1++;
|
|
|
|
p2++;
|
|
|
|
}
|
|
|
|
if(!*p2)
|
2020-11-27 14:16:49 +01:00
|
|
|
return (wchar_t*)str;
|
2020-07-15 14:05:36 +02:00
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return NULL;
|
2013-09-17 14:46:42 +02:00
|
|
|
}
|
2013-10-01 11:28:29 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wtoi64_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 CDECL _wtoi64_l(const wchar_t *str, _locale_t locale)
|
2013-10-01 11:28:29 +02:00
|
|
|
{
|
|
|
|
ULONGLONG RunningTotal = 0;
|
2013-10-30 22:00:11 +01:00
|
|
|
BOOL bMinus = FALSE;
|
2013-10-01 11:28:29 +02:00
|
|
|
|
2020-12-03 19:10:54 +01:00
|
|
|
while (_iswspace_l(*str, locale)) {
|
2013-10-01 11:28:29 +02:00
|
|
|
str++;
|
|
|
|
} /* while */
|
|
|
|
|
|
|
|
if (*str == '+') {
|
|
|
|
str++;
|
|
|
|
} else if (*str == '-') {
|
2013-10-30 22:00:11 +01:00
|
|
|
bMinus = TRUE;
|
2013-10-01 11:28:29 +02:00
|
|
|
str++;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
while (*str >= '0' && *str <= '9') {
|
|
|
|
RunningTotal = RunningTotal * 10 + *str - '0';
|
|
|
|
str++;
|
|
|
|
} /* while */
|
|
|
|
|
|
|
|
return bMinus ? -RunningTotal : RunningTotal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _wtoi64 (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
__int64 CDECL _wtoi64(const wchar_t *str)
|
2013-10-01 11:28:29 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wtoi64_l(str, NULL);
|
2013-10-01 11:28:29 +02:00
|
|
|
}
|
2013-10-01 11:29:22 +02:00
|
|
|
|
2014-06-12 17:52:56 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _wcsxfrm_l (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL _wcsxfrm_l(wchar_t *dest, const wchar_t *src,
|
2020-11-27 14:17:05 +01:00
|
|
|
size_t len, _locale_t locale)
|
2014-06-12 17:52:56 +02:00
|
|
|
{
|
2020-11-26 19:19:09 +01:00
|
|
|
pthreadlocinfo locinfo;
|
2014-06-12 17:52:56 +02:00
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
if(!MSVCRT_CHECK_PMT(src)) return INT_MAX;
|
|
|
|
if(!MSVCRT_CHECK_PMT(dest || !len)) return INT_MAX;
|
|
|
|
|
|
|
|
if(len > INT_MAX) {
|
|
|
|
FIXME("len > INT_MAX not supported\n");
|
|
|
|
len = INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!locale)
|
|
|
|
locinfo = get_locinfo();
|
|
|
|
else
|
|
|
|
locinfo = locale->locinfo;
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
if(!locinfo->lc_handle[LC_COLLATE]) {
|
2020-12-03 19:10:54 +01:00
|
|
|
wcsncpy(dest, src, len);
|
|
|
|
return wcslen(src);
|
2014-06-12 17:52:56 +02:00
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
ret = LCMapStringW(locinfo->lc_handle[LC_COLLATE],
|
2014-06-12 17:52:56 +02:00
|
|
|
LCMAP_SORTKEY, src, -1, NULL, 0);
|
|
|
|
if(!ret) {
|
|
|
|
if(len) dest[0] = 0;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = EILSEQ;
|
2014-06-12 17:52:56 +02:00
|
|
|
return INT_MAX;
|
|
|
|
}
|
|
|
|
if(!len) return ret-1;
|
|
|
|
|
|
|
|
if(ret > len) {
|
|
|
|
dest[0] = 0;
|
2020-12-01 13:51:23 +01:00
|
|
|
*_errno() = ERANGE;
|
2014-06-12 17:52:56 +02:00
|
|
|
return ret-1;
|
|
|
|
}
|
|
|
|
|
2020-11-30 14:37:48 +01:00
|
|
|
ret = LCMapStringW(locinfo->lc_handle[LC_COLLATE],
|
2014-06-12 17:52:56 +02:00
|
|
|
LCMAP_SORTKEY, src, -1, dest, len) - 1;
|
|
|
|
for(i=ret; i>=0; i--)
|
|
|
|
dest[i] = ((unsigned char*)dest)[i];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcsxfrm (MSVCRT.@)
|
|
|
|
*/
|
2020-12-03 19:10:54 +01:00
|
|
|
size_t CDECL wcsxfrm(wchar_t *dest, const wchar_t *src, size_t len)
|
2014-06-12 17:52:56 +02:00
|
|
|
{
|
2020-12-03 19:10:54 +01:00
|
|
|
return _wcsxfrm_l(dest, src, len, NULL);
|
2014-06-12 17:52:56 +02:00
|
|
|
}
|