add printing of null %s arguments as "(null)" in wide printf
authorRich Felker <dalias@aerifal.cx>
Sat, 13 Jun 2015 04:42:38 +0000 (04:42 +0000)
committerRich Felker <dalias@aerifal.cx>
Sat, 13 Jun 2015 04:42:38 +0000 (04:42 +0000)
this is undefined, but supported in our implementation of the normal
printf, so for consistency the wide variant should support it too.

src/stdio/vfwprintf.c

index 281f4e5..deff982 100644 (file)
@@ -296,6 +296,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
                case 'm':
                        arg.p = strerror(errno);
                case 's':
+                       if (!arg.p) arg.p = "(null)";
                        bs = arg.p;
                        if (p<0) p = INT_MAX;
                        for (i=l=0; l<p && (i=mbtowc(&wc, bs, MB_LEN_MAX))>0; bs+=i, l++);