brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 249f8fd Raw
37 lines · cpp
1//===-- Implementation of vscanf --------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/stdio/vscanf.h"10 11#include "hdr/stdio_macros.h"12#include "src/__support/OSUtil/io.h"13#include "src/__support/arg_list.h"14#include "src/__support/macros/config.h"15#include "src/stdio/baremetal/scanf_internal.h"16#include "src/stdio/scanf_core/scanf_main.h"17 18#include <stdarg.h>19 20namespace LIBC_NAMESPACE_DECL {21 22LLVM_LIBC_FUNCTION(int, vscanf,23                   (const char *__restrict format, va_list vlist)) {24  internal::ArgList args(vlist); // This holder class allows for easier copying25                                 // and pointer semantics, as well as handling26                                 // destruction automatically.27  va_end(vlist);28 29  scanf_core::StdinReader reader;30  int retval = scanf_core::scanf_main(&reader, format, args);31  // This is done to avoid including stdio.h in the internals. On most systems32  // EOF is -1, so this will be transformed into just "return retval".33  return (retval == -1) ? EOF : retval;34}35 36} // namespace LIBC_NAMESPACE_DECL37