From 757f810a1fe7a1d0305d766323abcb8abbdbb116 Mon Sep 17 00:00:00 2001 From: punkrockguy318 Date: Tue, 17 Jun 2008 17:58:33 +0000 Subject: [PATCH] changed itoa -> sprintf() itoa does not work with gcc, but sprintf serves our purposes --- src/utils/xstring.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/src/utils/xstring.cpp b/src/utils/xstring.cpp index 7e35b072..f1e75bf6 100644 --- a/src/utils/xstring.cpp +++ b/src/utils/xstring.cpp @@ -479,38 +479,11 @@ unsigned int uintDecFromIstream(std::istream* is) return ret; } -//FIXME: itoa isn't ANSI C compliant. Perhaps sprintf would be better here? -#ifdef WIN32 std::string stditoa(int n) { - char tempbuf[16]; - return itoa(n,tempbuf,10); + char tempbuf[16]; + sprintf(tempbuf, "%d", n); + return tempbuf; } -#else -std::string stditoa(int n) { - enum { kMaxDigits = 35 }; - - std::string buf; - - buf.reserve( kMaxDigits ); // Pre-allocate enough space. - - int quotient = n; - - // Translating number to string with base - do { - buf += "0123456789abcdef"[ std::abs( quotient % 10 ) ]; - quotient /= 10; - } while ( quotient ); - - - - // Append the negative sign for base 10 - if ( n < 0) buf += '-'; - - std::reverse( buf.begin(), buf.end() ); - - return buf; -} -#endif