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:
parent
e5f84dca39
commit
fd4db67b43
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user