mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
168
lib/sdk/crt/string/itoa.c
Normal file
168
lib/sdk/crt/string/itoa.c
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crt/??????
|
||||
* PURPOSE: Unknown
|
||||
* PROGRAMER: Unknown
|
||||
* UPDATE HISTORY:
|
||||
* 25/11/05: Added license header
|
||||
*/
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy _i64toa from wine cvs 2006 month 05 day 21
|
||||
*/
|
||||
char *
|
||||
_i64toa(__int64 value, char *string, int radix)
|
||||
{
|
||||
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(string, pos, &buffer[64] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy _i64toa from wine cvs 2006 month 05 day 21
|
||||
*/
|
||||
char *
|
||||
_ui64toa(unsigned __int64 value, char *string, int radix)
|
||||
{
|
||||
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(string, pos, &buffer[64] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *
|
||||
_itoa(int value, char *string, int radix)
|
||||
{
|
||||
return _ltoa(value, string, radix);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *
|
||||
_ltoa(long value, char *string, int radix)
|
||||
{
|
||||
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(string, pos, &buffer[32] - pos + 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
* copy it from wine 0.9.0 with small modifcations do check for NULL
|
||||
*/
|
||||
char *
|
||||
_ultoa(unsigned long value, char *string, int radix)
|
||||
{
|
||||
char buffer[33];
|
||||
char *pos;
|
||||
int digit;
|
||||
|
||||
pos = &buffer[32];
|
||||
*pos = '\0';
|
||||
|
||||
if (string == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
do {
|
||||
digit = value % radix;
|
||||
value = value / radix;
|
||||
if (digit < 10) {
|
||||
*--pos = '0' + digit;
|
||||
} else {
|
||||
*--pos = 'a' + digit - 10;
|
||||
} /* if */
|
||||
} while (value != 0L);
|
||||
|
||||
memcpy(string, pos, &buffer[32] - pos + 1);
|
||||
|
||||
return string;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue