2007-11-08 21:06:20 +00:00
|
|
|
/*
|
2007-03-14 20:24:57 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-09-19 13:50:57 +00:00
|
|
|
* FILE: lib/sdk/crt/string/itow.c
|
2007-03-14 20:24:57 +00:00
|
|
|
* PURPOSE: converts a integer to wchar_t
|
|
|
|
* PROGRAMER:
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2007-11-08 21:06:20 +00:00
|
|
|
wchar_t *
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
2007-11-08 21:06:20 +00:00
|
|
|
_i64tow(__int64 value, wchar_t *string, int radix)
|
|
|
|
{
|
|
|
|
ULONGLONG val;
|
|
|
|
int negative;
|
|
|
|
WCHAR buffer[65];
|
|
|
|
PWCHAR pos;
|
|
|
|
WCHAR digit;
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10) {
|
|
|
|
negative = 1;
|
|
|
|
val = -value;
|
|
|
|
} else {
|
|
|
|
negative = 0;
|
|
|
|
val = value;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
2011-09-15 17:11:53 +00:00
|
|
|
digit = (WCHAR)(val % radix);
|
2007-11-08 21:06:20 +00:00
|
|
|
val = val / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (val != 0L);
|
|
|
|
|
|
|
|
if (negative) {
|
|
|
|
*--pos = '-';
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
if (string != NULL) {
|
|
|
|
memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
|
|
|
|
} /* if */
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_i64tow_s(__int64 value, wchar_t *str, size_t size, int radix)
|
|
|
|
{
|
|
|
|
unsigned __int64 val;
|
|
|
|
unsigned int digit;
|
|
|
|
int is_negative;
|
|
|
|
wchar_t buffer[65], *pos;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
|
|
|
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
|
|
|
{
|
|
|
|
if (str && size)
|
|
|
|
str[0] = '\0';
|
|
|
|
|
|
|
|
#ifndef _LIBCNT_
|
|
|
|
*_errno() = EINVAL;
|
|
|
|
#endif
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10)
|
|
|
|
{
|
|
|
|
is_negative = 1;
|
|
|
|
val = -value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_negative = 0;
|
|
|
|
val = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = buffer + 64;
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
digit = val % radix;
|
|
|
|
val /= radix;
|
|
|
|
|
|
|
|
if (digit < 10)
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
else
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
}
|
|
|
|
while (val != 0);
|
|
|
|
|
|
|
|
if (is_negative)
|
|
|
|
*--pos = '-';
|
|
|
|
|
|
|
|
len = buffer + 65 - pos;
|
|
|
|
if (len > size)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
wchar_t *p = str;
|
|
|
|
|
|
|
|
/* Copy the temporary buffer backwards up to the available number of
|
|
|
|
* characters. Don't copy the negative sign if present. */
|
|
|
|
|
|
|
|
if (is_negative)
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pos = buffer + 63, i = 0; i < size; i++)
|
|
|
|
*p++ = *pos--;
|
|
|
|
|
2014-05-10 20:38:26 +00:00
|
|
|
MSVCRT_INVALID_PMT("str[size] is too small", ERANGE);
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
str[0] = '\0';
|
|
|
|
return ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(str, pos, len * sizeof(wchar_t));
|
|
|
|
return 0;
|
|
|
|
}
|
2007-11-08 21:06:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
wchar_t *
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
2007-11-08 21:06:20 +00:00
|
|
|
_ui64tow(unsigned __int64 value, wchar_t *string, int radix)
|
|
|
|
{
|
|
|
|
WCHAR buffer[65];
|
|
|
|
PWCHAR pos;
|
|
|
|
WCHAR digit;
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
2011-09-15 17:11:53 +00:00
|
|
|
digit = (WCHAR)(value % radix);
|
2007-11-08 21:06:20 +00:00
|
|
|
value = value / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
if (string != NULL) {
|
|
|
|
memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR));
|
|
|
|
} /* if */
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_ui64tow_s( unsigned __int64 value, wchar_t *str,
|
|
|
|
size_t size, int radix )
|
|
|
|
{
|
|
|
|
wchar_t buffer[65], *pos;
|
|
|
|
int digit;
|
|
|
|
|
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
|
|
|
!MSVCRT_CHECK_PMT(radix>=2) || !MSVCRT_CHECK_PMT(radix<=36)) {
|
|
|
|
#ifndef _LIBCNT_
|
|
|
|
*_errno() = EINVAL;
|
|
|
|
#endif
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = &buffer[64];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
|
|
|
digit = value % radix;
|
|
|
|
value = value / radix;
|
|
|
|
if (digit < 10)
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
else
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} while (value != 0);
|
|
|
|
|
2012-10-07 21:36:50 +00:00
|
|
|
if((size_t)(buffer-pos+65) > size) {
|
2014-05-10 20:38:26 +00:00
|
|
|
MSVCRT_INVALID_PMT("str[size] is too small", EINVAL);
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(str, pos, buffer-pos+65);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-11-08 21:06:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
wchar_t *
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
2007-11-08 21:06:20 +00:00
|
|
|
_itow(int value, wchar_t *string, int radix)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2007-11-08 21:06:20 +00:00
|
|
|
return _ltow(value, string, radix);
|
2007-03-14 20:24:57 +00:00
|
|
|
}
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_itow_s(int value, wchar_t *str, size_t size, int radix)
|
|
|
|
{
|
|
|
|
return _ltow_s(value, str, size, radix);
|
|
|
|
}
|
2007-11-08 21:06:20 +00:00
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2007-11-08 21:06:20 +00:00
|
|
|
wchar_t *
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
2007-11-08 21:06:20 +00:00
|
|
|
_ltow(long value, wchar_t *string, int radix)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2007-11-08 21:06:20 +00:00
|
|
|
unsigned long val;
|
2007-03-14 20:24:57 +00:00
|
|
|
int negative;
|
|
|
|
WCHAR buffer[33];
|
|
|
|
PWCHAR pos;
|
|
|
|
WCHAR digit;
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10) {
|
|
|
|
negative = 1;
|
|
|
|
val = -value;
|
|
|
|
} else {
|
|
|
|
negative = 0;
|
|
|
|
val = value;
|
|
|
|
} /* if */
|
|
|
|
|
|
|
|
pos = &buffer[32];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
2011-09-15 17:11:53 +00:00
|
|
|
digit = (WCHAR)(val % radix);
|
2007-03-14 20:24:57 +00:00
|
|
|
val = val / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (val != 0L);
|
|
|
|
|
|
|
|
if (negative) {
|
|
|
|
*--pos = '-';
|
|
|
|
} /* if */
|
|
|
|
|
2007-11-08 21:06:20 +00:00
|
|
|
if (string != NULL) {
|
2007-03-14 20:24:57 +00:00
|
|
|
memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
|
|
|
|
} /* if */
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
int
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_ltow_s(long value, wchar_t *str, size_t size, int radix)
|
|
|
|
{
|
|
|
|
unsigned long val;
|
|
|
|
unsigned int digit;
|
|
|
|
int is_negative;
|
|
|
|
wchar_t buffer[33], *pos;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (!MSVCRT_CHECK_PMT(str != NULL) || !MSVCRT_CHECK_PMT(size > 0) ||
|
|
|
|
!MSVCRT_CHECK_PMT(radix >= 2) || !MSVCRT_CHECK_PMT(radix <= 36))
|
|
|
|
{
|
|
|
|
if (str && size)
|
|
|
|
str[0] = '\0';
|
|
|
|
|
|
|
|
#ifndef _LIBCNT_
|
|
|
|
*_errno() = EINVAL;
|
|
|
|
#endif
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value < 0 && radix == 10)
|
|
|
|
{
|
|
|
|
is_negative = 1;
|
|
|
|
val = -value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is_negative = 0;
|
|
|
|
val = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = buffer + 32;
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
digit = val % radix;
|
|
|
|
val /= radix;
|
|
|
|
|
|
|
|
if (digit < 10)
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
else
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
}
|
|
|
|
while (val != 0);
|
|
|
|
|
|
|
|
if (is_negative)
|
|
|
|
*--pos = '-';
|
|
|
|
|
|
|
|
len = buffer + 33 - pos;
|
|
|
|
if (len > size)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
wchar_t *p = str;
|
|
|
|
|
|
|
|
/* Copy the temporary buffer backwards up to the available number of
|
|
|
|
* characters. Don't copy the negative sign if present. */
|
|
|
|
|
|
|
|
if (is_negative)
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pos = buffer + 31, i = 0; i < size; i++)
|
|
|
|
*p++ = *pos--;
|
|
|
|
|
2014-05-10 20:38:26 +00:00
|
|
|
MSVCRT_INVALID_PMT("str[size] is too small", ERANGE);
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
str[0] = '\0';
|
|
|
|
return ERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(str, pos, len * sizeof(wchar_t));
|
|
|
|
return 0;
|
|
|
|
}
|
2007-11-08 21:06:20 +00:00
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2007-11-08 21:06:20 +00:00
|
|
|
wchar_t *
|
2015-09-15 10:35:49 +00:00
|
|
|
CDECL
|
2007-11-08 21:06:20 +00:00
|
|
|
_ultow(unsigned long value, wchar_t *string, int radix)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[33];
|
|
|
|
PWCHAR pos;
|
|
|
|
WCHAR digit;
|
|
|
|
|
|
|
|
pos = &buffer[32];
|
|
|
|
*pos = '\0';
|
|
|
|
|
|
|
|
do {
|
2011-09-15 17:11:53 +00:00
|
|
|
digit = (WCHAR)(value % radix);
|
2007-03-14 20:24:57 +00:00
|
|
|
value = value / radix;
|
|
|
|
if (digit < 10) {
|
|
|
|
*--pos = '0' + digit;
|
|
|
|
} else {
|
|
|
|
*--pos = 'a' + digit - 10;
|
|
|
|
} /* if */
|
|
|
|
} while (value != 0L);
|
|
|
|
|
|
|
|
if (string != NULL) {
|
|
|
|
memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR));
|
|
|
|
} /* if */
|
|
|
|
return string;
|
|
|
|
}
|