31 lines · c
1//===-- Internal implementation header of scanf -----------------*- 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/__support/OSUtil/io.h"10#include "src/__support/macros/config.h"11#include "src/stdio/scanf_core/reader.h"12 13namespace LIBC_NAMESPACE_DECL {14 15namespace scanf_core {16 17struct StdinReader : public Reader<StdinReader> {18 LIBC_INLINE char getc() {19 char buf[1];20 auto result = read_from_stdin(buf, sizeof(buf));21 if (result <= 0)22 return EOF;23 return buf[0];24 }25 LIBC_INLINE void ungetc(int) {}26};27 28} // namespace scanf_core29 30} // namespace LIBC_NAMESPACE_DECL31