diff options
author | px4dev <px4@purgatory.org> | 2013-03-20 23:05:19 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-03-20 23:05:19 -0700 |
commit | db91dffb23cae1e8aa6c3945aa32b9d2e4ecd6a0 (patch) | |
tree | 0c6e8e86891285c45f7a60d857929a2a5e963599 /nuttx/libc/stdio/lib_sscanf.c | |
parent | f7b14b2e23113093d1f76565041b91f22be79246 (diff) | |
parent | b7d65bf8fc65b2fd7c98d46d60fb24fb937baa94 (diff) | |
download | px4-firmware-db91dffb23cae1e8aa6c3945aa32b9d2e4ecd6a0.tar.gz px4-firmware-db91dffb23cae1e8aa6c3945aa32b9d2e4ecd6a0.tar.bz2 px4-firmware-db91dffb23cae1e8aa6c3945aa32b9d2e4ecd6a0.zip |
Merge branch 'master' into export-build
Diffstat (limited to 'nuttx/libc/stdio/lib_sscanf.c')
-rw-r--r-- | nuttx/libc/stdio/lib_sscanf.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/nuttx/libc/stdio/lib_sscanf.c b/nuttx/libc/stdio/lib_sscanf.c index 77a6cf212..0092fbec2 100644 --- a/nuttx/libc/stdio/lib_sscanf.c +++ b/nuttx/libc/stdio/lib_sscanf.c @@ -197,7 +197,7 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap) noassign = false; lflag = false; - while (*fmt && *buf) + while (*fmt) { /* Skip over white space */ @@ -242,6 +242,33 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap) fmt--; } } + + /* Process %n: Character count */ + + if (*fmt == 'n') + { + lvdbg("vsscanf: Performing character count\n"); + + if (!noassign) + { + size_t nchars = (size_t)(buf - bufstart); + + if (lflag) + { + long *plong = va_arg(ap, long*); + *plong = (long)nchars; + } + else + { + int *pint = va_arg(ap, int*); + *pint = (int)nchars; + } + } + } else { + + /* Check for valid data in input string */ + if (!(*buf)) + break; /* Process %s: String conversion */ @@ -445,28 +472,7 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap) #endif } - /* Process %n: Character count */ - - else if (*fmt == 'n') - { - lvdbg("vsscanf: Performing character count\n"); - - if (!noassign) - { - size_t nchars = (size_t)(buf - bufstart); - - if (lflag) - { - long *plong = va_arg(ap, long*); - *plong = (long)nchars; - } - else - { - int *pint = va_arg(ap, int*); - *pint = (int)nchars; - } - } - } + } /* Note %n does not count as a conversion */ |