libs/libc/stdio: Optimize header file dependencies in *scanf.c file.

Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
likun17 2024-05-31 14:58:48 +08:00 committed by Xiang Xiao
parent 47eec633a0
commit b8835be6c5
5 changed files with 5 additions and 57 deletions

View file

@ -23,8 +23,6 @@
****************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include "libc.h"
/****************************************************************************
* Public Functions

View file

@ -22,21 +22,13 @@
* Included Files
****************************************************************************/
#include <nuttx/compiler.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/compiler.h>
#include <nuttx/streams.h>
#include "libc.h"
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
/****************************************************************************
* Pre-processor Definitions
@ -251,10 +243,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
unsigned char set[32]; /* Bit field (256 / 8) */
#endif
/* keep this for future reference:
* linfo("buf=\"%s\" fmt=\"%s\"\n", buf, fmt);
*/
/* Parse the format, extracting values from the input buffer as needed */
assigncount = 0;
@ -302,15 +290,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
if (fmt_char(fmt) == '%')
{
linfo("Specifier found\n");
/* Check for qualifiers on the conversion specifier */
fmt++;
for (; fmt_char(fmt); fmt++)
{
linfo("Processing %c\n", fmt_char(fmt));
#ifdef CONFIG_LIBC_SCANSET
if (strchr("diboupxXcseEfFgGaAn[%", fmt_char(fmt)))
#else
@ -402,8 +386,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
if (fmt_char(fmt) == 's')
{
linfo("Performing string conversion\n");
/* Get a pointer to the char * value. We need to do this even
* of we have reached the end of the input data in order to
* update the 'ap' variable.
@ -462,8 +444,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
if (fmt_char(fmt) == '[')
{
linfo("Performing scanset conversion\n");
fmt = findscanset(fmt, set); /* find scanset */
/* Get a pointer to the char * value. We need to do this even
@ -523,8 +503,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
else if (fmt_char(fmt) == 'c')
{
linfo("Performing character conversion\n");
/* Get a pointer to the char * value. We need to do this even
* if we have reached the end of the input data in order to
* update the 'ap' variable.
@ -587,8 +565,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
{
bool sign;
linfo("Performing integer conversion\n");
/* Get a pointer to the integer value. We need to do this even
* if we have reached the end of the input data in order to
* update the 'ap' variable.
@ -860,8 +836,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
tmp[fwidth] = 0;
linfo("tmp[]=\"%s\"\n", tmp);
/* Perform the integer conversion */
/* Preserve the errno value */
@ -928,17 +902,14 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
switch (modifier)
{
case HH_MOD:
linfo("Return %ld to %p\n", tmplong, pchar);
*pchar = (unsigned char)tmplong;
break;
case H_MOD:
linfo("Return %ld to %p\n", tmplong, pshort);
*pshort = (unsigned short)tmplong;
break;
case NO_MOD:
linfo("Return %ld to %p\n", tmplong, pint);
*pint = (unsigned int)tmplong;
break;
@ -946,14 +917,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
case L_MOD:
#endif
default:
linfo("Return %ld to %p\n", tmplong, plong);
*plong = tmplong;
break;
#ifdef CONFIG_HAVE_LONG_LONG
case LL_MOD:
linfo("Return %lld to %p\n", tmplonglong,
plonglong);
*plonglong = tmplonglong;
break;
#endif
@ -980,8 +948,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
FAR float *pf = NULL;
#endif
linfo("Performing floating point conversion\n");
/* Get a pointer to the double value. We need to do this even
* if we have reached the end of the input data in order to
* upate the 'ap' variable.
@ -1108,8 +1074,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
tmp[fwidth] = 0;
linfo("tmp[]=\"%s\"\n", tmp);
/* Perform the floating point conversion */
/* Preserve the errno value */
@ -1155,7 +1119,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
{
/* Return the double value */
linfo("Return %f to %p\n", dvalue, pd);
*pd = dvalue;
}
else
@ -1164,7 +1127,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
/* Return the float value */
# ifdef CONFIG_HAVE_FLOAT
linfo("Return %f to %p\n", (double)fvalue, pf);
*pf = fvalue;
# endif
}
@ -1181,8 +1143,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
else if (fmt_char(fmt) == 'n')
{
linfo("Performing character count\n");
if (!noassign)
{
size_t nchars = (size_t) (stream->nget - ngetstart);

View file

@ -23,7 +23,6 @@
****************************************************************************/
#include <stdio.h>
#include "libc.h"
/****************************************************************************
* Public Functions

View file

@ -23,9 +23,6 @@
****************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include <nuttx/streams.h>
#include "libc.h"
/****************************************************************************
* Public Functions

View file

@ -22,14 +22,8 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <nuttx/streams.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/