Commit 941bacc7 authored by Sandeep Mistry's avatar Sandeep Mistry

Put back ltoa and ultoa functions

parent b55555cd
......@@ -23,147 +23,93 @@
extern "C" {
#endif
/* reverse: reverse string s in place */
/*
static void reverse( char s[] )
extern char* ltoa( long value, char *string, int radix )
{
int i, j ;
char c ;
char tmp[33];
char *tp = tmp;
long i;
unsigned long v;
int sign;
char *sp;
if ( string == NULL )
{
return 0 ;
}
if (radix > 36 || radix <= 1)
{
return 0 ;
}
sign = (radix == 10 && value < 0);
if (sign)
{
v = -value;
}
else
{
v = (unsigned long)value;
}
for ( i = 0, j = strlen(s)-1 ; i < j ; i++, j-- )
while (v || tp == tmp)
{
c = s[i] ;
s[i] = s[j] ;
s[j] = c ;
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
if (sign)
*sp++ = '-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
*/
/* itoa: convert n to characters in s */
/*
extern void itoa( int n, char s[] )
extern char* ultoa( unsigned long value, char *string, int radix )
{
int i, sign ;
char tmp[33];
char *tp = tmp;
long i;
unsigned long v = value;
char *sp;
if ( (sign = n) < 0 ) // record sign
if ( string == NULL )
{
n = -n; // make n positive
return 0;
}
i = 0;
do
{ // generate digits in reverse order
s[i++] = n % 10 + '0'; // get next digit
} while ((n /= 10) > 0) ; // delete it
if (radix > 36 || radix <= 1)
{
return 0;
}
if (sign < 0 )
while (v || tp == tmp)
{
s[i++] = '-';
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
s[i] = '\0';
sp = string;
reverse( s ) ;
}
*/
// extern char* itoa( int value, char *string, int radix )
// {
// return ltoa( value, string, radix ) ;
// }
// extern char* ltoa( long value, char *string, int radix )
// {
// char tmp[33];
// char *tp = tmp;
// long i;
// unsigned long v;
// int sign;
// char *sp;
// if ( string == NULL )
// {
// return 0 ;
// }
// if (radix > 36 || radix <= 1)
// {
// return 0 ;
// }
// sign = (radix == 10 && value < 0);
// if (sign)
// {
// v = -value;
// }
// else
// {
// v = (unsigned long)value;
// }
// while (v || tp == tmp)
// {
// i = v % radix;
// v = v / radix;
// if (i < 10)
// *tp++ = i+'0';
// else
// *tp++ = i + 'a' - 10;
// }
// sp = string;
// if (sign)
// *sp++ = '-';
// while (tp > tmp)
// *sp++ = *--tp;
// *sp = 0;
// return string;
// }
// // extern char* utoa( unsigned long value, char *string, int radix )
// // {
// // return ultoa( value, string, radix ) ;
// // }
// extern char* ultoa( unsigned long value, char *string, int radix )
// {
// char tmp[33];
// char *tp = tmp;
// long i;
// unsigned long v = value;
// char *sp;
// if ( string == NULL )
// {
// return 0;
// }
// if (radix > 36 || radix <= 1)
// {
// return 0;
// }
// while (v || tp == tmp)
// {
// i = v % radix;
// v = v / radix;
// if (i < 10)
// *tp++ = i+'0';
// else
// *tp++ = i + 'a' - 10;
// }
// sp = string;
// while (tp > tmp)
// *sp++ = *--tp;
// *sp = 0;
// return string;
// }
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
#ifdef __cplusplus
} // extern "C"
......
......@@ -22,11 +22,7 @@
extern "C"{
#endif
//extern void itoa( int n, char s[] ) ;
// extern char* itoa( int value, char *string, int radix ) ;
extern char* ltoa( long value, char *string, int radix ) ;
// extern char* utoa( unsigned long value, char *string, int radix ) ;
extern char* ultoa( unsigned long value, char *string, int radix ) ;
#ifdef __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment