Commit 64c5ad58 authored by Jan Maria Matejka's avatar Jan Maria Matejka

Lib: recursive printf

Use like this:

void func(const char *msg, va_list args) {
  ...
  bvsnprintf(buf, len, "file %s, line %d: %V (foo %d, bar %d)", file, line, msg, &args, foo, bar);
  ...
}
parent 765f400f
Pipeline #39553 passed with stages
in 5 minutes and 44 seconds
......@@ -270,6 +270,17 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
*str++ = ' ';
continue;
case 'V': {
const char *vfmt = va_arg(args, const char *);
va_list *vargs = va_arg(args, va_list *);
int res = bvsnprintf(str, size, vfmt, *vargs);
if (res < 0)
return -1;
str += res;
size -= res;
continue;
}
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
......
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