2000-06-23 18:16:30 +02:00
|
|
|
/*
|
|
|
|
* NTDLL string functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
2001-01-22 03:17:29 +01:00
|
|
|
* Copyright 2000 Jon Griffiths
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
* Copyright 2003 Thomas Mertes
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2006-01-24 12:28:34 +01:00
|
|
|
#include "wine/port.h"
|
2000-06-23 18:16:30 +02:00
|
|
|
|
|
|
|
#include <ctype.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2006-04-18 20:30:43 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2000-06-23 18:16:30 +02:00
|
|
|
#include <string.h>
|
2006-04-18 20:30:43 +02:00
|
|
|
#include <search.h>
|
2000-06-23 18:16:30 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
|
2000-06-23 18:16:30 +02:00
|
|
|
|
2006-04-18 20:30:43 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* memchr (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl NTDLL_memchr( const void *ptr, int c, size_t n )
|
|
|
|
{
|
|
|
|
return memchr( ptr, c, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* memcmp (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_memcmp( const void *ptr1, const void *ptr2, size_t n )
|
|
|
|
{
|
|
|
|
return memcmp( ptr1, ptr2, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* memcpy (NTDLL.@)
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Behaves like memmove.
|
|
|
|
*/
|
|
|
|
void * __cdecl NTDLL_memcpy( void *dst, const void *src, size_t n )
|
|
|
|
{
|
|
|
|
return memmove( dst, src, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* memmove (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl NTDLL_memmove( void *dst, const void *src, size_t n )
|
|
|
|
{
|
|
|
|
return memmove( dst, src, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* memset (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl NTDLL_memset( void *dst, int c, size_t n )
|
|
|
|
{
|
|
|
|
return memset( dst, c, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* bsearch (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl NTDLL_bsearch( const void *key, const void *base, size_t nmemb,
|
|
|
|
size_t size, int (*compar)(const void *, const void *) )
|
|
|
|
{
|
|
|
|
return bsearch( key, base, nmemb, size, compar );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* qsort (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void __cdecl NTDLL_qsort( void *base, size_t nmemb, size_t size,
|
|
|
|
int(*compar)(const void *, const void *) )
|
|
|
|
{
|
|
|
|
return qsort( base, nmemb, size, compar );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _lfind (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl _lfind( const void *key, const void *base, size_t *nmemb,
|
|
|
|
size_t size, int(*compar)(const void *, const void *) )
|
|
|
|
{
|
|
|
|
return lfind( key, base, nmemb, size, compar );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strcat (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strcat( char *dst, const char *src )
|
|
|
|
{
|
|
|
|
return strcat( dst, src );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strchr (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strchr( const char *str, int c )
|
|
|
|
{
|
|
|
|
return strchr( str, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strcmp (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_strcmp( const char *str1, const char *str2 )
|
|
|
|
{
|
|
|
|
return strcmp( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strcpy (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strcpy( char *dst, const char *src )
|
|
|
|
{
|
|
|
|
return strcpy( dst, src );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strcspn (NTDLL.@)
|
|
|
|
*/
|
|
|
|
size_t __cdecl NTDLL_strcspn( const char *str, const char *reject )
|
|
|
|
{
|
|
|
|
return strcspn( str, reject );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strlen (NTDLL.@)
|
|
|
|
*/
|
|
|
|
size_t __cdecl NTDLL_strlen( const char *str )
|
|
|
|
{
|
|
|
|
return strlen( str );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strncat (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strncat( char *dst, const char *src, size_t len )
|
|
|
|
{
|
|
|
|
return strncat( dst, src, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strncmp (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_strncmp( const char *str1, const char *str2, size_t len )
|
|
|
|
{
|
|
|
|
return strncmp( str1, str2, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strncpy (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strncpy( char *dst, const char *src, size_t len )
|
|
|
|
{
|
|
|
|
return strncpy( dst, src, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strpbrk (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strpbrk( const char *str, const char *accept )
|
|
|
|
{
|
|
|
|
return strpbrk( str, accept );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strrchr (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strrchr( const char *str, int c )
|
|
|
|
{
|
|
|
|
return strrchr( str, c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strspn (NTDLL.@)
|
|
|
|
*/
|
|
|
|
size_t __cdecl NTDLL_strspn( const char *str, const char *accept )
|
|
|
|
{
|
|
|
|
return strspn( str, accept );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strstr (NTDLL.@)
|
|
|
|
*/
|
|
|
|
char * __cdecl NTDLL_strstr( const char *haystack, const char *needle )
|
|
|
|
{
|
|
|
|
return strstr( haystack, needle );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _memccpy (NTDLL.@)
|
|
|
|
*/
|
|
|
|
void * __cdecl _memccpy( void *dst, const void *src, int c, size_t n )
|
|
|
|
{
|
|
|
|
return memccpy( dst, src, c, n );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 18:16:30 +02:00
|
|
|
/*********************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* _memicmp (NTDLL.@)
|
2004-09-13 20:04:31 +02:00
|
|
|
*
|
|
|
|
* Compare two blocks of memory as strings, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* s1 [I] First string to compare to s2
|
|
|
|
* s2 [I] Second string to compare to s1
|
|
|
|
* len [I] Number of bytes to compare
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* An integer less than, equal to, or greater than zero indicating that
|
|
|
|
* s1 is less than, equal to or greater than s2 respectively.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Any Nul characters in s1 or s2 are ignored. This function always
|
|
|
|
* compares up to len bytes or the first place where s1 and s2 differ.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
2006-04-18 20:30:43 +02:00
|
|
|
INT __cdecl _memicmp( LPCSTR s1, LPCSTR s2, DWORD len )
|
2000-06-23 18:16:30 +02:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
if ((ret = tolower(*s1) - tolower(*s2))) break;
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
|
2006-01-24 12:28:34 +01:00
|
|
|
/*********************************************************************
|
2006-04-18 20:30:43 +02:00
|
|
|
* _stricmp (NTDLL.@)
|
|
|
|
* _strcmpi (NTDLL.@)
|
2006-01-24 12:28:34 +01:00
|
|
|
*/
|
2006-04-18 20:30:43 +02:00
|
|
|
int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 )
|
2006-01-24 12:28:34 +01:00
|
|
|
{
|
2006-04-18 20:30:43 +02:00
|
|
|
return strcasecmp( str1, str2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _strnicmp (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl _strnicmp( LPCSTR str1, LPCSTR str2, size_t n )
|
|
|
|
{
|
|
|
|
return strncasecmp( str1, str2, n );
|
2006-01-24 12:28:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 18:16:30 +02:00
|
|
|
/*********************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* _strupr (NTDLL.@)
|
2004-09-13 20:04:31 +02:00
|
|
|
*
|
|
|
|
* Convert a string to upper case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I/O] String to convert
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* str. There is no error return, if str is NULL or invalid, this
|
|
|
|
* function will crash.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
|
|
|
LPSTR __cdecl _strupr( LPSTR str )
|
|
|
|
{
|
|
|
|
LPSTR ret = str;
|
|
|
|
for ( ; *str; str++) *str = toupper(*str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
|
2000-06-23 18:16:30 +02:00
|
|
|
/*********************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* _strlwr (NTDLL.@)
|
2000-06-23 18:16:30 +02:00
|
|
|
*
|
2004-09-13 20:04:31 +02:00
|
|
|
* Convert a string to lowercase
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* str [I/O] String to convert
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* str. There is no error return, if str is NULL or invalid, this
|
|
|
|
* function will crash.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
|
|
|
LPSTR __cdecl _strlwr( LPSTR str )
|
|
|
|
{
|
|
|
|
LPSTR ret = str;
|
|
|
|
for ( ; *str; str++) *str = tolower(*str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-18 20:30:43 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* tolower (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_tolower( int c )
|
|
|
|
{
|
|
|
|
return tolower( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* toupper (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_toupper( int c )
|
|
|
|
{
|
|
|
|
return toupper( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isalnum (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isalnum( int c )
|
|
|
|
{
|
|
|
|
return isalnum( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isalpha (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isalpha( int c )
|
|
|
|
{
|
|
|
|
return isalpha( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* iscntrl (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_iscntrl( int c )
|
|
|
|
{
|
|
|
|
return iscntrl( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isdigit (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isdigit( int c )
|
|
|
|
{
|
|
|
|
return isdigit( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isgraph (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isgraph( int c )
|
|
|
|
{
|
|
|
|
return isgraph( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* islower (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_islower( int c )
|
|
|
|
{
|
|
|
|
return islower( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isprint (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isprint( int c )
|
|
|
|
{
|
|
|
|
return isprint( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ispunct (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_ispunct( int c )
|
|
|
|
{
|
|
|
|
return ispunct( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isspace (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isspace( int c )
|
|
|
|
{
|
|
|
|
return isspace( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isupper (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isupper( int c )
|
|
|
|
{
|
|
|
|
return isupper( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* isxdigit (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_isxdigit( int c )
|
|
|
|
{
|
|
|
|
return isxdigit( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strtol (NTDLL.@)
|
|
|
|
*/
|
|
|
|
long __cdecl NTDLL_strtol( const char *nptr, char **endptr, int base )
|
|
|
|
{
|
|
|
|
return strtol( nptr, endptr, base );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* strtoul (NTDLL.@)
|
|
|
|
*/
|
|
|
|
unsigned long __cdecl NTDLL_strtoul( const char *nptr, char **endptr, int base )
|
|
|
|
{
|
|
|
|
return strtoul( nptr, endptr, base );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* atoi (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_atoi( const char *nptr )
|
|
|
|
{
|
|
|
|
return atoi( nptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* atol (NTDLL.@)
|
|
|
|
*/
|
|
|
|
long __cdecl NTDLL_atol( const char *nptr )
|
|
|
|
{
|
|
|
|
return atol( nptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 18:16:30 +02:00
|
|
|
/*********************************************************************
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
* _ultoa (NTDLL.@)
|
|
|
|
*
|
2004-09-13 20:04:31 +02:00
|
|
|
* Convert an unsigned long integer to a string.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Converts value to a Nul terminated string which is copied to str.
|
|
|
|
* - The maximum length of the copied str is 33 bytes.
|
|
|
|
* - Does not check if radix is in the range of 2 to 36.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
char * __cdecl _ultoa(
|
|
|
|
unsigned long value, /* [I] Value to be converted */
|
|
|
|
char *str, /* [O] Destination for the converted value */
|
|
|
|
int radix) /* [I] Number base for conversion */
|
2000-06-23 18:16:30 +02:00
|
|
|
{
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
char buffer[33];
|
|
|
|
char *pos;
|
|
|
|
int digit;
|
2000-06-23 18:16:30 +02:00
|
|
|
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
pos = &buffer[32];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
digit = value % radix;
|
|
|
|
value = value / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
memcpy(str, pos, &buffer[32] - pos + 1);
|
|
|
|
return str;
|
2000-06-23 18:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
* _ltoa (NTDLL.@)
|
|
|
|
*
|
2004-09-13 20:04:31 +02:00
|
|
|
* Convert a long integer to a string.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Converts value to a Nul terminated string which is copied to str.
|
|
|
|
* - The maximum length of the copied str is 33 bytes. If radix
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* is 10 and value is negative, the value is converted with sign.
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Does not check if radix is in the range of 2 to 36.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
char * __cdecl _ltoa(
|
|
|
|
long value, /* [I] Value to be converted */
|
|
|
|
char *str, /* [O] Destination for the converted value */
|
|
|
|
int radix) /* [I] Number base for conversion */
|
2000-06-23 18:16:30 +02:00
|
|
|
{
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
unsigned long val;
|
|
|
|
int negative;
|
|
|
|
char buffer[33];
|
|
|
|
char *pos;
|
|
|
|
int digit;
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10) {
|
|
|
|
negative = 1;
|
|
|
|
val = -value;
|
|
|
|
} else {
|
|
|
|
negative = 0;
|
|
|
|
val = value;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[32];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
digit = val % radix;
|
|
|
|
val = val / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (val != 0L);
|
|
|
|
|
|
|
|
if (negative) {
|
|
|
|
*--pos = '-';
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
memcpy(str, pos, &buffer[32] - pos + 1);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _itoa (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Converts an integer to a string.
|
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Converts value to a '\0' terminated string which is copied to str.
|
|
|
|
* - The maximum length of the copied str is 33 bytes. If radix
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* is 10 and value is negative, the value is converted with sign.
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Does not check if radix is in the range of 2 to 36.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*/
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
char * __cdecl _itoa(
|
|
|
|
int value, /* [I] Value to be converted */
|
|
|
|
char *str, /* [O] Destination for the converted value */
|
|
|
|
int radix) /* [I] Number base for conversion */
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
{
|
|
|
|
return _ltoa(value, str, radix);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _ui64toa (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Converts a large unsigned integer to a string.
|
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Converts value to a '\0' terminated string which is copied to str.
|
|
|
|
* - The maximum length of the copied str is 65 bytes.
|
|
|
|
* - Does not check if radix is in the range of 2 to 36.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*/
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
char * __cdecl _ui64toa(
|
|
|
|
ULONGLONG value, /* [I] Value to be converted */
|
|
|
|
char *str, /* [O] Destination for the converted value */
|
|
|
|
int radix) /* [I] Number base for conversion */
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
{
|
|
|
|
char buffer[65];
|
|
|
|
char *pos;
|
|
|
|
int digit;
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
digit = value % radix;
|
|
|
|
value = value / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
memcpy(str, pos, &buffer[64] - pos + 1);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _i64toa (NTDLL.@)
|
|
|
|
*
|
|
|
|
* Converts a large integer to a string.
|
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Converts value to a Nul terminated string which is copied to str.
|
|
|
|
* - The maximum length of the copied str is 65 bytes. If radix
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* is 10 and value is negative, the value is converted with sign.
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Does not check if radix is in the range of 2 to 36.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* DIFFERENCES
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
* - The native DLL converts negative values (for base 10) wrong:
|
2004-09-13 20:04:31 +02:00
|
|
|
*| -1 is converted to -18446744073709551615
|
|
|
|
*| -2 is converted to -18446744073709551614
|
|
|
|
*| -9223372036854775807 is converted to -9223372036854775809
|
|
|
|
*| -9223372036854775808 is converted to -9223372036854775808
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* The native msvcrt _i64toa function and our ntdll _i64toa function
|
|
|
|
* do not have this bug.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*/
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
char * __cdecl _i64toa(
|
|
|
|
LONGLONG value, /* [I] Value to be converted */
|
|
|
|
char *str, /* [O] Destination for the converted value */
|
|
|
|
int radix) /* [I] Number base for conversion */
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
{
|
|
|
|
ULONGLONG val;
|
|
|
|
int negative;
|
|
|
|
char buffer[65];
|
|
|
|
char *pos;
|
|
|
|
int digit;
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10) {
|
|
|
|
negative = 1;
|
|
|
|
val = -value;
|
|
|
|
} else {
|
|
|
|
negative = 0;
|
|
|
|
val = value;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
digit = val % radix;
|
|
|
|
val = val / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (val != 0L);
|
|
|
|
|
|
|
|
if (negative) {
|
|
|
|
*--pos = '-';
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
memcpy(str, pos, &buffer[64] - pos + 1);
|
|
|
|
return str;
|
2000-06-23 18:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
* _atoi64 (NTDLL.@)
|
|
|
|
*
|
2004-09-13 20:04:31 +02:00
|
|
|
* Convert a string to a large integer.
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
*
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
* PARAMS
|
2004-09-13 20:04:31 +02:00
|
|
|
* str [I] String to be converted
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-09-13 20:04:31 +02:00
|
|
|
* Success: The integer value represented by str.
|
|
|
|
* Failure: 0. Note that this cannot be distinguished from a successful
|
|
|
|
* return, if the string contains "0".
|
- Implement RtlDowncaseUnicodeString, RtlUniform, iswdigit, iswlower,
iswspace, iswxdigit.
- Fixed RtlInt64ToUnicodeString and RtlIntegerToUnicodeString.
- According to tests RtlAppendUnicodeStringToString leaves the
destination unchanged when the source length is 0 (FIXED).
- Documentation updates in RtlExtendedMagicDivide,
RtlLargeIntegerToChar, RtlInt64ToUnicodeString, RtlUpperChar,
RtlUpperString, RtlUpcaseUnicodeChar, RtlCharToInteger,
RtlIntegerToChar, RtlUnicodeStringToInteger,
RtlIntegerToUnicodeString, _ultoa, _ltoa, _itoa, _ui64toa, _i64toa,
_atoi64, _ultow, _ltow, _itow, _ui64tow, _i64tow, _wtol, _wtoi,
_wtoi64.
2003-03-22 01:20:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-09-13 20:04:31 +02:00
|
|
|
* - Accepts: {whitespace} [+|-] {digits}
|
|
|
|
* - No check is made for value overflow, only the lower 64 bits are assigned.
|
|
|
|
* - If str is NULL it crashes, as the native function does.
|
2000-06-23 18:16:30 +02:00
|
|
|
*/
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
LONGLONG __cdecl _atoi64( char *str )
|
2000-06-23 18:16:30 +02:00
|
|
|
{
|
Implement _itoa, _ltoa, _ultoa, _i64toa, _ui64toa, _itow, _ltow,
_ultow, _i64tow, _ui64tow, _atoi64, _wtoi, _wtol, _wtoi64.
2003-03-12 21:16:07 +01:00
|
|
|
ULONGLONG RunningTotal = 0;
|
|
|
|
char bMinus = 0;
|
|
|
|
|
|
|
|
while (*str == ' ' || (*str >= '\011' && *str <= '\015')) {
|
|
|
|
str++;
|
|
|
|
} /* while */
|
|
|
|
|
|
|
|
if (*str == '+') {
|
|
|
|
str++;
|
|
|
|
} else if (*str == '-') {
|
|
|
|
bMinus = 1;
|
|
|
|
str++;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
while (*str >= '0' && *str <= '9') {
|
|
|
|
RunningTotal = RunningTotal * 10 + *str - '0';
|
|
|
|
str++;
|
|
|
|
} /* while */
|
|
|
|
|
|
|
|
return bMinus ? -RunningTotal : RunningTotal;
|
2000-06-23 18:16:30 +02:00
|
|
|
}
|
2001-01-22 03:17:29 +01:00
|
|
|
|
|
|
|
|
2006-04-18 20:30:43 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* sprintf (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_sprintf( char *str, const char *format, ... )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, format );
|
|
|
|
ret = vsprintf( str, format, valist );
|
|
|
|
va_end( valist );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* vsprintf (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_vsprintf( char *str, const char *format, va_list args )
|
|
|
|
{
|
|
|
|
return vsprintf( str, format, args );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _snprintf (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl _snprintf( char *str, size_t len, const char *format, ... )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, format );
|
|
|
|
ret = vsnprintf( str, len, format, valist );
|
|
|
|
va_end( valist );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _vsnprintf (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl _vsnprintf( char *str, size_t len, const char *format, va_list args )
|
|
|
|
{
|
|
|
|
return vsnprintf( str, len, format, args );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* sscanf (NTDLL.@)
|
|
|
|
*/
|
|
|
|
int __cdecl NTDLL_sscanf( const char *str, const char *format, ... )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list valist;
|
|
|
|
va_start( valist, format );
|
|
|
|
ret = vsscanf( str, format, valist );
|
|
|
|
va_end( valist );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-22 03:17:29 +01:00
|
|
|
/*********************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* _splitpath (NTDLL.@)
|
2004-09-13 20:04:31 +02:00
|
|
|
*
|
|
|
|
* Split a path into its component pieces.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* inpath [I] Path to split
|
|
|
|
* drv [O] Destination for drive component (e.g. "A:"). Must be at least 3 characters.
|
|
|
|
* dir [O] Destination for directory component. Should be at least MAX_PATH characters.
|
|
|
|
* fname [O] Destination for File name component. Should be at least MAX_PATH characters.
|
|
|
|
* ext [O] Destination for file extension component. Should be at least MAX_PATH characters.
|
2005-11-09 11:30:57 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2001-01-22 03:17:29 +01:00
|
|
|
*/
|
|
|
|
void __cdecl _splitpath(const char* inpath, char * drv, char * dir,
|
|
|
|
char* fname, char * ext )
|
|
|
|
{
|
2003-10-15 04:34:51 +02:00
|
|
|
const char *p, *end;
|
|
|
|
|
|
|
|
if (inpath[0] && inpath[1] == ':')
|
2001-01-22 03:17:29 +01:00
|
|
|
{
|
2003-10-15 04:34:51 +02:00
|
|
|
if (drv)
|
|
|
|
{
|
|
|
|
drv[0] = inpath[0];
|
|
|
|
drv[1] = inpath[1];
|
|
|
|
drv[2] = 0;
|
|
|
|
}
|
|
|
|
inpath += 2;
|
2001-01-22 03:17:29 +01:00
|
|
|
}
|
2003-10-15 04:34:51 +02:00
|
|
|
else if (drv) drv[0] = 0;
|
|
|
|
|
|
|
|
/* look for end of directory part */
|
|
|
|
end = NULL;
|
|
|
|
for (p = inpath; *p; p++) if (*p == '/' || *p == '\\') end = p + 1;
|
|
|
|
|
|
|
|
if (end) /* got a directory */
|
2001-01-22 03:17:29 +01:00
|
|
|
{
|
2003-10-15 04:34:51 +02:00
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
memcpy( dir, inpath, end - inpath );
|
|
|
|
dir[end - inpath] = 0;
|
|
|
|
}
|
|
|
|
inpath = end;
|
2001-01-22 03:17:29 +01:00
|
|
|
}
|
2003-10-15 04:34:51 +02:00
|
|
|
else if (dir) dir[0] = 0;
|
|
|
|
|
2003-10-22 01:51:06 +02:00
|
|
|
/* look for extension: what's after the last dot */
|
|
|
|
end = NULL;
|
|
|
|
for (p = inpath; *p; p++) if (*p == '.') end = p;
|
|
|
|
|
|
|
|
if (!end) end = p; /* there's no extension */
|
2001-01-22 03:17:29 +01:00
|
|
|
|
|
|
|
if (fname)
|
|
|
|
{
|
2003-10-15 04:34:51 +02:00
|
|
|
memcpy( fname, inpath, end - inpath );
|
|
|
|
fname[end - inpath] = 0;
|
2001-01-22 03:17:29 +01:00
|
|
|
}
|
2003-10-15 04:34:51 +02:00
|
|
|
if (ext) strcpy( ext, end );
|
2001-01-22 03:17:29 +01:00
|
|
|
}
|