libc: export lib_sprintf_internal function

This function does not take numbered arguments in printf

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2023-06-25 12:23:01 +08:00 committed by Petro Karashchenko
parent 0052ff2bd8
commit fe9251b546
2 changed files with 68 additions and 21 deletions

View File

@ -689,6 +689,31 @@ int lib_snoflush(FAR struct lib_sostream_s *this);
int lib_sprintf(FAR struct lib_outstream_s *obj,
FAR const IPTR char *fmt, ...) printf_like(2, 3);
/****************************************************************************
* Name: lib_sprintf_internal
*
* Description:
* This function does not take numbered arguments in printf.
* Equivalent to lib_sprintf when CONFIG_LIBC_NUMBERED_ARGS is not enabled
*
****************************************************************************/
int lib_sprintf_internal(FAR struct lib_outstream_s *obj,
FAR const IPTR char *fmt, ...) printf_like(2, 3);
/****************************************************************************
* Name: lib_vsprintf_internal
*
* Description:
* This function does not take numbered arguments in printf.
* Equivalent to lib_sprintf when CONFIG_LIBC_NUMBERED_ARGS is not enabled
*
****************************************************************************/
int lib_vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR const IPTR char *fmt, va_list ap)
printf_like(2, 0);
/****************************************************************************
* Name: lib_vsprintf
*

View File

@ -155,23 +155,6 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
* Private Functions
****************************************************************************/
#ifdef CONFIG_ALLSYMS
static int sprintf_internal(FAR struct lib_outstream_s *stream,
FAR const IPTR char *fmt, ...)
{
va_list ap;
int n;
/* Then let vsprintf_internal do the real work */
va_start(ap, fmt);
n = vsprintf_internal(stream, NULL, 0, fmt, ap);
va_end(ap);
return n;
}
#endif
static int vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR struct arg_s *arglist, int numargs,
FAR const IPTR char *fmt, va_list ap)
@ -1167,10 +1150,10 @@ str_lpad:
if (c == 'S')
{
total_len +=
sprintf_internal(stream,
"+%#tx/%#zx",
addr - symbol->sym_value,
symbolsize);
lib_sprintf_internal(stream,
"+%#tx/%#zx",
addr - symbol->sym_value,
symbolsize);
}
continue;
@ -1382,3 +1365,42 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream,
return vsprintf_internal(stream, NULL, 0, fmt, ap);
#endif
}
/****************************************************************************
* Name: lib_sprintf_internal
*
* Description:
* This function does not take numbered arguments in printf.
* Equivalent to lib_sprintf when CONFIG_LIBC_NUMBERED_ARGS is not enabled
*
****************************************************************************/
int lib_sprintf_internal(FAR struct lib_outstream_s *stream,
FAR const IPTR char *fmt, ...)
{
va_list ap;
int n;
/* Then let vsprintf_internal do the real work */
va_start(ap, fmt);
n = vsprintf_internal(stream, NULL, 0, fmt, ap);
va_end(ap);
return n;
}
/****************************************************************************
* Name: lib_vsprintf_internal
*
* Description:
* This function does not take numbered arguments in printf.
* Equivalent to lib_sprintf when CONFIG_LIBC_NUMBERED_ARGS is not enabled
*
****************************************************************************/
int lib_vsprintf_internal(FAR struct lib_outstream_s *stream,
FAR const IPTR char *fmt, va_list ap)
{
return vsprintf_internal(stream, NULL, 0, fmt, ap);
}