*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <limits.h>
#include <stdio.h>
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-/* INTERNAL: MSVCRT_malloc() based wstrndup */
-MSVCRT_wchar_t* msvcrt_wstrndup(const MSVCRT_wchar_t *buf, unsigned int size)
-{
- MSVCRT_wchar_t* ret;
- unsigned int len = strlenW(buf), max_len;
-
- max_len = size <= len? size : len + 1;
-
- ret = MSVCRT_malloc(max_len * sizeof (MSVCRT_wchar_t));
- if (ret)
- {
- memcpy(ret,buf,max_len * sizeof (MSVCRT_wchar_t));
- ret[max_len] = 0;
- }
- return ret;
-}
-
/*********************************************************************
* _wcsdup (MSVCRT.@)
*/
-MSVCRT_wchar_t* _wcsdup( const MSVCRT_wchar_t* str )
+MSVCRT_wchar_t* CDECL _wcsdup( const MSVCRT_wchar_t* str )
{
MSVCRT_wchar_t* ret = NULL;
if (str)
/*********************************************************************
* _wcsicoll (MSVCRT.@)
*/
-INT _wcsicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
+INT CDECL _wcsicoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
{
/* FIXME: handle collates */
return strcmpiW( str1, str2 );
/*********************************************************************
* _wcsnset (MSVCRT.@)
*/
-MSVCRT_wchar_t* _wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MSVCRT_size_t n )
+MSVCRT_wchar_t* CDECL _wcsnset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c, MSVCRT_size_t n )
{
MSVCRT_wchar_t* ret = str;
while ((n-- > 0) && *str) *str++ = c;
/*********************************************************************
* _wcsrev (MSVCRT.@)
*/
-MSVCRT_wchar_t* _wcsrev( MSVCRT_wchar_t* str )
+MSVCRT_wchar_t* CDECL _wcsrev( MSVCRT_wchar_t* str )
{
MSVCRT_wchar_t* ret = str;
MSVCRT_wchar_t* end = str + strlenW(str) - 1;
/*********************************************************************
* _wcsset (MSVCRT.@)
*/
-MSVCRT_wchar_t* _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
+MSVCRT_wchar_t* CDECL _wcsset( MSVCRT_wchar_t* str, MSVCRT_wchar_t c )
{
MSVCRT_wchar_t* ret = str;
while (*str) *str++ = c;
return ret;
}
+/******************************************************************
+ * _wcsupr_s (MSVCRT.@)
+ *
+ */
+INT CDECL MSVCRT__wcsupr_s( MSVCRT_wchar_t* str, MSVCRT_size_t n )
+{
+ MSVCRT_wchar_t* ptr = str;
+
+ if (!str || !n)
+ {
+ if (str) *str = '\0';
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+ }
+
+ while (n--)
+ {
+ if (!*ptr) return 0;
+ *ptr = toupperW(*ptr);
+ ptr++;
+ }
+
+ /* MSDN claims that the function should return and set errno to
+ * ERANGE, which doesn't seem to be true based on the tests. */
+ *str = '\0';
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+}
+
/*********************************************************************
* wcstod (MSVCRT.@)
*/
-double MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end)
+double CDECL MSVCRT_wcstod(const MSVCRT_wchar_t* lpszStr, MSVCRT_wchar_t** end)
{
const MSVCRT_wchar_t* str = lpszStr;
int negative = 0;
if( space >= len )
{
- memcpy( p, str, len*sizeof(WCHAR) );
+ if (out->buf.W) memcpy( p, str, len*sizeof(WCHAR) );
out->used += len;
return len;
}
- if( space > 0 )
+ if( space > 0 && out->buf.W )
memcpy( p, str, space*sizeof(WCHAR) );
out->used += len;
}
if( space >= n )
{
- WideCharToMultiByte( CP_ACP, 0, str, len, p, n, NULL, NULL );
+ if (out->buf.A) WideCharToMultiByte( CP_ACP, 0, str, len, p, n, NULL, NULL );
out->used += n;
return len;
}
- if( space > 0 )
+ if( space > 0 && out->buf.A )
WideCharToMultiByte( CP_ACP, 0, str, len, p, space, NULL, NULL );
out->used += n;
}
if( space >= len )
{
- memcpy( p, str, len );
+ if (out->buf.A) memcpy( p, str, len );
out->used += len;
return len;
}
- if( space > 0 )
+ if( space > 0 && out->buf.A )
memcpy( p, str, space );
out->used += len;
}
if( space >= n )
{
- MultiByteToWideChar( CP_ACP, 0, str, len, p, n );
+ if (out->buf.W) MultiByteToWideChar( CP_ACP, 0, str, len, p, n );
out->used += n;
return len;
}
- if( space > 0 )
+ if( space > 0 && out->buf.W )
MultiByteToWideChar( CP_ACP, 0, str, len, p, space );
out->used += n;
}
return -1;
}
+/* pf_fill: takes care of signs, alignment, zero and field padding */
static inline int pf_fill( pf_output *out, int len, pf_flags *flags, char left )
{
int i, r = 0;
+ 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 );
+ }
+
if( ( !left && flags->LeftAlign ) ||
( left && !flags->LeftAlign ))
{
}
}
+ if( left && flags->Sign && !flags->PadZero )
+ r = pf_output_stringA( out, &flags->Sign, 1 );
+
return r;
}
return r;
}
+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);
+}
+
+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;
+}
+
static inline BOOL pf_is_double_format( char fmt )
{
static const char float_fmts[] = "aeEfgG";
*p++ = 0;
}
+/* 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 )
+{
+ unsigned int base;
+ const char *digits;
+
+ int i, j, k;
+ char number[40], *tmp = number;
+
+ if( buf_len > sizeof number )
+ tmp = HeapAlloc( GetProcessHeap(), 0, buf_len );
+
+ 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 );
+
+ if( tmp != number )
+ HeapFree( GetProcessHeap(), 0, tmp );
+
+ return;
+}
+
+/* pf_fixup_exponent: convert a string containing a 2 digit exponent
+ to 3 digits, accounting for padding, in place. Needed to match
+ the native printf's which always use 3 digits. */
+static void pf_fixup_exponent( char *buf )
+{
+ char* tmp = buf;
+
+ while (tmp[0] && toupper(tmp[0]) != 'E')
+ tmp++;
+
+ if (tmp[0] && (tmp[1] == '+' || tmp[1] == '-') &&
+ isdigit(tmp[2]) && isdigit(tmp[3]))
+ {
+ char final;
+
+ if (isdigit(tmp[4]))
+ return; /* Exponent already 3 digits */
+
+ /* We have a 2 digit exponent. Prepend '0' to make it 3 */
+ tmp += 2;
+ final = tmp[2];
+ tmp[2] = tmp[1];
+ tmp[1] = tmp[0];
+ tmp[0] = '0';
+ if (final == '\0')
+ {
+ /* We didn't expand into trailing space, so this string isn't left
+ * justified. Terminate the string and strip a ' ' at the start of
+ * the string if there is one (as there may be if the string is
+ * right justified).
+ */
+ tmp[3] = '\0';
+ if (buf[0] == ' ')
+ memmove(buf, buf + 1, (tmp - buf) + 3);
+ }
+ /* Otherwise, we expanded into trailing space -> nothing to do */
+ }
+}
+
/*********************************************************************
* pf_vsnprintf (INTERNAL)
*
* implements both A and W vsnprintf functions
*/
-static int pf_vsnprintf( pf_output *out, const WCHAR *format, va_list valist )
+static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valist )
{
int r;
LPCWSTR q, p = format;
/* deal with the field width specifier */
flags.FieldLength = 0;
- if( *p == '*' )
+ if( *p == '*' )
{
flags.FieldLength = va_arg( valist, int );
+ if (flags.FieldLength < 0)
+ {
+ flags.LeftAlign = '-';
+ flags.FieldLength = -flags.FieldLength;
+ }
p++;
}
else while( isdigit(*p) )
{
if( *p == 'h' || *p == 'l' || *p == 'L' )
{
- if( flags.IntegerLength == *p ) /* FIXME: this is wrong */
- flags.IntegerDouble++;
- else
- flags.IntegerLength = *p;
+ flags.IntegerLength = *p;
p++;
}
else if( *p == 'I' )
flags.Format = *p;
r = 0;
- /* output a unicode string */
- if( ( flags.Format == 's' && (flags.WideString || flags.IntegerLength == 'l' )) ||
- ( !out->unicode && flags.Format == 'S' ) ||
- ( out->unicode && flags.Format == 's' ) )
+ if (flags.Format == '$')
{
- LPCWSTR str = va_arg( valist, const WCHAR * );
-
- if( str )
- r = pf_output_format_W( out, str, -1, &flags );
- else
- r = pf_output_format_A( out, "(null)", -1, &flags );
+ FIXME("Positional parameters are not supported (%s)\n", wine_dbgstr_w(format));
+ return -1;
}
+ /* 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') );
- /* output a ASCII string */
- else if( ( flags.Format == 's' && flags.IntegerLength == 'h' ) ||
- ( out->unicode && flags.Format == 'S' ) ||
- ( !out->unicode && flags.Format == 's' ) )
+ /* output a single character */
+ else if( flags.Format == 'c' || flags.Format == 'C' )
{
- LPCSTR str = va_arg( valist, const CHAR * );
+ INT ch = va_arg( valist, int );
- if( str )
- r = pf_output_format_A( out, str, -1, &flags );
- else
- r = pf_output_format_A( out, "(null)", -1, &flags );
- }
-
- /* output a single wide character */
- else if( ( flags.Format == 'c' && flags.IntegerLength == 'w' ) ||
- ( out->unicode && flags.Format == 'c' ) ||
- ( !out->unicode && flags.Format == 'C' ) )
- {
- WCHAR ch = va_arg( valist, int );
-
- r = pf_output_format_W( out, &ch, 1, &flags );
- }
-
- /* output a single ascii character */
- else if( ( flags.Format == 'c' && flags.IntegerLength == 'h' ) ||
- ( out->unicode && flags.Format == 'C' ) ||
- ( !out->unicode && flags.Format == 'c' ) )
- {
- CHAR ch = va_arg( valist, int );
-
- r = pf_output_format_A( out, &ch, 1, &flags );
+ r = pf_handle_string_format( out, &ch, 1, &flags, (flags.Format == 'C') );
}
/* output a pointer */
else if( flags.Format == 'p' )
{
- char pointer[11];
+ char pointer[32];
+ void *ptr = va_arg( valist, void * );
flags.PadZero = 0;
if( flags.Alternate )
- sprintf(pointer, "0X%08lX", va_arg(valist, long));
+ sprintf(pointer, "0X%0*lX", 2 * (int)sizeof(ptr), (ULONG_PTR)ptr);
else
- sprintf(pointer, "%08lX", va_arg(valist, long));
+ sprintf(pointer, "%0*lX", 2 * (int)sizeof(ptr), (ULONG_PTR)ptr);
r = pf_output_format_A( out, pointer, -1, &flags );
}
*x = out->used;
}
+ /* deal with 64-bit integers */
+ else if( pf_is_integer_format( flags.Format ) && flags.IntegerDouble )
+ {
+ char number[40], *x = number;
+
+ /* 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 );
+
+ pf_integer_conv( x, x_len, &flags, va_arg(valist, LONGLONG) );
+
+ r = pf_output_format_A( out, x, -1, &flags );
+ if( x != number )
+ HeapFree( GetProcessHeap(), 0, x );
+ }
+
/* deal with integers and floats using libc's printf */
else if( pf_is_valid_format( flags.Format ) )
{
char fmt[20], number[40], *x = number;
- if( flags.FieldLength >= sizeof number )
- x = HeapAlloc( GetProcessHeap(), 0, flags.FieldLength+1 );
+ /* 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 );
pf_rebuild_format_string( fmt, &flags );
if( pf_is_double_format( flags.Format ) )
+ {
sprintf( x, fmt, va_arg(valist, double) );
+ if (toupper(flags.Format) == 'E' || toupper(flags.Format) == 'G')
+ pf_fixup_exponent( x );
+ }
else
sprintf( x, fmt, va_arg(valist, int) );
r = pf_output_stringA( out, x, -1 );
if( x != number )
- HeapFree( GetProcessHeap(), 0, number );
+ HeapFree( GetProcessHeap(), 0, x );
}
else
continue;
/* check we reached the end, and null terminate the string */
assert( *p == 0 );
- r = pf_output_stringW( out, p, 1 );
- if( r<0 )
- return r;
+ pf_output_stringW( out, p, 1 );
return out->used - 1;
}
/*********************************************************************
* _vsnprintf (MSVCRT.@)
*/
-int MSVCRT_vsnprintf( char *str, unsigned int len,
- const char *format, va_list valist )
+int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
+ const char *format, __ms_va_list valist )
{
DWORD sz;
LPWSTR formatW = NULL;
return r;
}
+/*********************************************************************
+ * vsprintf (MSVCRT.@)
+ */
+int CDECL MSVCRT_vsprintf( char *str, const char *format, __ms_va_list valist)
+{
+ return MSVCRT_vsnprintf(str, INT_MAX, format, valist);
+}
+
+/*********************************************************************
+ * _vscprintf (MSVCRT.@)
+ */
+int CDECL _vscprintf( const char *format, __ms_va_list valist )
+{
+ return MSVCRT_vsnprintf( NULL, INT_MAX, format, valist );
+}
+
+/*********************************************************************
+ * _snprintf (MSVCRT.@)
+ */
+int CDECL MSVCRT__snprintf(char *str, unsigned int len, const char *format, ...)
+{
+ int retval;
+ __ms_va_list valist;
+ __ms_va_start(valist, format);
+ retval = MSVCRT_vsnprintf(str, len, format, valist);
+ __ms_va_end(valist);
+ return retval;
+}
+
/*********************************************************************
* _vsnwsprintf (MSVCRT.@)
*/
-int MSVCRT_vsnwprintf( MSVCRT_wchar_t *str, unsigned int len,
- const WCHAR *format, va_list valist )
+int CDECL MSVCRT_vsnwprintf( MSVCRT_wchar_t *str, unsigned int len,
+ const MSVCRT_wchar_t *format, __ms_va_list valist )
{
pf_output out;
return pf_vsnprintf( &out, format, valist );
}
+/*********************************************************************
+ * _snwprintf (MSVCRT.@)
+ */
+int CDECL MSVCRT__snwprintf( MSVCRT_wchar_t *str, unsigned int len, const MSVCRT_wchar_t *format, ...)
+{
+ int retval;
+ __ms_va_list valist;
+ __ms_va_start(valist, format);
+ retval = MSVCRT_vsnwprintf(str, len, format, valist);
+ __ms_va_end(valist);
+ return retval;
+}
+
/*********************************************************************
* sprintf (MSVCRT.@)
*/
-int MSVCRT_sprintf( char *str, const char *format, ... )
+int CDECL MSVCRT_sprintf( char *str, const char *format, ... )
{
- va_list ap;
+ __ms_va_list ap;
int r;
- va_start( ap, format );
+ __ms_va_start( ap, format );
r = MSVCRT_vsnprintf( str, INT_MAX, format, ap );
- va_end( ap );
+ __ms_va_end( ap );
return r;
}
/*********************************************************************
* swprintf (MSVCRT.@)
*/
-int MSVCRT_swprintf( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format, ... )
+int CDECL MSVCRT_swprintf( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format, ... )
{
- va_list ap;
+ __ms_va_list ap;
int r;
- va_start( ap, format );
+ __ms_va_start( ap, format );
r = MSVCRT_vsnwprintf( str, INT_MAX, format, ap );
- va_end( ap );
+ __ms_va_end( ap );
return r;
}
/*********************************************************************
* vswprintf (MSVCRT.@)
*/
-int MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, va_list args )
+int CDECL MSVCRT_vswprintf( MSVCRT_wchar_t* str, const MSVCRT_wchar_t* format, __ms_va_list args )
{
return MSVCRT_vsnwprintf( str, INT_MAX, format, args );
}
+/*********************************************************************
+ * _vscwprintf (MSVCRT.@)
+ */
+int CDECL _vscwprintf( const MSVCRT_wchar_t *format, __ms_va_list args )
+{
+ return MSVCRT_vsnwprintf( NULL, INT_MAX, format, args );
+}
+
+/*********************************************************************
+ * vswprintf_s (MSVCRT.@)
+ */
+int CDECL MSVCRT_vswprintf_s( MSVCRT_wchar_t* str, MSVCRT_size_t num, const MSVCRT_wchar_t* format, __ms_va_list args )
+{
+ /* FIXME: must handle positional arguments */
+ return MSVCRT_vsnwprintf( str, num, format, args );
+}
+
/*********************************************************************
* wcscoll (MSVCRT.@)
*/
-int MSVCRT_wcscoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
+int CDECL MSVCRT_wcscoll( const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* str2 )
{
/* FIXME: handle collates */
return strcmpW( str1, str2 );
/*********************************************************************
* wcspbrk (MSVCRT.@)
*/
-MSVCRT_wchar_t* MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* accept )
+MSVCRT_wchar_t* CDECL MSVCRT_wcspbrk( const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* accept )
{
const MSVCRT_wchar_t* p;
while (*str)
return NULL;
}
+/*********************************************************************
+ * wcstok (MSVCRT.@)
+ */
+MSVCRT_wchar_t * CDECL MSVCRT_wcstok( MSVCRT_wchar_t *str, const MSVCRT_wchar_t *delim )
+{
+ 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;
+}
+
+
/*********************************************************************
* wctomb (MSVCRT.@)
*/
-INT MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
+INT CDECL MSVCRT_wctomb( char *dst, MSVCRT_wchar_t ch )
{
return WideCharToMultiByte( CP_ACP, 0, &ch, 1, dst, 6, NULL, NULL );
}
/*********************************************************************
* iswalnum (MSVCRT.@)
*/
-INT MSVCRT_iswalnum( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswalnum( MSVCRT_wchar_t wc )
{
return isalnumW( wc );
}
/*********************************************************************
* iswalpha (MSVCRT.@)
*/
-INT MSVCRT_iswalpha( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswalpha( MSVCRT_wchar_t wc )
{
return isalphaW( wc );
}
/*********************************************************************
* iswcntrl (MSVCRT.@)
*/
-INT MSVCRT_iswcntrl( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswcntrl( MSVCRT_wchar_t wc )
{
return iscntrlW( wc );
}
/*********************************************************************
* iswdigit (MSVCRT.@)
*/
-INT MSVCRT_iswdigit( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswdigit( MSVCRT_wchar_t wc )
{
return isdigitW( wc );
}
/*********************************************************************
* iswgraph (MSVCRT.@)
*/
-INT MSVCRT_iswgraph( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswgraph( MSVCRT_wchar_t wc )
{
return isgraphW( wc );
}
/*********************************************************************
* iswlower (MSVCRT.@)
*/
-INT MSVCRT_iswlower( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswlower( MSVCRT_wchar_t wc )
{
return islowerW( wc );
}
/*********************************************************************
* iswprint (MSVCRT.@)
*/
-INT MSVCRT_iswprint( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswprint( MSVCRT_wchar_t wc )
{
return isprintW( wc );
}
/*********************************************************************
* iswpunct (MSVCRT.@)
*/
-INT MSVCRT_iswpunct( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswpunct( MSVCRT_wchar_t wc )
{
return ispunctW( wc );
}
/*********************************************************************
* iswspace (MSVCRT.@)
*/
-INT MSVCRT_iswspace( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswspace( MSVCRT_wchar_t wc )
{
return isspaceW( wc );
}
/*********************************************************************
* iswupper (MSVCRT.@)
*/
-INT MSVCRT_iswupper( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswupper( MSVCRT_wchar_t wc )
{
return isupperW( wc );
}
/*********************************************************************
* iswxdigit (MSVCRT.@)
*/
-INT MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
+INT CDECL MSVCRT_iswxdigit( MSVCRT_wchar_t wc )
{
return isxdigitW( wc );
}
+
+/*********************************************************************
+ * wcscpy_s (MSVCRT.@)
+ */
+INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, const MSVCRT_wchar_t *wcSrc)
+{
+ MSVCRT_size_t size = 0;
+
+ if(!wcDest || !numElement)
+ return MSVCRT_EINVAL;
+
+ wcDest[0] = 0;
+
+ if(!wcSrc)
+ {
+ return MSVCRT_EINVAL;
+ }
+
+ size = strlenW(wcSrc) + 1;
+
+ if(size > numElement)
+ {
+ return MSVCRT_ERANGE;
+ }
+
+ memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
+
+ return 0;
+}
+
+/******************************************************************
+ * wcsncpy_s (MSVCRT.@)
+ */
+INT CDECL MSVCRT_wcsncpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, const MSVCRT_wchar_t *wcSrc,
+ MSVCRT_size_t count )
+{
+ MSVCRT_size_t size = 0;
+
+ if (!wcDest || !numElement)
+ return MSVCRT_EINVAL;
+
+ wcDest[0] = 0;
+
+ if (!wcSrc)
+ {
+ return MSVCRT_EINVAL;
+ }
+
+ size = min(strlenW(wcSrc), count);
+
+ if (size >= numElement)
+ {
+ return MSVCRT_ERANGE;
+ }
+
+ memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
+ wcDest[size] = '\0';
+
+ return 0;
+}
+
+/******************************************************************
+ * wcscat_s (MSVCRT.@)
+ *
+ */
+INT CDECL MSVCRT_wcscat_s(MSVCRT_wchar_t* dst, MSVCRT_size_t elem, const MSVCRT_wchar_t* src)
+{
+ MSVCRT_wchar_t* ptr = dst;
+
+ if (!dst || elem == 0) return MSVCRT_EINVAL;
+ if (!src)
+ {
+ dst[0] = '\0';
+ return MSVCRT_EINVAL;
+ }
+
+ /* seek to end of dst string (or elem if no end of string is found */
+ while (ptr < dst + elem && *ptr != '\0') ptr++;
+ while (ptr < dst + elem)
+ {
+ if ((*ptr++ = *src++) == '\0') return 0;
+ }
+ /* not enough space */
+ dst[0] = '\0';
+ return MSVCRT_ERANGE;
+}