[libc-commits] [libc] [libc][test] make `str_to_float_comparison_test` independent of C++ headers. (PR #133978)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Apr 4 15:24:11 PDT 2025


================
@@ -150,24 +152,25 @@ int main(int argc, char *argv[]) {
   int detailedBitDiffs[4] = {0, 0, 0, 0};
 
   int total = 0;
-  for (int i = 1; i < argc; i++) {
-    std::cout << "Starting file " << argv[i] << "\n";
+
+  char *files = LIBC_NAMESPACE::getenv("FILES");
+  for (char *file = LIBC_NAMESPACE::strtok(files, ","); file != nullptr;
+       file = LIBC_NAMESPACE::strtok(nullptr, ",")) {
----------------
michaelrj-google wrote:

you should probably make a copy of `files` with `malloc`/`memcpy` if you're planning to use `strtok` on it. `getenv` returns a pointer to a section of the `env_ptr`, and `strtok` modifies the string passed to it.

https://github.com/llvm/llvm-project/pull/133978


More information about the libc-commits mailing list