if (cbuf->size + l > cbuf->maxsize)
{
- Con_Printf(CON_WARN "Cbuf_AddText: input too large, %zuKB ought to be enough for anybody.\n", cbuf->maxsize / 1024);
+ Con_Printf(CON_WARN "Cbuf_AddText: input too large, %luKB ought to be enough for anybody.\n", (unsigned long)(cbuf->maxsize / 1024));
return;
}
if (cbuf->size + l > cbuf->maxsize)
{
- Con_Printf(CON_WARN "Cbuf_InsertText: input too large, %zuKB ought to be enough for anybody.\n", cbuf->maxsize / 1024);
+ Con_Printf(CON_WARN "Cbuf_InsertText: input too large, %luKB ought to be enough for anybody.\n", (unsigned long)(cbuf->maxsize / 1024));
return;
}
buffer[buffersize - 1] = '\0';
// we could be inside Con_Printf
if (result < 0)
- Sys_Printf("dpvsnprintf: output error, buffer size %zu\n", buffersize);
+ Sys_Printf("dpvsnprintf: output error, buffer size %lu\n", (unsigned long)buffersize);
else
- Sys_Printf("dpvsnprintf: truncated to %zu bytes: \"%s\"\n", buffersize - 1, buffer);
+ Sys_Printf("dpvsnprintf: truncated to %lu bytes: \"%s\"\n", (unsigned long)buffersize - 1, buffer);
return -1;
}
if (p)
return p - 1;
end[-1] = '\0';
- Con_Printf(CON_WARN "%s: src string unterminated or truncated to %zu bytes: \"%s\"\n", __func__, dst == end ? 0 : (end - dst) - 1, dst);
+ Con_Printf(CON_WARN "%s: src string unterminated or truncated to %lu bytes: \"%s\"\n", __func__, (unsigned long)(dst == end ? 0 : (end - dst) - 1), dst);
return end;
}
if (slen >= dsize)
{
slen = dsize - 1;
- Con_Printf(CON_WARN "%s: src string truncated to %zu bytes: \"%.*s\"\n", __func__, slen, (int)slen, src);
+ Con_Printf(CON_WARN "%s: src string truncated to %lu bytes: \"%.*s\"\n", __func__, (unsigned long)slen, (int)slen, src);
}
memcpy(dst, src, slen);
dst[slen] = '\0';
if (p)
return (p - 1) - dst;
dst[dsize - 1] = '\0';
- Con_Printf(CON_WARN "%s:%u: src string unterminated or truncated to %zu bytes: \"%s\"\n", func, line, dsize - 1, dst);
+ Con_Printf(CON_WARN "%s:%u: src string unterminated or truncated to %lu bytes: \"%s\"\n", func, line, (unsigned long)dsize - 1, dst);
return dsize - 1;
}
#undef vsnprintf
#define vsnprintf DP_STATIC_ASSERT(0, "vsnprintf is forbidden for portability reasons. Use dpvsnprintf instead.")
-// dpsnprintf and dpvsnprintf
-// return the number of printed characters, excluding the final '\0'
-// or return -1 if the buffer isn't big enough to contain the entire string.
-// buffer is ALWAYS null-terminated
+// documentation duplicated deliberately for the benefit of IDEs that support https://www.doxygen.nl/manual/docblocks.html
+/// Returns the number of printed characters, excluding the final '\0'
+/// or returns -1 if the buffer isn't big enough to contain the entire string.
+/// Buffer is ALWAYS null-terminated.
extern int dpsnprintf (char *buffer, size_t buffersize, const char *format, ...) DP_FUNC_PRINTF(3);
+/// Returns the number of printed characters, excluding the final '\0'
+/// or returns -1 if the buffer isn't big enough to contain the entire string.
+/// Buffer is ALWAYS null-terminated.
extern int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list args);
// A bunch of functions are forbidden for security reasons (and also to please MSVS 2005, for some of them)
out = p - 1;
else
{
- VM_Warning(prog, "%zu of %zu bytes available, will truncate %zu byte string \"%s\"\n", outend - out, outsize - 1, strlen(s), s);
+ VM_Warning(prog, "%lu of %lu bytes available, will truncate %lu byte string \"%s\"\n", (unsigned long)(outend - out), (unsigned long)outsize - 1, (unsigned long)strlen(s), s);
out = outend;
*out = '\0';
}
return 0;
size = slen + 1;
if (developer_insane.integer)
- Con_DPrintf("PRVM_SetTempString %s: cursize %i, size %zu\n", prog->name, prog->tempstringsbuf.cursize, size);
+ Con_DPrintf("PRVM_SetTempString %s: cursize %i, size %lu\n", prog->name, prog->tempstringsbuf.cursize, (unsigned long)size);
if ((size_t)prog->tempstringsbuf.maxsize < prog->tempstringsbuf.cursize + size)
{
sizebuf_t old = prog->tempstringsbuf;
if (prog->tempstringsbuf.cursize + size >= 1<<28)
- prog->error_cmd("PRVM_SetTempString %s: ran out of tempstring memory! (refusing to grow tempstring buffer over 256MB, cursize %i, size %zu)\n", prog->name, prog->tempstringsbuf.cursize, size);
+ prog->error_cmd("PRVM_SetTempString %s: ran out of tempstring memory! (refusing to grow tempstring buffer over 256MB, cursize %i, size %lu)\n", prog->name, prog->tempstringsbuf.cursize, (unsigned long)size);
prog->tempstringsbuf.maxsize = max(prog->tempstringsbuf.maxsize, 65536);
while ((size_t)prog->tempstringsbuf.maxsize < prog->tempstringsbuf.cursize + size)
prog->tempstringsbuf.maxsize *= 2;