From afc4f6d1c85d274d1b00dc009c95a50fc08be316 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Thu, 2 May 2019 00:38:26 +0200 Subject: sci-libs/gdal: Fix build with poppler-0.75 and poppler-0.76 Needs backports from gdal-2.5.0. Closes: https://bugs.gentoo.org/681342 Closes: https://bugs.gentoo.org/682690 Package-Manager: Portage-2.3.66, Repoman-2.3.12 Signed-off-by: Andreas Sturmlechner --- sci-libs/gdal/files/gdal-2.4.1-poppler-0.75.patch | 148 ++++++++++++++++++++++ sci-libs/gdal/files/gdal-2.4.1-poppler-0.76.patch | 24 ++++ sci-libs/gdal/gdal-2.4.1.ebuild | 3 +- 3 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 sci-libs/gdal/files/gdal-2.4.1-poppler-0.75.patch create mode 100644 sci-libs/gdal/files/gdal-2.4.1-poppler-0.76.patch (limited to 'sci-libs/gdal') diff --git a/sci-libs/gdal/files/gdal-2.4.1-poppler-0.75.patch b/sci-libs/gdal/files/gdal-2.4.1-poppler-0.75.patch new file mode 100644 index 000000000000..49824022b3be --- /dev/null +++ b/sci-libs/gdal/files/gdal-2.4.1-poppler-0.75.patch @@ -0,0 +1,148 @@ +From 5c12d11614a325317ceaa7c0567070b3e4188275 Mon Sep 17 00:00:00 2001 +From: Even Rouault +Date: Tue, 26 Mar 2019 12:43:59 +0100 +Subject: [PATCH] Add support for Poppler 0.75.0 (fixes #1388) + +--- + gdal/frmts/pdf/pdfio.h | 5 --- + gdal/frmts/pdf/pdfobject.cpp | 59 ++++++++---------------------------- + 2 files changed, 12 insertions(+), 52 deletions(-) + +diff --git a/frmts/pdf/pdfio.h b/frmts/pdf/pdfio.h +index 7ae15c88aa3..ec13b8fe94c 100644 +--- a/frmts/pdf/pdfio.h ++++ b/frmts/pdf/pdfio.h +@@ -93,11 +93,6 @@ class VSIPDFFileStream final: public BaseStream + virtual void close() override; + + private: +- /* getChars/hasGetChars added in poppler 0.15.0 +- * POPPLER_BASE_STREAM_HAS_TWO_ARGS true from poppler 0.16, +- * This test will be wrong for poppler 0.15 or 0.16, +- * but will still compile correctly. +- */ + virtual GBool hasGetChars() override; + virtual int getChars(int nChars, Guchar *buffer) override; + +diff --git a/frmts/pdf/pdfobject.cpp b/frmts/pdf/pdfobject.cpp +--- a/frmts/pdf/pdfobject.cpp ++++ b/frmts/pdf/pdfobject.cpp +@@ -1195,7 +1195,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const char* pszKey) + return oIter->second; + + #if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58 +- Object o = m_poDict->lookupNF(((char*)pszKey)); ++ auto&& o(m_poDict->lookupNF(((char*)pszKey))); + if (!o.isNull()) + { + int nRefNum = 0; +@@ -1204,7 +1204,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const char* pszKey) + { + nRefNum = o.getRefNum(); + nRefGen = o.getRefGen(); +- Object o2 = m_poDict->lookup((char*)pszKey); ++ Object o2(m_poDict->lookup((char*)pszKey)); + if( !o2.isNull() ) + { + GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o2)), TRUE); +@@ -1215,7 +1215,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const char* pszKey) + } + else + { +- GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o)), TRUE); ++ GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o.copy())), TRUE); + poObj->SetRefNumAndGen(nRefNum, nRefGen); + m_map[pszKey] = poObj; + return poObj; +@@ -1329,7 +1329,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) + return m_v[nIndex]; + + #if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58 +- Object o = m_poArray->getNF(nIndex); ++ auto&& o(m_poArray->getNF(nIndex)); + if( !o.isNull() ) + { + int nRefNum = 0; +@@ -1338,7 +1338,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) + { + nRefNum = o.getRefNum(); + nRefGen = o.getRefGen(); +- Object o2 = m_poArray->get(nIndex); ++ Object o2(m_poArray->get(nIndex)); + if( !o2.isNull() ) + { + GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o2)), TRUE); +@@ -1349,7 +1349,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) + } + else + { +- GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o)), TRUE); ++ GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o.copy())), TRUE); + poObj->SetRefNumAndGen(nRefNum, nRefGen); + m_v[nIndex] = poObj; + return poObj; +@@ -1416,8 +1416,6 @@ int GDALPDFStreamPoppler::GetLength() + + char* GDALPDFStreamPoppler::GetBytes() + { +- /* fillGooString() available in poppler >= 0.16.0 */ +-#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS + GooString* gstr = new GooString(); + m_poStream->fillGooString(gstr); + +@@ -1427,7 +1425,12 @@ char* GDALPDFStreamPoppler::GetBytes() + char* pszContent = (char*) VSIMalloc(m_nLength + 1); + if (pszContent) + { +- memcpy(pszContent, gstr->getCString(), m_nLength); ++#if (POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 72) ++ const char* srcStr = gstr->c_str(); ++#else ++ const char* srcStr = gstr->getCString(); ++#endif ++ memcpy(pszContent, srcStr, m_nLength); + pszContent[m_nLength] = '\0'; + } + delete gstr; +@@ -1438,41 +1441,6 @@ char* GDALPDFStreamPoppler::GetBytes() + delete gstr; + return nullptr; + } +-#else +- int i; +- int nLengthAlloc = 0; +- char* pszContent = nullptr; +- if( m_nLength >= 0 ) +- { +- pszContent = (char*) VSIMalloc(m_nLength + 1); +- if (!pszContent) +- return nullptr; +- nLengthAlloc = m_nLength; +- } +- m_poStream->reset(); +- for(i = 0; ; ++i ) +- { +- int nVal = m_poStream->getChar(); +- if (nVal == EOF) +- break; +- if( i >= nLengthAlloc ) +- { +- nLengthAlloc = 32 + nLengthAlloc + nLengthAlloc / 3; +- char* pszContentNew = (char*) VSIRealloc(pszContent, nLengthAlloc + 1); +- if( pszContentNew == nullptr ) +- { +- CPLFree(pszContent); +- m_nLength = 0; +- return nullptr; +- } +- pszContent = pszContentNew; +- } +- pszContent[i] = (GByte)nVal; +- } +- m_nLength = i; +- pszContent[i] = '\0'; +- return pszContent; +-#endif + } + + #endif // HAVE_POPPLER diff --git a/sci-libs/gdal/files/gdal-2.4.1-poppler-0.76.patch b/sci-libs/gdal/files/gdal-2.4.1-poppler-0.76.patch new file mode 100644 index 000000000000..f15e540932d1 --- /dev/null +++ b/sci-libs/gdal/files/gdal-2.4.1-poppler-0.76.patch @@ -0,0 +1,24 @@ +From 8958528f9b5737581afa7249b0e16f2ff89d727e Mon Sep 17 00:00:00 2001 +From: Even Rouault +Date: Sun, 21 Apr 2019 12:19:56 +0200 +Subject: [PATCH] PDF: add support for Poppler 0.76.0 + +--- + gdal/frmts/pdf/pdfsdk_headers.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/frmts/pdf/pdfsdk_headers.h b/frmts/pdf/pdfsdk_headers.h +index 41e48ae91d6..1f77429bf9b 100644 +--- a/frmts/pdf/pdfsdk_headers.h ++++ b/frmts/pdf/pdfsdk_headers.h +@@ -55,7 +55,10 @@ + #else + typedef unsigned char Guchar; + #endif ++ ++#if !(POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 76) + #include ++#endif + + /* begin of poppler xpdf includes */ + #include diff --git a/sci-libs/gdal/gdal-2.4.1.ebuild b/sci-libs/gdal/gdal-2.4.1.ebuild index 303bd716b48f..ac9b89603d03 100644 --- a/sci-libs/gdal/gdal-2.4.1.ebuild +++ b/sci-libs/gdal/gdal-2.4.1.ebuild @@ -82,6 +82,8 @@ PATCHES=( "${FILESDIR}/${PN}-2.2.3-soname.patch" "${FILESDIR}/${PN}-2.2.3-bashcomp-path.patch" # bug 641866 "${FILESDIR}/${PN}-2.3.0-curl.patch" # bug 659840 + "${FILESDIR}/${P}-poppler-0.75.patch" + "${FILESDIR}/${P}-poppler-0.76.patch" ) src_prepare() { @@ -174,7 +176,6 @@ src_configure() { --without-rasterlite2 --without-pcraster --without-pdfium - --without-php --without-podofo --without-qhull --without-sde -- cgit v1.2.3-65-gdbad