Hi,

this fixes build with poppler-0.72.0 for me (at least on i386).

It would be nice if someone could try wether it also build with our old
poppler (0.61.1), so the fix could go in before the poppler update.

Ciao,
        Kili

Index: patches/patch-pdf-backend_cc
===================================================================
RCS file: patches/patch-pdf-backend_cc
diff -N patches/patch-pdf-backend_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pdf-backend_cc        27 Dec 2018 20:20:31 -0000
@@ -0,0 +1,49 @@
+$OpenBSD$
+
+Fix with newer poppler.
+
+From upstream commit 82699eee6b071c1f80682987d6842f4b61d024be.
+
+Index: pdf-backend.cc
+--- pdf-backend.cc.orig
++++ pdf-backend.cc
+@@ -226,7 +226,7 @@ const std::string pdf::Document::get_xmp()
+   mstring.reset(this->readMetadata());
+   if (mstring.get() == nullptr)
+     return "";
+-  const char *cstring = mstring->getCString();
++  const char *cstring = pdf::get_c_string(*mstring);
+   if (strncmp(cstring, "<?xpacket begin=", 16) != 0)
+     return "";
+   cstring += 16;
+@@ -393,7 +393,7 @@ pdf::Metadata::Metadata(pdf::Document &document)
+     char tzs = 0; int tzh = 0, tzm = 0;
+     if (!pdf::dict_lookup(info_dict, field.first, &object)->isString())
+       continue;
+-    const char *input = object.getString()->getCString();
++    const char *input = pdf::get_c_string(object.getString());
+     if (input[0] == 'D' && input[1] == ':')
+       input += 2;
+     int year = scan_date_digits(input, 4);
+@@ -617,6 +617,21 @@ namespace pdf
+     }
+     return stream;
+   }
++}
++
++template<typename S> static auto get_c_string_impl(const S &str) -> 
decltype(str.c_str())
++{
++  return str.c_str();
++}
++
++template<typename S> static auto get_c_string_impl(const S &str) -> 
decltype(str.getCString())
++{
++  return str.getCString();
++}
++
++const char * pdf::get_c_string(const pdf::String &str)
++{
++  return get_c_string_impl<pdf::String>(str);
+ }
+ 
+ // vim:ts=2 sts=2 sw=2 et
Index: patches/patch-pdf-backend_hh
===================================================================
RCS file: patches/patch-pdf-backend_hh
diff -N patches/patch-pdf-backend_hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pdf-backend_hh        27 Dec 2018 20:20:31 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+
+Fix with newer poppler.
+
+From upstream commit 82699eee6b071c1f80682987d6842f4b61d024be.
+
+Index: pdf-backend.hh
+--- pdf-backend.hh.orig
++++ pdf-backend.hh
+@@ -433,6 +433,14 @@ namespace pdf
+ 
+   double get_path_area(pdf::splash::Path &path);
+ 
++  const char * get_c_string(const pdf::String &str);
++
++  inline const char * get_c_string(const pdf::String *str)
++  {
++    return get_c_string(*str);
++  }
++
++
+ }
+ 
+ #endif
Index: patches/patch-pdf-unicode_cc
===================================================================
RCS file: patches/patch-pdf-unicode_cc
diff -N patches/patch-pdf-unicode_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pdf-unicode_cc        27 Dec 2018 20:20:31 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Fix with newer poppler.
+
+From upstream commit 82699eee6b071c1f80682987d6842f4b61d024be.
+
+Index: pdf-unicode.cc
+--- pdf-unicode.cc.orig
++++ pdf-unicode.cc
+@@ -53,7 +53,7 @@ std::string pdf::string_as_utf8(const pdf::String *str
+      * for description of both UTF-16 and UTF-8.
+      */
+     const static uint32_t replacement_character = 0xFFFD;
+-    const char *cstring = string->getCString();
++    const char *cstring = pdf::get_c_string(string);
+ #if POPPLER_VERSION < 3500
+     size_t clength = const_cast<pdf::String *>(string)->getLength();
+ #else
Index: patches/patch-pdf2djvu_cc
===================================================================
RCS file: patches/patch-pdf2djvu_cc
diff -N patches/patch-pdf2djvu_cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-pdf2djvu_cc   27 Dec 2018 20:20:31 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+
+Fix with newer poppler.
+
+From upstream commit 82699eee6b071c1f80682987d6842f4b61d024be.
+
+Index: pdf2djvu.cc
+--- pdf2djvu.cc.orig
++++ pdf2djvu.cc
+@@ -456,7 +456,7 @@ class MutedRenderer: public pdf::Renderer (public)
+     switch (link_action->getKind())
+     {
+     case actionURI:
+-      uri += 
dynamic_cast<pdf::link::URI*>(link_action)->getURI()->getCString();
++      uri += 
pdf::get_c_string(dynamic_cast<pdf::link::URI*>(link_action)->getURI());
+       break;
+     case actionGoTo:
+     {
+@@ -1396,7 +1396,7 @@ static int xmain(int argc, char * const argv[])
+       #pragma omp critical
+       {
+         debug(0)--;
+-        debug(1) << doc->getFileName()->getCString() << ":" << std::endl;
++        debug(1) << pdf::get_c_string(doc->getFileName()) << ":" << std::endl;
+         debug(0)++;
+       }
+       out1.reset(new MainRenderer(paper_color, config.monochrome));

Reply via email to