diff --git a/src/utils/guid.h b/src/utils/guid.h index f9c1e821..34120a0c 100644 --- a/src/utils/guid.h +++ b/src/utils/guid.h @@ -2,7 +2,7 @@ #define _guid_h_ #include -#include "types.h" +#include "../types.h" #include "valuearray.h" struct FCEU_Guid : public ValueArray @@ -15,4 +15,4 @@ struct FCEU_Guid : public ValueArray }; -#endif \ No newline at end of file +#endif diff --git a/src/utils/valuearray.h b/src/utils/valuearray.h index 7d9c4e3f..48a42b67 100644 --- a/src/utils/valuearray.h +++ b/src/utils/valuearray.h @@ -17,4 +17,5 @@ struct ValueArray } }; -#endif \ No newline at end of file +#endif + diff --git a/src/utils/xstring.cpp b/src/utils/xstring.cpp index a38e37e1..7e35b072 100644 --- a/src/utils/xstring.cpp +++ b/src/utils/xstring.cpp @@ -478,9 +478,39 @@ unsigned int uintDecFromIstream(std::istream* is) is->unget(); 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); -} \ No newline at end of file +} +#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 + +