Commit b7b13250 authored by Daniel Buckmaster's avatar Daniel Buckmaster

Merge pull request #697 from eightyeight/t2d-string-funcs

Added string functions from T2D
parents 195e05dc 33444e8a
......@@ -532,3 +532,32 @@ const char* dStristr( const char* str1, const char* str2 )
{
return dStristr( const_cast< char* >( str1 ), str2 );
}
int dStrrev(char* str)
{
int l=dStrlen(str)-1; //get the string length
for(int x=0;x < l;x++,l--)
{
str[x]^=str[l]; //triple XOR Trick
str[l]^=str[x]; //for not using a temp
str[x]^=str[l];
}
return l;
}
int dItoa(int n, char s[])
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n positive */
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + '0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
dStrrev(s);
return dStrlen(s);
}
......@@ -217,6 +217,9 @@ bool dStrEndsWith(const char* str1, const char* str2);
char* dStripPath(const char* filename);
int dStrrev(char* str);
int dItoa(int n, char s[]);
//------------------------------------------------------------------------------
// standard I/O functions [defined in platformString.cpp]
......
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