[libc-commits] [PATCH] D137117: [libc] add scanf reader

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 7 00:17:47 PST 2022


sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.

LGTM with minor fixes.



================
Comment at: libc/src/stdio/scanf_core/reader.h:37
+  // This returns the next character from the input and advances it by one
+  // character. If the file reaches EOF this function will return '\0'.
+  char getc();
----------------
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?


================
Comment at: libc/src/stdio/scanf_core/reader.h:41
+  // This moves the input back by one character, placing c into the buffer if
+  // this is a file reader, else c is ignored.
+  void ungetc(char c);
----------------
This comment should be next to where the ignore is actually happening and explain why.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137117/new/

https://reviews.llvm.org/D137117



More information about the libc-commits mailing list