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

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 7 10:24:08 PST 2022


michaelrj added inline comments.


================
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();
----------------
sivachandra wrote:
> 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?
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.


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