diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-03-13 11:07:52 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-03-13 17:30:15 -0400 |
commit | 875f1327a47f78d783c3abc7f7acc3977dc286ec (patch) | |
tree | bd145a6a8d17b877f6a478ce6515cdf84c43a2e6 | |
parent | e4d1970abfd6206aa8780cb6cafd2efc46a2666f (diff) | |
download | minetest-875f1327a47f78d783c3abc7f7acc3977dc286ec.tar.gz minetest-875f1327a47f78d783c3abc7f7acc3977dc286ec.tar.bz2 minetest-875f1327a47f78d783c3abc7f7acc3977dc286ec.zip |
Use fixed-width format specifiers in serializeStructToString
-rw-r--r-- | src/util/serialize.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/serialize.cpp b/src/util/serialize.cpp index 58f569fb7..170daa0f8 100644 --- a/src/util/serialize.cpp +++ b/src/util/serialize.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "../exceptions.h" #include "../irrlichttypes.h" +#include <inttypes.h> // For PRIxN, cinttypes is C++11-only #include <sstream> #include <iomanip> #include <vector> @@ -416,19 +417,19 @@ bool serializeStructToString(std::string *outstr, if (width == 16) { bufpos += PADDING(bufpos, u16); nprinted = snprintf(sbuf + pos, sbuflen, - is_unsigned ? "%u, " : "%d, ", + is_unsigned ? "%" PRIu16 ", " : "%" PRIi16 ", ", *((u16 *)bufpos)); bufpos += sizeof(u16); } else if (width == 32) { bufpos += PADDING(bufpos, u32); nprinted = snprintf(sbuf + pos, sbuflen, - is_unsigned ? "%u, " : "%d, ", + is_unsigned ? "%" PRIu32 ", " : "%" PRIi32 ", ", *((u32 *)bufpos)); bufpos += sizeof(u32); } else if (width == 64) { bufpos += PADDING(bufpos, u64); nprinted = snprintf(sbuf + pos, sbuflen, - is_unsigned ? "%llu, " : "%lli, ", + is_unsigned ? "%" PRIu64 ", " : "%" PRIi64 ", ", *((u64 *)bufpos)); bufpos += sizeof(u64); } |