Restore lib_sprintf(). It was removed because I thought was not used. But I was wrong; there is logic in drivers/syslog that depends on lib_sprintf().

This commits reverts a part of commit c271151d57.  That commit also removed lib_sscanf() which really is not needed.
This commit is contained in:
Gregory Nutt 2019-02-16 12:29:00 -06:00
parent 3131195d7a
commit 653ff2c34e
3 changed files with 77 additions and 3 deletions

View File

@ -442,6 +442,17 @@ int lib_noflush(FAR struct lib_outstream_s *stream);
int lib_snoflush(FAR struct lib_sostream_s *this);
/****************************************************************************
* Name: lib_sprintf
*
* Description:
* Stream-oriented implementation of sprintf. Used only by the SYSLOG.
*
****************************************************************************/
int lib_sprintf(FAR struct lib_outstream_s *obj,
FAR const IPTR char *fmt, ...);
/****************************************************************************
* Name: lib_vsprintf
*

View File

@ -1,7 +1,7 @@
############################################################################
# libs/libc/stdio/Make.defs
#
# Copyright (C) 2011-2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2014, 2019 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -37,8 +37,8 @@
# This first group of C files do not depend on having C streams.
CSRCS += lib_fileno.c lib_printf.c lib_sprintf.c lib_asprintf.c
CSRCS += lib_snprintf.c lib_vsprintf.c lib_vasprintf.c lib_vsnprintf.c
CSRCS += lib_dprintf.c lib_vdprintf.c
CSRCS += lib_snprintf.c lib_libsprintf.c lib_vsprintf.c lib_vasprintf.c
CSRCS += lib_vsnprintf.c lib_dprintf.c lib_vdprintf.c
CSRCS += lib_meminstream.c lib_memoutstream.c lib_memsistream.c
CSRCS += lib_memsostream.c lib_lowoutstream.c
CSRCS += lib_zeroinstream.c lib_nullinstream.c lib_nulloutstream.c

View File

@ -0,0 +1,63 @@
/****************************************************************************
* libs/libc/stdio/lib_libsprintf.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: lib_sprintf
****************************************************************************/
int lib_sprintf(FAR struct lib_outstream_s *obj, FAR const IPTR char *fmt,
...)
{
va_list ap;
int n;
/* Let lib_vsprintf do the real work */
va_start(ap, fmt);
n = lib_vsprintf(obj, fmt, ap);
va_end(ap);
return n;
}