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;
}
#ifdef WIN32
// memccpy() is standard in POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD, C23.
// Microsoft supports it, but apparently complains if we use it.
- #pragma warning(disable : 4996)
+ #undef memccpy
+ #define memccpy _memccpy
#endif
/** Chain-copies a string with truncation and efficiency (compared to strlcat()).
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;
}
*/
size_t dp__strlcat(char *dst, const char *src, size_t dsize, const char *func, unsigned line)
{
- char *p = (char *)memchr(dst, '\0', dsize) ?: dst;
- size_t offset = p - dst;
+ size_t offset;
+ char *p = (char *)memchr(dst, '\0', dsize);
+ if (!p)
+ p = dst;
+ offset = p - dst;
return dp__strlcpy(p, src, dsize - offset, func, line) + offset;
}