editors/abiword: fix build with libc++ 19

As noted in the libc++ 19 release notes [1], std::char_traits<> is now
only provided for char, char8_t, char16_t, char32_t and wchar_t, and any
instantiation for other types will fail.

This causes editors/abiword to fail to compile with clang 19 and
libc++ 19, resulting in errors similar to:

  /usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>'
    820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
        |                                          ^
  ut_string_class.cpp:1275:41: note: in instantiation of template class 'std::basic_string<unsigned int>' requested here
   1275 |         :       pimpl(new UT_StringImpl<UT_UCS4Char>(*rhs.pimpl))
        |                                                      ^
  /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
     23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
        |                             ^

This can be fixed by defining `UT_UCS4Char` as `char32_t` instead of
`gunichar`, and patching up a few places where those types are mixed
indiscriminately.

[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals

PR:		285657
Approved by:	gnome (fluffy)
MFH:		2025Q1
This commit is contained in:
Dimitry Andric 2025-03-25 20:20:28 +01:00
parent 27c82184c1
commit e6daa211c6
7 changed files with 77 additions and 0 deletions

View file

@ -0,0 +1,11 @@
--- plugins/kword/xp/ie_imp_KWord_1.cpp.orig 2021-07-03 15:46:07 UTC
+++ plugins/kword/xp/ie_imp_KWord_1.cpp
@@ -180,7 +180,7 @@ void IE_Imp_KWord_1::charData(const gchar *s, int len)
m_charDataSeen[m_lenCharDataSeen++] = currentChar;
if (m_lenCharDataSeen == m_lenCharDataExpected)
{
- buf += g_utf8_get_char(m_charDataSeen);
+ buf += static_cast<UT_UCS4Char>(g_utf8_get_char(m_charDataSeen));
m_lenCharDataSeen = 0;
}
}

View file

@ -0,0 +1,11 @@
--- src/af/ev/gtk/ev_UnixKeyboard.cpp.orig 2021-07-03 15:46:07 UTC
+++ src/af/ev/gtk/ev_UnixKeyboard.cpp
@@ -130,7 +130,7 @@ bool ev_UnixKeyboard::keyPressEvent(AV_View* pView, Gd
{
// TODO: is this necessary?
charData = gdk_keyval_to_unicode (charData);
- UT_UTF8String utf8 (static_cast<const UT_UCS4Char *>(&charData), 1);
+ UT_UTF8String utf8 (reinterpret_cast<const UT_UCS4Char *>(&charData), 1);
return charDataEvent (pView, state, utf8.utf8_str(), utf8.byteLength());
}

View file

@ -0,0 +1,11 @@
--- src/af/gr/xp/gr_CairoGraphics.cpp.orig 2021-07-03 15:46:07 UTC
+++ src/af/gr/xp/gr_CairoGraphics.cpp
@@ -535,7 +535,7 @@ void GR_CairoGraphics::drawGlyph(UT_uint32 Char, UT_si
void GR_CairoGraphics::drawGlyph(UT_uint32 Char, UT_sint32 xoff, UT_sint32 yoff)
{
- drawChars(&Char, 0, 1, xoff, yoff, NULL);
+ drawChars(reinterpret_cast<const UT_UCSChar*>(&Char), 0, 1, xoff, yoff, NULL);
}
void GR_CairoGraphics::setColorSpace(GR_Graphics::ColorSpace /* c */)

View file

@ -0,0 +1,11 @@
--- src/af/util/xp/ut_types.h.orig 2021-07-03 15:46:07 UTC
+++ src/af/util/xp/ut_types.h
@@ -40,7 +40,7 @@ typedef guint8 UT_Byte;
typedef guint8 UT_Byte;
-typedef gunichar UT_UCS4Char;
+typedef char32_t UT_UCS4Char;
typedef guint16 UT_UCS2Char;
typedef gint32 UT_GrowBufElement;

View file

@ -0,0 +1,11 @@
--- src/text/fmt/xp/fv_View_protected.cpp.orig 2021-07-03 15:46:07 UTC
+++ src/text/fmt/xp/fv_View_protected.cpp
@@ -5752,7 +5752,7 @@ UT_UCSChar * FV_View::_lookupSuggestion(fl_BlockLayout
UT_uint32 len = iLength;
for (UT_uint32 ldex=0; ldex < len && ldex < INPUTWORDLEN; ldex++)
{
- stMisspelledWord += *pWord == UCS_RQUOTE ? '\'' : *pWord;
+ stMisspelledWord += *pWord == UCS_RQUOTE ? U'\'' : *pWord;
++pWord;
}

View file

@ -0,0 +1,11 @@
--- src/wp/ap/gtk/ap_UnixDialog_Options.cpp.orig 2021-07-03 15:46:07 UTC
+++ src/wp/ap/gtk/ap_UnixDialog_Options.cpp
@@ -959,7 +959,7 @@ void AP_UnixDialog_Options::_setupSmartQuotesCombos(
wszDisplayString[1] = (gunichar)'O';
wszDisplayString[2] = XAP_EncodingManager::smartQuoteStyles[i].rightQuote;
wszDisplayString[3] = (gunichar)0;
- gchar* szDisplayStringUTF8 = g_ucs4_to_utf8 ( wszDisplayString, -1, NULL, NULL, NULL );
+ gchar* szDisplayStringUTF8 = g_ucs4_to_utf8 ( reinterpret_cast<const gunichar*>(wszDisplayString), -1, NULL, NULL, NULL );
XAP_appendComboBoxTextAndInt(combo, szDisplayStringUTF8, i);
g_free ( szDisplayStringUTF8 );
}

View file

@ -0,0 +1,11 @@
--- src/wp/ap/xp/ap_Menu_Functions.cpp.orig 2021-07-03 15:46:07 UTC
+++ src/wp/ap/xp/ap_Menu_Functions.cpp
@@ -744,7 +744,7 @@ Defun_EV_GetMenuItemComputedLabel_Fn(ap_GetLabel_Sugge
UT_UCSChar *p = pView->getContextSuggest(ndx);
gchar * c = NULL;
if (p && *p) {
- c = g_ucs4_to_utf8(p, -1, NULL, NULL, NULL);
+ c = g_ucs4_to_utf8(reinterpret_cast<const gunichar *>(p), -1, NULL, NULL, NULL);
}
else if (ndx == 1)
{