mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 03:06:10 +00:00
sscanf(): fix %*s%n
When using %*s, sscanf should honor conversion specifiers immediately following the %*s. For example, the following code should find the position of the end of the string "hello". int end; char buf[] = "hello world"; sscanf(buf, "%*s%n", &end); printf("%d\n", end); Ideally, sscanf would advance the fmt and str pointers the same as it would without the *, but the code for that is rather complicated and is not included in the patch. Signed-off-by: Andy Spencer <andy753421@gmail.com> Acked-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d41a4b515e
commit
8fccae2c95
1 changed files with 1 additions and 1 deletions
|
@ -1771,7 +1771,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
|
|||
* advance both strings to next white space
|
||||
*/
|
||||
if (*fmt == '*') {
|
||||
while (!isspace(*fmt) && *fmt)
|
||||
while (!isspace(*fmt) && *fmt != '%' && *fmt)
|
||||
fmt++;
|
||||
while (!isspace(*str) && *str)
|
||||
str++;
|
||||
|
|
Loading…
Reference in a new issue