[clang-tools-extra] [libc] Refactor scanf reader to match printf (PR #66023)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 22 11:09:44 PDT 2023


================
@@ -9,44 +9,61 @@
 #ifndef LLVM_LIBC_SRC_STDIO_SCANF_CORE_READER_H
 #define LLVM_LIBC_SRC_STDIO_SCANF_CORE_READER_H
 
-#include "src/stdio/scanf_core/file_reader.h"
-#include "src/stdio/scanf_core/string_reader.h"
+#include "src/__support/macros/attributes.h" // For LIBC_INLINE
 #include <stddef.h>
 
 namespace __llvm_libc {
 namespace scanf_core {
 
-enum class ReaderType { String, File };
+using StreamGetc = int (*)(void *);
+using StreamUngetc = void (*)(int, void *);
----------------
jhuber6 wrote:

Could we do this with templates instead? Then we'd presumably just specialize it for whether or not the user it `sscanf` or `fscanf` in the implementation.

https://github.com/llvm/llvm-project/pull/66023


More information about the cfe-commits mailing list