[libcxx-commits] [libcxx] [libcxx][FreeBSD] Re-enable the sucessful test. (PR #186130)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 5 07:23:26 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/3] [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/3] 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
>From 56d7f8446e5e8baf27b590e452175b7d15bcb7de Mon Sep 17 00:00:00 2001
From: aokblast <aokblast at FreeBSD.org>
Date: Fri, 5 Jun 2026 22:23:10 +0800
Subject: [PATCH 3/3] fixup! re_fix
---
libcxx/include/regex | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 08218584d1649..9e9c1a6a3bbc7 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1130,16 +1130,29 @@ 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());
+# if defined(__FreeBSD__)
// 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.
+ // which the fixed-size logic below could not handle.
typename string_type::size_type __sep = __d.find('.');
if (__sep != string_type::npos)
__d.erase(__sep);
+# else
+ switch (__d.size()) {
+ case 1:
+ break;
+ case 12:
+ __d[11] = __d[3];
+ break;
+ default:
+ __d.clear();
+ break;
+ }
+# endif
return __d;
}
@@ -1150,6 +1163,7 @@ 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());
+# if defined(__FreeBSD__)
// 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
@@ -1157,6 +1171,18 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator
typename string_type::size_type __sep = __d.find(static_cast<_CharT>(1));
if (__sep != string_type::npos)
__d.erase(__sep);
+# else
+ switch (__d.size()) {
+ case 1:
+ break;
+ case 3:
+ __d[2] = __d[0];
+ break;
+ default:
+ __d.clear();
+ break;
+ }
+# endif
return __d;
}
# endif
More information about the libcxx-commits
mailing list