From 722e121361d0f784083d10e897155b7d4e44e515 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Wed, 5 Sep 2018 00:31:06 +0200 Subject: Modified fix for compatibility with poppler 0.64 This is slightly uglier than a600c6438fef2f4c06f9a4a7d933d99fb054a973 but avoids duplicating strings (which is unnecessary and leaked memory). It's also closer to what upstream intended with the changes in 0.64. --- src/extension/internal/pdfinput/pdf-parser.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/extension/internal/pdfinput/pdf-parser.cpp') diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 5fa21263a..a3a8ff25a 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -32,6 +32,7 @@ #include "pdf-parser.h" #include "util/units.h" +#include "glib/poppler-features.h" #include "goo/gmem.h" #include "goo/GooString.h" #include "GlobalParams.h" @@ -2577,7 +2578,11 @@ void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/) } } +#if POPPLER_CHECK_VERSION(0,64,0) void PdfParser::doShowText(const GooString *s) { +#else +void PdfParser::doShowText(GooString *s) { +#endif GfxFont *font; int wMode; double riseX, riseY; @@ -2590,7 +2595,11 @@ void PdfParser::doShowText(const GooString *s) { Object charProc; Dict *resDict; Parser *oldParser; +#if POPPLER_CHECK_VERSION(0,64,0) + const char *p; +#else char *p; +#endif int len, n, uLen; font = state->getFont(); @@ -2626,7 +2635,7 @@ void PdfParser::doShowText(const GooString *s) { double lineX = state->getLineX(); double lineY = state->getLineY(); oldParser = parser; - p = g_strdup(s->getCString()); + p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, @@ -2681,7 +2690,7 @@ void PdfParser::doShowText(const GooString *s) { } else { state->textTransformDelta(0, state->getRise(), &riseX, &riseY); - p = g_strdup(s->getCString()); + p = s->getCString(); len = s->getLength(); while (len > 0) { n = font->getNextChar(p, len, &code, @@ -2727,7 +2736,11 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/) { Object obj1, obj2, obj3, refObj; - char *name = g_strdup(args[0].getName()); +#if POPPLER_CHECK_VERSION(0,64,0) + const char *name = args[0].getName(); +#else + char *name = args[0].getName(); +#endif #if defined(POPPLER_NEW_OBJECT_API) if ((obj1 = res->lookupXObject(name)).isNull()) { #else -- cgit v1.2.3