Issue 115394
Summary [libc] Clean up unnecessary function pointers in scanf
Labels good first issue, libc
Assignees
Reporter michaelrj-google
    The scanf reader is the abstraction that scanf uses to read from either a file or a string, similar to printf's writer. Unlike printf, however, there are only two variants of scanf: `fscanf` and `sscanf` (just `scanf` is the same as `fscanf(stdin, ...)`). This means that the `stream_getc` and `stream_ungetc` functions don't need to be pointers, they can be declared with `using` statements based on the current platform.

Files you'll need to edit:
[libc/src/stdio/scanf_core/vfscanf_internal.h](https://github.com/llvm/llvm-project/blob/main/libc/src/stdio/scanf_core/vfscanf_internal.h)
[libc/src/stdio/scanf_core/reader.h](https://github.com/llvm/llvm-project/blob/main/libc/src/stdio/scanf_core/reader.h)

What to do:
Move the definitions of `getc` and `ungetc` in `vfscanf_internal` into `reader.h` (along with the associated `#if defined` logic for each target).
Define the `stream_getc` and `stream_ungetc` functions with `using` statements inside of `class Reader` (or do something equivalent).
Clean up the relevant code.

If you have questions or need help, feel free to comment on this issue or reach out via the LLVM discord.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to