diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-22 13:49:53 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-22 13:49:53 +0200 |
commit | eea1beead9b981b48f0813283320ae318ee508f4 (patch) | |
tree | 10ebbd51ce13e38f22ef6feee079657b9f2821bf | |
parent | e64946fe51d57fea3547dfa4215277862b1115eb (diff) | |
download | px4-nuttx-eea1beead9b981b48f0813283320ae318ee508f4.tar.gz px4-nuttx-eea1beead9b981b48f0813283320ae318ee508f4.tar.bz2 px4-nuttx-eea1beead9b981b48f0813283320ae318ee508f4.zip |
Also consider negative values to be valid, and while we are at it add support for the full valid C99 number symbol range plus the binary numbers NuttX supports
-rw-r--r-- | nuttx/libc/stdio/lib_sscanf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/nuttx/libc/stdio/lib_sscanf.c b/nuttx/libc/stdio/lib_sscanf.c index e7585993b..5c99ee47b 100644 --- a/nuttx/libc/stdio/lib_sscanf.c +++ b/nuttx/libc/stdio/lib_sscanf.c @@ -461,7 +461,12 @@ 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] == '-' || tmp[c_count] == '+')) + if ((tmp[c_count] < '0' || tmp[c_count] > '9') && !(tmp[c_count] == '-' || + tmp[c_count] == '+' || + tmp[c_count] == 'x' || + tmp[c_count] == 'X' || + tmp[c_count] == 'b' || + tmp[c_count] == 'B')) { lvdbg("data invalid on char: %c (0x%02x), %d\n", tmp[c_count], tmp[c_count], c_count); tmp[c_count] = '\0'; @@ -578,7 +583,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap) { if ((tmp[c_count] < '0' || tmp[c_count] > '9') && !(tmp[c_count] == '.' || tmp[c_count] == '-' || - tmp[c_count] == '+')) + tmp[c_count] == '+' || + tmp[c_count] == 'x' || + tmp[c_count] == 'X')) { tmp[c_count] = '\0'; width = c_count; |