mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Use fixed-width format specifiers in serializeStructToString
This commit is contained in:
parent
e4d1970abf
commit
875f1327a4
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "../exceptions.h"
|
#include "../exceptions.h"
|
||||||
#include "../irrlichttypes.h"
|
#include "../irrlichttypes.h"
|
||||||
|
|
||||||
|
#include <inttypes.h> // For PRIxN, cinttypes is C++11-only
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -416,19 +417,19 @@ bool serializeStructToString(std::string *outstr,
|
|||||||
if (width == 16) {
|
if (width == 16) {
|
||||||
bufpos += PADDING(bufpos, u16);
|
bufpos += PADDING(bufpos, u16);
|
||||||
nprinted = snprintf(sbuf + pos, sbuflen,
|
nprinted = snprintf(sbuf + pos, sbuflen,
|
||||||
is_unsigned ? "%u, " : "%d, ",
|
is_unsigned ? "%" PRIu16 ", " : "%" PRIi16 ", ",
|
||||||
*((u16 *)bufpos));
|
*((u16 *)bufpos));
|
||||||
bufpos += sizeof(u16);
|
bufpos += sizeof(u16);
|
||||||
} else if (width == 32) {
|
} else if (width == 32) {
|
||||||
bufpos += PADDING(bufpos, u32);
|
bufpos += PADDING(bufpos, u32);
|
||||||
nprinted = snprintf(sbuf + pos, sbuflen,
|
nprinted = snprintf(sbuf + pos, sbuflen,
|
||||||
is_unsigned ? "%u, " : "%d, ",
|
is_unsigned ? "%" PRIu32 ", " : "%" PRIi32 ", ",
|
||||||
*((u32 *)bufpos));
|
*((u32 *)bufpos));
|
||||||
bufpos += sizeof(u32);
|
bufpos += sizeof(u32);
|
||||||
} else if (width == 64) {
|
} else if (width == 64) {
|
||||||
bufpos += PADDING(bufpos, u64);
|
bufpos += PADDING(bufpos, u64);
|
||||||
nprinted = snprintf(sbuf + pos, sbuflen,
|
nprinted = snprintf(sbuf + pos, sbuflen,
|
||||||
is_unsigned ? "%llu, " : "%lli, ",
|
is_unsigned ? "%" PRIu64 ", " : "%" PRIi64 ", ",
|
||||||
*((u64 *)bufpos));
|
*((u64 *)bufpos));
|
||||||
bufpos += sizeof(u64);
|
bufpos += sizeof(u64);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user