From c22ba2604dd92c646ce6848725bcb233890ed537 Mon Sep 17 00:00:00 2001 From: namespace Date: Mon, 11 Sep 2006 10:35:17 +0000 Subject: [PATCH] Fixed compile error on x86_64, see http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=1105 for details. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@102 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- CHANGES | 10 +++++++ libs/stream/textstream.h | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/CHANGES b/CHANGES index da078936..560d252d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,16 @@ This is the changelog for developers, != changelog for the end user that we distribute with the binaries. (see changelog) +11/09/2006 +namespace +- Fixed compile error on x86_64, see http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=1105 + for details. + +09/09/2996 +namespace +- Added strafing for the camerawindow while holding ctrl +- Additional forward movement can be enabled by pressing shift during strafe + 22/08/2006 SPoG - Added VFS support for locating the archive a file was loaded from. diff --git a/libs/stream/textstream.h b/libs/stream/textstream.h index 8e0c72c4..fff8a457 100644 --- a/libs/stream/textstream.h +++ b/libs/stream/textstream.h @@ -46,6 +46,17 @@ namespace TextOutputDetail } return ptr; } + + #if defined (_WIN64) || defined (__LP64__) + inline char* write_size_t_nonzero_decimal_backward(char* ptr, size_t decimal) + { + for (; decimal != 0; decimal /= 10) + { + *--ptr = char('0' + (size_t)(decimal % 10)); + } + return ptr; + } + #endif inline char* write_signed_nonzero_decimal_backward(char* ptr, int decimal, bool show_positive) { @@ -71,6 +82,18 @@ namespace TextOutputDetail } return ptr; } + + #if defined (_WIN64) || defined (__LP64__) + inline char* write_size_t_nonzero_decimal_backward(char* ptr, size_t decimal, bool show_positive) + { + ptr = write_size_t_nonzero_decimal_backward(ptr, decimal); + if(show_positive) + { + *--ptr = '+'; + } + return ptr; + } + #endif inline char* write_signed_decimal_backward(char* ptr, int decimal, bool show_positive) { @@ -97,6 +120,21 @@ namespace TextOutputDetail } return ptr; } + + #if defined (_WIN64) || defined (__LP64__) + inline char* write_size_t_decimal_backward(char* ptr, size_t decimal, bool show_positive) + { + if(decimal == 0) + { + *--ptr = '0'; + } + else + { + ptr = write_size_t_nonzero_decimal_backward(ptr, decimal, show_positive); + } + return ptr; + } + #endif } @@ -166,6 +204,27 @@ inline TextOutputStreamType& ostream_write(TextOutputStreamType& ostream, const return ostream; } +#if defined (_WIN64) || defined (__LP64__) + +/// \brief Writes a size_t \p i to \p ostream in decimal form. +template +inline TextOutputStreamType& ostream_write(TextOutputStreamType& ostream, const size_t i) +{ + // max is 18446744073709551615, buffer of 32 chars should always be enough + const std::size_t bufferSize = 32; +#if 1 + char buf[bufferSize]; + char* begin = TextOutputDetail::write_size_t_decimal_backward(buf + bufferSize, i, false); + ostream.write(begin, (buf + bufferSize) - begin); +#else + char buf[bufferSize]; + ostream.write(buf, snprintf(buf, bufferSize, "%u", i)); +#endif + return ostream; +} + +#endif + /// \brief Writes a null-terminated \p string to \p ostream. template inline TextOutputStreamType& ostream_write(TextOutputStreamType& ostream, const char* string) -- 2.39.2