[libcxx-commits] [libcxx] [libcxx][FreeBSD] Re-enable the sucessful test. (PR #186130)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 5 01:03:18 PDT 2026


https://github.com/aokblast updated https://github.com/llvm/llvm-project/pull/186130

>From f582f561e0e953d4c6f648f3583bc2aad38fa1d6 Mon Sep 17 00:00:00 2001
From: ShengYi Hung <aokblast at FreeBSD.org>
Date: Thu, 12 Mar 2026 20:39:15 +0800
Subject: [PATCH 1/2] [libcxx][FreeBSD] Re-enable the sucessful test.

---
 libcxx/test/std/re/re.traits/transform_primary.pass.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcxx/test/std/re/re.traits/transform_primary.pass.cpp b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp
index 422e3a591e643..ff866e6031b4a 100644
--- a/libcxx/test/std/re/re.traits/transform_primary.pass.cpp
+++ b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp
@@ -10,7 +10,6 @@
 // XFAIL: netbsd
 
 // XFAIL: LIBCXX-AIX-FIXME
-// XFAIL: LIBCXX-FREEBSD-FIXME
 
 // REQUIRES: locale.cs_CZ.ISO8859-2
 

>From 62a9754de32dab6c024175e38e0638b2ee9d80f7 Mon Sep 17 00:00:00 2001
From: aokblast <aokblast at FreeBSD.org>
Date: Fri, 5 Jun 2026 16:02:49 +0800
Subject: [PATCH 2/2] re_fix

---
 libcxx/include/regex | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/libcxx/include/regex b/libcxx/include/regex
index 695a0f21754c4..08218584d1649 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1130,16 +1130,16 @@ typename regex_traits<_CharT>::string_type
 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const {
   const string_type __s(__f, __l);
   string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
-  switch (__d.size()) {
-  case 1:
-    break;
-  case 12:
-    __d[11] = __d[3];
-    break;
-  default:
-    __d.clear();
-    break;
-  }
+  // FreeBSD's strxfrm() emits the weights one collation level at a time,
+  // separating the levels with a byte ('.') that is chosen to sort below every
+  // weight byte.  Primary equivalence only depends on the first (primary)
+  // level, so drop everything from the first separator onwards.  This keeps
+  // characters that share a primary weight equal (e.g. 'A' and 'A-acute' in
+  // cs_CZ) even when the lower levels expand to a different number of weights,
+  // which the previous fixed-size logic could not handle.
+  typename string_type::size_type __sep = __d.find('.');
+  if (__sep != string_type::npos)
+    __d.erase(__sep);
   return __d;
 }
 
@@ -1150,16 +1150,13 @@ typename regex_traits<_CharT>::string_type
 regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const {
   const string_type __s(__f, __l);
   string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
-  switch (__d.size()) {
-  case 1:
-    break;
-  case 3:
-    __d[2] = __d[0];
-    break;
-  default:
-    __d.clear();
-    break;
-  }
+  // As in the char overload above, FreeBSD's wcsxfrm() separates the collation
+  // levels with a weight (the value 1) that sorts below every real weight.
+  // Keep only the primary level so primary-equivalent characters compare equal
+  // regardless of how many weights their lower levels expand to.
+  typename string_type::size_type __sep = __d.find(static_cast<_CharT>(1));
+  if (__sep != string_type::npos)
+    __d.erase(__sep);
   return __d;
 }
 #    endif



More information about the libcxx-commits mailing list