options/ansi: implement vsscanf
@@ -697,23 +697,11 @@ int sprintf(char *__restrict buffer, const char *__restrict format, ...) {
return result;
}
int sscanf(const char *__restrict buffer, const char *__restrict format, ...) {
- class {
- public:
- char look_ahead() {
- return *buffer;
- }
-
- char consume() {
- num_consumed++;
- return *buffer++;
- }
-
- const char *buffer;
- int num_consumed;
- } handler = {buffer};
va_list args;
va_start(args, format);
- int result = do_scanf(handler, format, args);
+
+ int result = vsscanf(buffer, format, args);
+
va_end(args);
return result;
}
@@ -791,8 +779,23 @@ int vsprintf(char *__restrict buffer, const char *__restrict format, __gnuc_va_l
return p.count;
}
int vsscanf(const char *__restrict buffer, const char *__restrict format, __gnuc_va_list args) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
+ struct {
+ char look_ahead() {
+ return *buffer;
+ }
+
+ char consume() {
+ num_consumed++;
+ return *buffer++;
+ }
+
+ const char *buffer;
+ int num_consumed;
+ } handler = {buffer};
+
+ int result = do_scanf(handler, format, args);
+
+ return result;
}
int fwprintf(FILE *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY
