[libc-commits] [PATCH] D85779: [libc] Add strtok_r implementation.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 12 08:54:32 PDT 2020


sivachandra added inline comments.


================
Comment at: libc/spec/posix.td:16
   ConstType ConstCharPtr = ConstType<CharPtr>;
+  RestrictedPtrType RestrictedCharPtr = RestrictedPtrType<CharType>;
+  ConstType ConstRestrictedCharPtr = ConstType<RestrictedCharPtr>;
----------------
Other restricted pointer types are named like `RestrictSigSetType`. For consistency, we should use just one style everywhere.


================
Comment at: libc/src/string/strtok_r.cpp:16
+
+char *LLVM_LIBC_ENTRYPOINT(strtok_r)(char *src, const char *delimiter_string,
+                                     char **saveptr) {
----------------
Would it make sense to implement `strtok` and `strtok_r` over a common function which is equivalent in functionality to `strtok_r`?


================
Comment at: libc/src/string/strtok_r.cpp:35
+  *saveptr = src;
+  if (**saveptr) {
+    **saveptr = '\0';
----------------
Can we operator on `src` instead of `saveptr`?

```
if (*src) {
  *src = '\0';
  ++src;
}
*saveptr = src;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85779



More information about the libc-commits mailing list