Skip to content

[libc] Clean up unnecessary function pointers in scanf #115394

@michaelrj-google

Description

@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
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.

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributelibc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions