libc/wchar: Implement vswprintf
Implement vswprintf and let swprintf based on it. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
parent
6b35a49f6e
commit
5606e77ee0
@ -35,14 +35,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* swprintf
|
* vswprintf
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int swprintf(FAR wchar_t *buf, size_t maxlen, FAR const wchar_t *fmt, ...)
|
int vswprintf(FAR wchar_t *buf, size_t maxlen, FAR const wchar_t *fmt,
|
||||||
|
va_list ap)
|
||||||
{
|
{
|
||||||
struct lib_memoutstream_s memoutstream;
|
struct lib_memoutstream_s memoutstream;
|
||||||
va_list ap;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
/* Initialize a memory stream to write to the buffer */
|
/* Initialize a memory stream to write to the buffer */
|
||||||
|
|
||||||
@ -51,9 +50,23 @@ int swprintf(FAR wchar_t *buf, size_t maxlen, FAR const wchar_t *fmt, ...)
|
|||||||
|
|
||||||
/* Then let lib_vsprintf do the real work */
|
/* Then let lib_vsprintf do the real work */
|
||||||
|
|
||||||
|
return lib_vsprintf((FAR struct lib_outstream_s *)&memoutstream.public,
|
||||||
|
(FAR const char *)fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* swprintf
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int swprintf(FAR wchar_t *buf, size_t maxlen, FAR const wchar_t *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Then let vswprintf do the real work */
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
n = lib_vsprintf((FAR struct lib_outstream_s *)&memoutstream.public,
|
n = vswprintf(buf, maxlen, fmt, ap);
|
||||||
(FAR const char *)fmt, ap);
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
Loading…
Reference in New Issue
Block a user