This is the interface that will be used to read from a file or string in
scanf. This patch also adds the string and file implementations of the
reader, although the file reader is not yet complete since ungetc has
not yet been implemented.
Details
- Reviewers
sivachandra lntue - Commits
- rG0c8db885f627: [libc] add scanf reader
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM with minor fixes.
libc/src/stdio/scanf_core/reader.h | ||
---|---|---|
38 | There could be a valid \0 character in the input stream before EOF. Will this cause any problems? Either way, this seems to me like the method should return a cpp::optional value? | |
42 | This comment should be next to where the ignore is actually happening and explain why. |
add comment explaining ungetc behavior
libc/src/stdio/scanf_core/reader.h | ||
---|---|---|
38 | a \0 in a file will be treated the same as a \0 in a regular string; no scanf formats are allowed to cross it. As for if this should be optional, I don't think there should be any difference between the end of a file and the end of a string, so representing them both with a '\0' seems a lot simpler than adding machinery everywhere characters are read to handle optionals. |
There could be a valid \0 character in the input stream before EOF. Will this cause any problems? Either way, this seems to me like the method should return a cpp::optional value?