[libc-commits] [PATCH] D156923: [libc] Add nullptr check option to printf %s

Roland McGrath via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 9 14:18:45 PDT 2023


mcgrathr added inline comments.


================
Comment at: libc/src/stdio/printf_core/string_converter.h:29
+  if (str_ptr == nullptr) {
+    str_ptr = "null";
+  }
----------------
IIRC the traditional string is "(null)", not "null".
That's what glibc does.
Also note for `%p` it uses "(nil)" instead, so go figure.
Also glibc only writes "(null)" at all if the precision allows the full string, never truncates it to "(nu" for `%.3s`. If it doesn't fit, it just writes nothing instead (as for an argument of "").



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156923



More information about the libc-commits mailing list