[libc-commits] [PATCH] D85615: [libc] Add strtok implementation.

Chris Gyurgyik via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Aug 10 17:53:59 PDT 2020


cgyurgyik added inline comments.


================
Comment at: libc/test/src/string/strtok_test.cpp:61
+  token = __llvm_libc::strtok(nullptr, "_:,_");
+  ASSERT_STREQ(token, nullptr);
+  // Subsequent calls after hitting the end of the string should also return
----------------
sivachandra wrote:
> Does `strtok` as implemented above ever return `nullptr`?  This got me to go look why `ASSERT_STREQ` is happy. It turns out, our `STREQ` comparison first converts the string to `llvm::StringRef` which makes an empty string compare equal to a nullptr! That needs fixing separately.
Do we want `strtok` to return `nullptr` in the case the null terminator is hit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85615



More information about the libc-commits mailing list