git: dc3c414bcb9f - 2025Q1 - editors/abiword: fix build with libc++ 19

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 26 Mar 2025 18:38:44 UTC
The branch 2025Q1 has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=dc3c414bcb9fb5611a40597b1b7437c7de792f7f

commit dc3c414bcb9fb5611a40597b1b7437c7de792f7f
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-03-25 19:20:28 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-03-26 18:38:38 +0000

    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
    
    (cherry picked from commit e6daa211c609bde6ed3fe00fd5ce675714371805)
---
 .../files/patch-plugins_kword_xp_ie__imp__KWord__1.cpp        | 11 +++++++++++
 .../abiword/files/patch-src_af_ev_gtk_ev__UnixKeyboard.cpp    | 11 +++++++++++
 .../abiword/files/patch-src_af_gr_xp_gr__CairoGraphics.cpp    | 11 +++++++++++
 editors/abiword/files/patch-src_af_util_xp_ut__types.h        | 11 +++++++++++
 .../files/patch-src_text_fmt_xp_fv__View__protected.cpp       | 11 +++++++++++
 .../files/patch-src_wp_ap_gtk_ap__UnixDialog__Options.cpp     | 11 +++++++++++
 .../abiword/files/patch-src_wp_ap_xp_ap__Menu__Functions.cpp  | 11 +++++++++++
 7 files changed, 77 insertions(+)

diff --git a/editors/abiword/files/patch-plugins_kword_xp_ie__imp__KWord__1.cpp b/editors/abiword/files/patch-plugins_kword_xp_ie__imp__KWord__1.cpp
new file mode 100644
index 000000000000..6f18251f9fac
--- /dev/null
+++ b/editors/abiword/files/patch-plugins_kword_xp_ie__imp__KWord__1.cpp
@@ -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;
+ 	    }
+ 	}
diff --git a/editors/abiword/files/patch-src_af_ev_gtk_ev__UnixKeyboard.cpp b/editors/abiword/files/patch-src_af_ev_gtk_ev__UnixKeyboard.cpp
new file mode 100644
index 000000000000..7bcd4e0f414a
--- /dev/null
+++ b/editors/abiword/files/patch-src_af_ev_gtk_ev__UnixKeyboard.cpp
@@ -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());
+ 	  }
+ 
diff --git a/editors/abiword/files/patch-src_af_gr_xp_gr__CairoGraphics.cpp b/editors/abiword/files/patch-src_af_gr_xp_gr__CairoGraphics.cpp
new file mode 100644
index 000000000000..0d748743a49c
--- /dev/null
+++ b/editors/abiword/files/patch-src_af_gr_xp_gr__CairoGraphics.cpp
@@ -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 */)
diff --git a/editors/abiword/files/patch-src_af_util_xp_ut__types.h b/editors/abiword/files/patch-src_af_util_xp_ut__types.h
new file mode 100644
index 000000000000..d8eadeffacae
--- /dev/null
+++ b/editors/abiword/files/patch-src_af_util_xp_ut__types.h
@@ -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;
+ 
diff --git a/editors/abiword/files/patch-src_text_fmt_xp_fv__View__protected.cpp b/editors/abiword/files/patch-src_text_fmt_xp_fv__View__protected.cpp
new file mode 100644
index 000000000000..2a9a0c69c089
--- /dev/null
+++ b/editors/abiword/files/patch-src_text_fmt_xp_fv__View__protected.cpp
@@ -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;
+ 		}
+ 
diff --git a/editors/abiword/files/patch-src_wp_ap_gtk_ap__UnixDialog__Options.cpp b/editors/abiword/files/patch-src_wp_ap_gtk_ap__UnixDialog__Options.cpp
new file mode 100644
index 000000000000..46f8c131d284
--- /dev/null
+++ b/editors/abiword/files/patch-src_wp_ap_gtk_ap__UnixDialog__Options.cpp
@@ -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 );
+ 	}
diff --git a/editors/abiword/files/patch-src_wp_ap_xp_ap__Menu__Functions.cpp b/editors/abiword/files/patch-src_wp_ap_xp_ap__Menu__Functions.cpp
new file mode 100644
index 000000000000..f10d22f56c21
--- /dev/null
+++ b/editors/abiword/files/patch-src_wp_ap_xp_ap__Menu__Functions.cpp
@@ -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)
+ 	{