mirror of
https://github.com/fluencelabs/musl
synced 2025-07-04 09:02:02 +00:00
advantages over the old code: - correct results for floating point (old code was bogus) - wide/regular scanf separated so scanf does not pull in wide code - well-defined behavior on integers that overflow dest type - support for %[a-b] ranges with %[ (impl-defined by widely used) - no intermediate conversion of fmt string to wide string - cleaner, easier to share code with strto* functions - better standards conformance for corner cases the old code remains in the source tree, as the wide versions of the scanf-family functions are still using it. it will be removed when no longer needed.
16 lines
306 B
C
16 lines
306 B
C
#include "stdio_impl.h"
|
|
|
|
static size_t do_read(FILE *f, unsigned char *buf, size_t len)
|
|
{
|
|
return __string_read(f, buf, len);
|
|
}
|
|
|
|
int vsscanf(const char *s, const char *fmt, va_list ap)
|
|
{
|
|
FILE f = {
|
|
.buf = (void *)s, .cookie = (void *)s,
|
|
.read = do_read, .lock = -1
|
|
};
|
|
return vfscanf(&f, fmt, ap);
|
|
}
|