diff options
-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; |