libs/libc/stdio/lib_libvsprintf.c: Restore support for printing NULL string as "(null)". Legacy printf supported printing "(null)" in place for NULL string:

printf("null: %s\n", NULL); => null: (null).

This commit restores this functionality for new printf library.
This commit is contained in:
Jussi Kivilinna 2019-04-04 06:31:25 -06:00 committed by Gregory Nutt
parent e5f84dca39
commit fd4db67b43

View File

@ -136,6 +136,12 @@ struct arg
} value;
};
/****************************************************************************
* Private Constant Data
****************************************************************************/
static const char g_nullstring[] = "(null)";
/****************************************************************************
* Public Functions
****************************************************************************/
@ -847,6 +853,11 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
#else
pnt = va_arg(ap, FAR char *);
#endif
if (pnt == NULL)
{
pnt = g_nullstring;
}
size = strnlen(pnt, (flags & FL_PREC) ? prec : ~0);
str_lpad: