diff --git a/include/nuttx/streams.h b/include/nuttx/streams.h index 214d61d815..3e11371c3c 100644 --- a/include/nuttx/streams.h +++ b/include/nuttx/streams.h @@ -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 * diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index 06c9532b32..2f13334f5c 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -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); +}