[libc-commits] [libc] [libc][NFC] Clean up regex tables, headers, and CMake deps (PR #243759)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Wed Nov 18 01:06:29 PST 2026


================
@@ -71,20 +80,25 @@ LIBC_INLINE constexpr cpp::array<PosixClassEntry, 12> POSIX_CLASSES = {{
     {"punct", make_class_set([](char c) {
        return !internal::isalnum(c) && internal::isgraph(c);
      })},
-    {"space", space_class_set()},
+    {"space", SPACE_CLASS_SET},
     {"upper", make_class_set([](char c) { return internal::isupper(c); })},
     {"xdigit", make_class_set([](char c) {
        return internal::isdigit(c) || (c >= 'a' && c <= 'f') ||
               (c >= 'A' && c <= 'F');
      })},
 }};
 
-LIBC_INLINE constexpr cpp::optional<ByteSet>
-lookup_posix_class(cpp::string_view name) {
-  for (const auto &entry : POSIX_CLASSES)
-    if (entry.name == name)
-      return entry.set;
-  return cpp::nullopt;
+/// Unions the named POSIX character class into \p out.
+/// Returns false if \p name is not a recognized POSIX class name.
+[[nodiscard]] LIBC_INLINE constexpr bool add_posix_class(cpp::string_view name,
+                                                         ByteSet &out) {
+  for (const auto &entry : POSIX_CLASSES) {
+    if (cpp::string_view(entry.name.data(), entry.len) == name) {
----------------
labath wrote:

If this is going to be used elsewhere I'd make a member function for constructing the string_view.

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


More information about the libc-commits mailing list