mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
libs/libc/stdio: Optimize header file dependencies in *scanf.c file.
Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
@@ -23,8 +23,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include "libc.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
|
|||||||
@@ -22,21 +22,13 @@
|
|||||||
* Included Files
|
* 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 <nuttx/streams.h>
|
||||||
|
|
||||||
#include "libc.h"
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* 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) */
|
unsigned char set[32]; /* Bit field (256 / 8) */
|
||||||
#endif
|
#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 */
|
/* Parse the format, extracting values from the input buffer as needed */
|
||||||
|
|
||||||
assigncount = 0;
|
assigncount = 0;
|
||||||
@@ -302,15 +290,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
|
|
||||||
if (fmt_char(fmt) == '%')
|
if (fmt_char(fmt) == '%')
|
||||||
{
|
{
|
||||||
linfo("Specifier found\n");
|
|
||||||
|
|
||||||
/* Check for qualifiers on the conversion specifier */
|
/* Check for qualifiers on the conversion specifier */
|
||||||
|
|
||||||
fmt++;
|
fmt++;
|
||||||
for (; fmt_char(fmt); fmt++)
|
for (; fmt_char(fmt); fmt++)
|
||||||
{
|
{
|
||||||
linfo("Processing %c\n", fmt_char(fmt));
|
|
||||||
|
|
||||||
#ifdef CONFIG_LIBC_SCANSET
|
#ifdef CONFIG_LIBC_SCANSET
|
||||||
if (strchr("diboupxXcseEfFgGaAn[%", fmt_char(fmt)))
|
if (strchr("diboupxXcseEfFgGaAn[%", fmt_char(fmt)))
|
||||||
#else
|
#else
|
||||||
@@ -402,8 +386,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
|
|
||||||
if (fmt_char(fmt) == 's')
|
if (fmt_char(fmt) == 's')
|
||||||
{
|
{
|
||||||
linfo("Performing string conversion\n");
|
|
||||||
|
|
||||||
/* Get a pointer to the char * value. We need to do this even
|
/* 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
|
* of we have reached the end of the input data in order to
|
||||||
* update the 'ap' variable.
|
* 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) == '[')
|
if (fmt_char(fmt) == '[')
|
||||||
{
|
{
|
||||||
linfo("Performing scanset conversion\n");
|
|
||||||
|
|
||||||
fmt = findscanset(fmt, set); /* find scanset */
|
fmt = findscanset(fmt, set); /* find scanset */
|
||||||
|
|
||||||
/* Get a pointer to the char * value. We need to do this even
|
/* 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')
|
else if (fmt_char(fmt) == 'c')
|
||||||
{
|
{
|
||||||
linfo("Performing character conversion\n");
|
|
||||||
|
|
||||||
/* Get a pointer to the char * value. We need to do this even
|
/* 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
|
* if we have reached the end of the input data in order to
|
||||||
* update the 'ap' variable.
|
* update the 'ap' variable.
|
||||||
@@ -587,8 +565,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
{
|
{
|
||||||
bool sign;
|
bool sign;
|
||||||
|
|
||||||
linfo("Performing integer conversion\n");
|
|
||||||
|
|
||||||
/* Get a pointer to the integer value. We need to do this even
|
/* 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
|
* if we have reached the end of the input data in order to
|
||||||
* update the 'ap' variable.
|
* update the 'ap' variable.
|
||||||
@@ -860,8 +836,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
|
|
||||||
tmp[fwidth] = 0;
|
tmp[fwidth] = 0;
|
||||||
|
|
||||||
linfo("tmp[]=\"%s\"\n", tmp);
|
|
||||||
|
|
||||||
/* Perform the integer conversion */
|
/* Perform the integer conversion */
|
||||||
|
|
||||||
/* Preserve the errno value */
|
/* Preserve the errno value */
|
||||||
@@ -928,17 +902,14 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
switch (modifier)
|
switch (modifier)
|
||||||
{
|
{
|
||||||
case HH_MOD:
|
case HH_MOD:
|
||||||
linfo("Return %ld to %p\n", tmplong, pchar);
|
|
||||||
*pchar = (unsigned char)tmplong;
|
*pchar = (unsigned char)tmplong;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case H_MOD:
|
case H_MOD:
|
||||||
linfo("Return %ld to %p\n", tmplong, pshort);
|
|
||||||
*pshort = (unsigned short)tmplong;
|
*pshort = (unsigned short)tmplong;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_MOD:
|
case NO_MOD:
|
||||||
linfo("Return %ld to %p\n", tmplong, pint);
|
|
||||||
*pint = (unsigned int)tmplong;
|
*pint = (unsigned int)tmplong;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -946,14 +917,11 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
case L_MOD:
|
case L_MOD:
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
linfo("Return %ld to %p\n", tmplong, plong);
|
|
||||||
*plong = tmplong;
|
*plong = tmplong;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef CONFIG_HAVE_LONG_LONG
|
#ifdef CONFIG_HAVE_LONG_LONG
|
||||||
case LL_MOD:
|
case LL_MOD:
|
||||||
linfo("Return %lld to %p\n", tmplonglong,
|
|
||||||
plonglong);
|
|
||||||
*plonglong = tmplonglong;
|
*plonglong = tmplonglong;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -980,8 +948,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
FAR float *pf = NULL;
|
FAR float *pf = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
linfo("Performing floating point conversion\n");
|
|
||||||
|
|
||||||
/* Get a pointer to the double value. We need to do this even
|
/* 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
|
* if we have reached the end of the input data in order to
|
||||||
* upate the 'ap' variable.
|
* upate the 'ap' variable.
|
||||||
@@ -1108,8 +1074,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
|
|
||||||
tmp[fwidth] = 0;
|
tmp[fwidth] = 0;
|
||||||
|
|
||||||
linfo("tmp[]=\"%s\"\n", tmp);
|
|
||||||
|
|
||||||
/* Perform the floating point conversion */
|
/* Perform the floating point conversion */
|
||||||
|
|
||||||
/* Preserve the errno value */
|
/* 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 */
|
/* Return the double value */
|
||||||
|
|
||||||
linfo("Return %f to %p\n", dvalue, pd);
|
|
||||||
*pd = dvalue;
|
*pd = dvalue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1164,7 +1127,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
/* Return the float value */
|
/* Return the float value */
|
||||||
|
|
||||||
# ifdef CONFIG_HAVE_FLOAT
|
# ifdef CONFIG_HAVE_FLOAT
|
||||||
linfo("Return %f to %p\n", (double)fvalue, pf);
|
|
||||||
*pf = fvalue;
|
*pf = fvalue;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
@@ -1181,8 +1143,6 @@ static int vscanf_internal(FAR struct lib_instream_s *stream, FAR int *lastc,
|
|||||||
|
|
||||||
else if (fmt_char(fmt) == 'n')
|
else if (fmt_char(fmt) == 'n')
|
||||||
{
|
{
|
||||||
linfo("Performing character count\n");
|
|
||||||
|
|
||||||
if (!noassign)
|
if (!noassign)
|
||||||
{
|
{
|
||||||
size_t nchars = (size_t) (stream->nget - ngetstart);
|
size_t nchars = (size_t) (stream->nget - ngetstart);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "libc.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
|
|||||||
@@ -23,9 +23,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <nuttx/streams.h>
|
|
||||||
#include "libc.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
|
|||||||
@@ -22,14 +22,8 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <nuttx/streams.h>
|
#include <nuttx/streams.h>
|
||||||
|
|
||||||
#include "libc.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user