Added
Link Here
|
1 |
--- comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h.orig 2024-10-25 23:29:32.000000000 +0000 |
2 |
+++ comm/third_party/rnp/src/libsexpp/include/sexpp/sexp.h 2024-10-27 06:14:59.238155000 +0000 |
3 |
@@ -44,8 +44,93 @@ |
4 |
#include "sexp-public.h" |
5 |
#include "sexp-error.h" |
6 |
|
7 |
+// We are implementing char traits for octet_t with trhe following restrictions |
8 |
+// -- limit visibility so that other traits for unsigned char are still possible |
9 |
+// -- create template specializatio in std workspace (use workspace specialization |
10 |
+// is not specified and causes issues at least with gcc 4.8 |
11 |
+ |
12 |
namespace sexp { |
13 |
+using octet_t = uint8_t; |
14 |
+} // namespace sexp |
15 |
|
16 |
+namespace std { |
17 |
+ |
18 |
+template <> struct char_traits<sexp::octet_t> { |
19 |
+ typedef sexp::octet_t char_type; |
20 |
+ typedef int int_type; |
21 |
+ typedef std::streampos pos_type; |
22 |
+ typedef std::streamoff off_type; |
23 |
+ typedef mbstate_t state_type; |
24 |
+ |
25 |
+ static void assign(char_type &__c1, const char_type &__c2) noexcept { __c1 = __c2; } |
26 |
+ |
27 |
+ static constexpr bool eq(const char_type &__c1, const char_type &__c2) noexcept |
28 |
+ { |
29 |
+ return __c1 == __c2; |
30 |
+ } |
31 |
+ |
32 |
+ static constexpr bool lt(const char_type &__c1, const char_type &__c2) noexcept |
33 |
+ { |
34 |
+ return __c1 < __c2; |
35 |
+ } |
36 |
+ |
37 |
+ static int compare(const char_type *__s1, const char_type *__s2, size_t __n) |
38 |
+ { |
39 |
+ return memcmp(__s1, __s2, __n); |
40 |
+ } |
41 |
+ |
42 |
+ static size_t length(const char_type *__s) |
43 |
+ { |
44 |
+ return strlen(reinterpret_cast<const char *>(__s)); |
45 |
+ } |
46 |
+ |
47 |
+ static const char_type *find(const char_type *__s, size_t __n, const char_type &__a) |
48 |
+ { |
49 |
+ return static_cast<const char_type *>(memchr(__s, __a, __n)); |
50 |
+ } |
51 |
+ |
52 |
+ static char_type *move(char_type *__s1, const char_type *__s2, size_t __n) |
53 |
+ { |
54 |
+ return static_cast<char_type *>(memmove(__s1, __s2, __n)); |
55 |
+ } |
56 |
+ |
57 |
+ static char_type *copy(char_type *__s1, const char_type *__s2, size_t __n) |
58 |
+ { |
59 |
+ return static_cast<char_type *>(memcpy(__s1, __s2, __n)); |
60 |
+ } |
61 |
+ |
62 |
+ static char_type *assign(char_type *__s, size_t __n, char_type __a) |
63 |
+ { |
64 |
+ return static_cast<char_type *>(memset(__s, __a, __n)); |
65 |
+ } |
66 |
+ |
67 |
+ static constexpr char_type to_char_type(const int_type &__c) noexcept |
68 |
+ { |
69 |
+ return static_cast<char_type>(__c); |
70 |
+ } |
71 |
+ |
72 |
+ // To keep both the byte 0xff and the eof symbol 0xffffffff |
73 |
+ // from ending up as 0xffffffff. |
74 |
+ static constexpr int_type to_int_type(const char_type &__c) noexcept |
75 |
+ { |
76 |
+ return static_cast<int_type>(static_cast<unsigned char>(__c)); |
77 |
+ } |
78 |
+ |
79 |
+ static constexpr bool eq_int_type(const int_type &__c1, const int_type &__c2) noexcept |
80 |
+ { |
81 |
+ return __c1 == __c2; |
82 |
+ } |
83 |
+ |
84 |
+ static constexpr int_type eof() noexcept { return static_cast<int_type>(0xFFFFFFFF); } |
85 |
+ |
86 |
+ static constexpr int_type not_eof(const int_type &__c) noexcept |
87 |
+ { |
88 |
+ return (__c == eof()) ? 0 : __c; |
89 |
+ } |
90 |
+}; |
91 |
+} // namespace std |
92 |
+ |
93 |
+namespace sexp { |
94 |
/* |
95 |
* SEXP octet_t definitions |
96 |
* We maintain some presumable redundancy with ctype |
97 |
@@ -99,14 +184,14 @@ class sexp_input_stream_t; |
98 |
* SEXP simple string |
99 |
*/ |
100 |
|
101 |
-typedef uint8_t octet_t; |
102 |
+using octet_traits = std::char_traits<octet_t>; |
103 |
+using octet_string = std::basic_string<octet_t, octet_traits>; |
104 |
|
105 |
-class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public std::basic_string<octet_t>, |
106 |
- private sexp_char_defs_t { |
107 |
+class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public octet_string, private sexp_char_defs_t { |
108 |
public: |
109 |
sexp_simple_string_t(void) = default; |
110 |
- sexp_simple_string_t(const octet_t *dt) : std::basic_string<octet_t>{dt} {} |
111 |
- sexp_simple_string_t(const octet_t *bt, size_t ln) : std::basic_string<octet_t>{bt, ln} {} |
112 |
+ sexp_simple_string_t(const octet_t *dt) : octet_string{dt} {} |
113 |
+ sexp_simple_string_t(const octet_t *bt, size_t ln) : octet_string{bt, ln} {} |
114 |
sexp_simple_string_t &append(int c) |
115 |
{ |
116 |
(*this) += (octet_t)(c & 0xFF); |