related tdf#152305 writerfilter: avoid comment-related exceptions
[LibreOffice.git] / external / pdfium / build.patch.1
blob6f6a53a44ef3f164c2c441d0d82dd43c6105dd23
1 -*- Mode: diff -*-
2 diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
3 index 323de4ffc..f11a0b0ad 100644
4 --- a/core/fpdfdoc/cpdf_metadata.cpp
5 +++ b/core/fpdfdoc/cpdf_metadata.cpp
6 @@ -74,7 +74,7 @@ std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const {
7    CFX_XMLParser parser(stream);
8    std::unique_ptr<CFX_XMLDocument> doc = parser.Parse();
9    if (!doc)
10 -    return {};
11 +    return std::vector<UnsupportedFeature>();
13    std::vector<UnsupportedFeature> unsupported;
14    CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
15 diff --git a/third_party/base/span.h b/third_party/base/span.h
16 index ec9f9903f..1c17ad091 100644
17 --- a/third_party/base/span.h
18 +++ b/third_party/base/span.h
19 @@ -208,7 +208,7 @@ class span {
20    // Conversions from spans of compatible types: this allows a span<T> to be
21    // seamlessly used as a span<const T>, but not the other way around.
22    template <typename U, typename = internal::EnableIfLegalSpanConversion<U, T>>
23 -  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
24 +  span(const span<U>& other) : span(other.data(), other.size()) {}
25    span& operator=(const span& other) noexcept {
26      if (this != &other) {
27        ReleaseEmptySpan();
28 diff --git a/third_party/base/span.h b/third_party/base/span.h
29 index 0fb627ba8..dda1fc8bc 100644
30 --- a/third_party/base/span.h
31 +++ b/third_party/base/span.h
32 @@ -204,7 +204,7 @@ class span {
33    // size()|.
34    template <typename Container,
35              typename = internal::EnableIfSpanCompatibleContainer<Container, T>>
36 -  constexpr span(Container& container)
37 +  span(Container& container)
38        : span(container.data(), container.size()) {}
39    template <
40        typename Container,
41 diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp b/core/fxcodec/jpx/cjpx_decoder.cpp
42 index d8875786c..bc019ebe1 100644
43 --- a/core/fxcodec/jpx/cjpx_decoder.cpp
44 +++ b/core/fxcodec/jpx/cjpx_decoder.cpp
45 @@ -73,7 +73,7 @@ absl::optional<OpjImageRgbData> alloc_rgb(size_t size) {
46    if (!data.b)
47      return absl::nullopt;
49 -  return data;
50 +  return std::move(data);
51  }
53  void sycc_to_rgb(int offset,
54 diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
55 index 8b3a72700..ea1db23f4 100644
56 --- a/core/fxge/cfx_font.cpp
57 +++ b/core/fxge/cfx_font.cpp
58 @@ -47,25 +47,9 @@ struct OUTLINE_PARAMS {
59  // TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be
60  // available to all users in the future, remove FreeMMVar() and use
61  // FT_Done_MM_Var() directly.
62 -//
63 -// Use weak symbols to check if FT_Done_MM_Var() is available at runtime.
64 -#if !BUILDFLAG(IS_WIN)
65 -extern "C" __attribute__((weak)) decltype(FT_Done_MM_Var) FT_Done_MM_Var;
66 -#endif
68  void FreeMMVar(FXFT_FaceRec* rec, FXFT_MM_VarPtr variation_desc) {
69 -#if BUILDFLAG(IS_WIN)
70 -  // Assume `use_system_freetype` GN var is never set on Windows.
71 -  constexpr bool has_ft_done_mm_var_func = true;
72 -#else
73 -  static const bool has_ft_done_mm_var_func = !!FT_Done_MM_Var;
74 -#endif
75 -  if (has_ft_done_mm_var_func) {
76 -    FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
77 -                   variation_desc);
78 -  } else {
79      FXFT_Free(rec, variation_desc);
80 -  }
81  }
83  FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) {
84 diff --git a/third_party/base/numerics/safe_conversions_impl.h b/third_party/base/numerics/safe_conversions_impl.h
85 index 4d8a7b7d9..d14c6dc06 100644
86 --- a/third_party/base/numerics/safe_conversions_impl.h
87 +++ b/third_party/base/numerics/safe_conversions_impl.h
88 @@ -88,7 +88,7 @@ constexpr typename std::make_unsigned<T>::type SafeUnsignedAbs(T value) {
90  // TODO(jschuh): Switch to std::is_constant_evaluated() once C++20 is supported.
91  // Alternately, the usage could be restructured for "consteval if" in C++23.
92 -#define IsConstantEvaluated() (__builtin_is_constant_evaluated())
93 +#define IsConstantEvaluated() (false)
95  // TODO(jschuh): Debug builds don't reliably propagate constants, so we restrict
96  // some accelerated runtime paths to release builds until this can be forced
97 --- pdfium/core/fpdfapi/font/cpdf_cidfont.cpp.orig      2022-05-20 09:25:52.066728467 +0000
98 +++ pdfium/core/fpdfapi/font/cpdf_cidfont.cpp   2022-05-20 09:25:56.146736531 +0000
99 @@ -738,7 +738,7 @@
100          uint32_t maccode = CharCodeFromUnicodeForFreetypeEncoding(
101              FT_ENCODING_APPLE_ROMAN, name_unicode);
102          index = maccode ? FT_Get_Char_Index(face, maccode)
103 -                        : FT_Get_Name_Index(face, name);
104 +                        : FT_Get_Name_Index(face, const_cast<char*>(name));
105        }
106        if (index == 0 || index == 0xffff)
107          return charcode ? static_cast<int>(charcode) : -1;
108 --- pdfium/core/fpdfapi/font/cpdf_type1font.cpp.orig    2022-05-20 09:26:59.090862058 +0000
109 +++ pdfium/core/fpdfapi/font/cpdf_type1font.cpp 2022-05-20 09:27:33.810932435 +0000
110 @@ -260,7 +260,7 @@
111                                            static_cast<uint32_t>(charcode));
112        if (name) {
113          m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
114 -        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
115 +        m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), const_cast<char*>(name));
116        } else {
117          m_GlyphIndex[charcode] = FT_Get_Char_Index(
118              m_Font.GetFaceRec(), static_cast<uint32_t>(charcode));
119 @@ -291,7 +291,7 @@
120        continue;
122      m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
123 -    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), name);
124 +    m_GlyphIndex[charcode] = FT_Get_Name_Index(m_Font.GetFaceRec(), const_cast<char*>(name));
125      if (m_GlyphIndex[charcode] != 0)
126        continue;
128 --- pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp.orig 2022-05-20 09:26:12.066767996 +0000
129 +++ pdfium/core/fpdfapi/font/cpdf_truetypefont.cpp      2022-05-20 09:26:46.690836923 +0000
130 @@ -90,7 +90,7 @@
131                FT_ENCODING_APPLE_ROMAN,
132                m_Encoding.UnicodeFromCharCode(charcode));
133            if (!maccode) {
134 -            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
135 +            m_GlyphIndex[charcode] = FT_Get_Name_Index(face, const_cast<char*>(name));
136            } else {
137              m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
138            }
139 @@ -104,7 +104,7 @@
140          m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
141          continue;
142        }
143 -      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
144 +      m_GlyphIndex[charcode] = FT_Get_Name_Index(face, const_cast<char*>(name));
145        if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
146          continue;
148 diff --git a/third_party/libopenjpeg/openjpeg.c b/third_party/libopenjpeg/openjpeg.c
149 index 29d3ee528..d5c7a1bc9 100644
150 --- a/third_party/libopenjpeg/openjpeg.c
151 +++ b/third_party/libopenjpeg/openjpeg.c
152 @@ -433,7 +433,7 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
153      return OPJ_FALSE;
156 -OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
157 +OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
158          OPJ_BOOL strict)
160      if (p_codec) {