summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-09-22 13:42:35 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-09-22 13:42:35 +0200
commite64946fe51d57fea3547dfa4215277862b1115eb (patch)
treea041fa002c5dc135458938eb29196a7b607ecae1
parent2656cb4a6bdaa65d3765012ead38270336e851b4 (diff)
downloadnuttx-e64946fe51d57fea3547dfa4215277862b1115eb.tar.gz
nuttx-e64946fe51d57fea3547dfa4215277862b1115eb.tar.bz2
nuttx-e64946fe51d57fea3547dfa4215277862b1115eb.zip
Also consider negative values to be valid
-rw-r--r--nuttx/libc/stdio/lib_sscanf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/nuttx/libc/stdio/lib_sscanf.c b/nuttx/libc/stdio/lib_sscanf.c
index a6982d190..e7585993b 100644
--- a/nuttx/libc/stdio/lib_sscanf.c
+++ b/nuttx/libc/stdio/lib_sscanf.c
@@ -461,8 +461,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
int c_count;
for (c_count = 0; c_count < width; c_count++)
{
- if (tmp[c_count] < '0' || tmp[c_count] > '9')
+ if ((tmp[c_count] < '0' || tmp[c_count] > '9') && !(tmp[c_count] == '-' || tmp[c_count] == '+'))
{
+ lvdbg("data invalid on char: %c (0x%02x), %d\n", tmp[c_count], tmp[c_count], c_count);
tmp[c_count] = '\0';
width = c_count;
data_invalid = true;
@@ -575,7 +576,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
int c_count;
for (c_count = 0; c_count < width; c_count++)
{
- if ((tmp[c_count] < '0' || tmp[c_count] > '9') && tmp[c_count] != '.')
+ if ((tmp[c_count] < '0' || tmp[c_count] > '9') && !(tmp[c_count] == '.' ||
+ tmp[c_count] == '-' ||
+ tmp[c_count] == '+'))
{
tmp[c_count] = '\0';
width = c_count;