Add parameter to strecpy to log truncation at debug level 1 instead of 0

desync-debugging
Jonathan G Rennison 9 years ago
parent 227ac91741
commit 8722445e7f

@ -107,9 +107,10 @@ char *strecat(char *dst, const char *src, const char *last)
* @param dst The destination buffer
* @param src The buffer containing the string to copy
* @param last The pointer to the last element of the destination buffer
* @param quiet_mode If set to true, emitted warning for truncating the input string is emitted at level 1 instead of 0
* @return The pointer to the terminating null-character in the destination buffer
*/
char *strecpy(char *dst, const char *src, const char *last)
char *strecpy(char *dst, const char *src, const char *last, bool quiet_mode)
{
assert(dst <= last);
while (dst != last && *src != '\0') {
@ -121,7 +122,7 @@ char *strecpy(char *dst, const char *src, const char *last)
#if defined(STRGEN) || defined(SETTINGSGEN)
error("String too long for destination buffer");
#else /* STRGEN || SETTINGSGEN */
DEBUG(misc, 0, "String too long for destination buffer");
DEBUG(misc, quiet_mode ? 1 : 0, "String too long for destination buffer");
#endif /* STRGEN || SETTINGSGEN */
}
return dst;

@ -31,7 +31,7 @@
#include "string_type.h"
char *strecat(char *dst, const char *src, const char *last);
char *strecpy(char *dst, const char *src, const char *last);
char *strecpy(char *dst, const char *src, const char *last, bool quiet_mode = false);
char *stredup(const char *src, const char *last = nullptr);
int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FORMAT(3, 4);

Loading…
Cancel
Save