Commit fca416b1 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Allow %z[ui] in logging format strings

parent 308e7313
...@@ -473,6 +473,9 @@ static void __vsnprintf(char *str, size_t size, const char *format, va_list ap) ...@@ -473,6 +473,9 @@ static void __vsnprintf(char *str, size_t size, const char *format, va_list ap)
case 'l': case 'l':
block_size++; block_size++;
break; break;
case 'z':
block_size = 'z';
break;
case '.': case '.':
// just ignore '.'. If somebody cares: fix it. // just ignore '.'. If somebody cares: fix it.
break; break;
...@@ -523,6 +526,13 @@ static void __vsnprintf(char *str, size_t size, const char *format, va_list ap) ...@@ -523,6 +526,13 @@ static void __vsnprintf(char *str, size_t size, const char *format, va_list ap)
else else
snprintf(buf, sizeof(buf), "%lli", (long long int)va_arg(ap, long long int)); snprintf(buf, sizeof(buf), "%lli", (long long int)va_arg(ap, long long int));
break; break;
case 'z':
/* We do not use 'z' type of snprintf() here as it is not safe to use on a few outdated platforms. */
if (*format == 'u')
snprintf(buf, sizeof(buf), "%llu", (unsigned long long int)va_arg(ap, size_t));
else
snprintf(buf, sizeof(buf), "%lli", (long long int)va_arg(ap, ssize_t));
break;
default: default:
snprintf(buf, sizeof(buf), "<<<invalid>>>"); snprintf(buf, sizeof(buf), "<<<invalid>>>");
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment