From 86e1bec9b982a313576f070439940510068ac41e Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Mon, 16 Nov 2026 06:38:24 -0300
Subject: Use nullptr in Xpdf engine sources
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Group document, font, rendering, and stream handling around the xpdf-static target.

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 kpdf/xpdf/xpdf/Annot.cpp              |  38 +++++-----
 kpdf/xpdf/xpdf/Array.cpp              |   2 +-
 kpdf/xpdf/xpdf/BuiltinFont.cpp        |   2 +-
 kpdf/xpdf/xpdf/CMap.cpp               |   8 +-
 kpdf/xpdf/xpdf/Catalog.cpp            |  24 +++---
 kpdf/xpdf/xpdf/CharCodeToUnicode.cpp  |  20 ++---
 kpdf/xpdf/xpdf/Decrypt.cpp            |   4 +-
 kpdf/xpdf/xpdf/Dict.cpp               |   4 +-
 kpdf/xpdf/xpdf/Function.cpp           |  24 +++---
 kpdf/xpdf/xpdf/Gfx.cpp                |  88 +++++++++++-----------
 kpdf/xpdf/xpdf/Gfx.h                  |  14 ++--
 kpdf/xpdf/xpdf/GfxFont.cpp            |  60 +++++++--------
 kpdf/xpdf/xpdf/GfxState.cpp           | 100 ++++++++++++------------
 kpdf/xpdf/xpdf/GfxState.h             |   4 +-
 kpdf/xpdf/xpdf/GlobalParams.cpp       |  98 ++++++++++++------------
 kpdf/xpdf/xpdf/JArithmeticDecoder.cpp |   2 +-
 kpdf/xpdf/xpdf/JBIG2Stream.cpp        |  86 ++++++++++-----------
 kpdf/xpdf/xpdf/JPXStream.cpp          |  30 ++++----
 kpdf/xpdf/xpdf/Lexer.cpp              |   8 +-
 kpdf/xpdf/xpdf/Lexer.h                |   2 +-
 kpdf/xpdf/xpdf/Link.cpp               |  38 +++++-----
 kpdf/xpdf/xpdf/Link.h                 |  12 +--
 kpdf/xpdf/xpdf/NameToCharCode.cpp     |   4 +-
 kpdf/xpdf/xpdf/NameToUnicodeTable.h   |   2 +-
 kpdf/xpdf/xpdf/Outline.cpp            |  10 +--
 kpdf/xpdf/xpdf/OutputDev.cpp          |   4 +-
 kpdf/xpdf/xpdf/OutputDev.h            |   4 +-
 kpdf/xpdf/xpdf/PDFDoc.cpp             |  32 ++++----
 kpdf/xpdf/xpdf/PDFDoc.h               |  24 +++---
 kpdf/xpdf/xpdf/PSOutputDev.cpp        |  94 +++++++++++------------
 kpdf/xpdf/xpdf/PSOutputDev.h          |   4 +-
 kpdf/xpdf/xpdf/Page.cpp               |   4 +-
 kpdf/xpdf/xpdf/Page.h                 |  22 +++---
 kpdf/xpdf/xpdf/Parser.cpp             |   4 +-
 kpdf/xpdf/xpdf/Parser.h               |   2 +-
 kpdf/xpdf/xpdf/SecurityHandler.cpp    |  40 +++++-----
 kpdf/xpdf/xpdf/SplashOutputDev.cpp    |  68 ++++++++---------
 kpdf/xpdf/xpdf/Stream.cpp             |  64 ++++++++--------
 kpdf/xpdf/xpdf/Stream.h               |  14 ++--
 kpdf/xpdf/xpdf/TextOutputDev.cpp      | 138 +++++++++++++++++-----------------
 kpdf/xpdf/xpdf/UnicodeMap.cpp         |  18 ++---
 kpdf/xpdf/xpdf/XRef.cpp               |  24 +++---
 42 files changed, 622 insertions(+), 622 deletions(-)

