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
|
|
|
*/
|
2001-01-22 03:21:54 +01:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
2004-04-08 21:48:19 +02:00
|
|
|
#include <math.h>
|
2005-02-14 21:53:42 +01:00
|
|
|
#include <assert.h>
|
2001-01-11 00:59:25 +01:00
|
|
|
#include "msvcrt.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wine/unicode.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
|
|
|
|
2001-01-22 03:21:54 +01:00
|
|
|
|
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
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wcsdup( const MSVCRT_wchar_t* str )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t* ret = NULL;
|
2001-01-11 00:59:25 +01:00
|
|
|
if (str)
|
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
int size = (strlenW(str) + 1) * sizeof(MSVCRT_wchar_t);
|
2001-01-11 00:59:25 +01:00
|
|
|
ret = MSVCRT_malloc( size );
|
|
|
|
if (ret) memcpy( ret, str, size );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsicoll (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL _wcsicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
/* FIXME: handle collates */
|
|
|
|
return strcmpiW( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsnset (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MSVCRT_size_t n )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t* ret = str;
|
2001-01-11 00:59:25 +01:00
|
|
|
while ((n-- > 0) && *str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsrev (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wcsrev( MSVCRT_wchar_t* str )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t* ret = str;
|
|
|
|
MSVCRT_wchar_t* end = str + strlenW(str) - 1;
|
2001-01-11 00:59:25 +01:00
|
|
|
while (end > str)
|
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t t = *end;
|
2001-01-11 00:59:25 +01:00
|
|
|
*end-- = *str;
|
|
|
|
*str++ = t;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* _wcsset (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t* ret = str;
|
2001-01-11 00:59:25 +01:00
|
|
|
while (*str) *str++ = c;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-09-24 00:50:30 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstod (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
double CDECL MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end)
|
2003-09-24 00:50:30 +02:00
|
|
|
{
|
|
|
|
const MSVCRT_wchar_t* str = lpszStr;
|
|
|
|
int negative = 0;
|
|
|
|
double ret = 0, divisor = 10.0;
|
|
|
|
|
|
|
|
TRACE("(%s,%p) semi-stub\n", debugstr_w(lpszStr), end);
|
|
|
|
|
|
|
|
/* FIXME:
|
|
|
|
* - Should set errno on failure
|
|
|
|
* - Should fail on overflow
|
|
|
|
* - Need to check which input formats are allowed
|
|
|
|
*/
|
|
|
|
while (isspaceW(*str))
|
|
|
|
str++;
|
|
|
|
|
|
|
|
if (*str == '-')
|
|
|
|
{
|
|
|
|
negative = 1;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
ret = ret * 10.0 + (*str - '0');
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
if (*str == '.')
|
|
|
|
str++;
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
ret = ret + (*str - '0') / divisor;
|
|
|
|
divisor *= 10;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
|
2004-04-08 21:48:19 +02:00
|
|
|
if (*str == 'E' || *str == 'e' || *str == 'D' || *str == 'd')
|
|
|
|
{
|
|
|
|
int negativeExponent = 0;
|
|
|
|
int exponent = 0;
|
|
|
|
if (*(++str) == '-')
|
|
|
|
{
|
|
|
|
negativeExponent = 1;
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
while (isdigitW(*str))
|
|
|
|
{
|
|
|
|
exponent = exponent * 10 + (*str - '0');
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
if (exponent != 0)
|
|
|
|
{
|
|
|
|
if (negativeExponent)
|
|
|
|
ret = ret / pow(10.0, exponent);
|
|
|
|
else
|
|
|
|
ret = ret * pow(10.0, exponent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (negative)
|
|
|
|
ret = -ret;
|
|
|
|
|
2003-09-24 00:50:30 +02:00
|
|
|
if (end)
|
|
|
|
*end = (MSVCRT_wchar_t*)str;
|
|
|
|
|
|
|
|
TRACE("returning %g\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
|
|
|
|
typedef struct pf_output_t
|
|
|
|
{
|
|
|
|
int used;
|
|
|
|
int len;
|
|
|
|
BOOL unicode;
|
|
|
|
union {
|
|
|
|
LPWSTR W;
|
|
|
|
LPSTR A;
|
|
|
|
} buf;
|
|
|
|
} pf_output;
|
|
|
|
|
|
|
|
typedef struct pf_flags_t
|
|
|
|
{
|
|
|
|
char Sign, LeftAlign, Alternate, PadZero;
|
2005-10-27 12:20:08 +02:00
|
|
|
int FieldLength, Precision;
|
2005-02-14 21:53:42 +01:00
|
|
|
char IntegerLength, IntegerDouble;
|
|
|
|
char WideString;
|
|
|
|
char Format;
|
|
|
|
} pf_flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* writes a string of characters to the output
|
|
|
|
* returns -1 if the string doesn't fit in the output buffer
|
|
|
|
* return the length of the string if all characters were written
|
|
|
|
*/
|
|
|
|
static inline int pf_output_stringW( pf_output *out, LPCWSTR str, int len )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
int space = out->len - out->used;
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
if( len < 0 )
|
|
|
|
len = strlenW( str );
|
|
|
|
if( out->unicode )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
LPWSTR p = out->buf.W + out->used;
|
|
|
|
|
|
|
|
if( space >= len )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
memcpy( p, str, len*sizeof(WCHAR) );
|
|
|
|
out->used += len;
|
|
|
|
return len;
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
if( space > 0 )
|
|
|
|
memcpy( p, str, space*sizeof(WCHAR) );
|
|
|
|
out->used += len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int n = WideCharToMultiByte( CP_ACP, 0, str, len, NULL, 0, NULL, NULL );
|
|
|
|
LPSTR p = out->buf.A + out->used;
|
|
|
|
|
|
|
|
if( space >= n )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, str, len, p, n, NULL, NULL );
|
|
|
|
out->used += n;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
if( space > 0 )
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, str, len, p, space, NULL, NULL );
|
|
|
|
out->used += n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
static inline int pf_output_stringA( pf_output *out, LPCSTR str, int len )
|
|
|
|
{
|
|
|
|
int space = out->len - out->used;
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
if( len < 0 )
|
|
|
|
len = strlen( str );
|
|
|
|
if( !out->unicode )
|
|
|
|
{
|
|
|
|
LPSTR p = out->buf.A + out->used;
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
if( space >= len )
|
|
|
|
{
|
|
|
|
memcpy( p, str, len );
|
|
|
|
out->used += len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
if( space > 0 )
|
|
|
|
memcpy( p, str, space );
|
|
|
|
out->used += len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int n = MultiByteToWideChar( CP_ACP, 0, str, len, NULL, 0 );
|
|
|
|
LPWSTR p = out->buf.W + out->used;
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
if( space >= n )
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, str, len, p, n );
|
|
|
|
out->used += n;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
if( space > 0 )
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, str, len, p, space );
|
|
|
|
out->used += n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
/* pf_fill: takes care of signs, alignment, zero and field padding */
|
2005-02-14 21:53:42 +01:00
|
|
|
static inline int pf_fill( pf_output *out, int len, pf_flags *flags, char left )
|
|
|
|
{
|
|
|
|
int i, r = 0;
|
|
|
|
|
2005-12-26 13:01:38 +01:00
|
|
|
if( flags->Sign && !( flags->Format == 'd' || flags->Format == 'i' ) )
|
|
|
|
flags->Sign = 0;
|
|
|
|
|
|
|
|
if( left && flags->Sign )
|
|
|
|
{
|
|
|
|
flags->FieldLength--;
|
|
|
|
if( flags->PadZero )
|
|
|
|
r = pf_output_stringA( out, &flags->Sign, 1 );
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
if( ( !left && flags->LeftAlign ) ||
|
2005-12-20 11:49:05 +01:00
|
|
|
( left && !flags->LeftAlign ))
|
2005-02-14 21:53:42 +01:00
|
|
|
{
|
|
|
|
for( i=0; (i<(flags->FieldLength-len)) && (r>=0); i++ )
|
|
|
|
{
|
2005-12-20 11:49:05 +01:00
|
|
|
if( left && flags->PadZero )
|
2005-02-14 21:53:42 +01:00
|
|
|
r = pf_output_stringA( out, "0", 1 );
|
|
|
|
else
|
|
|
|
r = pf_output_stringA( out, " ", 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-26 13:01:38 +01:00
|
|
|
if( left && flags->Sign && !flags->PadZero )
|
|
|
|
r = pf_output_stringA( out, &flags->Sign, 1 );
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pf_output_format_W( pf_output *out, LPCWSTR str,
|
|
|
|
int len, pf_flags *flags )
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if( len < 0 )
|
|
|
|
len = strlenW( str );
|
|
|
|
|
2005-10-27 12:20:08 +02:00
|
|
|
if (flags->Precision >= 0 && flags->Precision < len)
|
|
|
|
len = flags->Precision;
|
2005-02-25 20:16:46 +01:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
r = pf_fill( out, len, flags, 1 );
|
|
|
|
|
|
|
|
if( r>=0 )
|
|
|
|
r = pf_output_stringW( out, str, len );
|
|
|
|
|
|
|
|
if( r>=0 )
|
|
|
|
r = pf_fill( out, len, flags, 0 );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int pf_output_format_A( pf_output *out, LPCSTR str,
|
|
|
|
int len, pf_flags *flags )
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if( len < 0 )
|
|
|
|
len = strlen( str );
|
|
|
|
|
2005-10-27 12:20:08 +02:00
|
|
|
if (flags->Precision >= 0 && flags->Precision < len)
|
|
|
|
len = flags->Precision;
|
2005-02-25 20:16:46 +01:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
r = pf_fill( out, len, flags, 1 );
|
|
|
|
|
|
|
|
if( r>=0 )
|
|
|
|
r = pf_output_stringA( out, str, len );
|
|
|
|
|
|
|
|
if( r>=0 )
|
|
|
|
r = pf_fill( out, len, flags, 0 );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-05-16 18:18:51 +02:00
|
|
|
static int pf_handle_string_format( pf_output *out, const void* str, int len,
|
|
|
|
pf_flags *flags, BOOL capital_letter)
|
|
|
|
{
|
|
|
|
if(str == NULL) /* catch NULL pointer */
|
|
|
|
return pf_output_format_A( out, "(null)", -1, flags);
|
|
|
|
|
|
|
|
/* prefixes take priority over %c,%s vs. %C,%S, so we handle them first */
|
|
|
|
if(flags->WideString || flags->IntegerLength == 'l')
|
|
|
|
return pf_output_format_W( out, str, len, flags);
|
|
|
|
if(flags->IntegerLength == 'h')
|
|
|
|
return pf_output_format_A( out, str, len, flags);
|
|
|
|
|
|
|
|
/* %s,%c -> chars in ansi functions & wchars in unicode
|
|
|
|
* %S,%C -> wchars in ansi functions & chars in unicode */
|
|
|
|
if( capital_letter == out->unicode) /* either both TRUE or both FALSE */
|
|
|
|
return pf_output_format_A( out, str, len, flags);
|
|
|
|
else
|
|
|
|
return pf_output_format_W( out, str, len, flags);
|
|
|
|
}
|
|
|
|
|
2005-12-26 13:01:38 +01:00
|
|
|
static inline BOOL pf_is_integer_format( char fmt )
|
|
|
|
{
|
|
|
|
static const char float_fmts[] = "diouxX";
|
|
|
|
if (!fmt)
|
|
|
|
return FALSE;
|
|
|
|
return strchr( float_fmts, fmt ) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
static inline BOOL pf_is_double_format( char fmt )
|
|
|
|
{
|
2005-12-19 21:26:46 +01:00
|
|
|
static const char float_fmts[] = "aeEfgG";
|
2005-02-14 21:53:42 +01:00
|
|
|
if (!fmt)
|
|
|
|
return FALSE;
|
|
|
|
return strchr( float_fmts, fmt ) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL pf_is_valid_format( char fmt )
|
|
|
|
{
|
2005-12-19 21:26:46 +01:00
|
|
|
static const char float_fmts[] = "acCdeEfgGinouxX";
|
2005-02-14 21:53:42 +01:00
|
|
|
if (!fmt)
|
|
|
|
return FALSE;
|
|
|
|
return strchr( float_fmts, fmt ) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pf_rebuild_format_string( char *p, pf_flags *flags )
|
|
|
|
{
|
|
|
|
*p++ = '%';
|
|
|
|
if( flags->Sign )
|
|
|
|
*p++ = flags->Sign;
|
|
|
|
if( flags->LeftAlign )
|
|
|
|
*p++ = flags->LeftAlign;
|
|
|
|
if( flags->Alternate )
|
|
|
|
*p++ = flags->Alternate;
|
|
|
|
if( flags->PadZero )
|
|
|
|
*p++ = flags->PadZero;
|
|
|
|
if( flags->FieldLength )
|
|
|
|
{
|
|
|
|
sprintf(p, "%d", flags->FieldLength);
|
|
|
|
p += strlen(p);
|
|
|
|
}
|
2005-10-27 12:20:08 +02:00
|
|
|
if( flags->Precision >= 0 )
|
2005-02-14 21:53:42 +01:00
|
|
|
{
|
|
|
|
sprintf(p, ".%d", flags->Precision);
|
|
|
|
p += strlen(p);
|
|
|
|
}
|
|
|
|
*p++ = flags->Format;
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
/* pf_integer_conv: prints x to buf, including alternate formats and
|
|
|
|
additional precision digits, but not field characters or the sign */
|
|
|
|
static void pf_integer_conv( char *buf, int buf_len, pf_flags *flags,
|
|
|
|
LONGLONG x )
|
2005-12-26 13:01:38 +01:00
|
|
|
{
|
|
|
|
unsigned int base;
|
2006-06-05 21:50:47 +02:00
|
|
|
const char *digits;
|
2005-12-26 13:01:38 +01:00
|
|
|
|
|
|
|
int i, j, k;
|
2006-11-14 04:55:02 +01:00
|
|
|
char number[40], *tmp = number;
|
|
|
|
|
|
|
|
if( buf_len > sizeof number )
|
|
|
|
tmp = HeapAlloc( GetProcessHeap(), 0, buf_len );
|
2005-12-26 13:01:38 +01:00
|
|
|
|
|
|
|
base = 10;
|
|
|
|
if( flags->Format == 'o' )
|
|
|
|
base = 8;
|
|
|
|
else if( flags->Format == 'x' || flags->Format == 'X' )
|
|
|
|
base = 16;
|
|
|
|
|
|
|
|
if( flags->Format == 'X' )
|
|
|
|
digits = "0123456789ABCDEFX";
|
|
|
|
else
|
|
|
|
digits = "0123456789abcdefx";
|
|
|
|
|
|
|
|
if( x < 0 && ( flags->Format == 'd' || flags->Format == 'i' ) )
|
|
|
|
{
|
|
|
|
x = -x;
|
|
|
|
flags->Sign = '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do conversion (backwards) */
|
|
|
|
i = 0;
|
|
|
|
if( x == 0 && flags->Precision )
|
|
|
|
tmp[i++] = '0';
|
|
|
|
else
|
|
|
|
while( x != 0 )
|
|
|
|
{
|
|
|
|
j = (ULONGLONG) x % base;
|
|
|
|
x = (ULONGLONG) x / base;
|
|
|
|
tmp[i++] = digits[j];
|
|
|
|
}
|
|
|
|
k = flags->Precision - i;
|
|
|
|
while( k-- > 0 )
|
|
|
|
tmp[i++] = '0';
|
|
|
|
if( flags->Alternate )
|
|
|
|
{
|
|
|
|
if( base == 16 )
|
|
|
|
{
|
|
|
|
tmp[i++] = digits[16];
|
|
|
|
tmp[i++] = '0';
|
|
|
|
}
|
|
|
|
else if( base == 8 && tmp[i-1] != '0' )
|
|
|
|
tmp[i++] = '0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reverse for buf */
|
|
|
|
j = 0;
|
|
|
|
while( i-- > 0 )
|
|
|
|
buf[j++] = tmp[i];
|
|
|
|
buf[j] = '\0';
|
|
|
|
|
|
|
|
/* Adjust precision so pf_fill won't truncate the number later */
|
|
|
|
flags->Precision = strlen( buf );
|
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
if( tmp != number )
|
|
|
|
HeapFree( GetProcessHeap(), 0, tmp );
|
|
|
|
|
2005-12-26 13:01:38 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* pf_vsnprintf (INTERNAL)
|
|
|
|
*
|
|
|
|
* implements both A and W vsnprintf functions
|
|
|
|
*/
|
|
|
|
static int pf_vsnprintf( pf_output *out, const WCHAR *format, va_list valist )
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
LPCWSTR q, p = format;
|
|
|
|
pf_flags flags;
|
|
|
|
|
2005-04-14 13:32:53 +02:00
|
|
|
TRACE("format is %s\n",debugstr_w(format));
|
2005-02-14 21:53:42 +01:00
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
q = strchrW( p, '%' );
|
|
|
|
|
|
|
|
/* there's no % characters left, output the rest of the string */
|
|
|
|
if( !q )
|
|
|
|
{
|
|
|
|
r = pf_output_stringW(out, p, -1);
|
|
|
|
if( r<0 )
|
|
|
|
return r;
|
|
|
|
p += r;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* there's characters before the %, output them */
|
|
|
|
if( q != p )
|
|
|
|
{
|
|
|
|
r = pf_output_stringW(out, p, q - p);
|
|
|
|
if( r<0 )
|
|
|
|
return r;
|
|
|
|
p = q;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we must be at a % now, skip over it */
|
|
|
|
assert( *p == '%' );
|
|
|
|
p++;
|
|
|
|
|
|
|
|
/* output a single % character */
|
|
|
|
if( *p == '%' )
|
|
|
|
{
|
2005-05-10 10:27:38 +02:00
|
|
|
r = pf_output_stringW(out, p++, 1);
|
2005-02-14 21:53:42 +01:00
|
|
|
if( r<0 )
|
|
|
|
return r;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse the flags */
|
|
|
|
memset( &flags, 0, sizeof flags );
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if( *p == '+' || *p == ' ' )
|
2005-12-21 20:07:03 +01:00
|
|
|
{
|
|
|
|
if ( flags.Sign != '+' )
|
|
|
|
flags.Sign = *p;
|
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
else if( *p == '-' )
|
|
|
|
flags.LeftAlign = *p;
|
|
|
|
else if( *p == '0' )
|
|
|
|
flags.PadZero = *p;
|
|
|
|
else if( *p == '#' )
|
|
|
|
flags.Alternate = *p;
|
|
|
|
else
|
2004-06-02 02:35:09 +02:00
|
|
|
break;
|
2005-02-14 21:53:42 +01:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* deal with the field width specifier */
|
|
|
|
flags.FieldLength = 0;
|
2007-01-29 23:53:46 +01:00
|
|
|
if( *p == '*' )
|
2005-04-14 13:32:53 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
flags.FieldLength = va_arg( valist, int );
|
2007-01-29 23:53:46 +01:00
|
|
|
if (flags.FieldLength < 0)
|
|
|
|
{
|
|
|
|
flags.LeftAlign = '-';
|
|
|
|
flags.FieldLength = -flags.FieldLength;
|
|
|
|
}
|
2005-04-14 13:32:53 +02:00
|
|
|
p++;
|
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
else while( isdigit(*p) )
|
|
|
|
{
|
|
|
|
flags.FieldLength *= 10;
|
|
|
|
flags.FieldLength += *p++ - '0';
|
|
|
|
}
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/* deal with precision */
|
2005-10-27 12:20:08 +02:00
|
|
|
flags.Precision = -1;
|
2005-02-14 21:53:42 +01:00
|
|
|
if( *p == '.' )
|
|
|
|
{
|
2005-10-27 12:20:08 +02:00
|
|
|
flags.Precision = 0;
|
2005-02-14 21:53:42 +01:00
|
|
|
p++;
|
|
|
|
if( *p == '*' )
|
2005-02-25 20:16:46 +01:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
flags.Precision = va_arg( valist, int );
|
2005-02-25 20:16:46 +01:00
|
|
|
p++;
|
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
else while( isdigit(*p) )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
flags.Precision *= 10;
|
|
|
|
flags.Precision += *p++ - '0';
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
}
|
2004-06-02 02:35:09 +02:00
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/* deal with integer width modifier */
|
|
|
|
while( *p )
|
|
|
|
{
|
|
|
|
if( *p == 'h' || *p == 'l' || *p == 'L' )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
2005-12-26 13:00:35 +01:00
|
|
|
flags.IntegerLength = *p;
|
2005-02-14 21:53:42 +01:00
|
|
|
p++;
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
2005-12-26 13:00:01 +01:00
|
|
|
else if( *p == 'I' )
|
|
|
|
{
|
|
|
|
if( *(p+1) == '6' && *(p+2) == '4' )
|
|
|
|
{
|
|
|
|
flags.IntegerDouble++;
|
|
|
|
p += 3;
|
|
|
|
}
|
|
|
|
else if( *(p+1) == '3' && *(p+2) == '2' )
|
|
|
|
p += 3;
|
|
|
|
else if( isdigit(*(p+1)) || *(p+1) == 0 )
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
p++;
|
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
else if( *p == 'w' )
|
|
|
|
flags.WideString = *p++;
|
2005-03-04 11:47:27 +01:00
|
|
|
else if( *p == 'F' )
|
|
|
|
p++; /* ignore */
|
2005-02-14 21:53:42 +01:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.Format = *p;
|
|
|
|
r = 0;
|
|
|
|
|
2006-05-16 18:18:51 +02:00
|
|
|
/* output a string */
|
|
|
|
if( flags.Format == 's' || flags.Format == 'S' )
|
|
|
|
r = pf_handle_string_format( out, va_arg(valist, const void*), -1,
|
|
|
|
&flags, (flags.Format == 'S') );
|
2005-02-14 21:53:42 +01:00
|
|
|
|
2006-05-16 18:18:51 +02:00
|
|
|
/* output a single character */
|
|
|
|
else if( flags.Format == 'c' || flags.Format == 'C' )
|
2005-02-14 21:53:42 +01:00
|
|
|
{
|
2006-05-16 18:18:51 +02:00
|
|
|
INT ch = va_arg( valist, int );
|
2005-02-14 21:53:42 +01:00
|
|
|
|
2006-05-16 18:18:51 +02:00
|
|
|
r = pf_handle_string_format( out, &ch, 1, &flags, (flags.Format == 'C') );
|
2005-02-14 21:53:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* output a pointer */
|
|
|
|
else if( flags.Format == 'p' )
|
|
|
|
{
|
2005-07-03 13:19:29 +02:00
|
|
|
char pointer[11];
|
2005-02-14 21:53:42 +01:00
|
|
|
|
|
|
|
flags.PadZero = 0;
|
|
|
|
if( flags.Alternate )
|
|
|
|
sprintf(pointer, "0X%08lX", va_arg(valist, long));
|
|
|
|
else
|
|
|
|
sprintf(pointer, "%08lX", va_arg(valist, long));
|
|
|
|
r = pf_output_format_A( out, pointer, -1, &flags );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* deal with %n */
|
|
|
|
else if( flags.Format == 'n' )
|
|
|
|
{
|
|
|
|
int *x = va_arg(valist, int *);
|
|
|
|
*x = out->used;
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
|
2005-12-26 13:01:38 +01:00
|
|
|
/* deal with 64-bit integers */
|
|
|
|
else if( pf_is_integer_format( flags.Format ) && flags.IntegerDouble )
|
|
|
|
{
|
|
|
|
char number[40], *x = number;
|
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
/* Estimate largest possible required buffer size:
|
|
|
|
* Chooses the larger of the field or precision
|
|
|
|
* Includes extra bytes: 1 byte for null, 1 byte for sign,
|
|
|
|
4 bytes for exponent, 2 bytes for alternate formats, 1 byte
|
|
|
|
for a decimal, and 1 byte for an additional float digit. */
|
|
|
|
int x_len = ((flags.FieldLength > flags.Precision) ?
|
|
|
|
flags.FieldLength : flags.Precision) + 10;
|
2005-12-26 13:01:38 +01:00
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
if( x_len >= sizeof number)
|
|
|
|
x = HeapAlloc( GetProcessHeap(), 0, x_len );
|
|
|
|
|
|
|
|
pf_integer_conv( x, x_len, &flags, va_arg(valist, LONGLONG) );
|
2005-12-26 13:01:38 +01:00
|
|
|
|
|
|
|
r = pf_output_format_A( out, x, -1, &flags );
|
|
|
|
if( x != number )
|
2006-11-14 04:51:17 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, x );
|
2005-12-26 13:01:38 +01:00
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/* deal with integers and floats using libc's printf */
|
|
|
|
else if( pf_is_valid_format( flags.Format ) )
|
|
|
|
{
|
|
|
|
char fmt[20], number[40], *x = number;
|
|
|
|
|
2006-11-14 04:55:02 +01:00
|
|
|
/* Estimate largest possible required buffer size:
|
|
|
|
* Chooses the larger of the field or precision
|
|
|
|
* Includes extra bytes: 1 byte for null, 1 byte for sign,
|
|
|
|
4 bytes for exponent, 2 bytes for alternate formats, 1 byte
|
|
|
|
for a decimal, and 1 byte for an additional float digit. */
|
|
|
|
int x_len = ((flags.FieldLength > flags.Precision) ?
|
|
|
|
flags.FieldLength : flags.Precision) + 10;
|
|
|
|
|
|
|
|
if( x_len >= sizeof number)
|
|
|
|
x = HeapAlloc( GetProcessHeap(), 0, x_len );
|
2005-02-14 21:53:42 +01:00
|
|
|
|
|
|
|
pf_rebuild_format_string( fmt, &flags );
|
|
|
|
|
|
|
|
if( pf_is_double_format( flags.Format ) )
|
2005-10-28 11:40:16 +02:00
|
|
|
sprintf( x, fmt, va_arg(valist, double) );
|
2005-02-14 21:53:42 +01:00
|
|
|
else
|
2005-10-28 11:40:16 +02:00
|
|
|
sprintf( x, fmt, va_arg(valist, int) );
|
2005-02-14 21:53:42 +01:00
|
|
|
|
2005-10-28 11:40:16 +02:00
|
|
|
r = pf_output_stringA( out, x, -1 );
|
2005-02-14 21:53:42 +01:00
|
|
|
if( x != number )
|
2006-11-14 04:51:17 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, x );
|
2005-02-14 21:53:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( r<0 )
|
|
|
|
return r;
|
|
|
|
p++;
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
2005-02-14 21:53:42 +01:00
|
|
|
|
|
|
|
/* check we reached the end, and null terminate the string */
|
|
|
|
assert( *p == 0 );
|
2006-01-14 17:30:02 +01:00
|
|
|
pf_output_stringW( out, p, 1 );
|
2005-02-14 21:53:42 +01:00
|
|
|
|
|
|
|
return out->used - 1;
|
2004-06-02 02:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2005-02-14 21:53:42 +01:00
|
|
|
* _vsnprintf (MSVCRT.@)
|
2004-06-02 02:35:09 +02:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
|
|
|
|
const char *format, va_list valist )
|
2005-02-14 21:53:42 +01:00
|
|
|
{
|
|
|
|
DWORD sz;
|
|
|
|
LPWSTR formatW = NULL;
|
|
|
|
pf_output out;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
out.unicode = FALSE;
|
|
|
|
out.buf.A = str;
|
|
|
|
out.used = 0;
|
|
|
|
out.len = len;
|
|
|
|
|
|
|
|
if( format )
|
|
|
|
{
|
|
|
|
sz = MultiByteToWideChar( CP_ACP, 0, format, -1, NULL, 0 );
|
|
|
|
formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
|
|
|
|
}
|
|
|
|
|
|
|
|
r = pf_vsnprintf( &out, formatW, valist );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, formatW );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-11-14 12:29:18 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* vsprintf (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT_vsprintf( char *str, const char *format, va_list valist)
|
|
|
|
{
|
|
|
|
return MSVCRT_vsnprintf(str, INT_MAX, format, valist);
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:30:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT__snprintf(char *str, unsigned int len, const char *format, ...)
|
2006-01-14 17:30:02 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
va_list valist;
|
|
|
|
va_start(valist, format);
|
|
|
|
retval = MSVCRT_vsnprintf(str, len, format, valist);
|
|
|
|
va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _vsnwsprintf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_vsnwprintf( MSVCRT_wchar_t *str, unsigned int len,
|
|
|
|
const MSVCRT_wchar_t *format, va_list valist )
|
2005-02-14 21:53:42 +01:00
|
|
|
{
|
|
|
|
pf_output out;
|
|
|
|
|
|
|
|
out.unicode = TRUE;
|
|
|
|
out.buf.W = str;
|
|
|
|
out.used = 0;
|
|
|
|
out.len = len;
|
|
|
|
|
|
|
|
return pf_vsnprintf( &out, format, valist );
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:30:02 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _snwprintf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT__snwprintf( MSVCRT_wchar_t *str, unsigned int len, const MSVCRT_wchar_t *format, ...)
|
2006-01-14 17:30:02 +01:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
va_list valist;
|
|
|
|
va_start(valist, format);
|
|
|
|
retval = MSVCRT_vsnwprintf(str, len, format, valist);
|
|
|
|
va_end(valist);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2005-02-14 21:53:42 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* sprintf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_sprintf( char *str, const char *format, ... )
|
2004-06-02 02:35:09 +02:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
va_start( ap, format );
|
2005-02-14 21:53:42 +01:00
|
|
|
r = MSVCRT_vsnprintf( str, INT_MAX, format, ap );
|
2004-06-02 02:35:09 +02:00
|
|
|
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
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_swprintf( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format, ... )
|
2001-01-22 03:21:54 +01:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
va_list ap;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
va_start( ap, format );
|
|
|
|
r = MSVCRT_vsnwprintf( str, INT_MAX, format, ap );
|
|
|
|
va_end( ap );
|
|
|
|
return r;
|
2001-01-22 03:21:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* vswprintf (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, va_list args )
|
2001-01-22 03:21:54 +01:00
|
|
|
{
|
2005-02-14 21:53:42 +01:00
|
|
|
return MSVCRT_vsnwprintf( str, INT_MAX, format, args );
|
2001-01-22 03:21:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcscoll (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
int CDECL MSVCRT_wcscoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
/* FIXME: handle collates */
|
|
|
|
return strcmpW( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* wcspbrk (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t* CDECL MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* accept )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
const MSVCRT_wchar_t* p;
|
2001-01-11 00:59:25 +01:00
|
|
|
while (*str)
|
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
for (p = accept; *p; p++) if (*p == *str) return (MSVCRT_wchar_t*)str;
|
2001-01-11 00:59:25 +01:00
|
|
|
str++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:24:49 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* wcstok (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim )
|
2006-01-14 17:24:49 +01:00
|
|
|
{
|
|
|
|
thread_data_t *data = msvcrt_get_thread_data();
|
|
|
|
MSVCRT_wchar_t *ret;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
if (!(str = data->wcstok_next)) return NULL;
|
|
|
|
|
|
|
|
while (*str && strchrW( delim, *str )) str++;
|
|
|
|
if (!*str) return NULL;
|
|
|
|
ret = str++;
|
|
|
|
while (*str && !strchrW( delim, *str )) str++;
|
|
|
|
if (*str) *str++ = 0;
|
|
|
|
data->wcstok_next = str;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* wctomb (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
return WideCharToMultiByte( CP_ACP, 0, &ch, 1, dst, 6, NULL, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswalnum (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswalnum( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isalnumW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswalpha (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswalpha( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isalphaW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswcntrl (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswcntrl( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return iscntrlW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswdigit (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswdigit( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isdigitW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswgraph (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswgraph( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isgraphW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswlower (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswlower( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return islowerW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswprint (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswprint( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isprintW( wc );
|
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
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswpunct( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return ispunctW( wc );
|
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
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswspace( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isspaceW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswupper (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswupper( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isupperW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-01-22 03:21:54 +01:00
|
|
|
* iswxdigit (MSVCRT.@)
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
INT CDECL MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-11-08 20:16:34 +01:00
|
|
|
return isxdigitW( wc );
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
2008-02-27 09:58:04 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* wcscpy_s (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, const MSVCRT_wchar_t *wcSrc)
|
|
|
|
{
|
|
|
|
INT size = 0;
|
|
|
|
|
2008-05-26 17:21:13 +02:00
|
|
|
if(!wcDest || !numElement)
|
2008-02-27 09:58:04 +01:00
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
|
2008-05-26 17:21:13 +02:00
|
|
|
wcDest[0] = 0;
|
|
|
|
|
2008-02-27 09:58:04 +01:00
|
|
|
if(!wcSrc)
|
|
|
|
{
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = strlenW(wcSrc) + 1;
|
|
|
|
|
|
|
|
if(size > numElement)
|
|
|
|
{
|
2008-05-26 17:21:13 +02:00
|
|
|
return MSVCRT_ERANGE;
|
2008-02-27 09:58:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(size > numElement)
|
|
|
|
size = numElement;
|
|
|
|
|
|
|
|
memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|