libs/libc/stdio: Remove unused, non-standard functions lib_sscanf() and lib_sprintf().

This commit is contained in:
Gregory Nutt
2019-02-15 18:01:39 -06:00
parent 928108036c
commit c271151d57
5 changed files with 46 additions and 69 deletions
+9 -15
View File
@@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* include/nuttx/streams.h * include/nuttx/streams.h
* *
* Copyright (C) 2009, 2011-2012, 2014-2016 Gregory Nutt. All rights * Copyright (C) 2009, 2011-2012, 2014-2016, 2019 Gregory Nutt. All
* reserved. * rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -44,10 +44,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdio.h> #include <stdio.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
@@ -447,29 +443,27 @@ int lib_noflush(FAR struct lib_outstream_s *stream);
int lib_snoflush(FAR struct lib_sostream_s *this); int lib_snoflush(FAR struct lib_sostream_s *this);
/**************************************************************************** /****************************************************************************
* Name: lib_sprintf and lib_vsprintf * Name: lib_vsprintf
* *
* Description: * Description:
* Stream-oriented versions of sprintf and vsprintf. * Stream-oriented implementation that underlies printf family: printf,
* fprint, sprint, etc.
* *
****************************************************************************/ ****************************************************************************/
int lib_sprintf(FAR struct lib_outstream_s *obj,
FAR const IPTR char *fmt, ...);
int lib_vsprintf(FAR struct lib_outstream_s *obj, int lib_vsprintf(FAR struct lib_outstream_s *obj,
FAR const IPTR char *src, va_list ap); FAR const IPTR char *src, va_list ap);
/**************************************************************************** /****************************************************************************
* Name: lib_sscanf and lib_vsscanf * Name: lib_vsscanf
* *
* Description: * Description:
* Stream-oriented versions of sscanf and vsscanf. * Stream-oriented implementation that underlies scanf family: fscanf,
* vfscanf, sscanf, and vsscanf
* *
****************************************************************************/ ****************************************************************************/
int lib_sscanf(FAR struct lib_instream_s *obj, int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
FAR const IPTR char *fmt, ...);
int lib_vsscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
FAR const IPTR char *src, va_list ap); FAR const IPTR char *src, va_list ap);
#undef EXTERN #undef EXTERN
+8 -12
View File
@@ -34,16 +34,15 @@
############################################################################ ############################################################################
# Add the stdio C files to the build # Add the stdio C files to the build
# This first group of C files do not depend on having file descriptors or # This first group of C files do not depend on having C streams.
# C streams.
CSRCS += lib_fileno.c lib_printf.c lib_sprintf.c lib_asprintf.c CSRCS += lib_fileno.c lib_printf.c lib_sprintf.c lib_asprintf.c
CSRCS += lib_snprintf.c lib_libsprintf.c lib_vsprintf.c lib_vasprintf.c CSRCS += lib_snprintf.c lib_vsprintf.c lib_vasprintf.c lib_vsnprintf.c
CSRCS += lib_vsnprintf.c lib_dprintf.c lib_vdprintf.c CSRCS += lib_dprintf.c lib_vdprintf.c
CSRCS += lib_meminstream.c lib_memoutstream.c lib_memsistream.c CSRCS += lib_meminstream.c lib_memoutstream.c lib_memsistream.c
CSRCS += lib_memsostream.c lib_lowoutstream.c CSRCS += lib_memsostream.c lib_lowoutstream.c
CSRCS += lib_zeroinstream.c lib_nullinstream.c lib_nulloutstream.c CSRCS += lib_zeroinstream.c lib_nullinstream.c lib_nulloutstream.c
CSRCS += lib_sscanf.c lib_vsscanf.c lib_libsscanf.c lib_libnoflush.c CSRCS += lib_sscanf.c lib_vsscanf.c lib_libvscanf.c lib_libnoflush.c
CSRCS += lib_libsnoflush.c CSRCS += lib_libsnoflush.c
ifeq ($(CONFIG_NANO_PRINTF),y) ifeq ($(CONFIG_NANO_PRINTF),y)
@@ -62,12 +61,7 @@ CSRCS += lib_libvsprintf.c
endif endif
# The remaining sources files depend upon file descriptors # The remaining sources files depend upon C streams
CSRCS += lib_rawinstream.c lib_rawoutstream.c lib_rawsistream.c
CSRCS += lib_rawsostream.c lib_remove.c
# And these depend upon both file descriptors and C streams
ifneq ($(CONFIG_NFILE_STREAMS),0) ifneq ($(CONFIG_NFILE_STREAMS),0)
@@ -79,7 +73,9 @@ CSRCS += lib_rdflush.c lib_wrflush.c lib_fputc.c lib_puts.c lib_fputs.c
CSRCS += lib_ungetc.c lib_vprintf.c lib_fprintf.c lib_vfprintf.c CSRCS += lib_ungetc.c lib_vprintf.c lib_fprintf.c lib_vfprintf.c
CSRCS += lib_stdinstream.c lib_stdoutstream.c lib_stdsistream.c CSRCS += lib_stdinstream.c lib_stdoutstream.c lib_stdsistream.c
CSRCS += lib_stdsostream.c lib_perror.c lib_feof.c lib_ferror.c CSRCS += lib_stdsostream.c lib_perror.c lib_feof.c lib_ferror.c
CSRCS += lib_clearerr.c lib_scanf.c lib_fscanf.c lib_vfscanf.c CSRCS += lib_rawinstream.c lib_rawoutstream.c lib_rawsistream.c
CSRCS += lib_rawsostream.c lib_remove.c lib_clearerr.c lib_scanf.c
CSRCS += lib_fscanf.c lib_vfscanf.c
endif endif
@@ -200,33 +200,14 @@ doexit:
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: lib_sscanf * Name: lib_vscanf
*
* Description:
* Stream-oriented version of sscanf.
*
****************************************************************************/
int lib_sscanf(FAR struct lib_instream_s *obj, FAR const IPTR char *fmt, ...)
{
va_list ap;
int count;
va_start(ap, fmt);
count = lib_vsscanf(obj, NULL, fmt, ap);
va_end(ap);
return count;
}
/****************************************************************************
* Name: lib_vsscanf
* *
* Description: * Description:
* Stream-oriented version of vsscanf. * Stream-oriented version of vsscanf.
* *
****************************************************************************/ ****************************************************************************/
int lib_vsscanf(FAR struct lib_instream_s *obj, FAR int *lastc, int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
FAR const IPTR char *fmt, va_list ap) FAR const IPTR char *fmt, va_list ap)
{ {
int c; int c;
+4 -4
View File
@@ -58,20 +58,20 @@ int vfscanf(FAR FILE *stream, FAR const IPTR char *fmt, va_list ap)
if (stream) if (stream)
{ {
/* Wrap the stream in a stream object and let lib_vsscanf do the work. */ /* Wrap the stream in a stream object and let lib_vscanf do the work. */
lib_stdinstream(&stdinstream, stream); lib_stdinstream(&stdinstream, stream);
/* Hold the stream semaphore throughout the lib_vsscanf call so that /* Hold the stream semaphore throughout the lib_vscanf call so that
* this thread can get its entire message out before being pre-empted by * this thread can get its entire message out before being pre-empted by
* the next thread. * the next thread.
*/ */
lib_take_semaphore(stream); lib_take_semaphore(stream);
n = lib_vsscanf(&stdinstream.public, &lastc, fmt, ap); n = lib_vscanf(&stdinstream.public, &lastc, fmt, ap);
/* The lib_vsscanf function reads always one character more, this /* The lib_vscanf function reads always one character more, this
* character needs to be written back. * character needs to be written back.
*/ */
@@ -1,8 +1,8 @@
/**************************************************************************** /****************************************************************************
* libs/libc/stdio/lib_libsprintf.c * libs/libc/stdio/lib_vscanf.c
* *
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@gnutt.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -37,27 +37,33 @@
* Included Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h> #include <stdio.h>
#include <semaphore.h>
#include <nuttx/streams.h>
#include "libc.h" #include "libc.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap)
* Name: lib_sprintf
****************************************************************************/
int lib_sprintf(FAR struct lib_outstream_s *obj, FAR const IPTR char *fmt,
...)
{ {
va_list ap; struct lib_meminstream_s meminstream;
int n; int n;
/* Let lib_vsprintf do the real work */ /* Initialize a memory stream to freadm from the buffer */
va_start(ap, fmt); lib_meminstream((FAR struct lib_meminstream_s *)&meminstream, buf,
n = lib_vsprintf(obj, fmt, ap); LIB_BUFLEN_UNKNOWN);
va_end(ap);
/* Then let lib_vscanf do the real work */
n = lib_vscanf((FAR struct lib_instream_s *)&meminstream.public, NULL,
fmt, ap);
return n; return n;
} }