diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-22 13:42:35 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-22 13:42:35 +0200 |
commit | e64946fe51d57fea3547dfa4215277862b1115eb (patch) | |
tree | a041fa002c5dc135458938eb29196a7b607ecae1 | |
parent | 2656cb4a6bdaa65d3765012ead38270336e851b4 (diff) | |
download | nuttx-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.c | 7 |
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; |