git: 74e2551e863b - main - mail/thunderbird: fix build with clang 19

From: Christoph Moench-Tegeder <cmt_at_FreeBSD.org>
Date: Sun, 27 Oct 2024 16:22:19 UTC
The branch main has been updated by cmt:

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

commit 74e2551e863ba50a34faeeec03b82a078e8cb8e2
Author:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
AuthorDate: 2024-10-27 16:20:12 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2024-10-27 16:20:12 +0000

    mail/thunderbird: fix build with clang 19
    
    clang/libcxx 19 is more strict about std::char_traits, causing build
    failure in the rnp submodule. Import patches from upstream (rnp).
    
    PR:             282347
    Submitted by:   jkim@
---
 mail/thunderbird/files/patch-rnp-clang19 | 200 +++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)

diff --git a/mail/thunderbird/files/patch-rnp-clang19 b/mail/thunderbird/files/patch-rnp-clang19
new file mode 100644
index 000000000000..e943dcdea81e
--- /dev/null
+++ b/mail/thunderbird/files/patch-rnp-clang19
@@ -0,0 +1,200 @@
+In clang/libcxx 19, treatment of std::char_traits was tightened
+down - e.g. no generic (std::char_traits<unsigned char> etc) traits
+are not implemented anymore - which resulted in fallout in HEAD
+after the import of llvm/libcxx 19.
+jkim@ collected the neccessary patches from
+https://github.com/rnpgp/rnp/commit/20419f739f632fb30666650544f0055e8d4f1afa
+https://github.com/rnpgp/sexpp/commit/46744a14ffc235330bb99cebfaf294829c31bba4
+
+--- comm/third_party/rnp/src/lib/types.h.orig	2024-10-25 23:29:32 UTC
++++ comm/third_party/rnp/src/lib/types.h
+@@ -95,9 +95,6 @@ class id_str_pair {
+     static int         lookup(const id_str_pair           pair[],
+                               const std::vector<uint8_t> &bytes,
+                               int                         notfound = 0);
+-    static int         lookup(const id_str_pair                 pair[],
+-                              const std::basic_string<uint8_t> &bytes,
+-                              int                               notfound = 0);
+ };
+ 
+ /** pgp_fingerprint_t */
+--- comm/third_party/rnp/src/lib/utils.cpp.orig	2024-10-25 23:29:32 UTC
++++ comm/third_party/rnp/src/lib/utils.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2021, 2024 [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -53,21 +53,6 @@ id_str_pair::lookup(const id_str_pair pair[], const st
+ 
+ int
+ id_str_pair::lookup(const id_str_pair pair[], const std::vector<uint8_t> &bytes, int notfound)
+-{
+-    while (pair && pair->str) {
+-        if ((strlen(pair->str) == bytes.size()) &&
+-            !memcmp(pair->str, bytes.data(), bytes.size())) {
+-            return pair->id;
+-        }
+-        pair++;
+-    }
+-    return notfound;
+-}
+-
+-int
+-id_str_pair::lookup(const id_str_pair                 pair[],
+-                    const std::basic_string<uint8_t> &bytes,
+-                    int                               notfound)
+ {
+     while (pair && pair->str) {
+         if ((strlen(pair->str) == bytes.size()) &&
+--- comm/third_party/rnp/src/librekey/key_store_g10.cpp.orig	2024-10-25 23:29:32 UTC
++++ comm/third_party/rnp/src/librekey/key_store_g10.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2017-2022, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2017-2024, [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -312,12 +312,12 @@ read_curve(const sexp_list_t *list, const std::string 
+ 
+     const auto &bytes = data->get_string();
+     pgp_curve_t curve = static_cast<pgp_curve_t>(
+-      id_str_pair::lookup(g10_curve_aliases, data->get_string(), PGP_CURVE_UNKNOWN));
++      id_str_pair::lookup(g10_curve_aliases, (const char *) bytes.data(), PGP_CURVE_UNKNOWN));
+     if (curve != PGP_CURVE_UNKNOWN) {
+         key.curve = curve;
+         return true;
+     }
+-    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (char *) bytes.data());
++    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (const char *) bytes.data());
+     return false;
+ }
+ 
+@@ -806,7 +806,7 @@ g23_parse_seckey(pgp_key_pkt_t &seckey,
+ 
+     auto &           alg_bt = alg_s_exp->sexp_string_at(0)->get_string();
+     pgp_pubkey_alg_t alg = static_cast<pgp_pubkey_alg_t>(
+-      id_str_pair::lookup(g10_alg_aliases, alg_bt.c_str(), PGP_PKA_NOTHING));
++      id_str_pair::lookup(g10_alg_aliases, (const char *) alg_bt.data(), PGP_PKA_NOTHING));
+     if (alg == PGP_PKA_NOTHING) {
+         RNP_LOG(
+           "Unsupported algorithm: '%.*s'", (int) alg_bt.size(), (const char *) alg_bt.data());
+--- comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h.orig	2024-10-25 23:29:32.000000000 +0000
++++ comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h	2024-10-27 06:14:59.238155000 +0000
+@@ -44,8 +44,93 @@
+ #include "sexp-public.h"
+ #include "sexp-error.h"
+ 
++// We are implementing char traits for octet_t with trhe following restrictions
++//  -- limit visibility so that other traits for unsigned char are still possible
++//  -- create template specializatio in std workspace (use workspace specialization
++//     is not specified and causes issues at least with gcc 4.8
++
+ namespace sexp {
++using octet_t = uint8_t;
++} // namespace sexp
+ 
++namespace std {
++
++template <> struct char_traits<sexp::octet_t> {
++    typedef sexp::octet_t  char_type;
++    typedef int            int_type;
++    typedef std::streampos pos_type;
++    typedef std::streamoff off_type;
++    typedef mbstate_t      state_type;
++
++    static void assign(char_type &__c1, const char_type &__c2) noexcept { __c1 = __c2; }
++
++    static constexpr bool eq(const char_type &__c1, const char_type &__c2) noexcept
++    {
++        return __c1 == __c2;
++    }
++
++    static constexpr bool lt(const char_type &__c1, const char_type &__c2) noexcept
++    {
++        return __c1 < __c2;
++    }
++
++    static int compare(const char_type *__s1, const char_type *__s2, size_t __n)
++    {
++        return memcmp(__s1, __s2, __n);
++    }
++
++    static size_t length(const char_type *__s)
++    {
++        return strlen(reinterpret_cast<const char *>(__s));
++    }
++
++    static const char_type *find(const char_type *__s, size_t __n, const char_type &__a)
++    {
++        return static_cast<const char_type *>(memchr(__s, __a, __n));
++    }
++
++    static char_type *move(char_type *__s1, const char_type *__s2, size_t __n)
++    {
++        return static_cast<char_type *>(memmove(__s1, __s2, __n));
++    }
++
++    static char_type *copy(char_type *__s1, const char_type *__s2, size_t __n)
++    {
++        return static_cast<char_type *>(memcpy(__s1, __s2, __n));
++    }
++
++    static char_type *assign(char_type *__s, size_t __n, char_type __a)
++    {
++        return static_cast<char_type *>(memset(__s, __a, __n));
++    }
++
++    static constexpr char_type to_char_type(const int_type &__c) noexcept
++    {
++        return static_cast<char_type>(__c);
++    }
++
++    // To keep both the byte 0xff and the eof symbol 0xffffffff
++    // from ending up as 0xffffffff.
++    static constexpr int_type to_int_type(const char_type &__c) noexcept
++    {
++        return static_cast<int_type>(static_cast<unsigned char>(__c));
++    }
++
++    static constexpr bool eq_int_type(const int_type &__c1, const int_type &__c2) noexcept
++    {
++        return __c1 == __c2;
++    }
++
++    static constexpr int_type eof() noexcept { return static_cast<int_type>(0xFFFFFFFF); }
++
++    static constexpr int_type not_eof(const int_type &__c) noexcept
++    {
++        return (__c == eof()) ? 0 : __c;
++    }
++};
++} // namespace std
++
++namespace sexp {
+ /*
+  * SEXP octet_t definitions
+  * We maintain some presumable redundancy with ctype
+@@ -99,14 +184,14 @@ class sexp_input_stream_t;
+  * SEXP simple string
+  */
+ 
+-typedef uint8_t octet_t;
++using octet_traits = std::char_traits<octet_t>;
++using octet_string = std::basic_string<octet_t, octet_traits>;
+ 
+-class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public std::basic_string<octet_t>,
+-                                                private sexp_char_defs_t {
++class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public octet_string, private sexp_char_defs_t {
+   public:
+     sexp_simple_string_t(void) = default;
+-    sexp_simple_string_t(const octet_t *dt) : std::basic_string<octet_t>{dt} {}
+-    sexp_simple_string_t(const octet_t *bt, size_t ln) : std::basic_string<octet_t>{bt, ln} {}
++    sexp_simple_string_t(const octet_t *dt) : octet_string{dt} {}
++    sexp_simple_string_t(const octet_t *bt, size_t ln) : octet_string{bt, ln} {}
+     sexp_simple_string_t &append(int c)
+     {
+         (*this) += (octet_t)(c & 0xFF);