diff --git a/kpdf/xpdf/xpdf/Annot.cpp b/kpdf/xpdf/xpdf/Annot.cpp
index 10d3ce73..6e7a0d03 100644
--- a/kpdf/xpdf/xpdf/Annot.cpp
+++ b/kpdf/xpdf/xpdf/Annot.cpp
@@ -97,9 +97,9 @@ Annot::Annot(XRef *xrefA, Dict * /*acroForm*/, Dict *dict, Ref *refA) {
   ok = gTrue;
   xref = xrefA;
   ref = *refA;
-  type = NULL;
-  appearBuf = NULL;
-  borderStyle = NULL;
+  type = nullptr;
+  appearBuf = nullptr;
+  borderStyle = nullptr;
 
   //----- parse the type
 
@@ -154,7 +154,7 @@ Annot::Annot(XRef *xrefA, Dict * /*acroForm*/, Dict *dict, Ref *refA) {
 
   borderType = annotBorderSolid;
   borderWidth = 1;
-  borderDash = NULL;
+  borderDash = nullptr;
   borderDashLength = 0;
   borderR = 0;
   borderG = 0;
@@ -307,7 +307,7 @@ void Annot::generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm) {
   if (annot->lookup("MK", &mkObj)->isDict()) {
     mkDict = mkObj.getDict();
   } else {
-    mkDict = NULL;
+    mkDict = nullptr;
   }
 
   // draw the background
@@ -436,9 +436,9 @@ void Annot::generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm) {
 
   // build the font dictionary
   if (drObj.isDict() && drObj.dictLookup("Font", &obj1)->isDict()) {
-    fontDict = new GfxFontDict(xref, NULL, obj1.getDict());
+    fontDict = new GfxFontDict(xref, nullptr, obj1.getDict());
   } else {
-    fontDict = NULL;
+    fontDict = nullptr;
   }
   obj1.free();
 
@@ -450,13 +450,13 @@ void Annot::generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm) {
   if (obj1.isString()) {
     da = obj1.getString()->copy();
   } else {
-    da = NULL;
+    da = nullptr;
   }
   obj1.free();
 
   // draw the field contents
   if (ftObj.isName("Btn")) {
-    caption = NULL;
+    caption = nullptr;
     if (mkDict) {
       if (mkDict->lookup("CA", &obj1)->isString()) {
 	caption = obj1.getString()->copy();
@@ -554,7 +554,7 @@ void Annot::generateFieldAppearance(Dict *field, Dict *annot, Dict *acroForm) {
 	// get the option text
 	text = (GString **)gmallocn(nOptions, sizeof(GString *));
 	for (i = 0; i < nOptions; ++i) {
-	  text[i] = NULL;
+	  text[i] = nullptr;
 	  obj1.arrayGet(i, &obj2);
 	  if (obj2.isString()) {
 	    text[i] = obj2.getString()->copy();
@@ -735,7 +735,7 @@ void Annot::drawText(GString *text, GString *da, GfxFontDict *fontDict,
       }
     }
   } else {
-    daToks = NULL;
+    daToks = nullptr;
   }
 
   // force ZapfDingbats
@@ -751,7 +751,7 @@ void Annot::drawText(GString *text, GString *da, GfxFontDict *fontDict,
   }
 
   // get the font and font size
-  font = NULL;
+  font = nullptr;
   fontSize = 0;
   if (tfPos >= 0) {
     tok = (GString *)daToks->get(tfPos);
@@ -1095,11 +1095,11 @@ void Annot::drawListBox(GString **text, GBool *selection,
       }
     }
   } else {
-    daToks = NULL;
+    daToks = nullptr;
   }
 
   // get the font and font size
-  font = NULL;
+  font = nullptr;
   fontSize = 0;
   if (tfPos >= 0) {
     tok = (GString *)daToks->get(tfPos);
@@ -1423,7 +1423,7 @@ void Annot::draw(Gfx *gfx, GBool printing) {
   // draw the appearance stream
   isLink = type && !type->cmp("Link");
   appearance.fetch(xref, &obj);
-  gfx->drawAnnot(&obj, isLink ? borderStyle : (AnnotBorderStyle *)NULL,
+  gfx->drawAnnot(&obj, isLink ? borderStyle : (AnnotBorderStyle *)nullptr,
 		 xMin, yMin, xMax, yMax);
   obj.free();
 }
@@ -1440,12 +1440,12 @@ Annots::Annots(XRef *xref, Catalog *catalog, Object *annotsObj) {
   int size;
   int i;
 
-  annots = NULL;
+  annots = nullptr;
   size = 0;
   nAnnots = 0;
 
   acroForm = catalog->getAcroForm()->isDict() ?
-               catalog->getAcroForm()->getDict() : NULL;
+               catalog->getAcroForm()->getDict() : nullptr;
   if (annotsObj->isArray()) {
     for (i = 0; i < annotsObj->arrayGetLength(); ++i) {
       if (annotsObj->arrayGetNF(i, &obj1)->isRef()) {
@@ -1496,7 +1496,7 @@ void Annots::generateAppearances(Dict *acroForm) {
 	ref.num = ref.gen = -1;
       }
       if (obj2.isDict()) {
-	scanFieldAppearances(obj2.getDict(), &ref, NULL, acroForm);
+	scanFieldAppearances(obj2.getDict(), &ref, nullptr, acroForm);
       }
       obj2.free();
     }
@@ -1552,5 +1552,5 @@ Annot *Annots::findAnnot(Ref *ref) {
       return annots[i];
     }
   }
-  return NULL;
+  return nullptr;
 }
diff --git a/kpdf/xpdf/xpdf/Array.cpp b/kpdf/xpdf/xpdf/Array.cpp
index 7c54605a..0f9070d2 100644
--- a/kpdf/xpdf/xpdf/Array.cpp
+++ b/kpdf/xpdf/xpdf/Array.cpp
@@ -24,7 +24,7 @@
 
 Array::Array(XRef *xrefA) {
   xref = xrefA;
-  elems = NULL;
+  elems = nullptr;
   size = length = 0;
   ref = 1;
 }
diff --git a/kpdf/xpdf/xpdf/BuiltinFont.cpp b/kpdf/xpdf/xpdf/BuiltinFont.cpp
index 6e9d2375..d7809283 100644
--- a/kpdf/xpdf/xpdf/BuiltinFont.cpp
+++ b/kpdf/xpdf/xpdf/BuiltinFont.cpp
@@ -26,7 +26,7 @@ BuiltinFontWidths::BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA) {
   size = sizeA;
   tab = (BuiltinFontWidth **)gmallocn(size, sizeof(BuiltinFontWidth *));
   for (i = 0; i < size; ++i) {
-    tab[i] = NULL;
+    tab[i] = nullptr;
   }
   for (i = 0; i < sizeA; ++i) {
     h = hash(widths[i].name);
diff --git a/kpdf/xpdf/xpdf/CMap.cpp b/kpdf/xpdf/xpdf/CMap.cpp
index dfad915f..8e414ca2 100644
--- a/kpdf/xpdf/xpdf/CMap.cpp
+++ b/kpdf/xpdf/xpdf/CMap.cpp
@@ -63,7 +63,7 @@ CMap *CMap::parse(CMapCache *cache, GString *collectionA,
 
     error(-1, "Couldn't find '%s' CMap file for '%s' collection",
 	  cMapNameA->getCString(), collectionA->getCString());
-    return NULL;
+    return nullptr;
   }
 
   cmap = new CMap(collectionA->copy(), cMapNameA->copy());
@@ -177,7 +177,7 @@ CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) {
   collection = collectionA;
   cMapName = cMapNameA;
   wMode = wModeA;
-  vector = NULL;
+  vector = nullptr;
   refCnt = 1;
 #if MULTITHREADED
   gInitMutex(&mutex);
@@ -360,7 +360,7 @@ CMapCache::CMapCache() {
   int i;
 
   for (i = 0; i < cMapCacheSize; ++i) {
-    cache[i] = NULL;
+    cache[i] = nullptr;
   }
 }
 
@@ -404,5 +404,5 @@ CMap *CMapCache::getCMap(GString *collection, GString *cMapName) {
     cmap->incRefCnt();
     return cmap;
   }
-  return NULL;
+  return nullptr;
 }
diff --git a/kpdf/xpdf/xpdf/Catalog.cpp b/kpdf/xpdf/xpdf/Catalog.cpp
index ce64af09..f3f39afc 100644
--- a/kpdf/xpdf/xpdf/Catalog.cpp
+++ b/kpdf/xpdf/xpdf/Catalog.cpp
@@ -37,10 +37,10 @@ Catalog::Catalog(XRef *xrefA) {
 
   ok = gTrue;
   xref = xrefA;
-  pages = NULL;
-  pageRefs = NULL;
+  pages = nullptr;
+  pageRefs = nullptr;
   numPages = pagesSize = 0;
-  baseURI = NULL;
+  baseURI = nullptr;
 
   xref->getCatalog(&catDict);
   if (!catDict.isDict()) {
@@ -69,7 +69,7 @@ Catalog::Catalog(XRef *xrefA) {
   pages = (Page **)gmallocn(pagesSize, sizeof(Page *));
   pageRefs = (Ref *)gmallocn(pagesSize, sizeof(Ref));
   for (i = 0; i < pagesSize; ++i) {
-    pages[i] = NULL;
+    pages[i] = nullptr;
     pageRefs[i].num = -1;
     pageRefs[i].gen = -1;
   }
@@ -81,7 +81,7 @@ Catalog::Catalog(XRef *xrefA) {
     alreadyRead[pagesDictRef.getRefNum()] = 1;
   }
   pagesDictRef.free();
-  numPages = readPageTree(pagesDict.getDict(), NULL, 0, alreadyRead);
+  numPages = readPageTree(pagesDict.getDict(), nullptr, 0, alreadyRead);
   gfree(alreadyRead);
   if (numPages != numPages0) {
     error(-1, "Page count in top-level pages object is incorrect");
@@ -182,7 +182,7 @@ GString *Catalog::readMetadata() {
   int c;
 
   if (!metadata.isStream()) {
-    return NULL;
+    return nullptr;
   }
   dict = metadata.streamGetDict();
   if (!dict->lookup("Subtype", &obj)->isName("XML")) {
@@ -240,7 +240,7 @@ int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start,
 	pages = (Page **)greallocn(pages, pagesSize, sizeof(Page *));
 	pageRefs = (Ref *)greallocn(pageRefs, pagesSize, sizeof(Ref));
 	for (j = pagesSize - 32; j < pagesSize; ++j) {
-	  pages[j] = NULL;
+	  pages[j] = nullptr;
 	  pageRefs[j].num = -1;
 	  pageRefs[j].gen = -1;
 	}
@@ -309,10 +309,10 @@ LinkDest *Catalog::findDest(GString *name) {
       obj1.free();
   }
   if (!found)
-    return NULL;
+    return nullptr;
 
   // construct LinkDest
-  dest = NULL;
+  dest = nullptr;
   if (obj1.isArray()) {
     dest = new LinkDest(obj1.getArray());
   } else if (obj1.isDict()) {
@@ -327,7 +327,7 @@ LinkDest *Catalog::findDest(GString *name) {
   obj1.free();
   if (dest && !dest->isOk()) {
     delete dest;
-    dest = NULL;
+    dest = nullptr;
   }
 
   return dest;
@@ -337,7 +337,7 @@ NameTree::NameTree()
 {
   size = 0;
   length = 0;
-  entries = NULL;
+  entries = nullptr;
 }
 
 NameTree::Entry::Entry(Array *array, int index) {
@@ -420,7 +420,7 @@ GBool NameTree::lookup(GString *name, Object *obj)
       obj->initNull();
       return gFalse;
   }
-  if (entry != NULL) {
+  if (entry) {
     entry->value.fetch(xref, obj);
     return gTrue;
   } else {
diff --git a/kpdf/xpdf/xpdf/CharCodeToUnicode.cpp b/kpdf/xpdf/xpdf/CharCodeToUnicode.cpp
index 1144caec..0271d7f3 100644
--- a/kpdf/xpdf/xpdf/CharCodeToUnicode.cpp
+++ b/kpdf/xpdf/xpdf/CharCodeToUnicode.cpp
@@ -66,7 +66,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GString *fileName,
   if (!(f = fopen(fileName->getCString(), "r"))) {
     error(-1, "Couldn't open cidToUnicode file '%s'",
 	  fileName->getCString());
-    return NULL;
+    return nullptr;
   }
 
   size = 32768;
@@ -90,7 +90,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GString *fileName,
   fclose(f);
 
   ctu = new CharCodeToUnicode(collection->copy(), mapA, mapLenA, gTrue,
-			      NULL, 0, 0);
+			      nullptr, 0, 0);
   gfree(mapA);
   return ctu;
 }
@@ -111,14 +111,14 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode(
   if (!(f = fopen(fileName->getCString(), "r"))) {
     error(-1, "Couldn't open unicodeToUnicode file '%s'",
 	  fileName->getCString());
-    return NULL;
+    return nullptr;
   }
 
   size = 4096;
   mapA = (Unicode *)gmallocn(size, sizeof(Unicode));
   memset(mapA, 0, size * sizeof(Unicode));
   len = 0;
-  sMapA = NULL;
+  sMapA = nullptr;
   sMapSizeA = sMapLenA = 0;
 
   line = 0;
@@ -132,7 +132,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode(
     }
     n = 0;
     while (n < maxUnicodeString) {
-      if (!(tok = strtok(NULL, " \t\r\n"))) {
+      if (!(tok = strtok(nullptr, " \t\r\n"))) {
 	break;
       }
       if (sscanf(tok, "%x", &uBuf[n]) != 1) {
@@ -184,14 +184,14 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode(
 }
 
 CharCodeToUnicode *CharCodeToUnicode::make8BitToUnicode(Unicode *toUnicode) {
-  return new CharCodeToUnicode(NULL, toUnicode, 256, gTrue, NULL, 0, 0);
+  return new CharCodeToUnicode(nullptr, toUnicode, 256, gTrue, nullptr, 0, 0);
 }
 
 CharCodeToUnicode *CharCodeToUnicode::parseCMap(GString *buf, int nBits) {
   CharCodeToUnicode *ctu;
   char *p;
 
-  ctu = new CharCodeToUnicode(NULL);
+  ctu = new CharCodeToUnicode(nullptr);
   p = buf->getCString();
   ctu->parseCMap1(&getCharFromString, &p, nBits);
   return ctu;
@@ -361,7 +361,7 @@ CharCodeToUnicode::CharCodeToUnicode(GString *tagA) {
   for (i = 0; i < mapLen; ++i) {
     map[i] = 0;
   }
-  sMap = NULL;
+  sMap = nullptr;
   sMapLen = sMapSize = 0;
   refCnt = 1;
 #if MULTITHREADED
@@ -489,7 +489,7 @@ CharCodeToUnicodeCache::CharCodeToUnicodeCache(int sizeA) {
   size = sizeA;
   cache = (CharCodeToUnicode **)gmallocn(size, sizeof(CharCodeToUnicode *));
   for (i = 0; i < size; ++i) {
-    cache[i] = NULL;
+    cache[i] = nullptr;
   }
 }
 
@@ -523,7 +523,7 @@ CharCodeToUnicode *CharCodeToUnicodeCache::getCharCodeToUnicode(GString *tag) {
       return ctu;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void CharCodeToUnicodeCache::add(CharCodeToUnicode *ctu) {
diff --git a/kpdf/xpdf/xpdf/Decrypt.cpp b/kpdf/xpdf/xpdf/Decrypt.cpp
index b3646292..5c9748db 100644
--- a/kpdf/xpdf/xpdf/Decrypt.cpp
+++ b/kpdf/xpdf/xpdf/Decrypt.cpp
@@ -1472,14 +1472,14 @@ static GBool makeAES256FileKey(int encRevision, int keyLength,
     memcpy(test + len, userKey->getCString() + 32, 8);
     sha256(test, len + 8, test);
     if (encRevision == 6) {
-      revision6Hash(userPassword, test, NULL);
+      revision6Hash(userPassword, test, nullptr);
     }
     if (!memcmp(test, userKey->getCString(), 32)) {
       memcpy(test, userPassword->getCString(), len);
       memcpy(test + len, userKey->getCString() + 40, 8);
       sha256(test, len + 8, test);
       if (encRevision == 6) {
-        revision6Hash(userPassword, test, NULL);
+        revision6Hash(userPassword, test, nullptr);
       }
       aes256KeyExpansion(&state, test, gTrue);
       memset(state.cbc, 0, sizeof(state.cbc));
diff --git a/kpdf/xpdf/xpdf/Dict.cpp b/kpdf/xpdf/xpdf/Dict.cpp
index 593e9a11..42c01214 100644
--- a/kpdf/xpdf/xpdf/Dict.cpp
+++ b/kpdf/xpdf/xpdf/Dict.cpp
@@ -25,7 +25,7 @@
 
 Dict::Dict(XRef *xrefA) {
   xref = xrefA;
-  entries = NULL;
+  entries = nullptr;
   size = length = 0;
   ref = 1;
 }
@@ -61,7 +61,7 @@ inline DictEntry *Dict::find(char *key) {
     if (!strcmp(key, entries[i].key))
       return &entries[i];
   }
-  return NULL;
+  return nullptr;
 }
 
 GBool Dict::is(char *type) {
diff --git a/kpdf/xpdf/xpdf/Function.cpp b/kpdf/xpdf/xpdf/Function.cpp
index f36c8f6c..1a88e52c 100644
--- a/kpdf/xpdf/xpdf/Function.cpp
+++ b/kpdf/xpdf/xpdf/Function.cpp
@@ -47,13 +47,13 @@ Function *Function::parse(Object *funcObj) {
     return new IdentityFunction();
   } else {
     error(-1, "Expected function dictionary or stream");
-    return NULL;
+    return nullptr;
   }
 
   if (!dict->lookup("FunctionType", &obj1)->isInt()) {
     error(-1, "Function type is missing or wrong type");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   funcType = obj1.getInt();
   obj1.free();
@@ -68,11 +68,11 @@ Function *Function::parse(Object *funcObj) {
     func = new PostScriptFunction(funcObj, dict);
   } else {
     error(-1, "Unimplemented function type (%d)", funcType);
-    return NULL;
+    return nullptr;
   }
   if (!func->isOk()) {
     delete func;
-    return NULL;
+    return nullptr;
   }
 
   return func;
@@ -193,8 +193,8 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) {
   Guint s;
   int i;
 
-  samples = NULL;
-  sBuf = NULL;
+  samples = nullptr;
+  sBuf = nullptr;
   ok = gFalse;
 
   //----- initialize the generic stuff
@@ -549,10 +549,10 @@ StitchingFunction::StitchingFunction(Object * /*funcObj*/, Dict *dict) {
   int i;
 
   ok = gFalse;
-  funcs = NULL;
-  bounds = NULL;
-  encode = NULL;
-  scale = NULL;
+  funcs = nullptr;
+  bounds = nullptr;
+  encode = nullptr;
+  scale = nullptr;
 
   //----- initialize the generic stuff
   if (!init(dict)) {
@@ -574,7 +574,7 @@ StitchingFunction::StitchingFunction(Object * /*funcObj*/, Dict *dict) {
   encode = (double *)gmallocn(2 * k, sizeof(double));
   scale = (double *)gmallocn(k, sizeof(double));
   for (i = 0; i < k; ++i) {
-    funcs[i] = NULL;
+    funcs[i] = nullptr;
   }
   for (i = 0; i < k; ++i) {
     if (!(funcs[i] = Function::parse(obj1.arrayGet(i, &obj2)))) {
@@ -1003,7 +1003,7 @@ PostScriptFunction::PostScriptFunction(Object *funcObj, Dict *dict) {
   int codePtr;
   GString *tok;
 
-  code = NULL;
+  code = nullptr;
   codeSize = 0;
   ok = gFalse;
 
diff --git a/kpdf/xpdf/xpdf/Gfx.cpp b/kpdf/xpdf/xpdf/Gfx.cpp
index 2a4fdb6e..ac3ea756 100644
--- a/kpdf/xpdf/xpdf/Gfx.cpp
+++ b/kpdf/xpdf/xpdf/Gfx.cpp
@@ -269,7 +269,7 @@ GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) {
   if (resDict) {
 
     // build font dictionary
-    fonts = NULL;
+    fonts = nullptr;
     resDict->lookupNF("Font", &obj1);
     if (obj1.isRef()) {
       obj1.fetch(xref, &obj2);
@@ -279,7 +279,7 @@ GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) {
       }
       obj2.free();
     } else if (obj1.isDict()) {
-      fonts = new GfxFontDict(xref, NULL, obj1.getDict());
+      fonts = new GfxFontDict(xref, nullptr, obj1.getDict());
     }
     obj1.free();
 
@@ -299,7 +299,7 @@ GfxResources::GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA) {
     resDict->lookup("ExtGState", &gStateDict);
 
   } else {
-    fonts = NULL;
+    fonts = nullptr;
     xObjDict.initNull();
     colorSpaceDict.initNull();
     patternDict.initNull();
@@ -332,7 +332,7 @@ GfxFont *GfxResources::lookupFont(char *name) {
     }
   }
   error(-1, "Unknown font tag '%s'", name);
-  return NULL;
+  return nullptr;
 }
 
 GBool GfxResources::lookupXObject(char *name, Object *obj) {
@@ -393,7 +393,7 @@ GfxPattern *GfxResources::lookupPattern(char *name) {
     }
   }
   error(-1, "Unknown pattern '%s'", name);
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxResources::lookupShading(char *name) {
@@ -412,7 +412,7 @@ GfxShading *GfxResources::lookupShading(char *name) {
     }
   }
   error(-1, "Unknown shading '%s'", name);
-  return NULL;
+  return nullptr;
 }
 
 GBool GfxResources::lookupGState(char *name, Object *obj) {
@@ -446,7 +446,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
   printCommands = globalParams->getPrintCommands();
 
   // start the resource stack
-  res = new GfxResources(xref, resDict, NULL);
+  res = new GfxResources(xref, resDict, nullptr);
 
   // initialize
   out = outA;
@@ -461,7 +461,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
     baseMatrix[i] = state->getCTM()[i];
   }
   formDepth = 0;
-  parser = NULL;
+  parser = nullptr;
   abortCheckCbk = abortCheckCbkA;
   abortCheckCbkData = abortCheckCbkDataA;
 
@@ -489,7 +489,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
   printCommands = globalParams->getPrintCommands();
 
   // start the resource stack
-  res = new GfxResources(xref, resDict, NULL);
+  res = new GfxResources(xref, resDict, nullptr);
 
   // initialize
   out = outA;
@@ -501,7 +501,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
     baseMatrix[i] = state->getCTM()[i];
   }
   formDepth = 0;
-  parser = NULL;
+  parser = nullptr;
   abortCheckCbk = abortCheckCbkA;
   abortCheckCbkData = abortCheckCbkDataA;
 
@@ -554,7 +554,7 @@ void Gfx::display(Object *obj, GBool topLevel) {
   parser = new Parser(xref, new Lexer(xref, obj), gFalse);
   go(topLevel);
   delete parser;
-  parser = NULL;
+  parser = nullptr;
 }
 
 void Gfx::go(GBool topLevel) {
@@ -709,7 +709,7 @@ Operator *Gfx::findOp(char *name) {
       a = b = m;
   }
   if (cmp != 0)
-    return NULL;
+    return nullptr;
   return &opTab[a];
 }
 
@@ -764,7 +764,7 @@ void Gfx::opSetDash(Object args[], int /*numArgs*/) {
   a = args[0].getArray();
   length = a->getLength();
   if (length == 0) {
-    dash = NULL;
+    dash = nullptr;
   } else {
     dash = (double *)gmallocn(length, sizeof(double));
     for (i = 0; i < length; ++i) {
@@ -877,7 +877,7 @@ void Gfx::opSetExtGState(Object args[], int /*numArgs*/) {
   }
   if (obj2.isName("Default") ||
       obj2.isName("Identity")) {
-    funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL;
+    funcs[0] = funcs[1] = funcs[2] = funcs[3] = nullptr;
     state->setTransfer(funcs);
     out->updateTransfer(state);
   } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
@@ -895,7 +895,7 @@ void Gfx::opSetExtGState(Object args[], int /*numArgs*/) {
     }
   } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) {
     if ((funcs[0] = Function::parse(&obj2))) {
-      funcs[1] = funcs[2] = funcs[3] = NULL;
+      funcs[1] = funcs[2] = funcs[3] = nullptr;
       state->setTransfer(funcs);
       out->updateTransfer(state);
     }
@@ -915,7 +915,7 @@ void Gfx::opSetExtGState(Object args[], int /*numArgs*/) {
 	alpha = gFalse;
       }
       obj3.free();
-      funcs[0] = NULL;
+      funcs[0] = nullptr;
       if (!obj2.dictLookup("TR", &obj3)->isNull()) {
 	funcs[0] = Function::parse(&obj3);
 	if (funcs[0]->getInputSize() != 1 ||
@@ -923,7 +923,7 @@ void Gfx::opSetExtGState(Object args[], int /*numArgs*/) {
 	  error(getPos(),
 		"Invalid transfer function in soft mask in ExtGState");
 	  delete funcs[0];
-	  funcs[0] = NULL;
+	  funcs[0] = nullptr;
 	}
       }
       obj3.free();
@@ -942,7 +942,7 @@ void Gfx::opSetExtGState(Object args[], int /*numArgs*/) {
       obj3.free();
       if (obj2.dictLookup("G", &obj3)->isStream()) {
 	if (obj3.streamGetDict()->lookup("Group", &obj4)->isDict()) {
-	  blendingColorSpace = NULL;
+	  blendingColorSpace = nullptr;
 	  isolated = knockout = gFalse;
 	  if (!obj4.dictLookup("CS", &obj5)->isNull()) {
 	    blendingColorSpace = GfxColorSpace::parse(&obj5);
@@ -1043,7 +1043,7 @@ void Gfx::doSoftMask(Object *str, GBool alpha,
 
   // get resources
   dict->lookup("Resources", &obj1);
-  resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL;
+  resDict = obj1.isDict() ? obj1.getDict() : (Dict *)nullptr;
 
   // draw it
   ++formDepth;
@@ -1068,7 +1068,7 @@ void Gfx::opSetRenderingIntent(Object * /*args[]*/, int /*numArgs*/) {
 void Gfx::opSetFillGray(Object args[], int /*numArgs*/) {
   GfxColor color;
 
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   state->setFillColorSpace(new GfxDeviceGrayColorSpace());
   out->updateFillColorSpace(state);
   color.c[0] = dblToCol(args[0].getNum());
@@ -1079,7 +1079,7 @@ void Gfx::opSetFillGray(Object args[], int /*numArgs*/) {
 void Gfx::opSetStrokeGray(Object args[], int /*numArgs*/) {
   GfxColor color;
 
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   state->setStrokeColorSpace(new GfxDeviceGrayColorSpace());
   out->updateStrokeColorSpace(state);
   color.c[0] = dblToCol(args[0].getNum());
@@ -1091,7 +1091,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int /*numArgs*/) {
   GfxColor color;
   int i;
 
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   state->setFillColorSpace(new GfxDeviceCMYKColorSpace());
   out->updateFillColorSpace(state);
   for (i = 0; i < 4; ++i) {
@@ -1105,7 +1105,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int /*numArgs*/) {
   GfxColor color;
   int i;
 
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   state->setStrokeColorSpace(new GfxDeviceCMYKColorSpace());
   out->updateStrokeColorSpace(state);
   for (i = 0; i < 4; ++i) {
@@ -1119,7 +1119,7 @@ void Gfx::opSetFillRGBColor(Object args[], int /*numArgs*/) {
   GfxColor color;
   int i;
 
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   state->setFillColorSpace(new GfxDeviceRGBColorSpace());
   out->updateFillColorSpace(state);
   for (i = 0; i < 3; ++i) {
@@ -1133,7 +1133,7 @@ void Gfx::opSetStrokeRGBColor(Object args[], int /*numArgs*/) {
   GfxColor color;
   int i;
 
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
   out->updateStrokeColorSpace(state);
   for (i = 0; i < 3; ++i) {
@@ -1148,7 +1148,7 @@ void Gfx::opSetFillColorSpace(Object args[], int /*numArgs*/) {
   GfxColorSpace *colorSpace;
   GfxColor color;
 
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&args[0]);
@@ -1172,7 +1172,7 @@ void Gfx::opSetStrokeColorSpace(Object args[], int /*numArgs*/) {
   GfxColorSpace *colorSpace;
   GfxColor color;
 
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   res->lookupColorSpace(args[0].getName(), &obj);
   if (obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&args[0]);
@@ -1199,7 +1199,7 @@ void Gfx::opSetFillColor(Object args[], int numArgs) {
     error(getPos(), "Incorrect number of arguments in 'sc' command");
     return;
   }
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   for (i = 0; i < numArgs; ++i) {
     color.c[i] = dblToCol(args[i].getNum());
   }
@@ -1215,7 +1215,7 @@ void Gfx::opSetStrokeColor(Object args[], int numArgs) {
     error(getPos(), "Incorrect number of arguments in 'SC' command");
     return;
   }
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   for (i = 0; i < numArgs; ++i) {
     color.c[i] = dblToCol(args[i].getNum());
   }
@@ -1254,7 +1254,7 @@ void Gfx::opSetFillColorN(Object args[], int numArgs) {
       error(getPos(), "Incorrect number of arguments in 'scn' command");
       return;
     }
-    state->setFillPattern(NULL);
+    state->setFillPattern(nullptr);
     for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) {
       if (args[i].isNum()) {
 	color.c[i] = dblToCol(args[i].getNum());
@@ -1297,7 +1297,7 @@ void Gfx::opSetStrokeColorN(Object args[], int numArgs) {
       error(getPos(), "Incorrect number of arguments in 'SCN' command");
       return;
     }
-    state->setStrokePattern(NULL);
+    state->setStrokePattern(nullptr);
     for (i = 0; i < numArgs && i < gfxColorMaxComps; ++i) {
       if (args[i].isNum()) {
 	color.c[i] = dblToCol(args[i].getNum());
@@ -1672,9 +1672,9 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
     state->setStrokeColorSpace(new GfxDeviceGrayColorSpace());
     out->updateStrokeColorSpace(state);
   }
-  state->setFillPattern(NULL);
+  state->setFillPattern(nullptr);
   out->updateFillColor(state);
-  state->setStrokePattern(NULL);
+  state->setStrokePattern(nullptr);
   out->updateStrokeColor(state);
   if (!stroke) {
     state->setLineWidth(0);
@@ -3343,7 +3343,7 @@ void Gfx::opXObject(Object args[], int /*numArgs*/) {
   } else if (obj2.isName("PS")) {
     obj1.streamGetDict()->lookup("Level1", &obj3);
     out->psXObject(obj1.getStream(),
-		   obj3.isStream() ? obj3.getStream() : (Stream *)NULL);
+		   obj3.isStream() ? obj3.getStream() : (Stream *)nullptr);
   } else if (obj2.isName()) {
     error(getPos(), "Unknown XObject subtype '%s'", obj2.getName());
   } else {
@@ -3492,7 +3492,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
     } else if (csMode == streamCSDeviceCMYK) {
       colorSpace = new GfxDeviceCMYKColorSpace();
     } else {
-      colorSpace = NULL;
+      colorSpace = nullptr;
     }
     obj1.free();
     if (!colorSpace) {
@@ -3512,10 +3512,10 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
 
     // get the mask
     haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
-    maskStr = NULL; // make gcc happy
+    maskStr = nullptr; // make gcc happy
     maskWidth = maskHeight = 0; // make gcc happy
     maskInvert = gFalse; // make gcc happy
-    maskColorMap = NULL; // make gcc happy
+    maskColorMap = nullptr; // make gcc happy
     dict->lookup("Mask", &maskObj);
     dict->lookup("SMask", &smaskObj);
     if (smaskObj.isStream()) {
@@ -3662,7 +3662,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
 			   maskStr, maskWidth, maskHeight, maskInvert);
     } else {
       out->drawImage(state, ref, str, width, height, colorMap,
-		     haveColorKeyMask ? maskColors : (int *)NULL, inlineImg);
+		     haveColorKeyMask ? maskColors : (int *)nullptr, inlineImg);
     }
     delete colorMap;
 
@@ -3740,11 +3740,11 @@ void Gfx::doForm(Object *str) {
 
   // get resources
   dict->lookup("Resources", &resObj);
-  resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL;
+  resDict = resObj.isDict() ? resObj.getDict() : (Dict *)nullptr;
 
   // check for a transparency group
   transpGroup = isolated = knockout = gFalse;
-  blendingColorSpace = NULL;
+  blendingColorSpace = nullptr;
   if (dict->lookup("Group", &obj1)->isDict()) {
     if (obj1.dictLookup("S", &obj2)->isName("Transparency")) {
       transpGroup = gTrue;
@@ -3882,7 +3882,7 @@ void Gfx::opBeginImage(Object * /*args[]*/, int /*numArgs*/) {
 
   // display the image
   if (str) {
-    doImage(NULL, str, gTrue);
+    doImage(nullptr, str, gTrue);
   
     // skip 'EI' tag
     c1 = str->getUndecodedStream()->getChar();
@@ -3924,7 +3924,7 @@ Stream *Gfx::buildImageStream() {
     error(getPos(), "End of file in inline image");
     obj.free();
     dict.free();
-    return NULL;
+    return nullptr;
   }
   obj.free();
 
@@ -4114,7 +4114,7 @@ void Gfx::drawAnnot(Object *str, AnnotBorderStyle *borderStyle,
 
     // get resources
     dict->lookup("Resources", &resObj);
-    resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL;
+    resDict = resObj.isDict() ? resObj.getDict() : (Dict *)nullptr;
 
     // draw it
     doForm1(str, resDict, m, bbox);
@@ -4125,7 +4125,7 @@ void Gfx::drawAnnot(Object *str, AnnotBorderStyle *borderStyle,
   // draw the border
   if (borderStyle && borderStyle->getWidth() > 0) {
     if (state->getStrokeColorSpace()->getMode() != csDeviceRGB) {
-      state->setStrokePattern(NULL);
+      state->setStrokePattern(nullptr);
       state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
       out->updateStrokeColorSpace(state);
     }
diff --git a/kpdf/xpdf/xpdf/Gfx.h b/kpdf/xpdf/xpdf/Gfx.h
index 0e4263ce..bda5cd9b 100644
--- a/kpdf/xpdf/xpdf/Gfx.h
+++ b/kpdf/xpdf/xpdf/Gfx.h
@@ -113,14 +113,14 @@ public:
   Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict,
       double hDPI, double vDPI, PDFRectangle *box,
       PDFRectangle *cropBox, int rotate,
-      GBool (*abortCheckCbkA)(void *data) = NULL,
-      void *abortCheckCbkDataA = NULL);
+      GBool (*abortCheckCbkA)(void *data) = nullptr,
+      void *abortCheckCbkDataA = nullptr);
 
   // Constructor for a sub-page object.
   Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict,
       PDFRectangle *box, PDFRectangle *cropBox,
-      GBool (*abortCheckCbkA)(void *data) = NULL,
-      void *abortCheckCbkDataA = NULL);
+      GBool (*abortCheckCbkA)(void *data) = nullptr,
+      void *abortCheckCbkDataA = nullptr);
 
   ~Gfx();
 
@@ -281,10 +281,10 @@ private:
   void doForm(Object *str);
   void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
 	       GBool transpGroup = gFalse, GBool softMask = gFalse,
-	       GfxColorSpace *blendingColorSpace = NULL,
+	       GfxColorSpace *blendingColorSpace = nullptr,
 	       GBool isolated = gFalse, GBool knockout = gFalse,
-	       GBool alpha = gFalse, Function *transferFunc = NULL,
-	       GfxColor *backdropColor = NULL);
+	       GBool alpha = gFalse, Function *transferFunc = nullptr,
+	       GfxColor *backdropColor = nullptr);
 
   // in-line image operators
   void opBeginImage(Object args[], int numArgs);
diff --git a/kpdf/xpdf/xpdf/GfxFont.cpp b/kpdf/xpdf/xpdf/GfxFont.cpp
index 4298b41c..d2750bcc 100644
--- a/kpdf/xpdf/xpdf/GfxFont.cpp
+++ b/kpdf/xpdf/xpdf/GfxFont.cpp
@@ -106,7 +106,7 @@ GfxFont *GfxFont::makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict) {
   Object obj1;
 
   // get base font name
-  nameA = NULL;
+  nameA = nullptr;
   fontDict->lookup("BaseFont", &obj1);
   if (obj1.isName()) {
     nameA = new GString(obj1.getName());
@@ -114,7 +114,7 @@ GfxFont *GfxFont::makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict) {
   obj1.free();
 
   // get font type
-  font = NULL;
+  font = nullptr;
   fontDict->lookup("Subtype", &obj1);
   if (obj1.isName("Type1") || obj1.isName("MMType1")) {
     font = new Gfx8BitFont(xref, tagA, idA, nameA, fontType1, fontDict);
@@ -142,8 +142,8 @@ GfxFont::GfxFont(char *tagA, Ref idA, GString *nameA) {
   id = idA;
   name = nameA;
   origName = nameA;
-  embFontName = NULL;
-  extFontFile = NULL;
+  embFontName = nullptr;
+  extFontFile = nullptr;
 }
 
 GfxFont::~GfxFont() {
@@ -312,7 +312,7 @@ CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict *fontDict, int nBits,
 
   if (!fontDict->lookup("ToUnicode", &obj1)->isStream()) {
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   buf = new GString();
   obj1.streamReset();
@@ -331,8 +331,8 @@ CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict *fontDict, int nBits,
 }
 
 void GfxFont::findExtFontFile() {
-  static char *type1Exts[] = { ".pfa", ".pfb", ".ps", "", NULL };
-  static char *ttExts[] = { ".ttf", ".ttc", NULL };
+  static char *type1Exts[] = { ".pfa", ".pfb", ".ps", "", nullptr };
+  static char *ttExts[] = { ".ttf", ".ttc", nullptr };
 
   if (name) {
     if (type == fontType1) {
@@ -349,7 +349,7 @@ char *GfxFont::readExtFontFile(int *len) {
 
   if (!(f = fopen(extFontFile->getCString(), "rb"))) {
     error(-1, "External font file '%s' vanished", extFontFile->getCString());
-    return NULL;
+    return nullptr;
   }
   fseek(f, 0, SEEK_END);
   *len = (int)ftell(f);
@@ -377,11 +377,11 @@ char *GfxFont::readEmbFontFile(XRef *xref, int *len) {
     obj2.free();
     obj1.free();
     embFontID.num = -1;
-    return NULL;
+    return nullptr;
   }
   str = obj2.getStream();
 
-  buf = NULL;
+  buf = nullptr;
   i = size = 0;
   str->reset();
   while ((c = str->getChar()) != EOF) {
@@ -429,7 +429,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   int n, i, a, b, m;
 
   type = typeA;
-  ctu = NULL;
+  ctu = nullptr;
 
   // do font name substitution for various aliases of the Base 14 font
   // names
@@ -461,7 +461,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   }
 
   // is it a built-in font?
-  builtinFont = NULL;
+  builtinFont = nullptr;
   if (name) {
     for (i = 0; i < nBuiltinFonts; ++i) {
       if (!name->cmp(builtinFonts[i].name)) {
@@ -552,7 +552,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   // check FontDict for base encoding
   hasEncoding = gFalse;
   usesMacRomanEnc = gFalse;
-  baseEnc = NULL;
+  baseEnc = nullptr;
   baseEncFromFontFile = gFalse;
   fontDict->lookup("Encoding", &obj1);
   if (obj1.isDict()) {
@@ -584,9 +584,9 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   // check embedded or external font file for base encoding
   // (only for Type 1 fonts - trying to get an encoding out of a
   // TrueType font is a losing proposition)
-  ffT1 = NULL;
-  ffT1C = NULL;
-  buf = NULL;
+  ffT1 = nullptr;
+  ffT1C = nullptr;
+  buf = nullptr;
   if (type == fontType1 && (extFontFile || embFontID.num >= 0)) {
     if (extFontFile) {
       ffT1 = FoFiType1::load(extFontFile->getCString());
@@ -1044,7 +1044,7 @@ Gushort *Gfx8BitFont::getCodeToGIDMap(FoFiTrueType *ff) {
 }
 
 Dict *Gfx8BitFont::getCharProcs() {
-  return charProcs.isDict() ? charProcs.getDict() : (Dict *)NULL;
+  return charProcs.isDict() ? charProcs.getDict() : (Dict *)nullptr;
 }
 
 Object *Gfx8BitFont::getCharProc(int code, Object *proc) {
@@ -1057,7 +1057,7 @@ Object *Gfx8BitFont::getCharProc(int code, Object *proc) {
 }
 
 Dict *Gfx8BitFont::getResources() {
-  return resources.isDict() ? resources.getDict() : (Dict *)NULL;
+  return resources.isDict() ? resources.getDict() : (Dict *)nullptr;
 }
 
 //------------------------------------------------------------------------
@@ -1091,16 +1091,16 @@ GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   ascent = 0.95;
   descent = -0.35;
   fontBBox[0] = fontBBox[1] = fontBBox[2] = fontBBox[3] = 0;
-  cMap = NULL;
-  ctu = NULL;
+  cMap = nullptr;
+  ctu = nullptr;
   widths.defWidth = 1.0;
   widths.defHeight = -1.0;
   widths.defVY = 0.880;
-  widths.exceps = NULL;
+  widths.exceps = nullptr;
   widths.nExceps = 0;
-  widths.excepsV = NULL;
+  widths.excepsV = nullptr;
   widths.nExcepsV = 0;
-  cidToGID = NULL;
+  cidToGID = nullptr;
   cidToGIDLen = 0;
 
   // get the descendant font
@@ -1157,7 +1157,7 @@ GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
   obj1.free();
 
   // look for a ToUnicode CMap
-  if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) {
+  if (!(ctu = readToUnicodeCMap(fontDict, 16, nullptr))) {
 
     // the "Adobe-Identity" and "Adobe-UCS" collections don't have
     // cidToUnicode files
@@ -1499,7 +1499,7 @@ CharCodeToUnicode *GfxCIDFont::getToUnicode() {
 }
 
 GString *GfxCIDFont::getCollection() {
-  return cMap ? cMap->getCollection() : (GString *)NULL;
+  return cMap ? cMap->getCollection() : (GString *)nullptr;
 }
 
 Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
@@ -1514,7 +1514,7 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
   int cidlen;
 
   *mapsizep = 0;
-  if (!ctu) return NULL;
+  if (!ctu) return nullptr;
 
   /* we use only unicode cmap */
   cmap = -1;
@@ -1525,7 +1525,7 @@ Gushort *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) {
       cmap = i;
   }
   if (cmap < 0)
-    return NULL;
+    return nullptr;
 
   cidlen = 0;
   mapsize = 64;
@@ -1582,11 +1582,11 @@ GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) {
 				   r, obj2.getDict());
       if (fonts[i] && !fonts[i]->isOk()) {
 	delete fonts[i];
-	fonts[i] = NULL;
+	fonts[i] = nullptr;
       }
     } else {
       error(-1, "font resource is not a dictionary");
-      fonts[i] = NULL;
+      fonts[i] = nullptr;
     }
     obj1.free();
     obj2.free();
@@ -1612,5 +1612,5 @@ GfxFont *GfxFontDict::lookup(char *tag) {
       return fonts[i];
     }
   }
-  return NULL;
+  return nullptr;
 }
diff --git a/kpdf/xpdf/xpdf/GfxState.cpp b/kpdf/xpdf/xpdf/GfxState.cpp
index f7cb1ce9..2274006a 100644
--- a/kpdf/xpdf/xpdf/GfxState.cpp
+++ b/kpdf/xpdf/xpdf/GfxState.cpp
@@ -96,7 +96,7 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
   GfxColorSpace *cs;
   Object obj1;
 
-  cs = NULL;
+  cs = nullptr;
   if (csObj->isName()) {
     if (csObj->isName("DeviceGray") || csObj->isName("G")) {
       cs = new GfxDeviceGrayColorSpace();
@@ -105,7 +105,7 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj) {
     } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
       cs = new GfxDeviceCMYKColorSpace();
     } else if (csObj->isName("Pattern")) {
-      cs = new GfxPatternColorSpace(NULL);
+      cs = new GfxPatternColorSpace(nullptr);
     } else {
       error(-1, "Bad color space '%s'", csObj->getName());
     }
@@ -227,7 +227,7 @@ GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr) {
   if (!obj1.isDict()) {
     error(-1, "Bad CalGray color space");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   cs = new GfxCalGrayColorSpace();
   if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
@@ -377,7 +377,7 @@ GfxColorSpace *GfxCalRGBColorSpace::parse(Array *arr) {
   if (!obj1.isDict()) {
     error(-1, "Bad CalRGB color space");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   cs = new GfxCalRGBColorSpace();
   if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
@@ -616,7 +616,7 @@ GfxColorSpace *GfxLabColorSpace::parse(Array *arr) {
   if (!obj1.isDict()) {
     error(-1, "Bad Lab color space");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   cs = new GfxLabColorSpace();
   if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
@@ -821,14 +821,14 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
   if (!obj1.isStream()) {
     error(-1, "Bad ICCBased color space (stream)");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   dict = obj1.streamGetDict();
   if (!dict->lookup("N", &obj2)->isInt()) {
     error(-1, "Bad ICCBased color space (N)");
     obj2.free();
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   nCompsA = obj2.getInt();
   obj2.free();
@@ -853,7 +853,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr) {
       error(-1, "Bad ICCBased color space - invalid N");
       obj2.free();
       obj1.free();
-      return NULL;
+      return nullptr;
     }
   }
   obj2.free();
@@ -1016,7 +1016,7 @@ GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr) {
  err2:
   obj1.free();
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GfxColor *GfxIndexedColorSpace::mapColorToBase(GfxColor *color,
@@ -1125,7 +1125,7 @@ GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr) {
  err2:
   obj1.free();
  err1:
-  return NULL;
+  return nullptr;
 }
 
 void GfxSeparationColorSpace::getGray(GfxColor *color, GfxGray *gray) {
@@ -1273,7 +1273,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr) {
  err2:
   obj1.free();
  err1:
-  return NULL;
+  return nullptr;
 }
 
 void GfxDeviceNColorSpace::getGray(GfxColor *color, GfxGray *gray) {
@@ -1345,7 +1345,7 @@ GfxPatternColorSpace::~GfxPatternColorSpace() {
 
 GfxColorSpace *GfxPatternColorSpace::copy() {
   return new GfxPatternColorSpace(under ? under->copy() :
-				          (GfxColorSpace *)NULL);
+				          (GfxColorSpace *)nullptr);
 }
 
 GfxColorSpace *GfxPatternColorSpace::parse(Array *arr) {
@@ -1355,15 +1355,15 @@ GfxColorSpace *GfxPatternColorSpace::parse(Array *arr) {
 
   if (arr->getLength() != 1 && arr->getLength() != 2) {
     error(-1, "Bad Pattern color space");
-    return NULL;
+    return nullptr;
   }
-  underA = NULL;
+  underA = nullptr;
   if (arr->getLength() == 2) {
     arr->get(1, &obj1);
     if (!(underA = GfxColorSpace::parse(&obj1))) {
       error(-1, "Bad Pattern color space (underlying color space)");
       obj1.free();
-      return NULL;
+      return nullptr;
     }
     obj1.free();
   }
@@ -1408,9 +1408,9 @@ GfxPattern *GfxPattern::parse(Object *obj) {
   } else if (obj->isStream()) {
     obj->streamGetDict()->lookup("PatternType", &obj1);
   } else {
-    return NULL;
+    return nullptr;
   }
-  pattern = NULL;
+  pattern = nullptr;
   if (obj1.isInt() && obj1.getInt() == 1) {
     pattern = GfxTilingPattern::parse(obj);
   } else if (obj1.isInt() && obj1.getInt() == 2) {
@@ -1435,7 +1435,7 @@ GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) {
   int i;
 
   if (!patObj->isStream()) {
-    return NULL;
+    return nullptr;
   }
   dict = patObj->streamGetDict();
 
@@ -1550,7 +1550,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj) {
   int i;
 
   if (!patObj->isDict()) {
-    return NULL;
+    return nullptr;
   }
   dict = patObj->getDict();
 
@@ -1558,7 +1558,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj) {
   shadingA = GfxShading::parse(&obj1);
   obj1.free();
   if (!shadingA) {
-    return NULL;
+    return nullptr;
   }
 
   matrixA[0] = 1; matrixA[1] = 0;
@@ -1603,7 +1603,7 @@ GfxPattern *GfxShadingPattern::copy() {
 
 GfxShading::GfxShading(int typeA) {
   type = typeA;
-  colorSpace = NULL;
+  colorSpace = nullptr;
 }
 
 GfxShading::GfxShading(GfxShading *shading) {
@@ -1639,13 +1639,13 @@ GfxShading *GfxShading::parse(Object *obj) {
   } else if (obj->isStream()) {
     dict = obj->streamGetDict();
   } else {
-    return NULL;
+    return nullptr;
   }
 
   if (!dict->lookup("ShadingType", &obj1)->isInt()) {
     error(-1, "Invalid ShadingType in shading dictionary");
     obj1.free();
-    return NULL;
+    return nullptr;
   }
   typeA = obj1.getInt();
   obj1.free();
@@ -1700,7 +1700,7 @@ GfxShading *GfxShading::parse(Object *obj) {
   return shading;
 
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GBool GfxShading::init(Dict *dict) {
@@ -1875,7 +1875,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict) {
 				   funcsA, nFuncsA);
   if (!shading->init(dict)) {
     delete shading;
-    return NULL;
+    return nullptr;
   }
   return shading;
 
@@ -1883,7 +1883,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict) {
   obj2.free();
  err1:
   obj1.free();
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxFunctionShading::copy() {
@@ -2040,12 +2040,12 @@ GfxAxialShading *GfxAxialShading::parse(Dict *dict) {
 				funcsA, nFuncsA, extend0A, extend1A);
   if (!shading->init(dict)) {
     delete shading;
-    return NULL;
+    return nullptr;
   }
   return shading;
 
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxAxialShading::copy() {
@@ -2208,12 +2208,12 @@ GfxRadialShading *GfxRadialShading::parse(Dict *dict) {
 				 funcsA, nFuncsA, extend0A, extend1A);
   if (!shading->init(dict)) {
     delete shading;
-    return NULL;
+    return nullptr;
   }
   return shading;
 
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxRadialShading::copy() {
@@ -2462,8 +2462,8 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
   obj1.free();
 
   nVerticesA = nTrianglesA = 0;
-  verticesA = NULL;
-  trianglesA = NULL;
+  verticesA = nullptr;
+  trianglesA = nullptr;
   vertSize = triSize = 0;
   state = 0;
   flag = 0; // make gcc happy
@@ -2553,14 +2553,14 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA,
 					  funcsA, nFuncsA);
   if (!shading->init(dict)) {
     delete shading;
-    return NULL;
+    return nullptr;
   }
   return shading;
 
  err2:
   obj1.free();
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxGouraudTriangleShading::copy() {
@@ -2759,7 +2759,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
   obj1.free();
 
   nPatchesA = 0;
-  patchesA = NULL;
+  patchesA = nullptr;
   patchesSize = 0;
   bitBuf = new GfxShadingBitBuf(str);
   while (1) {
@@ -3164,14 +3164,14 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict,
 				    funcsA, nFuncsA);
   if (!shading->init(dict)) {
     delete shading;
-    return NULL;
+    return nullptr;
   }
   return shading;
 
  err2:
   obj1.free();
  err1:
-  return NULL;
+  return nullptr;
 }
 
 GfxShading *GfxPatchMeshShading::copy() {
@@ -3203,7 +3203,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
 
   // initialize
   for (k = 0; k < gfxColorMaxComps; ++k) {
-    lookup[k] = NULL;
+    lookup[k] = nullptr;
   }
 
   // get decode map
@@ -3240,7 +3240,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
   // Optimization: for Indexed and Separation color spaces (which have
   // only one component), we store color values in the lookup table
   // rather than component values.
-  colorSpace2 = NULL;
+  colorSpace2 = nullptr;
   nComps2 = 0;
   if (colorSpace->getMode() == csIndexed) {
     // Note that indexHigh may not be the same as maxPixel --
@@ -3306,9 +3306,9 @@ GfxImageColorMap::GfxImageColorMap(GfxImageColorMap *colorMap) {
   bits = colorMap->bits;
   nComps = colorMap->nComps;
   nComps2 = colorMap->nComps2;
-  colorSpace2 = NULL;
+  colorSpace2 = nullptr;
   for (k = 0; k < gfxColorMaxComps; ++k) {
-    lookup[k] = NULL;
+    lookup[k] = nullptr;
   }
   n = 1 << bits;
   if (colorSpace->getMode() == csIndexed) {
@@ -3651,17 +3651,17 @@ GfxState::GfxState(double hDPIA, double vDPIA, PDFRectangle *pageBox,
   strokeColorSpace = new GfxDeviceGrayColorSpace();
   fillColor.c[0] = 0;
   strokeColor.c[0] = 0;
-  fillPattern = NULL;
-  strokePattern = NULL;
+  fillPattern = nullptr;
+  strokePattern = nullptr;
   blendMode = gfxBlendNormal;
   fillOpacity = 1;
   strokeOpacity = 1;
   fillOverprint = gFalse;
   strokeOverprint = gFalse;
-  transfer[0] = transfer[1] = transfer[2] = transfer[3] = NULL;
+  transfer[0] = transfer[1] = transfer[2] = transfer[3] = nullptr;
 
   lineWidth = 1;
-  lineDash = NULL;
+  lineDash = nullptr;
   lineDashLength = 0;
   lineDashStart = 0;
   flatness = 1;
@@ -3670,7 +3670,7 @@ GfxState::GfxState(double hDPIA, double vDPIA, PDFRectangle *pageBox,
   miterLimit = 10;
   strokeAdjust = gFalse;
 
-  font = NULL;
+  font = nullptr;
   fontSize = 0;
   textMat[0] = 1; textMat[1] = 0;
   textMat[2] = 0; textMat[3] = 1;
@@ -3691,7 +3691,7 @@ GfxState::GfxState(double hDPIA, double vDPIA, PDFRectangle *pageBox,
   clipXMax = pageWidth;
   clipYMax = pageHeight;
 
-  saved = NULL;
+  saved = nullptr;
 }
 
 GfxState::~GfxState() {
@@ -3750,7 +3750,7 @@ GfxState::GfxState(GfxState *state) {
     lineDash = (double *)gmallocn(lineDashLength, sizeof(double));
     memcpy(lineDash, state->lineDash, lineDashLength * sizeof(double));
   }
-  saved = NULL;
+  saved = nullptr;
 }
 
 void GfxState::setPath(GfxPath *pathA) {
@@ -4090,8 +4090,8 @@ GfxState *GfxState::restore() {
     oldState->lineX = lineX;
     oldState->lineY = lineY;
 
-    path = NULL;
-    saved = NULL;
+    path = nullptr;
+    saved = nullptr;
     delete this;
 
   } else {
diff --git a/kpdf/xpdf/xpdf/GfxState.h b/kpdf/xpdf/xpdf/GfxState.h
index 52c5c93c..8b02f2d7 100644
--- a/kpdf/xpdf/xpdf/GfxState.h
+++ b/kpdf/xpdf/xpdf/GfxState.h
@@ -583,7 +583,7 @@ public:
   double getXStep() { return xStep; }
   double getYStep() { return yStep; }
   Dict *getResDict()
-    { return resDict.isDict() ? resDict.getDict() : (Dict *)NULL; }
+    { return resDict.isDict() ? resDict.getDict() : (Dict *)nullptr; }
   double *getMatrix() { return matrix; }
   Object *getContentStream() { return &contentStream; }
 
@@ -1180,7 +1180,7 @@ public:
   // Push/pop GfxState on/off stack.
   GfxState *save();
   GfxState *restore();
-  GBool hasSaves() { return saved != NULL; }
+  GBool hasSaves() { return saved != nullptr; }
 
   // Misc
   GBool parseBlendMode(Object *obj, GfxBlendMode *mode);
diff --git a/kpdf/xpdf/xpdf/GlobalParams.cpp b/kpdf/xpdf/xpdf/GlobalParams.cpp
index d98a0ce5..7fc5a2a2 100644
--- a/kpdf/xpdf/xpdf/GlobalParams.cpp
+++ b/kpdf/xpdf/xpdf/GlobalParams.cpp
@@ -111,20 +111,20 @@ static struct {
   {"Helvetica-Bold",        "n019004l.pfb", "arialbd.ttf"},
   {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
   {"Helvetica-Oblique",     "n019023l.pfb", "ariali.ttf"},
-  {"Symbol",                "s050000l.pfb", NULL},
+  {"Symbol",                "s050000l.pfb", nullptr},
   {"Times-Bold",            "n021004l.pfb", "timesbd.ttf"},
   {"Times-BoldItalic",      "n021024l.pfb", "timesbi.ttf"},
   {"Times-Italic",          "n021023l.pfb", "timesi.ttf"},
   {"Times-Roman",           "n021003l.pfb", "times.ttf"},
-  {"ZapfDingbats",          "d050000l.pfb", NULL},
-  {NULL, NULL, NULL}
+  {"ZapfDingbats",          "d050000l.pfb", nullptr},
+  {nullptr, nullptr, nullptr}
 };
 
 #ifdef WIN32
 static char *displayFontDirs[] = {
   "c:/windows/fonts",
   "c:/winnt/fonts",
-  NULL
+  nullptr
 };
 #else
 static char *displayFontDirs[] = {
@@ -136,13 +136,13 @@ static char *displayFontDirs[] = {
   "/usr/share/fonts/default/ghostscript",
   "/usr/share/fonts/type1/gsfonts",
   "/usr/share/fonts/Type1",
-  NULL
+  nullptr
 };
 #endif
 
 //------------------------------------------------------------------------
 
-GlobalParams *globalParams = NULL;
+GlobalParams *globalParams = nullptr;
 
 //------------------------------------------------------------------------
 // DisplayFontParam
@@ -154,10 +154,10 @@ DisplayFontParam::DisplayFontParam(GString *nameA,
   kind = kindA;
   switch (kind) {
   case displayFontT1:
-    t1.fileName = NULL;
+    t1.fileName = nullptr;
     break;
   case displayFontTT:
-    tt.fileName = NULL;
+    tt.fileName = nullptr;
     break;
   }
 }
@@ -207,7 +207,7 @@ WinFontInfo *WinFontInfo::make(GString *nameA, GBool boldA, GBool italicA,
   int i;
 
   //----- find the font file
-  fileNameA = NULL;
+  fileNameA = nullptr;
   regName = nameA->copy();
   if (boldA) {
     regName->append(" Bold");
@@ -217,7 +217,7 @@ WinFontInfo *WinFontInfo::make(GString *nameA, GBool boldA, GBool italicA,
   }
   regName->append(" (TrueType)");
   n = sizeof(buf);
-  if (RegQueryValueEx(regKey, regName->getCString(), NULL, NULL,
+  if (RegQueryValueEx(regKey, regName->getCString(), nullptr, nullptr,
 		      (LPBYTE)buf, &n) == ERROR_SUCCESS) {
     fileNameA = new GString(winFontDir);
     fileNameA->append('\\')->append(buf);
@@ -225,7 +225,7 @@ WinFontInfo *WinFontInfo::make(GString *nameA, GBool boldA, GBool italicA,
   delete regName;
   if (!fileNameA) {
     delete nameA;
-    return NULL;
+    return nullptr;
   }
 
   //----- normalize the font name
@@ -290,7 +290,7 @@ WinFontList::WinFontList(char *winFontDirA) {
   char *path;
 
   fonts = new GList();
-  dc = GetDC(NULL);
+  dc = GetDC(nullptr);
   winFontDir = winFontDirA;
   version.dwOSVersionInfoSize = sizeof(version);
   GetVersionEx(&version);
@@ -302,10 +302,10 @@ WinFontList::WinFontList(char *winFontDirA) {
   if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0,
 		   KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
 		   &regKey) == ERROR_SUCCESS) {
-    EnumFonts(dc, NULL, &WinFontList::enumFunc1, (LPARAM)this);
+    EnumFonts(dc, nullptr, &WinFontList::enumFunc1, (LPARAM)this);
     RegCloseKey(regKey);
   }
-  ReleaseDC(NULL, dc);
+  ReleaseDC(nullptr, dc);
 }
 
 WinFontList::~WinFontList() {
@@ -382,13 +382,13 @@ WinFontInfo *WinFontList::find(GString *font) {
   }
 
   // search for the font
-  fi = NULL;
+  fi = nullptr;
   for (i = 0; i < fonts->getLength(); ++i) {
     fi = (WinFontInfo *)fonts->get(i);
     if (!fi->name->cmp(name) && fi->bold == bold && fi->italic == italic) {
       break;
     }
-    fi = NULL;
+    fi = nullptr;
   }
 
   delete name;
@@ -586,7 +586,7 @@ Plugin *Plugin::load(char *type, char *name) {
 #endif
  err1:
   delete path;
-  return NULL;
+  return nullptr;
 }
 
 #ifdef WIN32
@@ -688,7 +688,7 @@ GlobalParams::GlobalParams(char *cfgFileName) {
   psCenter = gTrue;
   psDuplex = gFalse;
   psLevel = psLevel2;
-  psFile = NULL;
+  psFile = nullptr;
   psFonts = new GHash();
   psNamedFonts16 = new GList();
   psFonts16 = new GList();
@@ -723,8 +723,8 @@ GlobalParams::GlobalParams(char *cfgFileName) {
   screenGamma = 1.0;
   screenBlackThreshold = 0.0;
   screenWhiteThreshold = 1.0;
-  urlCommand = NULL;
-  movieCommand = NULL;
+  urlCommand = nullptr;
+  movieCommand = nullptr;
   mapNumericCharNames = gTrue;
   mapUnknownCharNames = gFalse;
   createDefaultKeyBindings();
@@ -738,7 +738,7 @@ GlobalParams::GlobalParams(char *cfgFileName) {
   cMapCache = new CMapCache();
 
 #ifdef WIN32
-  winFontList = NULL;
+  winFontList = nullptr;
 #endif
 
 #ifdef ENABLE_PLUGINS
@@ -770,8 +770,8 @@ GlobalParams::GlobalParams(char *cfgFileName) {
   residentUnicodeMaps->add(map->getEncodingName(), map);
 
   // look for a user config file, then a system-wide config file
-  f = NULL;
-  fileName = NULL;
+  f = nullptr;
+  fileName = nullptr;
   if (cfgFileName && cfgFileName[0]) {
     fileName = new GString(cfgFileName);
     if (!(f = fopen(fileName->getCString(), "r"))) {
@@ -787,7 +787,7 @@ GlobalParams::GlobalParams(char *cfgFileName) {
   if (!f) {
 #if defined(WIN32) && !defined(__CYGWIN32__)
     char buf[512];
-    i = GetModuleFileName(NULL, buf, sizeof(buf));
+    i = GetModuleFileName(nullptr, buf, sizeof(buf));
     if (i <= 0 || i >= sizeof(buf)) {
       // error or path too long for buffer - just use the current dir
       buf[0] = '\0';
@@ -1157,7 +1157,7 @@ void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName,
   line2 = 1;
   while (getLine(buf, sizeof(buf), f)) {
     tok1 = strtok(buf, " \t\r\n");
-    tok2 = strtok(NULL, " \t\r\n");
+    tok2 = strtok(nullptr, " \t\r\n");
     if (tok1 && tok2) {
       sscanf(tok1, "%x", &u);
       nameToUnicode->add(tok2, u);
@@ -1384,7 +1384,7 @@ void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) {
     return;
   }
   param = new PSFontParam(((GString *)tokens->get(1))->copy(), 0,
-			  ((GString *)tokens->get(2))->copy(), NULL);
+			  ((GString *)tokens->get(2))->copy(), nullptr);
   psFonts->add(param->pdfFontName, param);
 }
 
@@ -1875,7 +1875,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 	 (BOOL (__stdcall *)(HWND hwndOwner, LPTSTR lpszPath,
 			     int nFolder, BOOL fCreate))
 	 GetProcAddress(shell32Lib, "SHGetSpecialFolderPathA"))) {
-      if (!(*SHGetSpecialFolderPathFunc)(NULL, winFontDir,
+      if (!(*SHGetSpecialFolderPathFunc)(nullptr, winFontDir,
 					 CSIDL_FONTS, FALSE)) {
 	winFontDir[0] = '\0';
       }
@@ -1884,7 +1884,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 #endif
   for (i = 0; displayFontTab[i].name; ++i) {
     fontName = new GString(displayFontTab[i].name);
-    fileName = NULL;
+    fileName = nullptr;
     kind = displayFontT1; // make gcc happy
     if (dir) {
       fileName = appendToPath(new GString(dir), displayFontTab[i].t1FileName);
@@ -1893,7 +1893,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 	fclose(f);
       } else {
 	delete fileName;
-	fileName = NULL;
+	fileName = nullptr;
       }
     }
 #ifdef WIN32
@@ -1905,7 +1905,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 	fclose(f);
       } else {
 	delete fileName;
-	fileName = NULL;
+	fileName = nullptr;
       }
     }
     // SHGetSpecialFolderPath(CSIDL_FONTS) doesn't work on Win 2k Server
@@ -1920,7 +1920,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 	  fclose(f);
 	} else {
 	  delete fileName;
-	  fileName = NULL;
+	  fileName = nullptr;
 	}
       }
     }
@@ -1933,7 +1933,7 @@ void GlobalParams::setupBaseFonts(char *dir) {
 	fclose(f);
       } else {
 	delete fileName;
-	fileName = NULL;
+	fileName = nullptr;
       }
     }
 #endif
@@ -1997,7 +1997,7 @@ FILE *GlobalParams::getUnicodeMapFile(GString *encodingName) {
   if ((fileName = (GString *)unicodeMaps->lookup(encodingName))) {
     f = fopen(fileName->getCString(), "r");
   } else {
-    f = NULL;
+    f = nullptr;
   }
   unlockGlobalParams;
   return f;
@@ -2013,7 +2013,7 @@ FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
   lockGlobalParams;
   if (!(list = (GList *)cMapDirs->lookup(collection))) {
     unlockGlobalParams;
-    return NULL;
+    return nullptr;
   }
   for (i = 0; i < list->getLength(); ++i) {
     dir = (GString *)list->get(i);
@@ -2026,7 +2026,7 @@ FILE *GlobalParams::findCMapFile(GString *collection, GString *cMapName) {
     }
   }
   unlockGlobalParams;
-  return NULL;
+  return nullptr;
 }
 
 FILE *GlobalParams::findToUnicodeFile(GString *name) {
@@ -2046,7 +2046,7 @@ FILE *GlobalParams::findToUnicodeFile(GString *name) {
     }
   }
   unlockGlobalParams;
-  return NULL;
+  return nullptr;
 }
 
 // KPDF: parse xpdf font name into family and style
@@ -2068,7 +2068,7 @@ void parseStyle(TQString& name, int& weight, int& slant, int& width)
 
 DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
   DisplayFontParam *dfp;
-  FcPattern *p=0,*m=0;
+  FcPattern *p=nullptr,*m=nullptr;
   FcChar8* s;
   char * ext;
   FcResult res;
@@ -2081,7 +2081,7 @@ DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
 	TQString name(fontName->getCString());
 	
 	parseStyle(name,weight,slant,width);
-	p = FcPatternBuild(0,FC_FAMILY,FcTypeString, name.ascii(), 
+	p = FcPatternBuild(nullptr,FC_FAMILY,FcTypeString, name.ascii(),
 		FC_SLANT, FcTypeInteger, slant, FC_WEIGHT, FcTypeInteger, weight,
 		FC_WIDTH, FcTypeInteger, width, FC_LANG, FcTypeString, "xx", (char*)0);
 	if (!p) goto fin;
@@ -2125,7 +2125,7 @@ GString *GlobalParams::getPSFile() {
   GString *s;
 
   lockGlobalParams;
-  s = psFile ? psFile->copy() : (GString *)NULL;
+  s = psFile ? psFile->copy() : (GString *)nullptr;
   unlockGlobalParams;
   return s;
 }
@@ -2226,7 +2226,7 @@ PSFontParam *GlobalParams::getPSFont16(GString *fontName,
   int i;
 
   lockGlobalParams;
-  p = NULL;
+  p = nullptr;
   if (fontName) {
     for (i = 0; i < psNamedFonts16->getLength(); ++i) {
       p = (PSFontParam *)psNamedFonts16->get(i);
@@ -2234,7 +2234,7 @@ PSFontParam *GlobalParams::getPSFont16(GString *fontName,
 	  p->wMode == wMode) {
 	break;
       }
-      p = NULL;
+      p = nullptr;
     }
   }
   if (!p && collection) {
@@ -2244,7 +2244,7 @@ PSFontParam *GlobalParams::getPSFont16(GString *fontName,
 	  p->wMode == wMode) {
 	break;
       }
-      p = NULL;
+      p = nullptr;
     }
   }
   unlockGlobalParams;
@@ -2371,7 +2371,7 @@ GString *GlobalParams::findFontFile(GString *fontName, char **exts) {
     }
   }
   unlockGlobalParams;
-  return NULL;
+  return nullptr;
 }
 
 GString *GlobalParams::getInitialZoom() {
@@ -2508,7 +2508,7 @@ GList *GlobalParams::getKeyBinding(int code, int mods, int context) {
   int i, j;
 
   lockGlobalParams;
-  cmds = NULL;
+  cmds = nullptr;
   // for ASCII chars, ignore the shift modifier
   modMask = code <= 0xff ? ~xpdfKeyModShift : ~0;
   for (i = 0; i < keyBindings->getLength(); ++i) {
@@ -2563,14 +2563,14 @@ CharCodeToUnicode *GlobalParams::getUnicodeToUnicode(GString *fontName) {
   GString *fontPattern, *fileName;
 
   lockGlobalParams;
-  fileName = NULL;
+  fileName = nullptr;
   unicodeToUnicodes->startIter(&iter);
   while (unicodeToUnicodes->getNext(&iter, &fontPattern, (void **)&fileName)) {
     if (strstr(fontName->getCString(), fontPattern->getCString())) {
       unicodeToUnicodes->killIter(&iter);
       break;
     }
-    fileName = NULL;
+    fileName = nullptr;
   }
   if (fileName) {
     if (!(ctu = unicodeToUnicodeCache->getCharCodeToUnicode(fileName))) {
@@ -2579,7 +2579,7 @@ CharCodeToUnicode *GlobalParams::getUnicodeToUnicode(GString *fontName) {
       }
     }
   } else {
-    ctu = NULL;
+    ctu = nullptr;
   }
   unlockGlobalParams;
   return ctu;
@@ -2929,7 +2929,7 @@ XpdfSecurityHandler *GlobalParams::getSecurityHandler(char *name) {
   unlockGlobalParams;
 
   if (!loadPlugin("security", name)) {
-    return NULL;
+    return nullptr;
   }
 
   lockGlobalParams;
@@ -2945,7 +2945,7 @@ XpdfSecurityHandler *GlobalParams::getSecurityHandler(char *name) {
   (void)name;
 #endif
 
-  return NULL;
+  return nullptr;
 }
 
 #ifdef ENABLE_PLUGINS
diff --git a/kpdf/xpdf/xpdf/JArithmeticDecoder.cpp b/kpdf/xpdf/xpdf/JArithmeticDecoder.cpp
index fccc05e9..baebf424 100644
--- a/kpdf/xpdf/xpdf/JArithmeticDecoder.cpp
+++ b/kpdf/xpdf/xpdf/JArithmeticDecoder.cpp
@@ -88,7 +88,7 @@ int JArithmeticDecoder::switchTab[47] = {
 };
 
 JArithmeticDecoder::JArithmeticDecoder() {
-  str = NULL;
+  str = nullptr;
   nBytesRead = 0;
   dataLen = 0;
   limitStream = gFalse;
diff --git a/kpdf/xpdf/xpdf/JBIG2Stream.cpp b/kpdf/xpdf/xpdf/JBIG2Stream.cpp
index 56216908..dd1d858f 100644
--- a/kpdf/xpdf/xpdf/JBIG2Stream.cpp
+++ b/kpdf/xpdf/xpdf/JBIG2Stream.cpp
@@ -320,7 +320,7 @@ private:
 };
 
 JBIG2HuffmanDecoder::JBIG2HuffmanDecoder() {
-  str = NULL;
+  str = nullptr;
   byteCounter = 0;
   reset();
 }
@@ -470,7 +470,7 @@ private:
 };
 
 JBIG2MMRDecoder::JBIG2MMRDecoder() {
-  str = NULL;
+  str = nullptr;
   byteCounter = 0;
   reset();
 }
@@ -783,7 +783,7 @@ void JBIG2Bitmap::clearToOne() {
 
 inline void JBIG2Bitmap::getPixelPtr(int x, int y, JBIG2BitmapPtr *ptr) {
   if (y < 0 || y >= h || x >= w) {
-    ptr->p = NULL;
+    ptr->p = nullptr;
     ptr->shift = 0; // make gcc happy
     ptr->x = 0; // make gcc happy
   } else if (x < 0) {
@@ -808,7 +808,7 @@ inline int JBIG2Bitmap::nextPixel(JBIG2BitmapPtr *ptr) {
   } else {
     pix = (*ptr->p >> ptr->shift) & 1;
     if (++ptr->x == w) {
-      ptr->p = NULL;
+      ptr->p = nullptr;
     } else if (ptr->shift == 0) {
       ++ptr->p;
       ptr->shift = 7;
@@ -1052,10 +1052,10 @@ JBIG2SymbolDict::JBIG2SymbolDict(Guint segNumA, Guint sizeA):
   size = sizeA;
   bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
   for (i = 0; i < size; ++i) {
-    bitmaps[i] = NULL;
+    bitmaps[i] = nullptr;
   }
-  genericRegionStats = NULL;
-  refinementRegionStats = NULL;
+  genericRegionStats = nullptr;
+  refinementRegionStats = nullptr;
 }
 
 JBIG2SymbolDict::~JBIG2SymbolDict() {
@@ -1145,7 +1145,7 @@ JBIG2CodeTable::~JBIG2CodeTable() {
 JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA):
   FilterStream(strA)
 {
-  pageBitmap = NULL;
+  pageBitmap = nullptr;
 
   arithDecoder = new JArithmeticDecoder();
   genericRegionStats = new JArithmeticDecoderStats(1 << 1);
@@ -1168,9 +1168,9 @@ JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA):
   mmrDecoder = new JBIG2MMRDecoder();
 
   globalsStreamA->copy(&globalsStream);
-  segments = globalSegments = NULL;
-  curStr = NULL;
-  dataPtr = dataEnd = NULL;
+  segments = globalSegments = nullptr;
+  curStr = nullptr;
+  dataPtr = dataEnd = nullptr;
   byteCounter = 0;
 }
 
@@ -1226,24 +1226,24 @@ void JBIG2Stream::reset() {
     dataPtr = pageBitmap->getDataPtr();
     dataEnd = dataPtr + pageBitmap->getDataSize();
   } else {
-    dataPtr = dataEnd = NULL;
+    dataPtr = dataEnd = nullptr;
   }
 }
 
 void JBIG2Stream::close() {
   if (pageBitmap) {
     delete pageBitmap;
-    pageBitmap = NULL;
+    pageBitmap = nullptr;
   }
   if (segments) {
     deleteGList(segments, JBIG2Segment);
-    segments = NULL;
+    segments = nullptr;
   }
   if (globalSegments) {
     deleteGList(globalSegments, JBIG2Segment);
-    globalSegments = NULL;
+    globalSegments = nullptr;
   }
-  dataPtr = dataEnd = NULL;
+  dataPtr = dataEnd = nullptr;
   FilterStream::close();
 }
 
@@ -1262,7 +1262,7 @@ int JBIG2Stream::lookChar() {
 }
 
 GString *JBIG2Stream::getPSFilter(int /*psLevel*/, char * /*indent*/) {
-  return NULL;
+  return nullptr;
 }
 
 GBool JBIG2Stream::isBinary(GBool /*last*/) {
@@ -1496,7 +1496,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
   Guint i, j, k;
   Guchar *p;
 
-  symWidths = NULL;
+  symWidths = nullptr;
 
   // symbol dictionary flags
   if (!readUWord(&flags)) {
@@ -1585,10 +1585,10 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
   bitmaps = (JBIG2Bitmap **)gmallocn(numInputSyms + numNewSyms,
 				     sizeof(JBIG2Bitmap *));
   for (i = 0; i < numInputSyms + numNewSyms; ++i) {
-    bitmaps[i] = NULL;
+    bitmaps[i] = nullptr;
   }
   k = 0;
-  inputSymbolDict = NULL;
+  inputSymbolDict = nullptr;
   for (i = 0; i < nRefSegs; ++i) {
     if ((seg = findSegment(refSegs[i]))) {
       if (seg->getType() == jbig2SegSymbolDict) {
@@ -1601,8 +1601,8 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
   }
 
   // get the Huffman tables
-  huffDHTable = huffDWTable = NULL; // make gcc happy
-  huffBMSizeTable = huffAggInstTable = NULL; // make gcc happy
+  huffDHTable = huffDWTable = nullptr; // make gcc happy
+  huffBMSizeTable = huffAggInstTable = nullptr; // make gcc happy
   i = 0;
   if (huff) {
     if (huffDH == 0) {
@@ -1655,7 +1655,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
     if (contextUsed && inputSymbolDict) {
       resetGenericStats(sdTemplate, inputSymbolDict->getGenericRegionStats());
     } else {
-      resetGenericStats(sdTemplate, NULL);
+      resetGenericStats(sdTemplate, nullptr);
     }
     resetIntStats(symCodeLen);
     arithDecoder->start();
@@ -1667,7 +1667,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
       resetRefinementStats(sdrTemplate,
 			   inputSymbolDict->getRefinementRegionStats());
     } else {
-      resetRefinementStats(sdrTemplate, NULL);
+      resetRefinementStats(sdrTemplate, nullptr);
     }
   }
 
@@ -1767,7 +1767,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
 	} else {
 	  bitmaps[numInputSyms + i] =
 	      readTextRegion(huff, gTrue, symWidth, symHeight,
-			     refAggNum, 0, numInputSyms + i, NULL,
+			     refAggNum, 0, numInputSyms + i, nullptr,
 			     symCodeLen, bitmaps, 0, 0, 0, 1, 0,
 			     huffTableF, huffTableH, huffTableK, huffTableO,
 			     huffTableO, huffTableO, huffTableO, huffTableA,
@@ -1778,7 +1778,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
       } else {
 	bitmaps[numInputSyms + i] =
 	    readGenericBitmap(gFalse, symWidth, symHeight,
-			      sdTemplate, gFalse, gFalse, NULL,
+			      sdTemplate, gFalse, gFalse, nullptr,
 			      sdATX, sdATY, 0);
       }
 
@@ -1808,7 +1808,7 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint /*length*/,
 	}
       } else {
 	collBitmap = readGenericBitmap(gTrue, totalWidth, symHeight,
-				       0, gFalse, gFalse, NULL, NULL, NULL,
+				       0, gFalse, gFalse, nullptr, nullptr, nullptr,
 				       bmSize);
       }
       x = 0;
@@ -2007,9 +2007,9 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
   }
 
   // get the Huffman tables
-  huffFSTable = huffDSTable = huffDTTable = NULL; // make gcc happy
-  huffRDWTable = huffRDHTable = NULL; // make gcc happy
-  huffRDXTable = huffRDYTable = huffRSizeTable = NULL; // make gcc happy
+  huffFSTable = huffDSTable = huffDTTable = nullptr; // make gcc happy
+  huffRDWTable = huffRDHTable = nullptr; // make gcc happy
+  huffRDXTable = huffRDYTable = huffRSizeTable = nullptr; // make gcc happy
   i = 0;
   if (huff) {
     if (huffFS == 0) {
@@ -2147,12 +2147,12 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
 
   // set up the arithmetic decoder
   } else {
-    symCodeTab = NULL;
+    symCodeTab = nullptr;
     resetIntStats(symCodeLen);
     arithDecoder->start();
   }
   if (refine) {
-    resetRefinementStats(templ, NULL);
+    resetRefinementStats(templ, nullptr);
   }
 
   bitmap = readTextRegion(huff, refine, w, h, numInstances,
@@ -2294,7 +2294,7 @@ JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
       } else {
 
 	// get the symbol bitmap
-	symbolBitmap = NULL;
+	symbolBitmap = nullptr;
 	if (refine) {
 	  if (huff) {
 	    ri = (int)huffDecoder->readBit();
@@ -2414,7 +2414,7 @@ void JBIG2Stream::readPatternDictSeg(Guint segNum, Guint length) {
 
   // set up the arithmetic decoder
   if (!mmr) {
-    resetGenericStats(templ, NULL);
+    resetGenericStats(templ, nullptr);
     arithDecoder->start();
   }
 
@@ -2424,7 +2424,7 @@ void JBIG2Stream::readPatternDictSeg(Guint segNum, Guint length) {
   atx[2] =  2;             aty[2] = -2;
   atx[3] = -2;             aty[3] = -2;
   bitmap = readGenericBitmap(mmr, (grayMax + 1) * patternW, patternH,
-			     templ, gFalse, gFalse, NULL,
+			     templ, gFalse, gFalse, nullptr,
 			     atx, aty, length - 7);
 
   // create the pattern dict object
@@ -2518,7 +2518,7 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
 
   // set up the arithmetic decoder
   if (!mmr) {
-    resetGenericStats(templ, NULL);
+    resetGenericStats(templ, nullptr);
     arithDecoder->start();
   }
 
@@ -2531,7 +2531,7 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
   }
 
   // compute the skip bitmap
-  skipBitmap = NULL;
+  skipBitmap = nullptr;
   if (enableSkip) {
     skipBitmap = new JBIG2Bitmap(0, gridW, gridH);
     skipBitmap->clearToZero();
@@ -2654,13 +2654,13 @@ void JBIG2Stream::readGenericRegionSeg(Guint segNum, GBool imm,
 
   // set up the arithmetic decoder
   if (!mmr) {
-    resetGenericStats(templ, NULL);
+    resetGenericStats(templ, nullptr);
     arithDecoder->start();
   }
 
   // read the bitmap
   bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
-			     NULL, atx, aty, mmr ? length - 18 : 0);
+			     nullptr, atx, aty, mmr ? length - 18 : 0);
 
   // combine the region bitmap into the page bitmap
   if (imm) {
@@ -3174,7 +3174,7 @@ void JBIG2Stream::readGenericRefinementRegionSeg(Guint segNum, GBool imm,
   }
 
   // set up the arithmetic decoder
-  resetRefinementStats(templ, NULL);
+  resetRefinementStats(templ, nullptr);
   arithDecoder->start();
 
   // read
@@ -3259,7 +3259,7 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
 	tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
 	tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
       } else {
-	tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
+	tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = nullptr; // make gcc happy
 	tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
 	tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
       }
@@ -3334,7 +3334,7 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
 	tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
 	tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
       } else {
-	tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
+	tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = nullptr; // make gcc happy
 	tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
 	tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
       }
@@ -3510,7 +3510,7 @@ JBIG2Segment *JBIG2Stream::findSegment(Guint segNum) {
       return seg;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 void JBIG2Stream::discardSegment(Guint segNum) {
diff --git a/kpdf/xpdf/xpdf/JPXStream.cpp b/kpdf/xpdf/xpdf/JPXStream.cpp
index 93b46471..6b07944a 100644
--- a/kpdf/xpdf/xpdf/JPXStream.cpp
+++ b/kpdf/xpdf/xpdf/JPXStream.cpp
@@ -234,14 +234,14 @@ JPXStream::JPXStream(Stream *strA):
   FilterStream(strA)
 {
   nComps = 0;
-  bpc = NULL;
+  bpc = nullptr;
   width = height = 0;
   haveCS = gFalse;
   havePalette = gFalse;
   haveCompMap = gFalse;
   haveChannelDefn = gFalse;
 
-  img.tiles = NULL;
+  img.tiles = nullptr;
   bitBuf = 0;
   bitBufLen = 0;
   bitBufSkip = gFalse;
@@ -276,7 +276,7 @@ void JPXStream::close() {
   Guint comp, i, k, r, pre, sb;
 
   gfree(bpc);
-  bpc = NULL;
+  bpc = nullptr;
   if (havePalette) {
     gfree(palette.bpc);
     gfree(palette.c);
@@ -342,7 +342,7 @@ void JPXStream::close() {
       }
     }
     gfree(img.tiles);
-    img.tiles = NULL;
+    img.tiles = nullptr;
   }
   FilterStream::close();
 }
@@ -434,7 +434,7 @@ void JPXStream::fillReadBuf() {
 }
 
 GString *JPXStream::getPSFilter(int /*psLevel*/, char * /*indent*/) {
-  return NULL;
+  return nullptr;
 }
 
 GBool JPXStream::isBinary(GBool /*last*/) {
@@ -916,10 +916,10 @@ GBool JPXStream::readCodestream(Guint /*len*/) {
 	img.tiles[i].tileComps = (JPXTileComp *)gmallocn(img.nComps,
 							 sizeof(JPXTileComp));
 	for (comp = 0; comp < img.nComps; ++comp) {
-	  img.tiles[i].tileComps[comp].quantSteps = NULL;
-	  img.tiles[i].tileComps[comp].data = NULL;
-	  img.tiles[i].tileComps[comp].buf = NULL;
-	  img.tiles[i].tileComps[comp].resLevels = NULL;
+	  img.tiles[i].tileComps[comp].quantSteps = nullptr;
+	  img.tiles[i].tileComps[comp].data = nullptr;
+	  img.tiles[i].tileComps[comp].buf = nullptr;
+	  img.tiles[i].tileComps[comp].resLevels = nullptr;
 	}
       }
       for (comp = 0; comp < img.nComps; ++comp) {
@@ -981,7 +981,7 @@ GBool JPXStream::readCodestream(Guint /*len*/) {
 		     (img.tiles[i].tileComps[comp].nDecompLevels + 1),
 		     sizeof(JPXResLevel));
 	  for (r = 0; r <= img.tiles[i].tileComps[comp].nDecompLevels; ++r) {
-	    img.tiles[i].tileComps[comp].resLevels[r].precincts = NULL;
+	    img.tiles[i].tileComps[comp].resLevels[r].precincts = nullptr;
 	  }
 	}
       }
@@ -1058,7 +1058,7 @@ GBool JPXStream::readCodestream(Guint /*len*/) {
 		     (img.tiles[i].tileComps[comp].nDecompLevels + 1),
 		     sizeof(JPXResLevel));
 	for (r = 0; r <= img.tiles[i].tileComps[comp].nDecompLevels; ++r) {
-	  img.tiles[i].tileComps[comp].resLevels[r].precincts = NULL;
+	  img.tiles[i].tileComps[comp].resLevels[r].precincts = nullptr;
 	}
       }
       for (r = 0; r <= img.tiles[0].tileComps[comp].nDecompLevels; ++r) {
@@ -1462,7 +1462,7 @@ GBool JPXStream::readTilePart() {
 	for (r = 0;
 	     r <= img.tiles[tileIdx].tileComps[comp].nDecompLevels;
 	     ++r) {
-	  img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL;
+	  img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = nullptr;
 	}
       }
       for (r = 0; r <= img.tiles[tileIdx].tileComps[0].nDecompLevels; ++r) {
@@ -1515,7 +1515,7 @@ GBool JPXStream::readTilePart() {
 		     (img.tiles[tileIdx].tileComps[comp].nDecompLevels + 1),
 		     sizeof(JPXResLevel));
       for (r = 0; r <= img.tiles[tileIdx].tileComps[comp].nDecompLevels; ++r) {
-	img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = NULL;
+	img.tiles[tileIdx].tileComps[comp].resLevels[r].precincts = nullptr;
       }
       for (r = 0; r <= img.tiles[tileIdx].tileComps[comp].nDecompLevels; ++r) {
 	if (img.tiles[tileIdx].tileComps[comp].style & 0x01) {
@@ -1896,8 +1896,8 @@ GBool JPXStream::readTilePart() {
 		  cb->coeffs[cbi].len = 0;
 		  cb->coeffs[cbi].mag = 0;
 		}
-		cb->arithDecoder = NULL;
-		cb->stats = NULL;
+		cb->arithDecoder = nullptr;
+		cb->stats = nullptr;
 		++cb;
 	      }
 	    }
diff --git a/kpdf/xpdf/xpdf/Lexer.cpp b/kpdf/xpdf/xpdf/Lexer.cpp
index 04eadef2..d8f3c1bb 100644
--- a/kpdf/xpdf/xpdf/Lexer.cpp
+++ b/kpdf/xpdf/xpdf/Lexer.cpp
@@ -201,7 +201,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
     n = 0;
     numParen = 1;
     done = gFalse;
-    s = NULL;
+    s = nullptr;
     do {
       c2 = EOF;
       switch (c = getChar()) {
@@ -298,7 +298,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
 	  n = 0;
 	  
 	  // we are growing see if the document is not malformed and we are growing too much
-	  if (objNum > 0 && xref != NULL)
+	  if (objNum > 0 && xref != nullptr)
 	  {
 	    int newObjNum = xref->getNumEntry(curStr.streamGetPos());
 	    if (newObjNum != objNum)
@@ -329,7 +329,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
   case '/':
     p = tokBuf;
     n = 0;
-    s = NULL;
+    s = nullptr;
     while ((c = lookChar()) != EOF && !specialChars[c]) {
       getChar();
       if (c == '#') {
@@ -404,7 +404,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
       p = tokBuf;
       m = n = 0;
       c2 = 0;
-      s = NULL;
+      s = nullptr;
       while (1) {
 	c = getChar();
 	if (c == '>') {
diff --git a/kpdf/xpdf/xpdf/Lexer.h b/kpdf/xpdf/xpdf/Lexer.h
index 3333be9f..8eb65db6 100644
--- a/kpdf/xpdf/xpdf/Lexer.h
+++ b/kpdf/xpdf/xpdf/Lexer.h
@@ -51,7 +51,7 @@ public:
 
   // Get stream.
   Stream *getStream()
-    { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
+    { return curStr.isNone() ? (Stream *)nullptr : curStr.getStream(); }
 
   // Get current position in file.  This is only used for error
   // messages, so it returns an int instead of a Guint.
diff --git a/kpdf/xpdf/xpdf/Link.cpp b/kpdf/xpdf/xpdf/Link.cpp
index 69106e13..b7d92f1b 100644
--- a/kpdf/xpdf/xpdf/Link.cpp
+++ b/kpdf/xpdf/xpdf/Link.cpp
@@ -32,7 +32,7 @@ LinkAction *LinkAction::parseDest(Object *obj) {
   action = new LinkGoTo(obj);
   if (!action->isOk()) {
     delete action;
-    return NULL;
+    return nullptr;
   }
   return action;
 }
@@ -43,7 +43,7 @@ LinkAction *LinkAction::parseAction(Object *obj, GString *baseURI) {
 
   if (!obj->isDict()) {
     error(-1, "Bad annotation action");
-    return NULL;
+    return nullptr;
   }
 
   obj->dictLookup("S", &obj2);
@@ -93,14 +93,14 @@ LinkAction *LinkAction::parseAction(Object *obj, GString *baseURI) {
   // action is missing or wrong type
   } else {
     error(-1, "Bad annotation action");
-    action = NULL;
+    action = nullptr;
   }
 
   obj2.free();
 
   if (action && !action->isOk()) {
     delete action;
-    return NULL;
+    return nullptr;
   }
   return action;
 }
@@ -109,7 +109,7 @@ GString *LinkAction::getFileSpecName(Object *fileSpecObj) {
   GString *name;
   Object obj1;
 
-  name = NULL;
+  name = nullptr;
 
   // string
   if (fileSpecObj->isString()) {
@@ -414,8 +414,8 @@ LinkDest::LinkDest(LinkDest *dest) {
 //------------------------------------------------------------------------
 
 LinkGoTo::LinkGoTo(Object *destObj) {
-  dest = NULL;
-  namedDest = NULL;
+  dest = nullptr;
+  namedDest = nullptr;
 
   // named destination
   if (destObj->isName()) {
@@ -428,7 +428,7 @@ LinkGoTo::LinkGoTo(Object *destObj) {
     dest = new LinkDest(destObj->getArray());
     if (!dest->isOk()) {
       delete dest;
-      dest = NULL;
+      dest = nullptr;
     }
 
   // error
@@ -449,8 +449,8 @@ LinkGoTo::~LinkGoTo() {
 //------------------------------------------------------------------------
 
 LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
-  dest = NULL;
-  namedDest = NULL;
+  dest = nullptr;
+  namedDest = nullptr;
 
   // get file name
   fileName = getFileSpecName(fileSpecObj);
@@ -466,7 +466,7 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) {
     dest = new LinkDest(destObj->getArray());
     if (!dest->isOk()) {
       delete dest;
-      dest = NULL;
+      dest = nullptr;
     }
 
   // error
@@ -492,8 +492,8 @@ LinkGoToR::~LinkGoToR() {
 LinkLaunch::LinkLaunch(Object *actionObj) {
   Object obj1, obj2;
 
-  fileName = NULL;
-  params = NULL;
+  fileName = nullptr;
+  params = nullptr;
 
   if (actionObj->isDict()) {
     if (!actionObj->dictLookup("F", &obj1)->isNull()) {
@@ -548,7 +548,7 @@ LinkURI::LinkURI(Object *uriObj, GString *baseURI) {
   int n;
   char c;
 
-  uri = NULL;
+  uri = nullptr;
   if (uriObj->isString()) {
     uri2 = uriObj->getString()->copy();
     if (baseURI && baseURI->getLength() > 0) {
@@ -588,7 +588,7 @@ LinkURI::~LinkURI() {
 //------------------------------------------------------------------------
 
 LinkNamed::LinkNamed(Object *nameObj) {
-  name = NULL;
+  name = nullptr;
   if (nameObj->isName()) {
     name = new GString(nameObj->getName());
   }
@@ -606,7 +606,7 @@ LinkNamed::~LinkNamed() {
 
 LinkMovie::LinkMovie(Object *annotObj, Object *titleObj) {
   annotRef.num = -1;
-  title = NULL;
+  title = nullptr;
   if (annotObj->isRef()) {
     annotRef = annotObj->getRef();
   } else if (titleObj->isString()) {
@@ -642,7 +642,7 @@ Link::Link(Dict *dict, GString *baseURI) {
   Object obj1, obj2;
   double t;
 
-  action = NULL;
+  action = nullptr;
   ok = gFalse;
 
   // get rectangle
@@ -728,7 +728,7 @@ Links::Links(Object *annots, GString *baseURI) {
   int size;
   int i;
 
-  links = NULL;
+  links = nullptr;
   size = 0;
   numLinks = 0;
 
@@ -770,7 +770,7 @@ LinkAction *Links::find(double x, double y) {
       return links[i]->getAction();
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 GBool Links::onLink(double x, double y) {
diff --git a/kpdf/xpdf/xpdf/Link.h b/kpdf/xpdf/xpdf/Link.h
index 698f2c85..c6a8a4b2 100644
--- a/kpdf/xpdf/xpdf/Link.h
+++ b/kpdf/xpdf/xpdf/Link.h
@@ -51,7 +51,7 @@ public:
   static LinkAction *parseDest(Object *obj);
 
   // Parse an action dictionary.
-  static LinkAction *parseAction(Object *obj, GString *baseURI = NULL);
+  static LinkAction *parseAction(Object *obj, GString *baseURI = nullptr);
 
   // Extract a file name from a file specification (string or
   // dictionary).
@@ -192,7 +192,7 @@ public:
   virtual ~LinkLaunch();
 
   // Was the LinkLaunch created successfully?
-  virtual GBool isOk() { return fileName != NULL; }
+  virtual GBool isOk() { return fileName != nullptr; }
 
   // Accessors.
   virtual LinkActionKind getKind() { return actionLaunch; }
@@ -219,7 +219,7 @@ public:
   virtual ~LinkURI();
 
   // Was the LinkURI created successfully?
-  virtual GBool isOk() { return uri != NULL; }
+  virtual GBool isOk() { return uri != nullptr; }
 
   // Accessors.
   virtual LinkActionKind getKind() { return actionURI; }
@@ -242,7 +242,7 @@ public:
 
   virtual ~LinkNamed();
 
-  virtual GBool isOk() { return name != NULL; }
+  virtual GBool isOk() { return name != nullptr; }
 
   virtual LinkActionKind getKind() { return actionNamed; }
   GString *getName() { return name; }
@@ -263,7 +263,7 @@ public:
 
   virtual ~LinkMovie();
 
-  virtual GBool isOk() { return annotRef.num >= 0 || title != NULL; }
+  virtual GBool isOk() { return annotRef.num >= 0 || title != nullptr; }
 
   virtual LinkActionKind getKind() { return actionMovie; }
   GBool hasAnnotRef() { return annotRef.num >= 0; }
@@ -290,7 +290,7 @@ public:
   virtual ~LinkUnknown();
 
   // Was the LinkUnknown create successfully?
-  virtual GBool isOk() { return action != NULL; }
+  virtual GBool isOk() { return action != nullptr; }
 
   // Accessors.
   virtual LinkActionKind getKind() { return actionUnknown; }
diff --git a/kpdf/xpdf/xpdf/NameToCharCode.cpp b/kpdf/xpdf/xpdf/NameToCharCode.cpp
index 23779f05..a030c03f 100644
--- a/kpdf/xpdf/xpdf/NameToCharCode.cpp
+++ b/kpdf/xpdf/xpdf/NameToCharCode.cpp
@@ -32,7 +32,7 @@ NameToCharCode::NameToCharCode() {
   len = 0;
   tab = (NameToCharCodeEntry *)gmallocn(size, sizeof(NameToCharCodeEntry));
   for (i = 0; i < size; ++i) {
-    tab[i].name = NULL;
+    tab[i].name = nullptr;
   }
 }
 
@@ -58,7 +58,7 @@ void NameToCharCode::add(char *name, CharCode c) {
     size = 2*size + 1;
     tab = (NameToCharCodeEntry *)gmallocn(size, sizeof(NameToCharCodeEntry));
     for (h = 0; h < size; ++h) {
-      tab[h].name = NULL;
+      tab[h].name = nullptr;
     }
     for (i = 0; i < oldSize; ++i) {
       if (oldTab[i].name) {
diff --git a/kpdf/xpdf/xpdf/NameToUnicodeTable.h b/kpdf/xpdf/xpdf/NameToUnicodeTable.h
index c5ecba49..24946ec1 100644
--- a/kpdf/xpdf/xpdf/NameToUnicodeTable.h
+++ b/kpdf/xpdf/xpdf/NameToUnicodeTable.h
@@ -1093,5 +1093,5 @@ static struct {
   {0x007c, "|"},
   {0x007d, "}"},
   {0x007e, "~"},
-  { 0, NULL }
+  { 0, nullptr }
 };
diff --git a/kpdf/xpdf/xpdf/Outline.cpp b/kpdf/xpdf/xpdf/Outline.cpp
index f5aba636..29b852eb 100644
--- a/kpdf/xpdf/xpdf/Outline.cpp
+++ b/kpdf/xpdf/xpdf/Outline.cpp
@@ -24,7 +24,7 @@
 Outline::Outline(Object *outlineObj, XRef *xref) {
   Object first, last;
 
-  items = NULL;
+  items = nullptr;
   if (!outlineObj->isDict()) {
     return;
   }
@@ -49,9 +49,9 @@ OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
   int i;
 
   xref = xrefA;
-  title = NULL;
-  action = NULL;
-  kids = NULL;
+  title = nullptr;
+  action = nullptr;
+  kids = nullptr;
 
   if (dict->lookup("Title", &obj1)->isString()) {
     s = obj1.getString();
@@ -146,6 +146,6 @@ void OutlineItem::open() {
 void OutlineItem::close() {
   if (kids) {
     deleteGList(kids, OutlineItem);
-    kids = NULL;
+    kids = nullptr;
   }
 }
diff --git a/kpdf/xpdf/xpdf/OutputDev.cpp b/kpdf/xpdf/xpdf/OutputDev.cpp
index 1b394ad4..21949f07 100644
--- a/kpdf/xpdf/xpdf/OutputDev.cpp
+++ b/kpdf/xpdf/xpdf/OutputDev.cpp
@@ -110,7 +110,7 @@ void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
 				Stream * /*maskStr*/,
 				int /*maskWidth*/, int /*maskHeight*/,
 				GBool /*maskInvert*/) {
-  drawImage(state, ref, str, width, height, colorMap, NULL, gFalse);
+  drawImage(state, ref, str, width, height, colorMap, nullptr, gFalse);
 }
 
 void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
@@ -119,7 +119,7 @@ void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
 				    Stream * /*maskStr*/,
 				    int /*maskWidth*/, int /*maskHeight*/,
 				    GfxImageColorMap * /*maskColorMap*/) {
-  drawImage(state, ref, str, width, height, colorMap, NULL, gFalse);
+  drawImage(state, ref, str, width, height, colorMap, nullptr, gFalse);
 }
 
 #if OPI_SUPPORT
diff --git a/kpdf/xpdf/xpdf/OutputDev.h b/kpdf/xpdf/xpdf/OutputDev.h
index a4ee37b1..e4d72265 100644
--- a/kpdf/xpdf/xpdf/OutputDev.h
+++ b/kpdf/xpdf/xpdf/OutputDev.h
@@ -89,8 +89,8 @@ public:
 			       int /*rotate*/, GBool /*useMediaBox*/, GBool /*crop*/,
 			       int /*sliceX*/, int /*sliceY*/, int /*sliceW*/, int /*sliceH*/,
 			       GBool /*printing*/, Catalog * /*catalog*/,
-			       GBool (* /*abortCheckCbk*/)(void *data) = NULL,
-			       void * /*abortCheckCbkData*/ = NULL)
+			       GBool (* /*abortCheckCbk*/)(void *data) = nullptr,
+			       void * /*abortCheckCbkData*/ = nullptr)
     { return gTrue; }
 
   // Start a page.
diff --git a/kpdf/xpdf/xpdf/PDFDoc.cpp b/kpdf/xpdf/xpdf/PDFDoc.cpp
index ee2bc4df..ec34ecbf 100644
--- a/kpdf/xpdf/xpdf/PDFDoc.cpp
+++ b/kpdf/xpdf/xpdf/PDFDoc.cpp
@@ -57,12 +57,12 @@ PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword,
 
   guiData = guiDataA;
 
-  file = NULL;
-  str = NULL;
-  xref = NULL;
-  catalog = NULL;
+  file = nullptr;
+  str = nullptr;
+  xref = nullptr;
+  catalog = nullptr;
 #ifndef DISABLE_OUTLINE
-  outline = NULL;
+  outline = nullptr;
 #endif
 
   fileName = fileNameA;
@@ -70,7 +70,7 @@ PDFDoc::PDFDoc(GString *fileNameA, GString *ownerPassword,
 
 
   // try to open file
-  fileName2 = NULL;
+  fileName2 = nullptr;
 #ifdef VMS
   if (!(file = fopen(fileName1->getCString(), "rb", "ctx=stm"))) {
     error(-1, "Couldn't open file '%s'", fileName1->getCString());
@@ -114,12 +114,12 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GString *ownerPassword,
 
   guiData = guiDataA;
 
-  file = NULL;
-  str = NULL;
-  xref = NULL;
-  catalog = NULL;
+  file = nullptr;
+  str = nullptr;
+  xref = nullptr;
+  catalog = nullptr;
 #ifndef DISABLE_OUTLINE
-  outline = NULL;
+  outline = nullptr;
 #endif
 
   //~ file name should be stored in Unicode (?)
@@ -165,14 +165,14 @@ PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword,
   if (strA->getFileName()) {
     fileName = strA->getFileName()->copy();
   } else {
-    fileName = NULL;
+    fileName = nullptr;
   }
-  file = NULL;
+  file = nullptr;
   str = strA;
-  xref = NULL;
-  catalog = NULL;
+  xref = nullptr;
+  catalog = nullptr;
 #ifndef DISABLE_OUTLINE
-  outline = NULL;
+  outline = nullptr;
 #endif
   ok = setup(ownerPassword, userPassword);
 }
diff --git a/kpdf/xpdf/xpdf/PDFDoc.h b/kpdf/xpdf/xpdf/PDFDoc.h
index 208b61ef..25ced327 100644
--- a/kpdf/xpdf/xpdf/PDFDoc.h
+++ b/kpdf/xpdf/xpdf/PDFDoc.h
@@ -35,14 +35,14 @@ class Outline;
 class PDFDoc {
 public:
 
-  PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
-	 GString *userPassword = NULL, void *guiDataA = NULL);
+  PDFDoc(GString *fileNameA, GString *ownerPassword = nullptr,
+	 GString *userPassword = nullptr, void *guiDataA = nullptr);
 #ifdef WIN32
-  PDFDoc(wchar_t *fileNameA, int fileNameLen, GString *ownerPassword = NULL,
-	 GString *userPassword = NULL, void *guiDataA = NULL);
+  PDFDoc(wchar_t *fileNameA, int fileNameLen, GString *ownerPassword = nullptr,
+	 GString *userPassword = nullptr, void *guiDataA = nullptr);
 #endif
-  PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
-	 GString *userPassword = NULL, void *guiDataA = NULL);
+  PDFDoc(BaseStream *strA, GString *ownerPassword = nullptr,
+	 GString *userPassword = nullptr, void *guiDataA = nullptr);
   ~PDFDoc();
 
   // Was PDF document successfully opened?
@@ -89,23 +89,23 @@ public:
   void displayPage(OutputDev *out, int page,
 		   double hDPI, double vDPI, int rotate,
 		   GBool useMediaBox, GBool crop, GBool printing,
-		   GBool (*abortCheckCbk)(void *data) = NULL,
-		   void *abortCheckCbkData = NULL);
+		   GBool (*abortCheckCbk)(void *data) = nullptr,
+		   void *abortCheckCbkData = nullptr);
 
   // Display a range of pages.
   void displayPages(OutputDev *out, int firstPage, int lastPage,
 		    double hDPI, double vDPI, int rotate,
 		    GBool useMediaBox, GBool crop, GBool printing,
-		    GBool (*abortCheckCbk)(void *data) = NULL,
-		    void *abortCheckCbkData = NULL);
+		    GBool (*abortCheckCbk)(void *data) = nullptr,
+		    void *abortCheckCbkData = nullptr);
 
   // Display part of a page.
   void displayPageSlice(OutputDev *out, int page,
 			double hDPI, double vDPI, int rotate,
 			GBool useMediaBox, GBool crop, GBool printing,
 			int sliceX, int sliceY, int sliceW, int sliceH,
-			GBool (*abortCheckCbk)(void *data) = NULL,
-			void *abortCheckCbkData = NULL);
+			GBool (*abortCheckCbk)(void *data) = nullptr,
+			void *abortCheckCbkData = nullptr);
 
   // Find a page, given its object ID.  Returns page number, or 0 if
   // not found.
diff --git a/kpdf/xpdf/xpdf/PSOutputDev.cpp b/kpdf/xpdf/xpdf/PSOutputDev.cpp
index f05c86ea..2cb443ae 100644
--- a/kpdf/xpdf/xpdf/PSOutputDev.cpp
+++ b/kpdf/xpdf/xpdf/PSOutputDev.cpp
@@ -697,7 +697,7 @@ static char *prolog[] = {
   "} def",
   "~123sn",
   "end",
-  NULL
+  nullptr
 };
 
 static char *cmapProlog[] = {
@@ -742,7 +742,7 @@ static char *cmapProlog[] = {
   "  currentdict CMapName exch /CMap defineresource pop",
   "end",
   "end",
-  NULL
+  nullptr
 };
 
 //------------------------------------------------------------------------
@@ -769,7 +769,7 @@ static char *psFonts[] = {
   "Times-Italic",
   "Times-BoldItalic",
   "ZapfDingbats",
-  NULL
+  nullptr
 };
 
 static PSSubstFont psSubstFonts[] = {
@@ -832,7 +832,7 @@ PSOutCustomColor::PSOutCustomColor(double cA, double mA,
   y = yA;
   k = kA;
   name = nameA;
-  next = NULL;
+  next = nullptr;
 }
 
 PSOutCustomColor::~PSOutCustomColor() {
@@ -861,7 +861,7 @@ public:
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; }
   virtual int lookChar()
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; }
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return nullptr; }
   virtual GBool isBinary(GBool /*last*/ = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -885,7 +885,7 @@ DeviceNRecoder::DeviceNRecoder(Stream *strA, int widthA, int heightA,
   width = widthA;
   height = heightA;
   colorMap = colorMapA;
-  imgStr = NULL;
+  imgStr = nullptr;
   pixelIdx = 0;
   bufIdx = gfxColorMaxComps;
   bufSize = ((GfxDeviceNColorSpace *)colorMap->getColorSpace())->
@@ -951,23 +951,23 @@ PSOutputDev::PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
   FILE *f;
   PSFileType fileTypeA;
 
-  underlayCbk = NULL;
-  underlayCbkData = NULL;
-  overlayCbk = NULL;
-  overlayCbkData = NULL;
-
-  fontIDs = NULL;
-  fontFileIDs = NULL;
-  fontFileNames = NULL;
-  font8Info = NULL;
-  font16Enc = NULL;
-  imgIDs = NULL;
-  formIDs = NULL;
-  xobjStack = NULL;
-  embFontList = NULL;
-  customColors = NULL;
+  underlayCbk = nullptr;
+  underlayCbkData = nullptr;
+  overlayCbk = nullptr;
+  overlayCbkData = nullptr;
+
+  fontIDs = nullptr;
+  fontFileIDs = nullptr;
+  fontFileNames = nullptr;
+  font8Info = nullptr;
+  font16Enc = nullptr;
+  imgIDs = nullptr;
+  formIDs = nullptr;
+  xobjStack = nullptr;
+  embFontList = nullptr;
+  customColors = nullptr;
   haveTextClip = gFalse;
-  t3String = NULL;
+  t3String = nullptr;
   
   forceRasterize = forceRasterizeA;
 
@@ -1520,7 +1520,7 @@ void PSOutputDev::setupFonts(Dict *resDict) {
 
   if (forceRasterize) return;
 
-  gfxFontDict = NULL;
+  gfxFontDict = nullptr;
   resDict->lookupNF("Font", &obj1);
   if (obj1.isRef()) {
     obj1.fetch(xref, &obj2);
@@ -1530,7 +1530,7 @@ void PSOutputDev::setupFonts(Dict *resDict) {
     }
     obj2.free();
   } else if (obj1.isDict()) {
-    gfxFontDict = new GfxFontDict(xref, NULL, obj1.getDict());
+    gfxFontDict = new GfxFontDict(xref, nullptr, obj1.getDict());
   }
   if (gfxFontDict) {
     for (i = 0; i < gfxFontDict->getNumFonts(); ++i) {
@@ -1666,7 +1666,7 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
   } else if (!font->isCIDFont()) {
     subst = gTrue;
     name = font->getName();
-    psName = NULL;
+    psName = nullptr;
     if (name) {
       for (i = 0; psFonts[i]; ++i) {
 	if (name->cmp(psFonts[i]) == 0) {
@@ -2017,7 +2017,7 @@ void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id,
   // convert it to a Type 1 font
   fontBuf = font->readEmbFontFile(xref, &fontLen);
   if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) {
-    ffT1C->convertToType1(psName->getCString(), NULL, gTrue,
+    ffT1C->convertToType1(psName->getCString(), nullptr, gTrue,
 			  outputFunc, outputStream);
     delete ffT1C;
   }
@@ -2058,7 +2058,7 @@ void PSOutputDev::setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id,
   fontBuf = font->readEmbFontFile(xref, &fontLen);
   if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
     if (ffTT->isOpenTypeCFF()) {
-      ffTT->convertToType1(psName->getCString(), NULL, gTrue,
+      ffTT->convertToType1(psName->getCString(), nullptr, gTrue,
 			   outputFunc, outputStream);
     }
     delete ffTT;
@@ -2108,7 +2108,7 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id,
     ffTT->convertToType42(psName->getCString(),
 			  ((Gfx8BitFont *)font)->getHasEncoding()
 			    ? ((Gfx8BitFont *)font)->getEncoding()
-			    : (char **)NULL,
+			    : (char **)nullptr,
 			  codeToGID, outputFunc, outputStream);
     if (codeToGID) {
       if (font8InfoLen >= font8InfoSize) {
@@ -2176,7 +2176,7 @@ GString *PSOutputDev::setupExternalTrueTypeFont(GfxFont *font) {
     ffTT->convertToType42(psName->getCString(),
 			  ((Gfx8BitFont *)font)->getHasEncoding()
 			    ? ((Gfx8BitFont *)font)->getEncoding()
-			    : (char **)NULL,
+			    : (char **)nullptr,
 			  codeToGID, outputFunc, outputStream);
     if (codeToGID) {
       if (font8InfoLen >= font8InfoSize) {
@@ -2473,7 +2473,7 @@ void PSOutputDev::setupType3Font(GfxFont *font, GString *psName,
     box.y1 = m[1];
     box.x2 = m[2];
     box.y2 = m[3];
-    gfx = new Gfx(xref, this, resDict, &box, NULL);
+    gfx = new Gfx(xref, this, resDict, &box, nullptr);
     inType3Char = gTrue;
     for (i = 0; i < charProcs->getLength(); ++i) {
       t3Cacheable = gFalse;
@@ -2495,7 +2495,7 @@ void PSOutputDev::setupType3Font(GfxFont *font, GString *psName,
 	(*outputFunc)(outputStream, t3String->getCString(),
 		      t3String->getLength());
 	delete t3String;
-	t3String = NULL;
+	t3String = nullptr;
       }
       if (t3NeedsRestore) {
 	(*outputFunc)(outputStream, "Q\n", 2);
@@ -2780,7 +2780,7 @@ void PSOutputDev::setupForm(Ref id, Object *strObj) {
 
   // get resources
   dict->lookup("Resources", &resObj);
-  resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL;
+  resDict = resObj.isDict() ? resObj.getDict() : (Dict *)nullptr;
 
   writePSFmt("/f_{0:d}_{1:d} {{\n", id.num, id.gen);
   writePS("q\n");
@@ -3036,7 +3036,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
     (*underlayCbk)(this, underlayCbkData);
   }
   if (overlayCbk) {
-    saveState(NULL);
+    saveState(nullptr);
   }
 
   switch (mode) {
@@ -3192,7 +3192,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state) {
 
 void PSOutputDev::endPage() {
   if (overlayCbk) {
-    restoreState(NULL);
+    restoreState(nullptr);
     (*overlayCbk)(this, overlayCbkData);
   }
 
@@ -3613,7 +3613,7 @@ void PSOutputDev::tilingPatternFill(GfxState * /*state*/, Object *str,
   box.y1 = bbox[1];
   box.x2 = bbox[2];
   box.y2 = bbox[3];
-  gfx = new Gfx(xref, this, resDict, &box, NULL);
+  gfx = new Gfx(xref, this, resDict, &box, nullptr);
   writePS("/x {\n");
   if (paintType == 2) {
     writePSFmt("{0:.4g} 0 {1:.4g} {2:.4g} {3:.4g} {4:.4g} setcachedevice\n",
@@ -4084,8 +4084,8 @@ void PSOutputDev::drawString(GfxState *state, GString *s) {
   wMode = font->getWMode();
 
   // check for a subtitute 16-bit font
-  uMap = NULL;
-  codeToGID = NULL;
+  uMap = nullptr;
+  codeToGID = nullptr;
   if (font->isCIDFont()) {
     for (i = 0; i < font16EncLen; ++i) {
       if (font->getID()->num == font16Enc[i].fontID.num &&
@@ -4186,17 +4186,17 @@ void PSOutputDev::drawImageMask(GfxState * /*state*/, Object *ref, Stream *str,
   switch (level) {
   case psLevel1:
   case psLevel1Sep:
-    doImageL1(ref, NULL, invert, inlineImg, str, width, height, len);
+    doImageL1(ref, nullptr, invert, inlineImg, str, width, height, len);
     break;
   case psLevel2:
   case psLevel2Sep:
-    doImageL2(ref, NULL, invert, inlineImg, str, width, height, len,
-	      NULL, NULL, 0, 0, gFalse);
+    doImageL2(ref, nullptr, invert, inlineImg, str, width, height, len,
+	      nullptr, nullptr, 0, 0, gFalse);
     break;
   case psLevel3:
   case psLevel3Sep:
-    doImageL3(ref, NULL, invert, inlineImg, str, width, height, len,
-	      NULL, NULL, 0, 0, gFalse);
+    doImageL3(ref, nullptr, invert, inlineImg, str, width, height, len,
+	      nullptr, nullptr, 0, 0, gFalse);
     break;
   }
 }
@@ -4219,12 +4219,12 @@ void PSOutputDev::drawImage(GfxState * /*state*/, Object *ref, Stream *str,
   case psLevel2:
   case psLevel2Sep:
     doImageL2(ref, colorMap, gFalse, inlineImg, str,
-	      width, height, len, maskColors, NULL, 0, 0, gFalse);
+	      width, height, len, maskColors, nullptr, 0, 0, gFalse);
     break;
   case psLevel3:
   case psLevel3Sep:
     doImageL3(ref, colorMap, gFalse, inlineImg, str,
-	      width, height, len, maskColors, NULL, 0, 0, gFalse);
+	      width, height, len, maskColors, nullptr, 0, 0, gFalse);
     break;
   }
   t3Cacheable = gFalse;
@@ -4251,12 +4251,12 @@ void PSOutputDev::drawMaskedImage(GfxState * /*state*/, Object *ref, Stream *str
   case psLevel2:
   case psLevel2Sep:
     doImageL2(ref, colorMap, gFalse, gFalse, str, width, height, len,
-	      NULL, maskStr, maskWidth, maskHeight, maskInvert);
+	      nullptr, maskStr, maskWidth, maskHeight, maskInvert);
     break;
   case psLevel3:
   case psLevel3Sep:
     doImageL3(ref, colorMap, gFalse, gFalse, str, width, height, len,
-	      NULL, maskStr, maskWidth, maskHeight, maskInvert);
+	      nullptr, maskStr, maskWidth, maskHeight, maskInvert);
     break;
   }
   t3Cacheable = gFalse;
@@ -5448,7 +5448,7 @@ void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace,
       if (((GfxDeviceNColorSpace *)baseCS)->getAlt()->getMode() == csLab) {
 	labCS = (GfxLabColorSpace *)((GfxDeviceNColorSpace *)baseCS)->getAlt();
       } else {
-	labCS = NULL;
+	labCS = nullptr;
       }
       numAltComps = ((GfxDeviceNColorSpace *)baseCS)->getAlt()->getNComps();
       p = lookup;
diff --git a/kpdf/xpdf/xpdf/PSOutputDev.h b/kpdf/xpdf/xpdf/PSOutputDev.h
index e069f2f7..04bf5f07 100644
--- a/kpdf/xpdf/xpdf/PSOutputDev.h
+++ b/kpdf/xpdf/xpdf/PSOutputDev.h
@@ -124,8 +124,8 @@ public:
 			       int rotate, GBool useMediaBox, GBool crop,
 			       int sliceX, int sliceY, int sliceW, int sliceH,
 			       GBool printing, Catalog *catalog,
-			       GBool (*abortCheckCbk)(void *data) = NULL,
-			       void *abortCheckCbkData = NULL);
+			       GBool (*abortCheckCbk)(void *data) = nullptr,
+			       void *abortCheckCbkData = nullptr);
 
   // Start a page.
   virtual void startPage(int pageNum, GfxState *state);
diff --git a/kpdf/xpdf/xpdf/Page.cpp b/kpdf/xpdf/xpdf/Page.cpp
index de2fe6c0..692627f8 100644
--- a/kpdf/xpdf/xpdf/Page.cpp
+++ b/kpdf/xpdf/xpdf/Page.cpp
@@ -426,7 +426,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
   }
 
   gfx = new Gfx(xref, out, num, attrs->getResourceDict(),
-		hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)NULL,
+		hDPI, vDPI, &box, crop ? cropBox : (PDFRectangle *)nullptr,
 		rotate, abortCheckCbk, abortCheckCbkData);
   contents.fetch(xref, &obj);
   if (!obj.isNull()) {
@@ -440,7 +440,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
   annotList = new Annots(xref, catalog, getAnnots(&obj));
   obj.free();
   acroForm = catalog->getAcroForm()->isDict() ?
-               catalog->getAcroForm()->getDict() : NULL;
+               catalog->getAcroForm()->getDict() : nullptr;
   if (acroForm) {
     if (acroForm->lookup("NeedAppearances", &obj)) {
       if (obj.isBool() && obj.getBool()) {
diff --git a/kpdf/xpdf/xpdf/Page.h b/kpdf/xpdf/xpdf/Page.h
index 111554c7..78105a0c 100644
--- a/kpdf/xpdf/xpdf/Page.h
+++ b/kpdf/xpdf/xpdf/Page.h
@@ -61,20 +61,20 @@ public:
   int getRotate() { return rotate; }
   GString *getLastModified()
     { return lastModified.isString()
-	? lastModified.getString() : (GString *)NULL; }
+	? lastModified.getString() : (GString *)nullptr; }
   Dict *getBoxColorInfo()
-    { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }
+    { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)nullptr; }
   Dict *getGroup()
-    { return group.isDict() ? group.getDict() : (Dict *)NULL; }
+    { return group.isDict() ? group.getDict() : (Dict *)nullptr; }
   Stream *getMetadata()
-    { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }
+    { return metadata.isStream() ? metadata.getStream() : (Stream *)nullptr; }
   Dict *getPieceInfo()
-    { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }
+    { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)nullptr; }
   Dict *getSeparationInfo()
     { return separationInfo.isDict()
-	? separationInfo.getDict() : (Dict *)NULL; }
+	? separationInfo.getDict() : (Dict *)nullptr; }
   Dict *getResourceDict()
-    { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
+    { return resources.isDict() ? resources.getDict() : (Dict *)nullptr; }
 
 private:
 
@@ -223,16 +223,16 @@ public:
   void display(OutputDev *out, double hDPI, double vDPI,
 	       int rotate, GBool useMediaBox, GBool crop,
 	       GBool printing, Catalog *catalog,
-	       GBool (*abortCheckCbk)(void *data) = NULL,
-	       void *abortCheckCbkData = NULL);
+	       GBool (*abortCheckCbk)(void *data) = nullptr,
+	       void *abortCheckCbkData = nullptr);
 
   // Display part of a page.
   void displaySlice(OutputDev *out, double hDPI, double vDPI,
 		    int rotate, GBool useMediaBox, GBool crop,
 		    int sliceX, int sliceY, int sliceW, int sliceH,
 		    GBool printing, Catalog *catalog,
-		    GBool (*abortCheckCbk)(void *data) = NULL,
-		    void *abortCheckCbkData = NULL);
+		    GBool (*abortCheckCbk)(void *data) = nullptr,
+		    void *abortCheckCbkData = nullptr);
 
   void makeBox(double hDPI, double vDPI, int rotate,
 	       GBool useMediaBox, GBool upsideDown,
diff --git a/kpdf/xpdf/xpdf/Parser.cpp b/kpdf/xpdf/xpdf/Parser.cpp
index 95475b85..634e39f9 100644
--- a/kpdf/xpdf/xpdf/Parser.cpp
+++ b/kpdf/xpdf/xpdf/Parser.cpp
@@ -160,7 +160,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
   } else {
     error(getPos(), "Bad 'Length' attribute in stream");
     obj.free();
-    return NULL;
+    return nullptr;
   }
 
   // check for length in damaged file
@@ -171,7 +171,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
   // in badly damaged PDF files, we can run off the end of the input
   // stream immediately after the "stream" token
   if (!lexer->getStream()) {
-    return NULL;
+    return nullptr;
   }
   baseStr = lexer->getStream()->getBaseStream();
 
diff --git a/kpdf/xpdf/xpdf/Parser.h b/kpdf/xpdf/xpdf/Parser.h
index 1cca9954..77d374ba 100644
--- a/kpdf/xpdf/xpdf/Parser.h
+++ b/kpdf/xpdf/xpdf/Parser.h
@@ -31,7 +31,7 @@ public:
   ~Parser();
 
   // Get the next object from the input stream.
-  Object *getObj(Object *obj, Guchar *fileKey = NULL,
+  Object *getObj(Object *obj, Guchar *fileKey = nullptr,
 		 CryptAlgorithm encAlgorithm = cryptRC4, int keyLength = 0,
 		 int objNum = 0, int objGen = 0);
 
diff --git a/kpdf/xpdf/xpdf/SecurityHandler.cpp b/kpdf/xpdf/xpdf/SecurityHandler.cpp
index 018e2488..338823cc 100644
--- a/kpdf/xpdf/xpdf/SecurityHandler.cpp
+++ b/kpdf/xpdf/xpdf/SecurityHandler.cpp
@@ -50,13 +50,13 @@ SecurityHandler *SecurityHandler::make(PDFDoc *docA, Object *encryptDictA) {
 #endif
       error(-1, "Couldn't find the '%s' security handler",
 	    filterObj.getName());
-      secHdlr = NULL;
+      secHdlr = nullptr;
 #ifdef ENABLE_PLUGINS
     }
 #endif
   } else {
     error(-1, "Missing or invalid 'Filter' entry in encryption dictionary");
-    secHdlr = NULL;
+    secHdlr = nullptr;
   }
   filterObj.free();
   return secHdlr;
@@ -78,7 +78,7 @@ GBool SecurityHandler::checkEncryption(GString *ownerPassword,
   if (ownerPassword || userPassword) {
     authData = makeAuthData(ownerPassword, userPassword);
   } else {
-    authData = NULL;
+    authData = nullptr;
   }
   ok = authorize(authData);
   if (authData) {
@@ -154,12 +154,12 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA,
   encAlgorithm = cryptRC4;
   encryptMetadata = gTrue;
   memset(fileKey, 0, sizeof(fileKey));
-  fileID = NULL;
-  ownerKey = NULL;
-  userKey = NULL;
-  ownerEnc = NULL;
-  userEnc = NULL;
-  perms = NULL;
+  fileID = nullptr;
+  ownerKey = nullptr;
+  userKey = nullptr;
+  ownerEnc = nullptr;
+  userEnc = nullptr;
+  perms = nullptr;
 
   encryptDictA->dictLookup("V", &versionObj);
   encryptDictA->dictLookup("R", &revisionObj);
@@ -322,9 +322,9 @@ StandardSecurityHandler::~StandardSecurityHandler() {
 void *StandardSecurityHandler::makeAuthData(GString *ownerPassword,
 					    GString *userPassword) {
   return new StandardAuthData(ownerPassword ? ownerPassword->copy()
-			                    : (GString *)NULL,
+			                    : (GString *)nullptr,
 			      userPassword ? userPassword->copy()
-			                   : (GString *)NULL);
+			                   : (GString *)nullptr);
 }
 
 void *StandardSecurityHandler::getAuthData() {
@@ -334,7 +334,7 @@ void *StandardSecurityHandler::getAuthData() {
 
   if (!(core = (XPDFCore *)doc->getGUIData()) ||
       !(password = core->getPassword())) {
-    return NULL;
+    return nullptr;
   }
   return new StandardAuthData(password, password->copy());
 #elif HAVE_WINPDFCORE
@@ -343,11 +343,11 @@ void *StandardSecurityHandler::getAuthData() {
 
   if (!(core = (WinPDFCore *)doc->getGUIData()) ||
       !(password = core->getPassword())) {
-    return NULL;
+    return nullptr;
   }
   return new StandardAuthData(password, password->copy());
 #else
-  return NULL;
+  return nullptr;
 #endif
 }
 
@@ -365,8 +365,8 @@ GBool StandardSecurityHandler::authorize(void *authData) {
     ownerPassword = ((StandardAuthData *)authData)->ownerPassword;
     userPassword = ((StandardAuthData *)authData)->userPassword;
   } else {
-    ownerPassword = NULL;
-    userPassword = NULL;
+    ownerPassword = nullptr;
+    userPassword = nullptr;
   }
   if (!Decrypt::makeFileKey(encVersion, encRevision, fileKeyLength,
 			    ownerKey, userKey, ownerEnc, userEnc, perms, permFlags, fileID,
@@ -411,10 +411,10 @@ void *ExternalSecurityHandler::makeAuthData(GString *ownerPassword,
   char *opw, *upw;
   void *authData;
 
-  opw = ownerPassword ? ownerPassword->getCString() : (char *)NULL;
-  upw = userPassword ? userPassword->getCString() : (char *)NULL;
+  opw = ownerPassword ? ownerPassword->getCString() : (char *)nullptr;
+  upw = userPassword ? userPassword->getCString() : (char *)nullptr;
   if (!(*xsh->makeAuthData)(xsh->handlerData, docData, opw, upw, &authData)) {
-    return NULL;
+    return nullptr;
   }
   return authData;
 }
@@ -423,7 +423,7 @@ void *ExternalSecurityHandler::getAuthData() {
   void *authData;
 
   if (!(*xsh->getAuthData)(xsh->handlerData, docData, &authData)) {
-    return NULL;
+    return nullptr;
   }
   return authData;
 }
diff --git a/kpdf/xpdf/xpdf/SplashOutputDev.cpp b/kpdf/xpdf/xpdf/SplashOutputDev.cpp
index 20898701..1654d5da 100644
--- a/kpdf/xpdf/xpdf/SplashOutputDev.cpp
+++ b/kpdf/xpdf/xpdf/SplashOutputDev.cpp
@@ -388,7 +388,7 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest,
 
 // NB: This must match the GfxBlendMode enum defined in GfxState.h.
 SplashBlendFunc splashOutBlendFuncs[] = {
-  NULL,
+  nullptr,
   &splashOutBlendMultiply,
   &splashOutBlendScreen,
   &splashOutBlendOverlay,
@@ -526,7 +526,7 @@ T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A,
     cacheSets = 1;
   }
   cacheData = (Guchar *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize);
-  if (cacheData != NULL)
+  if (cacheData)
   {
     cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc,
 					 sizeof(T3FontCacheTag));
@@ -536,7 +536,7 @@ T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A,
   }
   else
   {
-    cacheTags = NULL;
+    cacheTags = nullptr;
   }
 }
 
@@ -599,23 +599,23 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA,
   reverseVideo = reverseVideoA;
   splashColorCopy(paperColor, paperColorA);
 
-  xref = NULL;
+  xref = nullptr;
 
   bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
 			    colorMode != splashModeMono1, bitmapTopDown);
   splash = new Splash(bitmap, vectorAntialias, &screenParams);
   splash->clear(paperColor, 0);
 
-  fontEngine = NULL;
+  fontEngine = nullptr;
 
   nT3Fonts = 0;
-  t3GlyphStack = NULL;
+  t3GlyphStack = nullptr;
 
-  font = NULL;
+  font = nullptr;
   needFontUpdate = gFalse;
-  textClipPath = NULL;
+  textClipPath = nullptr;
 
-  transpGroupStack = NULL;
+  transpGroupStack = nullptr;
 }
 
 void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) {
@@ -765,7 +765,7 @@ void SplashOutputDev::startPage(int /*pageNum*/, GfxState *state) {
   splash->setFillPattern(new SplashSolidColor(color));
   splash->setLineCap(splashLineCapButt);
   splash->setLineJoin(splashLineJoinMiter);
-  splash->setLineDash(NULL, 0, 0);
+  splash->setLineDash(nullptr, 0, 0);
   splash->setMiterLimit(10);
   splash->setFlatness(1);
   // the SA parameter supposedly defaults to false, but Acrobat
@@ -920,7 +920,7 @@ SplashPattern *SplashOutputDev::getColor(GfxGray gray, GfxRGB *rgb) {
     b = rgb->b;
   }
 
-  pattern = NULL; // make gcc happy
+  pattern = nullptr; // make gcc happy
   switch (colorMode) {
   case splashModeMono1:
   case splashModeMono8:
@@ -969,7 +969,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
   GfxFontType fontType;
   SplashOutFontFileID *id;
   SplashFontFile *fontFile;
-  SplashFontSrc *fontsrc = NULL;
+  SplashFontSrc *fontsrc = nullptr;
   FoFiTrueType *ff;
   Ref embRef;
   Object refObj, strObj;
@@ -988,11 +988,11 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
   int faceIndex = 0;
 
   needFontUpdate = gFalse;
-  font = NULL;
-  fileName = NULL;
-  tmpBuf = NULL;
+  font = nullptr;
+  fileName = nullptr;
+  tmpBuf = nullptr;
   substIdx = -1;
-  dfp = NULL;
+  dfp = nullptr;
 
   if (!(gfxFont = state->getFont())) {
     goto err1;
@@ -1121,7 +1121,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
 	n = 256;
 	delete ff;
       } else {
-	codeToGID = NULL;
+	codeToGID = nullptr;
 	n = 0;
       }
       if (!(fontFile = fontEngine->loadTrueTypeFont(
@@ -1157,7 +1157,7 @@ void SplashOutputDev::doUpdateFont(GfxState *state) {
       break;
     case fontCIDType2:
     case fontCIDType2OT:
-      codeToGID = NULL;
+      codeToGID = nullptr;
       n = 0;
       if (dfp) {
 	// create a CID-to-GID mapping, via Unicode
@@ -1526,7 +1526,7 @@ GBool SplashOutputDev::beginType3Char(GfxState *state, double /*x*/, double /*y*
   // is the glyph in the cache?
   i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc;
   for (j = 0; j < t3Font->cacheAssoc; ++j) {
-    if (t3Font->cacheTags != NULL) {
+    if (t3Font->cacheTags != nullptr) {
       if ((t3Font->cacheTags[i+j].mru & 0x8000) &&
 	t3Font->cacheTags[i+j].code == code) {
         drawType3Glyph(t3Font, &t3Font->cacheTags[i+j],
@@ -1542,8 +1542,8 @@ GBool SplashOutputDev::beginType3Char(GfxState *state, double /*x*/, double /*y*
   t3GlyphStack = t3gs;
   t3GlyphStack->code = code;
   t3GlyphStack->cache = t3Font;
-  t3GlyphStack->cacheTag = NULL;
-  t3GlyphStack->cacheData = NULL;
+  t3GlyphStack->cacheTag = nullptr;
+  t3GlyphStack->cacheData = nullptr;
 
   return gFalse;
 }
@@ -1696,7 +1696,7 @@ void SplashOutputDev::endTextObject(GfxState * /*state*/) {
   if (textClipPath) {
     splash->clipToPath(textClipPath, gFalse);
     delete textClipPath;
-    textClipPath = NULL;
+    textClipPath = nullptr;
   }
 }
 
@@ -1751,7 +1751,7 @@ void SplashOutputDev::drawImageMask(GfxState *state, Object * /*ref*/, Stream *s
   imgMaskData.y = 0;
 
   splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat,
-			t3GlyphStack != NULL);
+			t3GlyphStack != nullptr);
   if (inlineImg) {
     while (imgMaskData.y < height) {
       imgMaskData.imgStr->getLine();
@@ -1995,7 +1995,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object * /*ref*/, Stream *str,
 
   // special case for one-channel (monochrome/gray/separation) images:
   // build a lookup table here
-  imgData.lookup = NULL;
+  imgData.lookup = nullptr;
   if (colorMap->getNumPixelComps() == 1) {
     n = 1 << colorMap->getBits();
     switch (colorMode) {
@@ -2239,7 +2239,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref,
 
     // special case for one-channel (monochrome/gray/separation) images:
     // build a lookup table here
-    imgData.lookup = NULL;
+    imgData.lookup = nullptr;
     if (colorMap->getNumPixelComps() == 1) {
       n = 1 << colorMap->getBits();
       switch (colorMode) {
@@ -2331,7 +2331,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object * /*ref*/,
 				       maskColorMap->getBits());
   imgMaskData.imgStr->reset();
   imgMaskData.colorMap = maskColorMap;
-  imgMaskData.maskColors = NULL;
+  imgMaskData.maskColors = nullptr;
   imgMaskData.colorMode = splashModeMono8;
   imgMaskData.width = maskWidth;
   imgMaskData.height = maskHeight;
@@ -2363,7 +2363,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object * /*ref*/,
 				   colorMap->getBits());
   imgData.imgStr->reset();
   imgData.colorMap = colorMap;
-  imgData.maskColors = NULL;
+  imgData.maskColors = nullptr;
   imgData.colorMode = colorMode;
   imgData.width = width;
   imgData.height = height;
@@ -2371,7 +2371,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object * /*ref*/,
 
   // special case for one-channel (monochrome/gray/separation) images:
   // build a lookup table here
-  imgData.lookup = NULL;
+  imgData.lookup = nullptr;
   if (colorMap->getNumPixelComps() == 1) {
     n = 1 << colorMap->getBits();
     switch (colorMode) {
@@ -2418,7 +2418,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object * /*ref*/,
   }
   splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat);
 
-  splash->setSoftMask(NULL);
+  splash->setSoftMask(nullptr);
   gfree(imgData.lookup);
   delete imgData.imgStr;
   str->close();
@@ -2702,7 +2702,7 @@ void SplashOutputDev::setSoftMask(GfxState * /*state*/, double * /*bbox*/,
 }
 
 void SplashOutputDev::clearSoftMask(GfxState * /*state*/) {
-  splash->setSoftMask(NULL);
+  splash->setSoftMask(nullptr);
 }
 
 void SplashOutputDev::setPaperColor(SplashColorPtr paperColorA) {
@@ -2778,7 +2778,7 @@ SplashFont *SplashOutputDev::getFont(GString *name, double *textMatA) {
     }
   }
   if (i == 16) {
-    return NULL;
+    return nullptr;
   }
   ref.num = i;
   ref.gen = -1;
@@ -2797,7 +2797,7 @@ SplashFont *SplashOutputDev::getFont(GString *name, double *textMatA) {
       fontFile = fontEngine->loadType1Font(id, fontsrc, winAnsiEncoding);
     } else if (dfp && dfp->kind == displayFontTT) {
       if (!(ff = FoFiTrueType::load(dfp->tt.fileName->getCString()))) {
-	return NULL;
+	return nullptr;
       }
       for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) {
 	if ((ff->getCmapPlatform(cmap) == 3 &&
@@ -2808,7 +2808,7 @@ SplashFont *SplashOutputDev::getFont(GString *name, double *textMatA) {
       }
       if (cmap == ff->getNumCmaps()) {
 	delete ff;
-	return NULL;
+	return nullptr;
       }
       codeToGID = (Gushort *)gmallocn(256, sizeof(Gushort));
       for (i = 0; i < 256; ++i) {
@@ -2823,7 +2823,7 @@ SplashFont *SplashOutputDev::getFont(GString *name, double *textMatA) {
       fontsrc->setFile(dfp->tt.fileName->getCString(), gFalse);
       fontFile = fontEngine->loadTrueTypeFont(id, fontsrc, codeToGID, 256);
     } else {
-      return NULL;
+      return nullptr;
     }
   }
 
diff --git a/kpdf/xpdf/xpdf/Stream.cpp b/kpdf/xpdf/xpdf/Stream.cpp
index 0d85a766..edb14561 100644
--- a/kpdf/xpdf/xpdf/Stream.cpp
+++ b/kpdf/xpdf/xpdf/Stream.cpp
@@ -69,7 +69,7 @@ char *Stream::getLine(char *buf, int size) {
   int c;
 
   if (lookChar() == EOF)
-    return NULL;
+    return nullptr;
   for (i = 0; i < size - 1; ++i) {
     c = getChar();
     if (c == EOF || c == '\n')
@@ -410,7 +410,7 @@ StreamPredictor::StreamPredictor(Stream *strA, int predictorA,
   width = widthA;
   nComps = nCompsA;
   nBits = nBitsA;
-  predLine = NULL;
+  predLine = nullptr;
   ok = gFalse;
 
   nVals = width * nComps;
@@ -777,7 +777,7 @@ EmbedStream::~EmbedStream() {
 Stream *EmbedStream::makeSubStream(Guint /*start*/, GBool /*limitedA*/,
 				   Guint /*lengthA*/, Object * /*dictA*/) {
   error(-1, "Internal: called makeSubStream() on EmbedStream");
-  return NULL;
+  return nullptr;
 }
 
 int EmbedStream::getChar() {
@@ -885,10 +885,10 @@ GString *ASCIIHexStream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 2) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("/ASCIIHexDecode filter\n");
   return s;
@@ -966,10 +966,10 @@ GString *ASCII85Stream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 2) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("/ASCII85Decode filter\n");
   return s;
@@ -990,10 +990,10 @@ LZWStream::LZWStream(Stream *strA, int predictor, int columns, int colors,
     pred = new StreamPredictor(this, predictor, columns, colors, bits);
     if (!pred->isOk()) {
       delete pred;
-      pred = NULL;
+      pred = nullptr;
     }
   } else {
-    pred = NULL;
+    pred = nullptr;
   }
   early = earlyA;
   eof = gFalse;
@@ -1152,10 +1152,10 @@ GString *LZWStream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 2 || pred) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("<< ");
   if (!early) {
@@ -1193,10 +1193,10 @@ GString *RunLengthStream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 2) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("/RunLengthDecode filter\n");
   return s;
@@ -1259,7 +1259,7 @@ CCITTFaxStream::CCITTFaxStream(Stream *strA, int encodingA, GBool endOfLineA,
   codingLine = (int *)gmallocn_checkoverflow(columns + 1, sizeof(int));
   refLine = (int *)gmallocn_checkoverflow(columns + 2, sizeof(int));
 
-  if (codingLine != NULL && refLine != NULL) {
+  if (codingLine && refLine) {
     eof = gFalse;
     codingLine[0] = columns;
   } else {
@@ -1285,7 +1285,7 @@ void CCITTFaxStream::reset() {
 
   str->reset();
 
-  if (codingLine != NULL && refLine != NULL) {
+  if (codingLine && refLine) {
     eof = gFalse;
     codingLine[0] = columns;
   } else {
@@ -1851,10 +1851,10 @@ GString *CCITTFaxStream::getPSFilter(int psLevel, char *indent) {
   char s1[50];
 
   if (psLevel < 2) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("<< ");
   if (encoding != 0) {
@@ -1944,9 +1944,9 @@ DCTStream::DCTStream(Stream *strA, GBool colorXformA):
   x = y = dy = 0;
   for (i = 0; i < 4; ++i) {
     for (j = 0; j < 32; ++j) {
-      rowBuf[i][j] = NULL;
+      rowBuf[i][j] = nullptr;
     }
-    frameBuf[i] = NULL;
+    frameBuf[i] = nullptr;
   }
 
   if (!dctClipInit) {
@@ -2076,10 +2076,10 @@ void DCTStream::close() {
   for (i = 0; i < 4; ++i) {
     for (j = 0; j < 32; ++j) {
       gfree(rowBuf[i][j]);
-      rowBuf[i][j] = NULL;
+      rowBuf[i][j] = nullptr;
     }
     gfree(frameBuf[i]);
-    frameBuf[i] = NULL;
+    frameBuf[i] = nullptr;
   }
   FilterStream::close();
 }
@@ -3305,10 +3305,10 @@ GString *DCTStream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 2) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("<< >> /DCTDecode filter\n");
   return s;
@@ -3958,13 +3958,13 @@ FlateStream::FlateStream(Stream *strA, int predictor, int columns,
     pred = new StreamPredictor(this, predictor, columns, colors, bits);
     if (!pred->isOk()) {
       delete pred;
-      pred = NULL;
+      pred = nullptr;
     }
   } else {
-    pred = NULL;
+    pred = nullptr;
   }
-  litCodeTab.codes = NULL;
-  distCodeTab.codes = NULL;
+  litCodeTab.codes = nullptr;
+  distCodeTab.codes = nullptr;
   memset(buf, 0, flateWindow);
 }
 
@@ -4067,10 +4067,10 @@ GString *FlateStream::getPSFilter(int psLevel, char *indent) {
   GString *s;
 
   if (psLevel < 3 || pred) {
-    return NULL;
+    return nullptr;
   }
   if (!(s = str->getPSFilter(psLevel, indent))) {
-    return NULL;
+    return nullptr;
   }
   s->append(indent)->append("<< >> /FlateDecode filter\n");
   return s;
@@ -4154,11 +4154,11 @@ GBool FlateStream::startBlock() {
   if (litCodeTab.codes != fixedLitCodeTab.codes) {
     gfree(litCodeTab.codes);
   }
-  litCodeTab.codes = NULL;
+  litCodeTab.codes = nullptr;
   if (distCodeTab.codes != fixedDistCodeTab.codes) {
     gfree(distCodeTab.codes);
   }
-  distCodeTab.codes = NULL;
+  distCodeTab.codes = nullptr;
 
   // read block header
   blockHdr = getCodeWord(3);
@@ -4228,7 +4228,7 @@ GBool FlateStream::readDynamicCodes() {
   int len, repeat, code;
   int i;
 
-  codeLenCodeTab.codes = NULL;
+  codeLenCodeTab.codes = nullptr;
 
   // read lengths
   if ((numLitCodes = getCodeWord(5)) == EOF) {
diff --git a/kpdf/xpdf/xpdf/Stream.h b/kpdf/xpdf/xpdf/Stream.h
index 4a7988b2..0dc085d3 100644
--- a/kpdf/xpdf/xpdf/Stream.h
+++ b/kpdf/xpdf/xpdf/Stream.h
@@ -125,7 +125,7 @@ public:
 			      StreamColorSpaceMode * /*csMode*/) {}
 
   // Return the next stream in the "stack".
-  virtual Stream *getNextStream() { return NULL; }
+  virtual Stream *getNextStream() { return nullptr; }
 
   // Add filters to this stream according to the parameters in <dict>.
   // Returns the new stream.
@@ -156,7 +156,7 @@ public:
   virtual BaseStream *getBaseStream() { return this; }
   virtual Stream *getUndecodedStream() { return this; }
   virtual Dict *getDict() { return dict.getDict(); }
-  virtual GString *getFileName() { return NULL; }
+  virtual GString *getFileName() { return nullptr; }
 
   // Get/set position of first byte of stream within the file.
   virtual Guint getStart() = 0;
@@ -741,7 +741,7 @@ public:
   virtual void reset() {}
   virtual int getChar() { return EOF; }
   virtual int lookChar() { return EOF; }
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/)  { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/)  { return nullptr; }
   virtual GBool isBinary(GBool /*last*/ = gTrue) { return gFalse; }
 };
 
@@ -758,7 +758,7 @@ public:
   virtual void reset();
   virtual int getChar();
   virtual int lookChar();
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return nullptr; }
   virtual GBool isBinary(GBool last = gTrue);
   virtual GBool isEncoder() { return gTrue; }
 
@@ -783,7 +783,7 @@ public:
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return nullptr; }
   virtual GBool isBinary(GBool /*last*/ = gTrue) { return gFalse; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -813,7 +813,7 @@ public:
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return nullptr; }
   virtual GBool isBinary(GBool /*last*/ = gTrue) { return gFalse; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -843,7 +843,7 @@ public:
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return NULL; }
+  virtual GString *getPSFilter(int /*psLevel*/, char * /*indent*/) { return nullptr; }
   virtual GBool isBinary(GBool /*last*/ = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
 
diff --git a/kpdf/xpdf/xpdf/TextOutputDev.cpp b/kpdf/xpdf/xpdf/TextOutputDev.cpp
index 3387a31a..8d580942 100644
--- a/kpdf/xpdf/xpdf/TextOutputDev.cpp
+++ b/kpdf/xpdf/xpdf/TextOutputDev.cpp
@@ -174,7 +174,7 @@ TextFontInfo::TextFontInfo(GfxState *state) {
 #if TEXTOUT_WORD_LIST
   fontName = (gfxFont && gfxFont->getOrigName())
                  ? gfxFont->getOrigName()->copy()
-                 : (GString *)NULL;
+                 : (GString *)nullptr;
   flags = gfxFont ? gfxFont->getFlags() : 0;
 #endif
 }
@@ -261,11 +261,11 @@ TextWord::TextWord(GfxState *state, int rotA, double x0, double y0,
     base = x;
     break;
   }
-  text = NULL;
-  edge = NULL;
+  text = nullptr;
+  edge = nullptr;
   len = size = 0;
   spaceAfter = gFalse;
-  next = NULL;
+  next = nullptr;
 
 #if TEXTOUT_WORD_LIST
   GfxRGB rgb;
@@ -281,7 +281,7 @@ TextWord::TextWord(GfxState *state, int rotA, double x0, double y0,
 #endif
 
   underlined = gFalse;
-  link = NULL;
+  link = nullptr;
 }
 
 TextWord::~TextWord() {
@@ -475,8 +475,8 @@ void TextWord::getCharBBox(int charIdx, double *xMinA, double *yMinA,
 TextPool::TextPool() {
   minBaseIdx = 0;
   maxBaseIdx = -1;
-  pool = NULL;
-  cursor = NULL;
+  pool = nullptr;
+  cursor = nullptr;
   cursorBaseIdx = -1;
 }
 
@@ -519,14 +519,14 @@ void TextPool::addWord(TextWord *word) {
     pool = (TextWord **)gmallocn(maxBaseIdx - minBaseIdx + 1,
 				 sizeof(TextWord *));
     for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) {
-      pool[baseIdx - minBaseIdx] = NULL;
+      pool[baseIdx - minBaseIdx] = nullptr;
     }
   } else if (wordBaseIdx < minBaseIdx) {
     newMinBaseIdx = wordBaseIdx - 128;
     newPool = (TextWord **)gmallocn(maxBaseIdx - newMinBaseIdx + 1,
 				    sizeof(TextWord *));
     for (baseIdx = newMinBaseIdx; baseIdx < minBaseIdx; ++baseIdx) {
-      newPool[baseIdx - newMinBaseIdx] = NULL;
+      newPool[baseIdx - newMinBaseIdx] = nullptr;
     }
     memcpy(&newPool[minBaseIdx - newMinBaseIdx], pool,
 	   (maxBaseIdx - minBaseIdx + 1) * sizeof(TextWord *));
@@ -538,7 +538,7 @@ void TextPool::addWord(TextWord *word) {
     pool = (TextWord **)greallocn(pool, newMaxBaseIdx - minBaseIdx + 1,
 				  sizeof(TextWord *));
     for (baseIdx = maxBaseIdx + 1; baseIdx <= newMaxBaseIdx; ++baseIdx) {
-      pool[baseIdx - minBaseIdx] = NULL;
+      pool[baseIdx - minBaseIdx] = nullptr;
     }
     maxBaseIdx = newMaxBaseIdx;
   }
@@ -549,7 +549,7 @@ void TextPool::addWord(TextWord *word) {
     w0 = cursor;
     w1 = cursor->next;
   } else {
-    w0 = NULL;
+    w0 = nullptr;
     w1 = pool[wordBaseIdx - minBaseIdx];
   }
   for (; w1 && word->primaryCmp(w1) > 0; w0 = w1, w1 = w1->next) ;
@@ -573,14 +573,14 @@ TextLine::TextLine(TextBlock *blkA, int rotA, double baseA) {
   xMin = yMin = 0;
   xMax = yMax = -1;
   base = baseA;
-  words = lastWord = NULL;
-  text = NULL;
-  edge = NULL;
-  col = NULL;
+  words = lastWord = nullptr;
+  text = nullptr;
+  edge = nullptr;
+  col = nullptr;
   len = 0;
   convertedLen = 0;
   hyphenated = gFalse;
-  next = NULL;
+  next = nullptr;
 }
 
 TextLine::~TextLine() {
@@ -1110,10 +1110,10 @@ TextBlock::TextBlock(TextPage *pageA, int rotA) {
   priMin = 0;
   priMax = page->pageWidth;
   pool = new TextPool();
-  lines = NULL;
-  curLine = NULL;
-  next = NULL;
-  stackNext = NULL;
+  lines = nullptr;
+  curLine = nullptr;
+  next = nullptr;
+  stackNext = nullptr;
 }
 
 TextBlock::~TextBlock() {
@@ -1174,13 +1174,13 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
 	maxBaseIdx = pool->getBaseIdx(word0->base - secDelta);
       }
       found = gFalse;
-      word1 = word2 = NULL; // make gcc happy
+      word1 = word2 = nullptr; // make gcc happy
       for (idx1 = idx0; idx1 <= maxBaseIdx; ++idx1) {
 	if (idx1 == idx0) {
 	  word1 = word0;
 	  word2 = word0->next;
 	} else {
-	  word1 = NULL;
+	  word1 = nullptr;
 	  word2 = pool->getPool(idx1);
 	}
 	for (; word2; word1 = word2, word2 = word2->next) {
@@ -1226,7 +1226,7 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
   }
 
   // build the lines
-  curLine = NULL;
+  curLine = nullptr;
   poolMinBaseIdx = pool->minBaseIdx;
   charCount = 0;
   nLines = 0;
@@ -1258,7 +1258,7 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
     // create a new line
     word0 = pool->getPool(startBaseIdx);
     pool->setPool(startBaseIdx, word0->next);
-    word0->next = NULL;
+    word0->next = nullptr;
     line = new TextLine(this, word0->rot, word0->base);
     line->addWord(word0);
     lastWord = word0;
@@ -1276,9 +1276,9 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
       // find the left-most word whose baseline is in the range for
       // this line
       bestWordBaseIdx = 0;
-      bestWord0 = bestWord1 = NULL;
+      bestWord0 = bestWord1 = nullptr;
       for (baseIdx = minBaseIdx; baseIdx <= maxBaseIdx; ++baseIdx) {
-	for (word0 = NULL, word1 = pool->getPool(baseIdx);
+	for (word0 = nullptr, word1 = pool->getPool(baseIdx);
 	     word1;
 	     word0 = word1, word1 = word1->next) {
 	  if (word1->base >= minBase &&
@@ -1305,7 +1305,7 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
       } else {
 	pool->setPool(bestWordBaseIdx, bestWord1->next);
       }
-      bestWord1->next = NULL;
+      bestWord1->next = nullptr;
       line->addWord(bestWord1);
       lastWord = bestWord1;
     }
@@ -1315,7 +1315,7 @@ void TextBlock::coalesce(UnicodeMap *uMap) {
       line0 = curLine;
       line1 = curLine->next;
     } else {
-      line0 = NULL;
+      line0 = nullptr;
       line1 = lines;
     }
     for (;
@@ -1588,7 +1588,7 @@ TextFlow::TextFlow(TextPage *pageA, TextBlock *blk) {
   priMin = blk->priMin;
   priMax = blk->priMax;
   blocks = lastBlk = blk;
-  next = NULL;
+  next = nullptr;
 }
 
 TextFlow::~TextFlow() {
@@ -1722,7 +1722,7 @@ int TextWordList::getLength() {
 
 TextWord *TextWordList::get(int idx) {
   if (idx < 0 || idx >= words->getLength()) {
-    return NULL;
+    return nullptr;
   }
   return (TextWord *)words->get(idx);
 }
@@ -1737,9 +1737,9 @@ TextPage::TextPage(GBool rawOrderA) {
   int rot;
 
   rawOrder = rawOrderA;
-  curWord = NULL;
+  curWord = nullptr;
   charPos = 0;
-  curFont = NULL;
+  curFont = nullptr;
   curFontSize = 0;
   nest = 0;
   nTinyChars = 0;
@@ -1749,10 +1749,10 @@ TextPage::TextPage(GBool rawOrderA) {
       pools[rot] = new TextPool();
     }
   }
-  flows = NULL;
-  blocks = NULL;
-  rawWords = NULL;
-  rawLastWord = NULL;
+  flows = nullptr;
+  blocks = nullptr;
+  rawWords = nullptr;
+  rawLastWord = nullptr;
   fonts = new GList();
   lastFindXMin = lastFindYMin = 0;
   haveLastFind = gFalse;
@@ -1797,7 +1797,7 @@ void TextPage::clear() {
 
   if (curWord) {
     delete curWord;
-    curWord = NULL;
+    curWord = nullptr;
   }
   if (rawOrder) {
     while (rawWords) {
@@ -1818,9 +1818,9 @@ void TextPage::clear() {
   }
   deleteGList(fonts, TextFontInfo);
 
-  curWord = NULL;
+  curWord = nullptr;
   charPos = 0;
-  curFont = NULL;
+  curFont = nullptr;
   curFontSize = 0;
   nest = 0;
   nTinyChars = 0;
@@ -1829,10 +1829,10 @@ void TextPage::clear() {
       pools[rot] = new TextPool();
     }
   }
-  flows = NULL;
-  blocks = NULL;
-  rawWords = NULL;
-  rawLastWord = NULL;
+  flows = nullptr;
+  blocks = nullptr;
+  rawWords = nullptr;
+  rawLastWord = nullptr;
   fonts = new GList();
 }
 
@@ -1845,13 +1845,13 @@ void TextPage::updateFont(GfxState *state) {
   int i;
 
   // get the font info object
-  curFont = NULL;
+  curFont = nullptr;
   for (i = 0; i < fonts->getLength(); ++i) {
     curFont = (TextFontInfo *)fonts->get(i);
     if (curFont->matches(state)) {
       break;
     }
-    curFont = NULL;
+    curFont = nullptr;
   }
   if (!curFont) {
     curFont = new TextFontInfo(state);
@@ -2077,7 +2077,7 @@ void TextPage::endWord() {
 
   if (curWord) {
     addWord(curWord);
-    curWord = NULL;
+    curWord = nullptr;
   }
 }
 
@@ -2136,8 +2136,8 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
   }
 
   uMap = globalParams->getTextEncoding();
-  blkList = NULL;
-  lastBlk = NULL;
+  blkList = nullptr;
+  lastBlk = nullptr;
   nBlocks = 0;
   primaryRot = -1;
 
@@ -2344,7 +2344,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
       // create a new block
       word0 = pool->getPool(startBaseIdx);
       pool->setPool(startBaseIdx, word0->next);
-      word0->next = NULL;
+      word0->next = nullptr;
       blk = new TextBlock(this, rot);
       blk->addWord(word0);
 
@@ -2365,7 +2365,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	for (baseIdx = pool->getBaseIdx(minBase);
 	     baseIdx >= pool->getBaseIdx(minBase - lineSpace);
 	     --baseIdx) {
-	  word0 = NULL;
+	  word0 = nullptr;
 	  word1 = pool->getPool(baseIdx);
 	  while (word1) {
 	    if (word1->base < minBase &&
@@ -2382,7 +2382,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 		pool->setPool(baseIdx, word1->next);
 	      }
 	      word1 = word1->next;
-	      word2->next = NULL;
+	      word2->next = nullptr;
 	      blk->addWord(word2);
 	      found = gTrue;
 	      newMinBase = word2->base;
@@ -2400,7 +2400,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	for (baseIdx = pool->getBaseIdx(maxBase);
 	     baseIdx <= pool->getBaseIdx(maxBase + lineSpace);
 	     ++baseIdx) {
-	  word0 = NULL;
+	  word0 = nullptr;
 	  word1 = pool->getPool(baseIdx);
 	  while (word1) {
 	    if (word1->base > maxBase &&
@@ -2417,7 +2417,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 		pool->setPool(baseIdx, word1->next);
 	      }
 	      word1 = word1->next;
-	      word2->next = NULL;
+	      word2->next = nullptr;
 	      blk->addWord(word2);
 	      found = gTrue;
 	      newMaxBase = word2->base;
@@ -2434,7 +2434,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace);
 	     baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace);
 	     ++baseIdx) {
-	  word0 = NULL;
+	  word0 = nullptr;
 	  word1 = pool->getPool(baseIdx);
 	  while (word1) {
 	    if (word1->base >= minBase - intraLineSpace &&
@@ -2453,7 +2453,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 		pool->setPool(baseIdx, word1->next);
 	      }
 	      word1 = word1->next;
-	      word2->next = NULL;
+	      word2->next = nullptr;
 	      blk->addWord(word2);
 	      found = gTrue;
 	    } else {
@@ -2497,7 +2497,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	  for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace);
 	       baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace);
 	       ++baseIdx) {
-	    word0 = NULL;
+	    word0 = nullptr;
 	    word1 = pool->getPool(baseIdx);
 	    while (word1) {
 	      if (word1->base >= minBase - intraLineSpace &&
@@ -2516,7 +2516,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 		  pool->setPool(baseIdx, word1->next);
 		}
 		word1 = word1->next;
-		word2->next = NULL;
+		word2->next = nullptr;
 		blk->addWord(word2);
 		if (word2->base < minBase) {
 		  minBase = word2->base;
@@ -2561,7 +2561,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	  for (baseIdx = pool->getBaseIdx(minBase - intraLineSpace);
 	       baseIdx <= pool->getBaseIdx(maxBase + intraLineSpace);
 	       ++baseIdx) {
-	    word0 = NULL;
+	    word0 = nullptr;
 	    word1 = pool->getPool(baseIdx);
 	    while (word1) {
 	      if (word1->base >= minBase - intraLineSpace &&
@@ -2580,7 +2580,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 		  pool->setPool(baseIdx, word1->next);
 		}
 		word1 = word1->next;
-		word2->next = NULL;
+		word2->next = nullptr;
 		blk->addWord(word2);
 		if (word2->base < minBase) {
 		  minBase = word2->base;
@@ -2812,7 +2812,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
   //~ this also needs to account for right-to-left column ordering
   blkArray = (TextBlock **)gmallocn(nBlocks, sizeof(TextBlock *));
   memcpy(blkArray, blocks, nBlocks * sizeof(TextBlock *));
-  flows = lastFlow = NULL;
+  flows = lastFlow = nullptr;
   firstBlkIdx = 0;
   nBlocksLeft = nBlocks;
   while (nBlocksLeft > 0) {
@@ -2833,9 +2833,9 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
 	}
       }
     }
-    blkArray[i] = NULL;
+    blkArray[i] = nullptr;
     --nBlocksLeft;
-    blk->next = NULL;
+    blk->next = nullptr;
 
     // create a new flow, starting with the upper-left-most block
     flow = new TextFlow(this, blk);
@@ -2848,7 +2848,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
     fontSize = blk->lines->words->fontSize;
 
     // push the upper-left-most block on the stack
-    blk->stackNext = NULL;
+    blk->stackNext = nullptr;
     blkStack = blk;
 
     // find the other blocks in this flow
@@ -2857,7 +2857,7 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
       // find the upper-left-most block under (but within
       // maxBlockSpacing of) the top block on the stack
       blkSpace = maxBlockSpacing * blkStack->lines->words->fontSize;
-      blk = NULL;
+      blk = nullptr;
       i = -1;
       for (j = firstBlkIdx; j < nBlocks; ++j) {
 	blk1 = blkArray[j];
@@ -2879,9 +2879,9 @@ void TextPage::coalesce(GBool /*physLayout*/, GBool doHTML) {
       // if a suitable block was found, add it to the flow and push it
       // onto the stack
       if (blk && flow->blockFits(blk, blkStack)) {
-	blkArray[i] = NULL;
+	blkArray[i] = nullptr;
 	--nBlocksLeft;
-	blk->next = NULL;
+	blk->next = nullptr;
 	flow->addBlock(blk);
 	fontSize = blk->lines->words->fontSize;
 	blk->stackNext = blkStack;
@@ -2960,7 +2960,7 @@ GBool TextPage::findText(Unicode *s, int len,
     s2 = s;
   }
 
-  txt = NULL;
+  txt = nullptr;
   txtSize = 0;
 
   xStart = yStart = xStop = yStop = 0;
@@ -3822,7 +3822,7 @@ static void TextOutputDev_outputToFile(void *stream, char *text, int len) {
 
 TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA,
 			     GBool rawOrderA, GBool append) {
-  text = NULL;
+  text = nullptr;
   physLayout = physLayoutA;
   rawOrder = rawOrderA;
   doHTML = gFalse;
@@ -3846,7 +3846,7 @@ TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA,
     }
     outputFunc = &TextOutputDev_outputToFile;
   } else {
-    outputStream = NULL;
+    outputStream = nullptr;
   }
 
   // set up text object
diff --git a/kpdf/xpdf/xpdf/UnicodeMap.cpp b/kpdf/xpdf/xpdf/UnicodeMap.cpp
index f3d18715..0406ff00 100644
--- a/kpdf/xpdf/xpdf/UnicodeMap.cpp
+++ b/kpdf/xpdf/xpdf/UnicodeMap.cpp
@@ -47,7 +47,7 @@ UnicodeMap *UnicodeMap::parse(GString *encodingNameA) {
   if (!(f = globalParams->getUnicodeMapFile(encodingNameA))) {
     error(-1, "Couldn't find unicodeMap file for the '%s' encoding",
 	  encodingNameA->getCString());
-    return NULL;
+    return nullptr;
   }
 
   map = new UnicodeMap(encodingNameA->copy());
@@ -59,8 +59,8 @@ UnicodeMap *UnicodeMap::parse(GString *encodingNameA) {
   line = 1;
   while (getLine(buf, sizeof(buf), f)) {
     if ((tok1 = strtok(buf, " \t\r\n")) &&
-	(tok2 = strtok(NULL, " \t\r\n"))) {
-      if (!(tok3 = strtok(NULL, " \t\r\n"))) {
+	(tok2 = strtok(nullptr, " \t\r\n"))) {
+      if (!(tok3 = strtok(nullptr, " \t\r\n"))) {
 	tok3 = tok2;
 	tok2 = tok1;
       }
@@ -111,9 +111,9 @@ UnicodeMap::UnicodeMap(GString *encodingNameA) {
   encodingName = encodingNameA;
   unicodeOut = gFalse;
   kind = unicodeMapUser;
-  ranges = NULL;
+  ranges = nullptr;
   len = 0;
-  eMaps = NULL;
+  eMaps = nullptr;
   eMapsLen = 0;
   refCnt = 1;
 #if MULTITHREADED
@@ -128,7 +128,7 @@ UnicodeMap::UnicodeMap(char *encodingNameA, GBool unicodeOutA,
   kind = unicodeMapResident;
   ranges = rangesA;
   len = lenA;
-  eMaps = NULL;
+  eMaps = nullptr;
   eMapsLen = 0;
   refCnt = 1;
 #if MULTITHREADED
@@ -142,7 +142,7 @@ UnicodeMap::UnicodeMap(char *encodingNameA, GBool unicodeOutA,
   unicodeOut = unicodeOutA;
   kind = unicodeMapFunc;
   func = funcA;
-  eMaps = NULL;
+  eMaps = nullptr;
   eMapsLen = 0;
   refCnt = 1;
 #if MULTITHREADED
@@ -245,7 +245,7 @@ UnicodeMapCache::UnicodeMapCache() {
   int i;
 
   for (i = 0; i < unicodeMapCacheSize; ++i) {
-    cache[i] = NULL;
+    cache[i] = nullptr;
   }
 }
 
@@ -289,5 +289,5 @@ UnicodeMap *UnicodeMapCache::getUnicodeMap(GString *encodingName) {
     map->incRefCnt();
     return map;
   }
-  return NULL;
+  return nullptr;
 }
diff --git a/kpdf/xpdf/xpdf/XRef.cpp b/kpdf/xpdf/xpdf/XRef.cpp
index ec40ec47..645a2aa4 100644
--- a/kpdf/xpdf/xpdf/XRef.cpp
+++ b/kpdf/xpdf/xpdf/XRef.cpp
@@ -81,8 +81,8 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
 
   objStrNum = objStrNumA;
   nObjects = 0;
-  objs = NULL;
-  objNums = NULL;
+  objs = nullptr;
+  objNums = nullptr;
   ok = gFalse;
 
   if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) {
@@ -208,10 +208,10 @@ XRef::XRef(BaseStream *strA) {
   ok = gTrue;
   errCode = errNone;
   size = 0;
-  entries = NULL;
-  streamEnds = NULL;
+  entries = nullptr;
+  streamEnds = nullptr;
   streamEndsLen = 0;
-  objStr = NULL;
+  objStr = nullptr;
 
   encrypted = gFalse;
   permFlags = defPermFlags;
@@ -314,8 +314,8 @@ GBool XRef::readXRef(Guint *pos) {
 
   // start up a parser, parse one token
   obj.initNull();
-  parser = new Parser(NULL,
-	     new Lexer(NULL,
+  parser = new Parser(nullptr,
+	     new Lexer(nullptr,
 	       str->makeSubStream(start + *pos, gFalse, 0, &obj)),
 	     gTrue);
   parser->getObj(&obj);
@@ -656,7 +656,7 @@ GBool XRef::constructXRef() {
 
   gfree(entries);
   size = 0;
-  entries = NULL;
+  entries = nullptr;
 
   error(-1, "PDF file is damaged - attempting to reconstruct xref table...");
   gotRoot = gFalse;
@@ -676,8 +676,8 @@ GBool XRef::constructXRef() {
     // got trailer dictionary
     if (!strncmp(p, "trailer", 7)) {
       obj.initNull();
-      parser = new Parser(NULL,
-		 new Lexer(NULL,
+      parser = new Parser(nullptr,
+		 new Lexer(nullptr,
 		   str->makeSubStream(pos + 7, gFalse, 0, &obj)),
 		 gFalse);
       parser->getObj(&newTrailerDict);
@@ -831,7 +831,7 @@ Object *XRef::fetch(int num, int gen, Object *obj) {
       delete parser;
       goto err;
     }
-    parser->getObj(obj, encrypted ? fileKey : (Guchar *)NULL,
+    parser->getObj(obj, encrypted ? fileKey : nullptr,
 		   encAlgorithm, keyLength, num, gen);
     obj1.free();
     obj2.free();
@@ -850,7 +850,7 @@ Object *XRef::fetch(int num, int gen, Object *obj) {
       objStr = new ObjectStream(this, e->offset);
       if (!objStr->isOk()) {
 	delete objStr;
-	objStr = NULL;
+	objStr = nullptr;
 	goto err;
       }
     }
-- 
cgit v1.2.3

