[libc-commits] [PATCH] D141236: [libc] Implement str{,n}casecmp

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Sun Jan 8 21:59:11 PST 2023


sivachandra added inline comments.


================
Comment at: libc/src/string/strcasecmp.cpp:19
+  auto case_cmp = [](char a, char b) {
+    return __llvm_libc::tolower(a) - __llvm_libc::tolower(b);
+  };
----------------
This add a symbol level dependence on `tolower`. To avoid it, add a `tolower` implementation here: https://github.com/llvm/llvm-project/blob/main/libc/src/__support/ctype_utils.h.


================
Comment at: libc/test/src/string/strcasecmp_test.cpp:28
+  // This should be '\0' - 'a' = -97
+  ASSERT_EQ(result, -97);
+
----------------
Does comparing with the exact difference tightly couple this test with implementation details?


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

https://reviews.llvm.org/D141236



More information about the libc-commits mailing list