texlive[45031] Build/source/libs: xpdf 4.00

commits+kakuto at tug.org commits+kakuto at tug.org
Sun Aug 13 09:14:49 CEST 2017


Revision: 45031
          http://tug.org/svn/texlive?view=revision&revision=45031
Author:   kakuto
Date:     2017-08-13 09:14:48 +0200 (Sun, 13 Aug 2017)
Log Message:
-----------
xpdf 4.00

Modified Paths:
--------------
    trunk/Build/source/libs/README
    trunk/Build/source/libs/xpdf/ChangeLog
    trunk/Build/source/libs/xpdf/Makefile.am
    trunk/Build/source/libs/xpdf/Makefile.in
    trunk/Build/source/libs/xpdf/TLpatches/ChangeLog
    trunk/Build/source/libs/xpdf/TLpatches/TL-Changes
    trunk/Build/source/libs/xpdf/configure
    trunk/Build/source/libs/xpdf/version.ac
    trunk/Build/source/libs/xpdf/xpdf-src/ANNOUNCE
    trunk/Build/source/libs/xpdf/xpdf-src/CHANGES
    trunk/Build/source/libs/xpdf/xpdf-src/INSTALL
    trunk/Build/source/libs/xpdf/xpdf-src/README
    trunk/Build/source/libs/xpdf/xpdf-src/aconf2.h
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/sample-xpdfrc
    trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.1
    trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.cat
    trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.5
    trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.cat
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiBase.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiEncodings.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiIdentifier.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.h
    trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.h
    trunk/Build/source/libs/xpdf/xpdf-src/goo/GHash.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/GList.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/GMutex.h
    trunk/Build/source/libs/xpdf/xpdf-src/goo/GString.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.h
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.h
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.cc
    trunk/Build/source/libs/xpdf/xpdf-src/goo/parseargs.c
    trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashBitmap.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFileID.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashMath.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPattern.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashTypes.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.cc
    trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFontTables.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/FontEncodingTables.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Function.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JArithmeticDecoder.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Link.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/NameToCharCode.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFDoc.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFDoc.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFDocEncoding.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PSOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PSOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PSTokenizer.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Page.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Page.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Parser.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Parser.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PreScanOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PreScanOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/SecurityHandler.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/SecurityHandler.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Stream.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Stream.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TextOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TextOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TextString.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TextString.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UTF8.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UnicodeMap.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UnicodeMap.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UnicodeMapTables.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UnicodeTypeTable.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XFAForm.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XFAForm.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XRef.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XRef.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Zoox.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Zoox.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/config.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdfdetach.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdffonts.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdfimages.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdfinfo.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdftopng.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdftoppm.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdftops.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/pdftotext.cc

Added Paths:
-----------
    trunk/Build/source/libs/xpdf/TLpatches/patch-bunched
    trunk/Build/source/libs/xpdf/xpdf-src/CMakeLists.txt
    trunk/Build/source/libs/xpdf/xpdf-src/cmake-config.txt
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/CMakeLists.txt
    trunk/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
    trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.h
    trunk/Build/source/libs/xpdf/xpdf-src/splash/CMakeLists.txt
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileCache.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileCache.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileCompositor.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileCompositor.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileMap.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/TileMap.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/UTF8.cc

Removed Paths:
-------------
    trunk/Build/source/libs/xpdf/TLpatches/patch-10-exclude-body-of-Page_getDefaultCTM
    trunk/Build/source/libs/xpdf/TLpatches/patch-20-skip-reading-config-file
    trunk/Build/source/libs/xpdf/TLpatches/patch-22-exclude-openTempFile
    trunk/Build/source/libs/xpdf/TLpatches/patch-30-include-strings_h
    trunk/Build/source/libs/xpdf/TLpatches/patch-40-W32TeX
    trunk/Build/source/libs/xpdf/TLpatches/patch-41-W32TeX
    trunk/Build/source/libs/xpdf/xpdf-foolabs/
    trunk/Build/source/libs/xpdf/xpdf-src/Makefile.in
    trunk/Build/source/libs/xpdf/xpdf-src/aclocal.m4
    trunk/Build/source/libs/xpdf/xpdf-src/aconf-dj.h
    trunk/Build/source/libs/xpdf/xpdf-src/aconf-win32.h
    trunk/Build/source/libs/xpdf/xpdf-src/aconf.h.in
    trunk/Build/source/libs/xpdf/xpdf-src/configure
    trunk/Build/source/libs/xpdf/xpdf-src/configure.in
    trunk/Build/source/libs/xpdf/xpdf-src/dj_make.bat
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.dep
    trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.in
    trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.dep
    trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.in
    trunk/Build/source/libs/xpdf/xpdf-src/misc/
    trunk/Build/source/libs/xpdf/xpdf-src/ms_make.bat
    trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.dep
    trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.in
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.dep
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.in
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFApp.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFApp.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFCore.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFCore.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFTree.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFTree.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFTreeP.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFViewer.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XPDFViewer.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XpdfPluginAPI.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/XpdfPluginAPI.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/about-text.h
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/about.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/backArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/backArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/dblLeftArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/dblLeftArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/dblRightArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/dblRightArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/find.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/findDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/forwardArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/forwardArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/leftArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/leftArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/print.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/printDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/rightArrow.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/rightArrowDis.xbm
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/xpdf.cc
    trunk/Build/source/libs/xpdf/xpdf-src/xpdf/xpdfIcon.xpm

Modified: trunk/Build/source/libs/README
===================================================================
--- trunk/Build/source/libs/README	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/README	2017-08-13 07:14:48 UTC (rev 45031)
@@ -58,8 +58,8 @@
 teckit 2.5.7 - checked 27jun17
   https://github.com/silnrsi/teckit/archive/2.5.7.tar.gz
 
-xpdf 3.04 - checked 28may14
-  ftp://ftp.foolabs.com/pub/xpdf/
+xpdf 4.00 - checked 13aug17
+  http://www.xpdfreader.com/download.html
   with modifications for pdftex
 
 zlib 1.2.11 - checked 15jan17

Modified: trunk/Build/source/libs/xpdf/ChangeLog
===================================================================
--- trunk/Build/source/libs/xpdf/ChangeLog	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/ChangeLog	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,3 +1,9 @@
+2017-08-13  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	* Import xpdf-4.00.
+	* Makefile.am, version.ac: Adjust.
+	* xpdf-foolabs: Remove.
+
 2017-03-27  Karl Berry  <karl at freefriends.org>
 
 	* Makefile.am (EXTRA_DIST): TLpatches not Tlpatches.

Modified: trunk/Build/source/libs/xpdf/Makefile.am
===================================================================
--- trunk/Build/source/libs/xpdf/Makefile.am	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/Makefile.am	2017-08-13 07:14:48 UTC (rev 45031)
@@ -112,6 +112,7 @@
 	@XPDF_TREE@/xpdf/Stream.cc \
 	@XPDF_TREE@/xpdf/TextString.cc \
 	@XPDF_TREE@/xpdf/UnicodeMap.cc \
+	@XPDF_TREE@/xpdf/UTF8.cc \
 	@XPDF_TREE@/xpdf/XFAForm.cc \
 	@XPDF_TREE@/xpdf/XRef.cc \
 	@XPDF_TREE@/xpdf/Zoox.cc

Modified: trunk/Build/source/libs/xpdf/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -160,6 +160,7 @@
 	@XPDF_TREE@/xpdf/Stream.$(OBJEXT) \
 	@XPDF_TREE@/xpdf/TextString.$(OBJEXT) \
 	@XPDF_TREE@/xpdf/UnicodeMap.$(OBJEXT) \
+	@XPDF_TREE@/xpdf/UTF8.$(OBJEXT) \
 	@XPDF_TREE@/xpdf/XFAForm.$(OBJEXT) \
 	@XPDF_TREE@/xpdf/XRef.$(OBJEXT) \
 	@XPDF_TREE@/xpdf/Zoox.$(OBJEXT)
@@ -472,6 +473,7 @@
 	@XPDF_TREE@/xpdf/Stream.cc \
 	@XPDF_TREE@/xpdf/TextString.cc \
 	@XPDF_TREE@/xpdf/UnicodeMap.cc \
+	@XPDF_TREE@/xpdf/UTF8.cc \
 	@XPDF_TREE@/xpdf/XFAForm.cc \
 	@XPDF_TREE@/xpdf/XRef.cc \
 	@XPDF_TREE@/xpdf/Zoox.cc
@@ -677,6 +679,9 @@
 @XPDF_TREE@/xpdf/UnicodeMap.$(OBJEXT):  \
 	@XPDF_TREE@/xpdf/$(am__dirstamp) \
 	@XPDF_TREE@/xpdf/$(DEPDIR)/$(am__dirstamp)
+ at XPDF_TREE@/xpdf/UTF8.$(OBJEXT):  \
+	@XPDF_TREE@/xpdf/$(am__dirstamp) \
+	@XPDF_TREE@/xpdf/$(DEPDIR)/$(am__dirstamp)
 @XPDF_TREE@/xpdf/XFAForm.$(OBJEXT): @XPDF_TREE@/xpdf/$(am__dirstamp) \
 	@XPDF_TREE@/xpdf/$(DEPDIR)/$(am__dirstamp)
 @XPDF_TREE@/xpdf/XRef.$(OBJEXT): @XPDF_TREE@/xpdf/$(am__dirstamp) \
@@ -748,6 +753,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/Stream.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/TextString.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/UnicodeMap.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/UTF8.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/XFAForm.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/XRef.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@XPDF_TREE@/xpdf/$(DEPDIR)/Zoox.Po at am__quote@

Modified: trunk/Build/source/libs/xpdf/TLpatches/ChangeLog
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/ChangeLog	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/ChangeLog	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,3 +1,11 @@
+2017-08-13  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Imported xpdf-4.00 source tree:
+	  http://www.xpdfreader.com/download.html
+	  xpdf-4.00.tar.gz
+	* patch-bunched: Added patch-10, patch-20, patch-22, patch-30,
+	patch-40, and patch-41 by Peter, for simplicity.
+
 2015-05-09  Peter Breitenlohner  <peb at mppmu.mpg.de>
 
 	* patch-41-W32TeX: On Windows use USERPROFILE instead of HOME.

Modified: trunk/Build/source/libs/xpdf/TLpatches/TL-Changes
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/TL-Changes	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/TL-Changes	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,6 +1,6 @@
-Changes applied to the xpdf-3.04/ tree as obtained from:
-	ftp://ftp.foolabs.com/pub/xpdf/
+Changes applied to the xpdf-4.00/ tree as obtained from:
+	http://www.xpdfreader.com/download.html
 
 Removed:
-	install-sh
-
+	aconf.h.in
+	xpdf-qt/

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-10-exclude-body-of-Page_getDefaultCTM
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-10-exclude-body-of-Page_getDefaultCTM	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-10-exclude-body-of-Page_getDefaultCTM	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,23 +0,0 @@
-	Enable compilation with -DPDF_PARSER_ONLY
-
-diff -ur -N xpdf-3.04.orig/xpdf/Page.cc xpdf-3.04/xpdf/Page.cc
---- xpdf-3.04.orig/xpdf/Page.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/Page.cc	2014-05-30 19:57:46.000000000 +0200
-@@ -468,9 +468,9 @@
-   delete links;
- }
- 
--#ifndef PDF_PARSER_ONLY
- void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI,
- 			 int rotate, GBool useMediaBox, GBool upsideDown) {
-+#ifndef PDF_PARSER_ONLY
-   GfxState *state;
-   int i;
- 
-@@ -487,5 +487,5 @@
-     ctm[i] = state->getCTM()[i];
-   }
-   delete state;
--}
- #endif
-+}

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-20-skip-reading-config-file
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-20-skip-reading-config-file	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-20-skip-reading-config-file	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,60 +0,0 @@
-	Patches for pdfTeX / luaTeX / XeTeX
-
-	Declare GlobalParams constructor with a default config file argument
-	and skip reading a config file.
-
-	from:
-		Han The Thanh <thanh at pdftex.org>
-		Peter Breitenlohner <tex-live at tug.org>
-
-diff -ur -N xpdf-3.04.orig/xpdf/GlobalParams.cc xpdf-3.04/xpdf/GlobalParams.cc
---- xpdf-3.04.orig/xpdf/GlobalParams.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/GlobalParams.cc	2014-05-30 19:29:23.000000000 +0200
-@@ -5,6 +5,9 @@
- // Copyright 2001-2003 Glyph & Cog, LLC
- //
- //========================================================================
-+//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
-+//  See top-level ChangeLog for a list of all modifications
-+//========================================================================
- 
- #include <aconf.h>
- 
-@@ -812,6 +815,7 @@
-   f = NULL;
-   fileName = NULL;
-   if (cfgFileName && cfgFileName[0]) {
-+#ifndef PDF_PARSER_ONLY
-     fileName = new GString(cfgFileName);
-     if (!(f = fopen(fileName->getCString(), "r"))) {
-       delete fileName;
-@@ -844,6 +848,7 @@
-     parseFile(fileName, f);
-     delete fileName;
-     fclose(f);
-+#endif /* !PDF_PARSER_ONLY */
-   }
- }
- 
-diff -ur -N xpdf-3.04.orig/xpdf/GlobalParams.h xpdf-3.04/xpdf/GlobalParams.h
---- xpdf-3.04.orig/xpdf/GlobalParams.h	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/GlobalParams.h	2014-05-30 19:29:23.000000000 +0200
-@@ -5,6 +5,9 @@
- // Copyright 2001-2003 Glyph & Cog, LLC
- //
- //========================================================================
-+//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
-+//  See top-level ChangeLog for a list of all modifications
-+//========================================================================
- 
- #ifndef GLOBALPARAMS_H
- #define GLOBALPARAMS_H
-@@ -173,7 +176,7 @@
- 
-   // Initialize the global parameters by attempting to read a config
-   // file.
--  GlobalParams(const char *cfgFileName);
-+  GlobalParams(const char *cfgFileName = NULL);
- 
-   ~GlobalParams();
- 

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-22-exclude-openTempFile
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-22-exclude-openTempFile	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-22-exclude-openTempFile	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,34 +0,0 @@
-	Patches for pdfTeX / luaTeX / XeTeX
-
-	from:
-		Han The Thanh <thanh at pdftex.org>
-
-diff -ur -N xpdf-3.04.orig/goo/gfile.cc xpdf-3.04/goo/gfile.cc
---- xpdf-3.04.orig/goo/gfile.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/goo/gfile.cc	2014-05-30 19:42:41.000000000 +0200
-@@ -7,6 +7,9 @@
- // Copyright 1996-2003 Glyph & Cog, LLC
- //
- //========================================================================
-+//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
-+//  See top-level ChangeLog for a list of all modifications
-+//========================================================================
- 
- #include <aconf.h>
- 
-@@ -441,6 +444,7 @@
- #endif
- }
- 
-+#ifndef PDF_PARSER_ONLY
- GBool openTempFile(GString **name, FILE **f,
- 		   const char *mode, const char *ext) {
- #if defined(_WIN32)
-@@ -551,6 +555,7 @@
-   return gTrue;
- #endif
- }
-+#endif
- 
- GBool createDir(char *path, int mode) {
- #ifdef _WIN32

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-30-include-strings_h
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-30-include-strings_h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-30-include-strings_h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,15 +0,0 @@
-	The Posix manpage says strcasecmp() is declared in <strings.h>
-	and this indeed required for AIX 4.3 and xlc.
-
-diff -ur -N xpdf-3.04.orig/xpdf/GlobalParams.cc xpdf-3.04/xpdf/GlobalParams.cc
---- xpdf-3.04.orig/xpdf/GlobalParams.cc	2014-05-30 19:29:23.000000000 +0200
-+++ xpdf-3.04/xpdf/GlobalParams.cc	2014-05-30 19:47:44.000000000 +0200
-@@ -54,6 +54,8 @@
- #ifdef _WIN32
- #  define strcasecmp stricmp
- #  define strncasecmp strnicmp
-+#else
-+#  include <strings.h>
- #endif
- 
- #if MULTITHREADED

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-40-W32TeX
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-40-W32TeX	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-40-W32TeX	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,29 +0,0 @@
-	WIN32TeX uses MSVC 5.0 with the kpathsea headers and library.
-
-diff -ur -N xpdf-3.04.orig/xpdf/GlobalParams.cc xpdf-3.04/xpdf/GlobalParams.cc
---- xpdf-3.04.orig/xpdf/GlobalParams.cc	2014-05-30 19:47:44.000000000 +0200
-+++ xpdf-3.04/xpdf/GlobalParams.cc	2014-05-30 19:52:04.000000000 +0200
-@@ -52,6 +52,8 @@
- #include "GlobalParams.h"
- 
- #ifdef _WIN32
-+#  undef strcasecmp
-+#  undef strncasecmp
- #  define strcasecmp stricmp
- #  define strncasecmp strnicmp
- #else
-diff -ur -N xpdf-3.04.orig/xpdf/config.h xpdf-3.04/xpdf/config.h
---- xpdf-3.04.orig/xpdf/config.h	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/config.h	2014-05-30 19:52:04.000000000 +0200
-@@ -78,11 +78,6 @@
- // popen
- //------------------------------------------------------------------------
- 
--#if defined(_MSC_VER) || defined(__BORLANDC__)
--#define popen _popen
--#define pclose _pclose
--#endif
--
- #if defined(VMS) || defined(VMCMS) || defined(DOS) || defined(OS2) || defined(__EMX__) || defined(_WIN32) || defined(__DJGPP__) || defined(MACOS)
- #define POPEN_READ_MODE "rb"
- #else

Deleted: trunk/Build/source/libs/xpdf/TLpatches/patch-41-W32TeX
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-41-W32TeX	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-41-W32TeX	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,177 +0,0 @@
-diff -ur -N xpdf-3.04.orig/goo/gfile.cc xpdf-3.04/goo/gfile.cc
---- xpdf-3.04.orig/goo/gfile.cc	2014-05-30 19:42:41.000000000 +0200
-+++ xpdf-3.04/goo/gfile.cc	2015-05-09 15:49:36.000000000 +0200
-@@ -55,7 +55,11 @@
-   char *s;
-   GString *ret;
- 
-+#ifdef _WIN32
-+  if ((s = getenv("USERPROFILE")))
-+#else
-   if ((s = getenv("HOME")))
-+#endif
-     ret = new GString(s);
-   else
-     ret = new GString(".");
-@@ -559,7 +563,7 @@
- 
- GBool createDir(char *path, int mode) {
- #ifdef _WIN32
--  return !mkdir(path);
-+  return !_mkdir(path);
- #else
-   return !mkdir(path, mode);
- #endif
-diff -ur -N xpdf-3.04.orig/xpdf/GlobalParams.cc xpdf-3.04/xpdf/GlobalParams.cc
---- xpdf-3.04.orig/xpdf/GlobalParams.cc	2014-05-30 19:52:04.000000000 +0200
-+++ xpdf-3.04/xpdf/GlobalParams.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -16,7 +16,9 @@
- #endif
- 
- #ifdef _WIN32
-+#  ifndef _WIN32_WINNT
- #  define _WIN32_WINNT 0x0500 // for GetSystemWindowsDirectory
-+#  endif
- #  include <windows.h>
- #endif
- #include <string.h>
-@@ -54,8 +56,8 @@
- #ifdef _WIN32
- #  undef strcasecmp
- #  undef strncasecmp
--#  define strcasecmp stricmp
--#  define strncasecmp strnicmp
-+#  define strcasecmp _stricmp
-+#  define strncasecmp _strnicmp
- #else
- #  include <strings.h>
- #endif
-@@ -2138,8 +2140,11 @@
- 				   base14->fontNum,
- 				   displayFontTab[i].obliqueFactor));
-       } else {
-+// Do not display unnecessary looking message on W32
-+#ifndef _WIN32
- 	error(errConfig, -1, "No display font for '{0:s}'",
- 	      displayFontTab[i].name);
-+#endif
-       }
-     }
-   }
-diff -ur -N xpdf-3.04.orig/xpdf/pdfdetach.cc xpdf-3.04/xpdf/pdfdetach.cc
---- xpdf-3.04.orig/xpdf/pdfdetach.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdfdetach.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -74,6 +74,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if ((doList ? 1 : 0) +
-diff -ur -N xpdf-3.04.orig/xpdf/pdffonts.cc xpdf-3.04/xpdf/pdffonts.cc
---- xpdf-3.04.orig/xpdf/pdffonts.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdffonts.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -107,6 +107,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc != 2 || printVersion || printHelp) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdfimages.cc xpdf-3.04/xpdf/pdfimages.cc
---- xpdf-3.04.orig/xpdf/pdfimages.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdfimages.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -76,6 +76,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc != 3 || printVersion || printHelp) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdfinfo.cc xpdf-3.04/xpdf/pdfinfo.cc
---- xpdf-3.04.orig/xpdf/pdfinfo.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdfinfo.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -100,6 +100,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc != 2 || printVersion || printHelp) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdftohtml.cc xpdf-3.04/xpdf/pdftohtml.cc
---- xpdf-3.04.orig/xpdf/pdftohtml.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdftohtml.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -86,6 +86,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc != 3 || printVersion || printHelp) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdftopng.cc xpdf-3.04/xpdf/pdftopng.cc
---- xpdf-3.04.orig/xpdf/pdftopng.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdftopng.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -99,6 +99,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (mono && gray) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdftoppm.cc xpdf-3.04/xpdf/pdftoppm.cc
---- xpdf-3.04.orig/xpdf/pdftoppm.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdftoppm.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -111,6 +111,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (mono && gray) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdftops.cc xpdf-3.04/xpdf/pdftops.cc
---- xpdf-3.04.orig/xpdf/pdftops.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdftops.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -168,6 +168,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc < 2 || argc > 3 || printVersion || printHelp) {
-diff -ur -N xpdf-3.04.orig/xpdf/pdftotext.cc xpdf-3.04/xpdf/pdftotext.cc
---- xpdf-3.04.orig/xpdf/pdftotext.cc	2014-05-28 20:50:50.000000000 +0200
-+++ xpdf-3.04/xpdf/pdftotext.cc	2015-05-07 08:43:30.000000000 +0200
-@@ -129,6 +129,9 @@
- 
-   exitCode = 99;
- 
-+#ifdef _MSC_VER
-+  (void)kpse_set_program_name(argv[0], NULL);
-+#endif
-   // parse args
-   ok = parseArgs(argDesc, &argc, argv);
-   if (!ok || argc < 2 || argc > 3 || printVersion || printHelp) {

Added: trunk/Build/source/libs/xpdf/TLpatches/patch-bunched
===================================================================
--- trunk/Build/source/libs/xpdf/TLpatches/patch-bunched	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/TLpatches/patch-bunched	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,176 @@
+diff -ur xpdf-4.00.orig/goo/gfile.cc xpdf-4.00/goo/gfile.cc
+--- xpdf-4.00.orig/goo/gfile.cc	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/goo/gfile.cc	Sun Aug 13 13:46:03 2017
+@@ -7,6 +7,9 @@
+ // Copyright 1996-2003 Glyph & Cog, LLC
+ //
+ //========================================================================
++//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
++//  See top-level ChangeLog for a list of all modifications
++//========================================================================
+ 
+ #include <aconf.h>
+ 
+@@ -51,7 +54,11 @@
+   char *s;
+   GString *ret;
+ 
++#ifdef _WIN32
++  if ((s = getenv("USERPROFILE")))
++#else
+   if ((s = getenv("HOME")))
++#endif
+     ret = new GString(s);
+   else
+     ret = new GString(".");
+@@ -400,6 +407,7 @@
+ #endif
+ }
+ 
++#ifndef PDF_PARSER_ONLY
+ GBool openTempFile(GString **name, FILE **f,
+ 		   const char *mode, const char *ext) {
+ #if defined(_WIN32)
+@@ -514,10 +522,11 @@
+   return gTrue;
+ #endif
+ }
++#endif
+ 
+ GBool createDir(char *path, int mode) {
+ #ifdef _WIN32
+-  return !mkdir(path);
++  return !_mkdir(path);
+ #else
+   return !mkdir(path, mode);
+ #endif
+diff -ur xpdf-4.00.orig/xpdf/GlobalParams.cc xpdf-4.00/xpdf/GlobalParams.cc
+--- xpdf-4.00.orig/xpdf/GlobalParams.cc	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/xpdf/GlobalParams.cc	Sun Aug 13 13:51:37 2017
+@@ -5,6 +5,9 @@
+ // Copyright 2001-2003 Glyph & Cog, LLC
+ //
+ //========================================================================
++//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
++//  See top-level ChangeLog for a list of all modifications
++//========================================================================
+ 
+ #include <aconf.h>
+ 
+@@ -38,8 +41,12 @@
+ #include "GlobalParams.h"
+ 
+ #ifdef _WIN32
+-#  define strcasecmp stricmp
+-#  define strncasecmp strnicmp
++#  undef strcasecmp
++#  undef strncasecmp
++#  define strcasecmp _stricmp
++#  define strncasecmp _strnicmp
++#else
++#  include <strings.h>
+ #endif
+ 
+ #if MULTITHREADED
+@@ -677,6 +684,7 @@
+   f = NULL;
+   fileName = NULL;
+   if (cfgFileName && cfgFileName[0]) {
++#ifndef PDF_PARSER_ONLY
+     fileName = new GString(cfgFileName);
+     if (!(f = fopen(fileName->getCString(), "r"))) {
+       delete fileName;
+@@ -709,6 +717,7 @@
+     parseFile(fileName, f);
+     delete fileName;
+     fclose(f);
++#endif /* !PDF_PARSER_ONLY */
+   }
+ }
+ 
+@@ -2105,8 +2114,11 @@
+ 				   base14->fontNum,
+ 				   displayFontTab[i].obliqueFactor));
+       } else {
++// Do not display unnecessary looking message on W32
++#ifndef _WIN32
+ 	error(errConfig, -1, "No display font for '{0:s}'",
+ 	      displayFontTab[i].name);
++#endif
+       }
+     }
+   }
+diff -ur xpdf-4.00.orig/xpdf/GlobalParams.h xpdf-4.00/xpdf/GlobalParams.h
+--- xpdf-4.00.orig/xpdf/GlobalParams.h	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/xpdf/GlobalParams.h	Sun Aug 13 13:32:19 2017
+@@ -5,6 +5,9 @@
+ // Copyright 2001-2003 Glyph & Cog, LLC
+ //
+ //========================================================================
++//  Modified for TeX Live by Peter Breitenlohner <tex-live at tug.org>
++//  See top-level ChangeLog for a list of all modifications
++//========================================================================
+ 
+ #ifndef GLOBALPARAMS_H
+ #define GLOBALPARAMS_H
+@@ -217,7 +220,7 @@
+ 
+   // Initialize the global parameters by attempting to read a config
+   // file.
+-  GlobalParams(const char *cfgFileName);
++  GlobalParams(const char *cfgFileName = NULL);
+ 
+   ~GlobalParams();
+ 
+diff -ur xpdf-4.00.orig/xpdf/Page.cc xpdf-4.00/xpdf/Page.cc
+--- xpdf-4.00.orig/xpdf/Page.cc	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/xpdf/Page.cc	Sun Aug 13 13:24:07 2017
+@@ -480,9 +480,9 @@
+   delete links;
+ }
+ 
+-#ifndef PDF_PARSER_ONLY
+ void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI,
+ 			 int rotate, GBool useMediaBox, GBool upsideDown) {
++#ifndef PDF_PARSER_ONLY
+   GfxState *state;
+   int i;
+ 
+@@ -499,5 +499,5 @@
+     ctm[i] = state->getCTM()[i];
+   }
+   delete state;
+-}
+ #endif
++}
+diff -ur xpdf-4.00.orig/xpdf/XFAForm.cc xpdf-4.00/xpdf/XFAForm.cc
+--- xpdf-4.00.orig/xpdf/XFAForm.cc	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/xpdf/XFAForm.cc	Sun Aug 13 14:28:34 2017
+@@ -27,8 +27,10 @@
+ #include "XFAForm.h"
+ 
+ #ifdef _WIN32
+-#  define strcasecmp stricmp
+-#  define strncasecmp strnicmp
++#  undef strcasecmp
++#  undef strncasecmp
++#  define strcasecmp _stricmp
++#  define strncasecmp _strnicmp
+ #endif
+ 
+ //------------------------------------------------------------------------
+diff -ur xpdf-4.00.orig/xpdf/config.h xpdf-4.00/xpdf/config.h
+--- xpdf-4.00.orig/xpdf/config.h	Wed Aug 09 08:22:50 2017
++++ xpdf-4.00/xpdf/config.h	Sun Aug 13 13:42:04 2017
+@@ -78,11 +78,6 @@
+ // popen
+ //------------------------------------------------------------------------
+ 
+-#if defined(_MSC_VER) || defined(__BORLANDC__)
+-#define popen _popen
+-#define pclose _pclose
+-#endif
+-
+ #if defined(VMS) || defined(VMCMS) || defined(DOS) || defined(OS2) || defined(__EMX__) || defined(_WIN32) || defined(__DJGPP__)
+ #define POPEN_READ_MODE "rb"
+ #else

Modified: trunk/Build/source/libs/xpdf/configure
===================================================================
--- trunk/Build/source/libs/xpdf/configure	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/configure	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xpdf (TeX Live) 3.04.
+# Generated by GNU Autoconf 2.69 for xpdf (TeX Live) 4.00.
 #
 # Report bugs to <tex-k at tug.org>.
 #
@@ -580,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='xpdf (TeX Live)'
 PACKAGE_TARNAME='xpdf--tex-live-'
-PACKAGE_VERSION='3.04'
-PACKAGE_STRING='xpdf (TeX Live) 3.04'
+PACKAGE_VERSION='4.00'
+PACKAGE_STRING='xpdf (TeX Live) 4.00'
 PACKAGE_BUGREPORT='tex-k at tug.org'
 PACKAGE_URL=''
 
@@ -1290,7 +1290,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures xpdf (TeX Live) 3.04 to adapt to many kinds of systems.
+\`configure' configures xpdf (TeX Live) 4.00 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1356,7 +1356,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of xpdf (TeX Live) 3.04:";;
+     short | recursive ) echo "Configuration of xpdf (TeX Live) 4.00:";;
    esac
   cat <<\_ACEOF
 
@@ -1460,7 +1460,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-xpdf (TeX Live) configure 3.04
+xpdf (TeX Live) configure 4.00
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1867,7 +1867,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by xpdf (TeX Live) $as_me 3.04, which was
+It was created by xpdf (TeX Live) $as_me 4.00, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3790,7 +3790,7 @@
 
 # Define the identity of the package.
  PACKAGE='xpdf--tex-live-'
- VERSION='3.04'
+ VERSION='4.00'
 
 
 # Some tools Automake needs.
@@ -6703,7 +6703,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by xpdf (TeX Live) $as_me 3.04, which was
+This file was extended by xpdf (TeX Live) $as_me 4.00, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6773,7 +6773,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-xpdf (TeX Live) config.status 3.04
+xpdf (TeX Live) config.status 4.00
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/libs/xpdf/version.ac
===================================================================
--- trunk/Build/source/libs/xpdf/version.ac	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/version.ac	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,4 +8,4 @@
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current xpdf version
-m4_define([xpdf_version], [3.04])
+m4_define([xpdf_version], [4.00])

Modified: trunk/Build/source/libs/xpdf/xpdf-src/ANNOUNCE
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/ANNOUNCE	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/ANNOUNCE	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,31 +1,33 @@
-Subject: ANNOUNCE: Xpdf 3.04 - a PDF viewer for X
+Subject: ANNOUNCE: Xpdf 4.00 - a PDF viewer and related tools
 
-
 Glyph & Cog, LLC is pleased to announce a new version of Xpdf, the
-open source Portable Document Format (PDF) viewer for X.  The Xpdf
-project also includes a PDF text extractor, PDF-to-PostScript
-converter, and various other utilities.
+open source Portable Document Format (PDF) viewer.  The Xpdf project
+also includes a PDF text extractor, PDF-to-PostScript converter, and
+various other utilities.
 
-Xpdf runs under the X Window System on Unix, and OS/2.  The non-X
-components (pdftops, pdftotext, etc.) also run on Win32 systems and
-should run on pretty much any system with a decent C++ compiler.
+*** The Xpdf web site has moved to www.xpdfreader.com ***
 
+Xpdf uses the Qt toolkit and runs on Linux and Windows.  The
+non-graphical components (pdftops, pdftotext, etc.) run on Linux,
+Unix, Windows, MacOSX, and pretty much any other system with a decent
+C++ compiler.
+
 Major changes:
-* New text extractor.
-* Added the pdftohtml tool.
-* Added the pdftopng tool.
-* New trapezoid-based rasterizer core (for performance).
+* Complete rewrite of the xpdf GUI, using Qt instead of Motif.
+* Multithreaded rasterization in the viewer - pages are now rasterized
+  in a separate thread so that scrolling and other UI activity is not
+  blocked.
+* Added a linear text selection mode.
 
 See the `CHANGES' file for a complete list of changes.
 
 Source (C++ and C) is available, and it should be fairly easy to
-compile for UNIX, OS/2, and Win32.
+compile for Linux and Windows.
 
 More information, source code, and precompiled binaries are on the
-xpdf web page and ftp site:
+xpdf web page:
 
-    http://www.foolabs.com/xpdf/
-    ftp://ftp.foolabs.com/pub/xpdf/
+    http://www.xpdfreader.com/
 
 For information on commercial licensing and consulting, please see the
 Glyph & Cog web site:

Modified: trunk/Build/source/libs/xpdf/xpdf-src/CHANGES
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/CHANGES	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/CHANGES	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2321,3 +2321,136 @@
   size, do it in stream mode instead of prescaling the whole image
   (to avoid running out of memory).
 Added infinite loop detection to pdffonts.
+
+4.00 (2017-aug-10)
+------------------
+Complete rewrite of the xpdf GUI, using Qt instead of Motif.
+Multithreaded rasterization in the viewer - pages are now rasterized
+  in a separate thread so that scrolling and other UI activity is not
+  blocked.
+Added a linear text selection mode.
+Limit transparency groups to the clip rectangle (performance
+  optimization).
+Optimized the SplashScreen code, used in 1-bit monochrome mode.
+Added setmode calls to pdftopng, when writing to stdout on Windows.
+  [Thanks to Robert Schroll.]
+Regenerate the appearance stream for an AcroForm field if there is
+  no appearance stream, even if NeedAppearances isn't set.
+When regenerating AcroForm field appearance streams, use a default
+  font (Helvetica) for fields that don't have a valid font.
+When the line width is increased by the minLineWidth setting, force
+  the line join mode to "bevel" to avoid "whiskers" at sharp corners.
+Change the pdftoppm/pdftopng resolution (-r) argument from an integer
+  to floating point.
+Use the FontDescriptor 'CapHeight' value in place of 'Ascent' if it's
+  available.
+OC (optional content) entries in image XObjects were being ignored.
+Added support for preblended soft-masked images.
+Added optional support for using libjpeg to decode DCT (JPEG)
+  streams.
+Transparency groups weren't being composited correctly in mono1 mode.
+Switched to a different IDCT transform in the DCT (JPEG) decoder, to
+  get better accuracy; the new transform is also a bit faster.
+Modified the polygon scan converter to avoid O(n^2) performance, which
+  can get really bad with paths that have extremely large numbers of
+  segments.
+Added the maxTileWidth, maxTileHeight, tileCacheSize, and
+  workerThreads xpdfrc settings.
+Modified PSOutputDev so it doesn't output resources (fonts, etc.) for
+  pages that are rasterized (because they use transparency).
+Added the -alpha flag to pdftopng.
+Handle TrueType fonts with out-of-bounds loca entries.
+Optimize consectutive "q" (gsave) operations in PostScript output.
+Various improvements to the XFA rendering code.
+Added the -nodiag flag to pdftotext.
+Switched to cmake instead of autoconf.
+Look for Widget-type annotations that aren't attached to the
+  AcroForm, and add them to the AcroForm.
+Added the "-z" option to pdftohtml.
+The JPEG 2000 decoder now treats invalid boxes after the image
+  codestream as non-fatal errors.
+Improved the handling of drop caps in pdftohtml.
+Added the "psNeverRasterize" setting.
+Pdftohtml now converts invisible PDF text to transparent HTML text.
+Check for zero-width/height bitmaps in the JBIG2 decoder -- these can
+  happen in corrupted JBIG2 streams.
+Pdfimages was inverting 1-bit monochrome images.
+Added CCITTFaxStream::getBlock() to speed up the CCITTFax decoder.
+Added resolution info to PNG files generated by pdftopng.
+The DCT decoder now ignores non-Adobe APP14 markers (rather than
+  generating an error).
+Regenerate appearance streams for FreeText annotations.
+The TextString class now handles UTF-16LE in addition to UTF-16BE.
+  (UTF-16LE isn't allowed by the PDF spec, but I've seen it used.)
+Added the simple one-column text extraction mode (pdftotext -simple).
+Added a -cmyk option to pdftoppm to write CMYK PAM files.
+Modified pdfinfo to output "static XFA" or "dynamic XFA", rather than
+  just "XFA".
+Added the "drawFormFields" xpdfrc command.
+Various performance optimizations in the rasterizer.
+Fixed the tiling pattern code to avoid stripes between pattern cells,
+  and to honor the TilingType flag.
+Always split axial shadings into 256 slices.
+Handle the case where an optional content block is left open at the
+  end of a page content stream.
+Accept code-to-CID-type CMaps as ToUnicode CMaps (to work around buggy
+  PDF generators).
+Unicode-to-unicode maps weren't working correctly with fonts that have
+  an "Identity" encoding.
+Modify the lexer to interpret "--123.4" as -123.4, "--123" as 0, and
+  "123-45" as "123" to match Adobe's behavior.
+The text extractor now reverses the order of side-by-side columns for
+  right-to-left scripts.
+Worked on right-to-left script support in pdftohtml (still not
+  complete).
+Switched the default display mode to continuous (from single page).
+Added the "-bom" switch to pdftotext.
+Share font objects when multiple font tags point to the same object.
+The transfer function goes before alpha blending in the rasterizer
+  pipeline.
+Added the "-allinvisible" switch to pdftohtml.
+Added overprint mode (OPM) support in Level 3 PostScript output.
+Added support for DeviceN color spaces in Level 3 PostScript output.
+Added the "-userunit" option to pdftops.
+Added the "-raw" and "-list" options to pdfimages.
+Pdfimages now writes PGM files (instead of PPM files) for DeviceGray
+  and CalGray images.
+Added grayscale PostScript output -- added the '-level2gray' and
+  '-level3gray' switches to pdftops.
+Fix up Type 1 fonts when embedding in PostScript.
+Added the "problematic" column to pdffonts output.
+Generate an appearance stream for signature fields in AcroForms.
+Correctly handle line dash patterns with zero-length segments when the
+  line cap is butt or project.
+Added the "strokeAdjust cad" xpdfrc option; fixed some issues with
+  stroke adjustment and projecting line caps.
+Added support for Code128B bar codes in XFA forms.
+Look at both the ON and OFF arrays in the default OCCD (optional
+  content config dict), to work around certain broken PDF files.
+Added support for XFA 'numericEdit' fields.
+Added support for 'picture' formatting in XFA forms.
+Added mouseClickN events (in addition to mousePressN and
+  mouseReleaseN).
+External CID OpenType CFF fonts should map through Unicode (similarly
+  to external CID TrueType fonts).
+Handle axial and radial shadings in SplashOutputDev, in device space.
+Use the PDF 2.0 inline image length field.
+Handle duplicate embedded Type 1 font names in PostScript output.
+Handle the case of a stroked closed path with a dash pattern -- if the
+  dash pattern is "on" at both the start and end of a subpath, it
+  should be joined.
+If the line dash phase is negative, add a multiple of 2x the total
+  dash length.
+Indexed color space indexes should be clipped to [0,hival].
+Fix the handling of the text render mode with Type 3 fonts, in the
+  rasterizer and in PostScript output.
+CID font metrics shouldn't be sorted - the PDF 2.0 spec says that, in
+  the case of duplicate entries, the first entry should be used.
+PSOutputDev now converts tiling patterns to PostScript tiling patterns
+  (in Level 2/3).
+Fixed a security hole in SecurityHandler.cc (uninitialized variables).
+  This vulnerability was discovered by Kushal Shah of Fortinet's
+  FortiGuard Labs.
+Fixed a security hole in Function.cc (write past end of array).
+Fixed a security hole with the use of d0/d1 operators outside of a
+  Type3 CharProc [CVE-2016-9027].

Added: trunk/Build/source/libs/xpdf/xpdf-src/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/CMakeLists.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/CMakeLists.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,41 @@
+#========================================================================
+#
+# cmake-xpdf.txt
+#
+# CMake script for the Xpdf package.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+cmake_minimum_required(VERSION 2.8.8)
+
+project(xpdf)
+
+include(cmake-config.txt)
+
+add_subdirectory(goo)
+add_subdirectory(fofi)
+add_subdirectory(splash)
+add_subdirectory(xpdf)
+add_subdirectory(xpdf-qt)
+
+if (NOT HAVE_FREETYPE_H)
+  message(WARNING "Couldn't find FreeType -- will not build pdftoppm, pdftopng, pdftohtml, or xpdf.")
+endif ()
+
+if (NOT PNG_FOUND)
+  message(WARNING "Couldn't find libpng -- will not build pdftopng or pdftohtml.")
+endif ()
+
+if (NOT QT4_FOUND AND NOT Qt5Widgets_FOUND)
+  message(WARNING "Couldn't find Qt4 or Qt5 -- will not build xpdf.")
+endif ()
+
+if (NOT MULTITHREADED)
+  message(WARNING "Multithreading is disabled -- will not build xpdf.")
+endif ()
+
+if (NOT USE_EXCEPTIONS)
+  message(WARNING "C++ exceptions are disabled -- will not build xpdf.")
+endif ()


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/INSTALL
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/INSTALL	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/INSTALL	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,14 +1,14 @@
 Xpdf
 ====
 
-version 3.04
-2014-may-28
+version 4.00
+2017-aug-10
 
 The Xpdf software and documentation are
-copyright 1996-2014 Glyph & Cog, LLC.
+copyright 1996-2017 Glyph & Cog, LLC.
 
-Email: derekn at foolabs.com
-WWW: http://www.foolabs.com/xpdf/
+Email: xpdf at xpdfreader.com
+WWW: http://www.xpdfreader.com/
 
 
 Compiling xpdf
@@ -18,179 +18,157 @@
 any ANSI-compliant C++ and C compilers.  The systems and compilers
 it's been tested with are listed on the xpdf web page.
 
-Xpdf requires the Motif (or Lesstif) toolkit.
+Xpdf requires the Qt toolkit.  The non-GUI command line tools do not
+use Qt.
 
 The following notes give specific instructions for compiling on
 different systems.
 
 
-**************
-***  UNIX  ***
-**************
+*********************
+***  Linux, OS X  ***
+*********************
 
-* Install FreeType 2 (this is required).  WARNING: You must have
-  version 2.0.5 or newer.  Some older versions of XFree86 ship with an
-  older version of FreeType, which means you'll need to explicitly set
-  include and library paths to get the correct version:
+* Make sure you have the following installed:
 
-    --with-freetype2-library=PATH
-    --with-freetype2-includes=PATH
+    - CMake 2.8.8 or newer
+    - FreeType 2.0.5 or newer
+    - Qt 4.8.x or 5.x (for xpdf only)
+    - libpng (for pdftoppm and pdftohtml)
+    - zlib (for pdftoppm and pdftohtml)
 
-* If you have Motif (or Lesstif) installed in a non-standard place,
-  you can use the following options to tell configure where to find
-  it:
+  If Qt isn't found, the GUI viewer (xpdf) won't be built, but the
+  command line tools will still be built.
 
-    --with-Xm-library=PATH
-    --with-Xm-includes=PATH
+* Create a build directory.  These instructions assume that you create
+  a directory called "build" under the top-level xpdf source
+  directory, but the build directory can be anywhere you like.  Create
+  the directory and cd into it:
 
-* Run the configure script:
+      cd ..../xpdf-X.YY
+      mkdir build
+      cd build
 
-    ./configure
+* Run cmake:
 
-  This should produce a set of makefiles customized for your system.
-  The configure script accepts the following options (in addition to
-  the usual things accepted by autoconf configure scripts):
+      cmake -DCMAKE_BUILD_TYPE=Release {other options - see below} ..
 
-    --prefix=PREFIX
-        Changes the directory where xpdf is installed.  The default is
-        /usr/local.
+  If your build directory isn't under the source, use the full path to
+  the source directory:
 
-    --enable-a4-paper
-        Switches the default paper size for PostScript output (xpdf
-        and pdftops) to A4.  The default is Letter size.
+      cmake -DCMAKE_BUILD_TYPE=Release {other options} ..../xpdf-X.YY
 
-    --enable-no-text-select
-        With this option, xpdf will not copy text.  (This is only
-        useful on closed systems where the user can't get at the PDF
-        file directly.)
+* If cmake doesn't find FreeType, you can set FREETYPE_DIR to point to
+  the FreeType install directory.  Add this to the cmake command line:
 
-    --enable-opi
-        Enables support for generation of OPI (Open Prepress
-        Interface) comments with pdftops.
+      -DFREETYPE_DIR=/opt/freetype
 
-    --sysconfdir=DIR
-        Look for the system-wide xpdfrc config file in this directory.
-        The default is PREFIX/etc.
+  Cmake will look for ${FREETYPE_DIR}/include.
 
-    --with-appdef-dir=DIR
-        Use the specified app-defaults directory.  The default is
-        /usr/lib/X11/app-defaults.
+  You can also set the FreeType library location with:
 
-  If you need to pass specific options to the C and/or C++ compiler,
-  you can set the CFLAGS and/or CXXFLAGS environment variables before
-  running the configure script.  Any options given that way will be
-  added to the CFLAGS/CXXFLAGS used by all of the Xpdf makefiles.
+      -DFREETYPE_LIBRARY=/opt/freetype/lib/libfreetype.so
 
-* Type 'make'.  This should build the executables:
+* If cmake doesn't find Qt, make sure qmake is on your executable
+  search path.
 
-    xpdf/xpdf
-    xpdf/pdftops
-    xpdf/pdftotext
-    xpdf/pdfinfo
-    xpdf/pdffonts
-    xpdf/pdfdetach
-    xpdf/pdftoppm
-    xpdf/pdfimages
+* To change the xpdf install directory, use:
 
-* If desired, type 'make install' to install the binaries and man
-  pages.
+      -DCMAKE_INSTALL_PREFIX=/opt/xpdf
 
-The old Makefile.config and Makefiles are no longer provided or
-supported.  If you really want to manually configure Xpdf (which is
-not recommended), the files that need to be created are aconf.h,
-Makefile, goo/Makefile, fofi/Makefile, splash/Makefile, and
-xpdf/Makefile, all of which are generated from the corresponding '.in'
-files.
+  If you're familiar with autoconf, this is similar to the "--prefix"
+  option.
 
-If you want to run a quick test, there is a tiny PDF file included
-with xpdf, as misc/hello.pdf .
+* Other configuration options are:
 
+    -DSPLASH_CMYK=ON
+        Enable CMYK rasterization support.
 
-**************
-***  OS/2  ***
-**************
+    -DA4_PAPER=ON
+        Switches the default paper size for PostScript output (xpdf
+        and pdftops) to A4.  The default is Letter size.
 
-Xpdf is known to run under OS/2 with the EMX runtime environment and
-XFree86.  Using a proper autoconf port you can generate a valid
-configure script version.
+    -DNO_TEXT_SELECT=ON
+        With this option, xpdf will not copy text.  (This is only
+        useful on closed systems where the user can't get at the PDF
+        file directly.)
 
+    -DOPI_SUPPORT=ON
+        Enables support for generation of OPI (Open Prepress
+        Interface) comments with pdftops.
 
-***************
-***  Win32  ***
-***************
+    -DMULTITHREADED=0
+        Disables multithreading, which also disables building the GUI
+        viewer (xpdf).  This does not affect the command line tools.
+        Disabling multithreading should only be necessary if you're
+        building with a compiler other than gcc, clang, or Microsoft
+        Visual Studio.
 
-The non-X programs (pdftops, pdftotext, pdfinfo, pdffonts, pdfdetach,
-pdfimages, and pdftoppm) will compile with both gcc (from cygwin),
-djgpp (the Delorie port of gcc) and Microsoft Visual C++.
+    -DSYSTEM_XPDFRC="/etc/xpdfrc"
+        Look for a system-wide xpdfrc config file in this directory.
 
-With cygwin, the build procedure is the same as for Unix:
+     -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1
+     -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1
+        Do not search for the Qt4/Qt5 libraries.  This will disable
+        building the GUI viewer (xpdf).
 
-  * Open a shell.
+     -DCMAKE_C_FLAGS="..."
+     -DCMAKE_CXX_FLAGS="..."
+        Set additional options to pass to the C and/or C++ compilers.
 
-  * ./configure
+     -DCMAKE_EXE_LINKER_FLAGS="..."
+        Set additional options to pass to the linker.
 
-  * make
+* Build:
 
-  * make install
+      make
 
-It is also possible to build the Xpdf viewer with the cygwin XFree86
-port (thanks to Michael A. Richmond for these instructions):
+  This will build the executables in the build directory:
 
-  * make sure you have the lesstif, XFree86-base, and XFree86-prog
-    cygwin packages installed (all from the "XFree86" category)
+      xpdf/xpdf
+      xpdf/pdftops
+      xpdf/pdftotext
+      xpdf/pdftohtml
+      xpdf/pdfinfo
+      xpdf/pdffonts
+      xpdf/pdfdetach
+      xpdf/pdftoppm
+      xpdf/pdftopng
+      xpdf/pdfimages
+      xpdf-qt/xpdf
 
-  * to build xpdf:
-    - cd xpdf-x.yy
-    - ./configure
-        --with-freetype2-library=/usr/lib
-        --with-freetype2-includes=/usr/include/freetype2
-        --with-Xm-library=/usr/lib
-        --with-Xm-includes=/usr/include
-      (all on one line)
-    - make
-    (this should build xpdf.exe, in addition to the command line
-    utilities)
+* If desired, install the binaries and man pages:
 
-With djgpp:
+      make install
 
-  * Open a DOS window.
+If you want to run a quick test, there is a tiny PDF file included
+with xpdf, as misc/hello.pdf .
 
-  * ./dj_make
 
-  * djgpp is a DOS/Windows port of gcc, available from
-    http://www.delorie.com/
+*****************
+***  Windows  ***
+*****************
 
-With djgpp, for DOS 6 (instead of Win32):
+The Windows build procedure is essentially the same as for Unix.  If
+building with cygwin, the procedure is identical to Unix.
 
-  * ./dj_make
+If building with Visual Studio:
 
-  * cd xpdf
+* Make sure you have CMake, FreeType, libpng, and zlib installed.
 
-  * strip pdftops.exe
+* You'll need to set the FREETYPE_DIR variable to point to your
+  FreeType installation, CMAKE_INCLUDE_PATH to point to your libpng
+  includes, CMAKE_LIBRARY_PATH to point to your libpng library, and
+  ZLIB_ROOT to point to your zlib installation.
 
-  * exe2coff pdftops.exe
+      cmake -G "NMake Makefiles"
+            -DCMAKE_BUILD_TYPE=Release
+            -DFREETYPE_DIR="c:/software/freetype"
+            -DCMAKE_INCLUDE_PATH="c:/software/libpng"
+            -DCMAKE_LIBRARY_PATH="c:/software/libpng"
+            -DZLIB_ROOT="c:/software/zlib"
+            ..
 
-  * copy /B c:\djgpp\bin\cwsdstub.exe+pdftops pdftops.exe
+* Build:
 
-  * upx pdftops.exe
-    - if you want compressed executables
-
-  * and similarly for the other executables
-
-  * cwsdstub.exe comes from djgpp/v2misc/csdpmi5b.zip on any of the
-    djgpp ftp mirrors; exe2coff is part of the standard djgpp install
-
-  * upx comes from http://upx.sourceforge.net/
-
-With the Microsoft tools:
-
-  * Open a DOS window.
-
-  * Type "cl".  If you get the message "Bad command or file name", you
-    must run VCVARS32.BAT. (The location of this BAT file can be
-    determined with Explorer.)
-
-  * Type "ms_make"
-
-The dj_make and ms_make scripts don't build pdftoppm -- you'll need to
-install FreeType 2 before you can compile pdftoppm.
+      nmake

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,134 +0,0 @@
-#========================================================================
-#
-# Main xpdf Makefile.
-#
-# Copyright 1996-2003 Glyph & Cog, LLC
-#
-#========================================================================
-
-SHELL = /bin/sh
-
-DESTDIR =
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-srcdir = @srcdir@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-EXE = @EXE@
-
-all:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) @XPDF_TARGET@
-
-all-no-x:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) all-no-x
-
-xpdf: dummy
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) xpdf$(EXE)
-
-pdftops: dummy
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdftops$(EXE)
-
-pdftotext: dummy
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdftotext$(EXE)
-
-pdfinfo:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdfinfo$(EXE)
-
-pdffonts:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdffonts$(EXE)
-
-pdfdetach:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdfdetach$(EXE)
-
-pdftoppm:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdftoppm$(EXE)
-
-pdfimages:
-	cd goo; $(MAKE)
-	cd @UP_DIR at fofi; $(MAKE)
-	cd @UP_DIR at splash; $(MAKE)
-	cd @UP_DIR at xpdf; $(MAKE) pdfimages$(EXE)
-
-dummy:
-
-install: dummy
-	-mkdir -p $(DESTDIR)@bindir@
- at X@	$(INSTALL_PROGRAM) xpdf/xpdf$(EXE) $(DESTDIR)@bindir@/xpdf$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdftops$(EXE) $(DESTDIR)@bindir@/pdftops$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdftotext$(EXE) $(DESTDIR)@bindir@/pdftotext$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdfinfo$(EXE) $(DESTDIR)@bindir@/pdfinfo$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdffonts$(EXE) $(DESTDIR)@bindir@/pdffonts$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdfdetach$(EXE) $(DESTDIR)@bindir@/pdfdetach$(EXE)
- at X@	$(INSTALL_PROGRAM) xpdf/pdftoppm$(EXE) $(DESTDIR)@bindir@/pdftoppm$(EXE)
-	$(INSTALL_PROGRAM) xpdf/pdfimages$(EXE) $(DESTDIR)@bindir@/pdfimages$(EXE)
-	-mkdir -p $(DESTDIR)@mandir@/man1
- at X@	$(INSTALL_DATA) $(srcdir)/doc/xpdf.1 $(DESTDIR)@mandir@/man1/xpdf.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdftops.1 $(DESTDIR)@mandir@/man1/pdftops.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdftotext.1 $(DESTDIR)@mandir@/man1/pdftotext.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdfinfo.1 $(DESTDIR)@mandir@/man1/pdfinfo.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdffonts.1 $(DESTDIR)@mandir@/man1/pdffonts.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdfdetach.1 $(DESTDIR)@mandir@/man1/pdfdetach.1
- at X@	$(INSTALL_DATA) $(srcdir)/doc/pdftoppm.1 $(DESTDIR)@mandir@/man1/pdftoppm.1
-	$(INSTALL_DATA) $(srcdir)/doc/pdfimages.1 $(DESTDIR)@mandir@/man1/pdfimages.1
-	-mkdir -p $(DESTDIR)@mandir@/man5
-	$(INSTALL_DATA) $(srcdir)/doc/xpdfrc.5 $(DESTDIR)@mandir@/man5/xpdfrc.5
-	-mkdir -p $(DESTDIR)@sysconfdir@
-	@if test ! -f $(DESTDIR)@sysconfdir@/xpdfrc; then \
-		echo "$(INSTALL_DATA) $(srcdir)/doc/sample-xpdfrc $(DESTDIR)@sysconfdir@/xpdfrc"; \
-		$(INSTALL_DATA) $(srcdir)/doc/sample-xpdfrc $(DESTDIR)@sysconfdir@/xpdfrc; \
-	else \
-		echo "# not overwriting the existing $(DESTDIR)@sysconfdir@/xpdfrc"; \
-	fi
-
-clean:
-	-cd goo; $(MAKE) clean
-	-cd @UP_DIR at fofi; $(MAKE) clean
-	-cd @UP_DIR at splash; $(MAKE) clean
-	-cd @UP_DIR at xpdf; $(MAKE) clean
-
-distclean: clean
-	rm -f config.log config.status config.cache
-	rm -f aconf.h
-	rm -f Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile
-	rm -f goo/Makefile.dep fofi/Makefile.dep splash/Makefile.dep xpdf/Makefile.dep
-	rm -f goo/Makefile.in.bak fofi/Makefile.in.bak splash/Makefile.in.bak xpdf/Makefile.in.bak
-	touch goo/Makefile.dep
-	touch fofi/Makefile.dep
-	touch splash/Makefile.dep
-	touch xpdf/Makefile.dep
-
-depend:
-	cd goo; $(MAKE) depend
-	cd @UP_DIR at fofi; $(MAKE) depend
-	cd @UP_DIR at splash; $(MAKE) depend
-	cd @UP_DIR at xpdf; $(MAKE) depend

Modified: trunk/Build/source/libs/xpdf/xpdf-src/README
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/README	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/README	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,17 +1,17 @@
 Xpdf
 ====
 
-version 3.04
-2014-may-28
+version 4.00
+2017-aug-10
 
 The Xpdf software and documentation are
-copyright 1996-2014 Glyph & Cog, LLC.
+copyright 1996-2017 Glyph & Cog, LLC.
 
-Email: derekn at foolabs.com
-WWW: http://www.foolabs.com/xpdf/
+Email: xpdf at xpdfreader.com
+WWW: http://www.xpdfreader.com/
 
 The PDF data structures, operators, and specification are
-copyright 1985-2006 Adobe Systems Inc.
+documented in ISO 32000-1:2008.
 
 
 What is Xpdf?
@@ -23,16 +23,14 @@
 PDF text extractor, PDF-to-PostScript converter, and various other
 utilities.
 
-Xpdf runs under the X Window System on UNIX and OS/2.  The non-X
-components (pdftops, pdftotext, etc.) also run on Windows and Mac OSX
-systems and should run on pretty much any system with a decent C++
-compiler.  Xpdf will run on 32-bit and 64-bit machines.
+The Xpdf viewer uses the Qt cross-platform GUI toolkit.  The other
+command line utilties do not require Qt.
 
 
 License & Distribution
 ----------------------
 
-Xpdf is licensed under the GNU General Pulbic License (GPL), version 2
+Xpdf is licensed under the GNU General Public License (GPL), version 2
 or 3.  This means that you can distribute derivatives of Xpdf under
 any of the following:
   - GPL v2 only
@@ -64,18 +62,14 @@
 Compatibility
 -------------
 
-Xpdf is developed and tested on Linux.
+Xpdf uses the Qt toolkit and runs on Linux, Windows, and OS X -- and
+probably other systems that have a Qt port.
 
-In addition, it has been compiled by others on Solaris, AIX, HP-UX,
-Digital Unix, Irix, and numerous other Unix implementations, as well
-as OS/2.  It should work on pretty much any system which runs X11 and
-has Unix-like libraries.  You'll need ANSI C++ and C compilers to
-compile it.
+The non-GUI command line utilities (pdftops, pdftotext, pdftohtml,
+pdfinfo, pdffonts, pdfdetach, pdftoppm, pdftopng, and pdfimages) run
+on Linux, Windows, and OS X -- and should run on pretty much any
+system with a decent C++ compiler.
 
-The non-X components of Xpdf (pdftops, pdftotext, pdfinfo, pdffonts,
-pdfdetach, pdftoppm, and pdfimages) can also be compiled on Windows
-and Mac OSX systems.  See the Xpdf web page for details.
-
 If you compile Xpdf for a system not listed on the web page, please
 let me know.  If you're willing to make your binary available by ftp
 or on the web, I'll be happy to add a link from the Xpdf web page.  I
@@ -85,21 +79,14 @@
 If you can't get Xpdf to compile on your system, send me email and
 I'll try to help.
 
-Xpdf has been ported to the Acorn, Amiga, BeOS, and EPOC.  See the
-Xpdf web page for links.
 
-
 Getting Xpdf
 ------------
 
 The latest version is available from:
 
-  http://www.foolabs.com/xpdf/
+  http://www.xpdfreader.com/
 
-or:
-
-  ftp://ftp.foolabs.com/pub/xpdf/
-
 Source code and several precompiled executables are available.
 
 Announcements of new versions are posted to comp.text.pdf and emailed
@@ -114,8 +101,7 @@
 
   xpdf file.pdf
 
-To generate a PostScript file, hit the "print" button in xpdf, or run
-pdftops:
+To generate a PostScript file, run pdftops:
 
   pdftops file.pdf
 
@@ -123,9 +109,10 @@
 
   pdftotext file.pdf
 
-There are five additional utilities (which are fully described in
+There are several additional utilities (which are fully described in
 their man pages):
 
+  pdftohtml -- converts a PDF file to HTML
   pdfinfo -- dumps a PDF file's Info dictionary (plus some other
              useful information)
   pdffonts -- lists the fonts used in a PDF file along with various
@@ -134,6 +121,7 @@
                PDF file
   pdftoppm -- converts a PDF file to a series of PPM/PGM/PBM-format
               bitmaps
+  pdftopng -- converts a PDF file to a series of PNG image files
   pdfimages -- extracts the images from a PDF file
 
 Command line options and many other details are described in the man
@@ -143,30 +131,6 @@
 xpdfrc(5) man page.
 
 
-Upgrading from Xpdf 3.02 (and earlier)
---------------------------------------
-
-The font configuration system has been changed.  Previous versions
-used mostly separate commands to configure fonts for display and for
-PostScript output.  As of 3.03, configuration options that make sense
-for both display and PS output have been unified.
-
-The following xpdfrc commands have been removed:
-* displayFontT1, displayFontTT: replaced with fontFile
-* displayNamedCIDFontT1, displayNamedCIDFontTT: replaced with fontFile
-* displayCIDFontT1, displayCIDFontTT: replaced with fontFileCC
-* psFont: replaced with psResidentFont
-* psNamedFont16: replaced with psResidentFont16
-* psFont16: replaced with psResidentFontCC
-
-See the xpdfrc(5) man page for more information on the new commands.
-
-Pdftops will now embed external 16-bit fonts (configured with the
-fontFileCC command) when the PDF file refers to a non-embedded font.
-It does not do any subsetting (yet), so the resulting PS files will be
-large.
-
-
 Compiling Xpdf
 --------------
 
@@ -187,7 +151,8 @@
 
 Xpdf uses the following libraries:
 * FreeType [http://www.freetype.org/]
-* libpng [http://www.libpng.com/pub/png/libpng.html] (used by pdftohtml)
+* libpng [http://www.libpng.com/pub/png/libpng.html] (used by pdftohtml
+  and pdftopng)
 * zlib [http://zlib.net/] (used by pdftohtml)
 
 
@@ -231,16 +196,21 @@
 References
 ----------
 
-Adobe Systems Inc., _PDF Reference, sixth edition: Adobe Portable
-Document Format version 1.7_.
+Adobe Systems Inc., ISO 32000-1:2008, Document Management - Portable
+document format - Part 1: PDF 1.7.
 http://www.adobe.com/devnet/pdf/pdf_reference.html
 [The manual for PDF version 1.7.]
 
-Adobe Systems Inc., "Errata for the PDF Reference, sixth edition,
-version 1.7", October 16, 2006.
+Adobe Systems Inc., Adobe Supplement to the ISO 32000, BaseVersion
+1.7, ExtensionLevel 3, June 2008.
 http://www.adobe.com/devnet/pdf/pdf_reference.html
-[The errata for the PDF 1.7 spec.]
+[Additions to the PDF 1.7 spec.]
 
+Adobe Systems Inc., Adobe Supplement to ISO 32000-1, BaseVersion 1.7,
+ExtensionLevel 5, June 2009.
+http://www.adobe.com/devnet/pdf/pdf_reference.html
+[Additions to the PDF 1.7 spec.]
+
 Adobe Systems Inc., _PostScript Language Reference_, 3rd ed.
 Addison-Wesley, 1999, ISBN 0-201-37922-8.
 [The official PostScript manual.]

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/aclocal.m4
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/aclocal.m4	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/aclocal.m4	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,274 +0,0 @@
-# <<< smr.m4 from smr_macros 0.2.4 >>>
-
-dnl ####################### -*- Mode: M4 -*- ###########################
-dnl smr.m4 -- 
-dnl 
-dnl Copyright (C) 1999 Matthew D. Langston <langston at SLAC.Stanford.EDU>
-dnl Copyright (C) 1998 Steve Robbins <stever at cs.mcgill.ca>
-dnl
-dnl This file is free software; you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This file is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this file; if not, write to:
-dnl
-dnl   Free Software Foundation, Inc.
-dnl   Suite 330
-dnl   59 Temple Place
-dnl   Boston, MA 02111-1307, USA.
-dnl ####################################################################
-
-
-dnl NOTE: The macros in this file are extensively documented in the
-dnl       accompanying `smr_macros.texi' Texinfo file.  Please see the
-dnl       Texinfo documentation for the definitive specification of how
-dnl       these macros are supposed to work.  If the macros work
-dnl       differently than the Texinfo documentation says they should,
-dnl       then the macros (and not the Texinfo documentation) has the
-dnl       bug(s).
-
-dnl This is a convenient macro which translates illegal characters for
-dnl bourne shell variables into legal characters.  It has the same
-dnl functionality as sed 'y%./+-:%__p__%'.
-AC_DEFUN([smr_safe_translation], [patsubst(patsubst([$1], [+], [p]), [./-:], [_])])
-
-AC_DEFUN(smr_SWITCH,
-[
-  dnl Define convenient aliases for the arguments since there are so
-  dnl many of them and I keep confusing myself whenever I have to edit
-  dnl this macro.
-  pushdef([smr_name],        $1)
-  pushdef([smr_help_string], $2)
-  pushdef([smr_default],     $3)
-  pushdef([smr_yes_define],  $4)
-  pushdef([smr_no_define],   $5)
-
-  dnl Do some sanity checking of the arguments.
-  ifelse([regexp(smr_default, [^\(yes\|no\)$])], -1, [AC_MSG_ERROR($0: third arg must be either yes or no)])
-
-  dnl Create the help string
-  pushdef([smr_lhs], [--ifelse(smr_default, yes, disable, enable)-smr_name])dnl
-  pushdef([smr_rhs], [ifelse(smr_default, yes, disable, enable) smr_help_string (default is smr_default)])dnl
-
-  dnl Add the option to `configure --help'.  We don't need to supply the
-  dnl 4th argument to AC_ARG_ENABLE (i.e. the code to set the default
-  dnl value) because that is done below by AC_CACHE_CHECK.
-  AC_ARG_ENABLE([smr_name],
-                AC_HELP_STRING([smr_lhs], [smr_rhs]),
-                smr_cv_enable_[]smr_name=$enableval)
-
-  dnl We cache the result so that the user doesn't have to remember
-  dnl which flags they passed to `configure'.
-  AC_CACHE_CHECK([whether to enable smr_help_string],
-                 smr_cv_enable_[]smr_name,
-                 smr_cv_enable_[]smr_name=smr_default)
-
-    ifelse(smr_yes_define, , , test x"[$]smr_cv_enable_[]smr_name" = xyes && AC_DEFINE(smr_yes_define))
-    ifelse(smr_no_define, , ,  test x"[$]smr_cv_enable_[]smr_name" = xno  && AC_DEFINE(smr_no_define))
-
-  dnl Sanity check the value assigned to smr_cv_enable_$1 to force it to
-  dnl be either `yes' or `no'.
-  if test ! x"[$]smr_cv_enable_[]smr_name" = xyes; then
-    if test ! x"[$]smr_cv_enable_[]smr_name" = xno; then
-      AC_MSG_ERROR([smr_lhs must be either yes or no])
-    fi
-  fi
-
-  popdef([smr_name])
-  popdef([smr_help_string])
-  popdef([smr_default])
-  popdef([smr_yes_define])
-  popdef([smr_no_define])
-  popdef([smr_lhs])
-  popdef([smr_rhs])
-])
-
-
-AC_DEFUN(smr_ARG_WITHLIB,
-[
-  dnl Define convenient aliases for the arguments since there are so
-  dnl many of them and I keep confusing myself whenever I have to edit
-  dnl this macro.
-  pushdef([smr_name],        $1)
-  pushdef([smr_libname],     ifelse($2, , smr_name, $2))
-  pushdef([smr_help_string], $3)
-  pushdef([smr_safe_name],   smr_safe_translation(smr_name))
-
-  dnl Add the option to `configure --help'.  We don't need to supply the
-  dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
-  dnl value) because that is done below by AC_CACHE_CHECK.
-  AC_ARG_WITH(smr_safe_name-library,
-              AC_HELP_STRING([--with-smr_safe_name-library[[=PATH]]],
-                             [use smr_name library ifelse(smr_help_string, , , (smr_help_string))]),
-              smr_cv_with_[]smr_safe_name[]_library=$withval)
-
-  dnl We cache the result so that the user doesn't have to remember
-  dnl which flags they passed to `configure'.
-  AC_CACHE_CHECK([whether to use smr_name library],
-                 smr_cv_with_[]smr_safe_name[]_library,
-                 smr_cv_with_[]smr_safe_name[]_library=maybe)
-
-
-  case x"[$]smr_cv_with_[]smr_safe_name[]_library" in
-      xyes | xmaybe)
-          smr_safe_name[]_LIBS="-l[]smr_libname"
-          with_[]smr_safe_name=[$]smr_cv_with_[]smr_safe_name[]_library
-          ;;
-      xno)
-          smr_safe_name[]_LIBS=
-          with_[]smr_safe_name=no
-          ;;
-      *)
-          if test -f "[$]smr_cv_with_[]smr_safe_name[]_library"; then
-            smr_safe_name[]_LIBS=[$]smr_cv_with_[]smr_safe_name[]_library
-          elif test -d "[$]smr_cv_with_[]smr_safe_name[]_library"; then
-            smr_safe_name[]_LIBS="-L[$]smr_cv_with_[]smr_safe_name[]_library -l[]smr_libname"
-          else
-            AC_MSG_ERROR([argument must be boolean, file, or directory])
-          fi
-          with_[]smr_safe_name=yes
-          ;;
-  esac
-
-  popdef([smr_name])
-  popdef([smr_libname])
-  popdef([smr_help_string])
-  popdef([smr_safe_name])
-])
-
-
-AC_DEFUN(smr_ARG_WITHINCLUDES,
-[
-  dnl Define convenient aliases for the arguments since there are so
-  dnl many of them and I keep confusing myself whenever I have to edit
-  dnl this macro.
-  pushdef([smr_name],        $1)
-  pushdef([smr_header],      $2)
-  pushdef([smr_extra_flags], $3)
-  pushdef([smr_safe_name],   smr_safe_translation(smr_name))
-
-  dnl Add the option to `configure --help'.  We don't need to supply the
-  dnl 4th argument to AC_ARG_WITH (i.e. the code to set the default
-  dnl value) because that is done below by AC_CACHE_CHECK.
-  AC_ARG_WITH(smr_safe_name-includes,
-              AC_HELP_STRING([--with-smr_safe_name-includes[[=DIR]]],
-                             [set directory for smr_name headers]),
-              smr_cv_with_[]smr_safe_name[]_includes=$withval)
-
-  dnl We cache the result so that the user doesn't have to remember
-  dnl which flags they passed to `configure'.
-  AC_CACHE_CHECK([where to find the smr_name header files],
-                 smr_cv_with_[]smr_safe_name[]_includes,
-                 smr_cv_with_[]smr_safe_name[]_includes=)
-
-  if test ! x"[$]smr_cv_with_[]smr_safe_name[]_includes" = x; then
-    if test -d "[$]smr_cv_with_[]smr_safe_name[]_includes"; then
-      smr_safe_name[]_CFLAGS="-I[$]smr_cv_with_[]smr_safe_name[]_includes"
-    else
-      AC_MSG_ERROR([argument must be a directory])
-    fi
-  else
-    smr_safe_name[]_CFLAGS=
-  fi
-
-  dnl This bit of logic comes from the autoconf AC_PROG_CC macro.  We
-  dnl need to put the given include directory into CPPFLAGS temporarily,
-  dnl but then restore CPPFLAGS to its old value.
-  smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS [$]smr_safe_name[]_CFLAGS smr_extra_flags"
-
-  dnl If the header file smr_header exists, then define
-  dnl HAVE_[]smr_header (in all capitals).
-  AC_CHECK_HEADERS([smr_header],
-                   smr_have_[]smr_safe_name[]_header=yes,
-                   smr_have_[]smr_safe_name[]_header=no)
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-  popdef([smr_name])
-  popdef([smr_header])
-  popdef([smr_extra_flags])
-  popdef([smr_safe_name])
-])
-
-
-AC_DEFUN(smr_CHECK_LIB,
-[
-  dnl Define convenient aliases for the arguments since there are so
-  dnl many of them and I keep confusing myself whenever I have to edit
-  dnl this macro.
-  pushdef([smr_name],        $1)
-  pushdef([smr_libname],     ifelse($2, , smr_name, $2))
-  pushdef([smr_help_string], $3)
-  pushdef([smr_function],    $4)
-  pushdef([smr_header],      $5)
-  pushdef([smr_extra_libs],  $6)
-  pushdef([smr_extra_flags], $7)
-  pushdef([smr_prototype],   $8)
-  pushdef([smr_safe_name],   smr_safe_translation(smr_name))
-
-  dnl Give the user (via "configure --help") an interface to specify
-  dnl whether we should use the library or not, and possibly where we
-  dnl should find it.
-  smr_ARG_WITHLIB([smr_name], [smr_libname], [smr_help_string])
-
-  if test ! x"$with_[]smr_safe_name" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-    dnl If the caller of smr_CHECK_LIB specified a header file for this
-    dnl library, then give the user (via "configure --help") an
-    dnl interface to specify where this header file can be found (if it
-    dnl isn't found by the compiler by default).
-    ifelse(smr_header, , , [smr_ARG_WITHINCLUDES(smr_name, smr_header, smr_extra_flags)])
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test [$]smr_have_[]smr_safe_name[]_header != no; then
-
-       AC_CHECK_LIB(smr_libname,
-                    smr_function,
-                    smr_have_[]smr_safe_name[]_library=yes,
-                    smr_have_[]smr_safe_name[]_library=no,
-                    [$]smr_safe_name[]_CFLAGS [smr_extra_flags] [$]smr_safe_name[]_LIBS [smr_extra_libs],
-                    [ifelse(smr_prototype, , , [[#]include <smr_header>])],
-                    smr_prototype)
-    fi
-
-    if test x"[$]smr_have_[]smr_safe_name[]_library" = xyes; then
-      AC_MSG_RESULT([using smr_name library])
-    else
-      smr_safe_name[]_LIBS=
-      smr_safe_name[]_CFLAGS=
-
-      if test x"$with_[]smr_safe_name" = xmaybe; then
-        AC_MSG_RESULT([not using smr_name library])
-      else
-        AC_MSG_WARN([requested smr_name library not found!])
-      fi
-    fi
-  fi
-
-  popdef([smr_name])
-  popdef([smr_libname])
-  popdef([smr_help_string])
-  popdef([smr_function])
-  popdef([smr_header])
-  popdef([smr_extra_libs])
-  popdef([smr_extra_flags])
-  popdef([smr_prototype])
-  popdef([smr_safe_name])
-])

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/aconf-dj.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/aconf-dj.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/aconf-dj.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,73 +0,0 @@
-/*
- * aconf-dj.h
- *
- * Copyright 2002-2003 Glyph & Cog, LLC
- */
-
-#ifndef ACONF_H
-#define ACONF_H
-
-/*
- * Use A4 paper size instead of Letter for PostScript output.
- */
-#undef A4_PAPER
-
-/*
- * Do not allow text selection.
- */
-#undef NO_TEXT_SELECT
-
-/*
- * Include support for OPI comments.
- */
-#undef OPI_SUPPORT
-
-/*
- * Directory with the Xpdf app-defaults file.
- */
-#undef APPDEFDIR
-
-/*
- * Full path for the system-wide xpdfrc file.
- */
-#undef SYSTEM_XPDFRC
-
-/*
- * Various include files and functions.
- */
-#define HAVE_DIRENT_H 1
-#undef HAVE_SYS_NDIR_H
-#undef HAVE_SYS_DIR_H
-#undef HAVE_NDIR_H
-#undef HAVE_SYS_SELECT_H
-#undef HAVE_SYS_BSDTYPES_H
-#undef HAVE_STRINGS_H
-#undef HAVE_BSTRING_H
-#define HAVE_POPEN 1
-#undef HAVE_MKSTEMP
-#undef SELECT_TAKES_INT
-#define HAVE_STD_SORT 1
-#undef HAVE_FSEEK64
-
-/*
- * This is defined if using libXpm.
- */
-#undef HAVE_X11_XPM_H
-
-/*
- * One of these is defined if using FreeType (version 1 or 2).
- */
-#undef HAVE_FREETYPE_H
-#undef HAVE_FREETYPE_FREETYPE_H
-
-/*
- * This is defined if using FreeType version 2.
- */
-#undef FREETYPE2
-
-/*
- * This is defined if using libpaper.
- */
-#undef HAVE_PAPER_H
-
-#endif

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/aconf-win32.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/aconf-win32.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/aconf-win32.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,112 +0,0 @@
-/*
- * aconf-win32.h
- *
- * Copyright 2002-2003 Glyph & Cog, LLC
- */
-
-#ifndef ACONF_H
-#define ACONF_H
-
-#include <aconf2.h>
-
-/*
- * Use A4 paper size instead of Letter for PostScript output.
- */
-#undef A4_PAPER
-
-/*
- * Do not allow text selection.
- */
-#undef NO_TEXT_SELECT
-
-/*
- * Include support for OPI comments.
- */
-#undef OPI_SUPPORT
-
-/*
- * Enable multithreading support.
- */
-#define MULTITHREADED 1
-
-/*
- * Enable C++ exceptions.
- */
-#define USE_EXCEPTIONS 1
-
-/*
- * Use fixed point (instead of floating point) arithmetic.
- */
-#undef USE_FIXEDPOINT
-
-/*
- * Directory with the Xpdf app-defaults file.
- */
-#undef APPDEFDIR
-
-/*
- * Full path for the system-wide xpdfrc file.
- */
-#undef SYSTEM_XPDFRC
-
-/*
- * Various include files and functions.
- */
-#undef HAVE_DIRENT_H
-#undef HAVE_SYS_NDIR_H
-#undef HAVE_SYS_DIR_H
-#undef HAVE_NDIR_H
-#undef HAVE_SYS_SELECT_H
-#undef HAVE_SYS_BSDTYPES_H
-#undef HAVE_STRINGS_H
-#undef HAVE_BSTRING_H
-#undef HAVE_POPEN
-#undef HAVE_MKSTEMP
-#undef HAVE_MKSTEMPS
-#undef SELECT_TAKES_INT
-#define HAVE_STD_SORT 1
-#undef HAVE_FSEEKO
-#undef HAVE_FSEEK64
-#define HAVE_FSEEKI64 1
-#undef _FILE_OFFSET_BITS
-#undef _LARGE_FILES
-#undef _LARGEFILE_SOURCE
-#undef HAVE_XTAPPSETEXITFLAG
-
-/*
- * This is defined if using libXpm.
- */
-#undef HAVE_X11_XPM_H
-
-/*
- * One of these is defined if using FreeType (version 1 or 2).
- */
-#undef HAVE_FREETYPE_H
-#define HAVE_FREETYPE_FREETYPE_H 1
-
-/*
- * This is defined if using FreeType version 2.
- */
-#define FREETYPE2
-
-/*
- * This is defined if using libpaper.
- */
-#undef HAVE_PAPER_H
-
-/*
- * Enable support for loading plugins.
- */
-#undef ENABLE_PLUGINS
-
-/*
- * Defined if the Splash library is avaiable.
- */
-#define HAVE_SPLASH 1
-
-/*
- * Enable support for CMYK output.
- */
-#define SPLASH_CMYK 1
-
-#endif

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/aconf.h.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/aconf.h.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/aconf.h.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,107 +0,0 @@
-/*
- * aconf.h
- *
- * Copyright 2002-2003 Glyph & Cog, LLC
- */
-
-#ifndef ACONF_H
-#define ACONF_H
-
-#include <aconf2.h>
-
-/*
- * Use A4 paper size instead of Letter for PostScript output.
- */
-#undef A4_PAPER
-
-/*
- * Do not allow text selection.
- */
-#undef NO_TEXT_SELECT
-
-/*
- * Include support for OPI comments.
- */
-#undef OPI_SUPPORT
-
-/*
- * Enable multithreading support.
- */
-#undef MULTITHREADED
-
-/*
- * Enable C++ exceptions.
- */
-#undef USE_EXCEPTIONS
-
-/*
- * Use fixed point (instead of floating point) arithmetic.
- */
-#undef USE_FIXEDPOINT
-
-/*
- * Directory with the Xpdf app-defaults file.
- */
-#undef APPDEFDIR
-
-/*
- * Full path for the system-wide xpdfrc file.
- */
-#undef SYSTEM_XPDFRC
-
-/*
- * Various include files and functions.
- */
-#undef HAVE_DIRENT_H
-#undef HAVE_SYS_NDIR_H
-#undef HAVE_SYS_DIR_H
-#undef HAVE_NDIR_H
-#undef HAVE_SYS_SELECT_H
-#undef HAVE_SYS_BSDTYPES_H
-#undef HAVE_STRINGS_H
-#undef HAVE_BSTRING_H
-#undef HAVE_POPEN
-#undef HAVE_MKSTEMP
-#undef HAVE_MKSTEMPS
-#undef SELECT_TAKES_INT
-#undef HAVE_STD_SORT
-#undef HAVE_FSEEKO
-#undef HAVE_FSEEK64
-#undef HAVE_FSEEKI64
-#undef _FILE_OFFSET_BITS
-#undef _LARGE_FILES
-#undef _LARGEFILE_SOURCE
-#undef HAVE_XTAPPSETEXITFLAG
-
-/*
- * This is defined if using libXpm.
- */
-#undef HAVE_X11_XPM_H
-
-/*
- * One of these is defined if using FreeType 2.
- */
-#undef HAVE_FREETYPE_H
-#undef HAVE_FREETYPE_FREETYPE_H
-
-/*
- * This is defined if using libpaper.
- */
-#undef HAVE_PAPER_H
-
-/*
- * Enable support for loading plugins.
- */
-#undef ENABLE_PLUGINS
-
-/*
- * Defined if the Splash library is avaiable.
- */
-#undef HAVE_SPLASH
-
-/*
- * Enable support for CMYK output.
- */
-#undef SPLASH_CMYK
-
-#endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/aconf2.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/aconf2.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/aconf2.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,7 +15,7 @@
 /*
  * This controls the use of the interface/implementation pragmas.
  */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__clang__)
 #define USE_GCC_PRAGMAS
 #endif
 /* There is a bug in the version of gcc which ships with MacOS X 10.2 */

Added: trunk/Build/source/libs/xpdf/xpdf-src/cmake-config.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/cmake-config.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/cmake-config.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,290 @@
+#========================================================================
+#
+# cmake-config.txt
+#
+# CMake script to do misc cmake config and platform-specific config.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include(CheckFunctionExists)
+include(CheckCXXSourceCompiles)
+
+enable_language(CXX)
+
+#--- set default C/C++ compiler flags for Unix
+#    and add a 'Profiling' build mode
+if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+  if (CYGWIN)
+    set(PIC_FLAG "")
+  else ()
+    set(PIC_FLAG "-fPIC")
+  endif ()
+  set(CMAKE_C_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
+  set(CMAKE_CXX_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
+  set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g -O -Wall ${PIC_FLAG}")
+  set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall ${PIC_FLAG}")
+  set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall ${PIC_FLAG}")
+  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-O2 -Wall ${PIC_FLAG}")
+  set(CMAKE_C_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
+      CACHE STRING "C compiler flags for profiling mode")
+  set(CMAKE_CXX_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
+      CACHE STRING "C++ compiler flags for profiling mode")
+  set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-g -pg -O -Wall ${PIC_FLAG}"
+      CACHE STRING "linker flags for profiling mode")
+  mark_as_advanced(
+    CMAKE_C_FLAGS_PROFILING
+    CMAKE_CXX_FLAGS_PROFILING
+    CMAKE_EXE_LINKER_FLAGS_PROFILING)
+  set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
+      "Choose build mode - options are: None Debug Release RelWithDebInfo MinSiz
+eRel Profiling")
+endif ()
+
+#--- set default C/C++ compiler flags for Windows
+if (WIN32)
+  foreach (var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
+               CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
+               CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
+               CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+    # note: this converts /MD to /MT and /MDd to /MTd
+    string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
+  endforeach ()
+  set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
+  set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
+  foreach (var CMAKE_C_FLAGS_DEBUG
+               CMAKE_C_FLAGS_RELEASE
+               CMAKE_C_FLAGS_MINSIZEREL
+               CMAKE_C_FLAGS_RELWITHDEBINFO)
+    set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996")
+  endforeach ()
+  foreach (var CMAKE_CXX_FLAGS_DEBUG
+               CMAKE_CXX_FLAGS_RELEASE
+               CMAKE_CXX_FLAGS_MINSIZEREL
+               CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+    set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996 /EHsc")
+  endforeach ()
+endif ()
+
+#--- don't set an rpath
+set(CMAKE_SKIP_RPATH FALSE)
+
+#--- miscellaneous options
+option(A4_PAPER "use A4 (instead of Letter) paper size by default for PostScript output" OFF)
+option(NO_TEXT_SELECT "do not allow text selection" OFF)
+option(OPI_SUPPORT "include support for OPI comments" OFF)
+option(MULTITHREADED "include support for multithreading" ON)
+option(USE_EXCEPTIONS "use C++ exceptions" ON)
+option(USE_FIXEDPOINT "use fixed point (instead of floating point) arithmetic" OFF)
+option(SPLASH_CMYK "include support for CMYK rasterization" OFF)
+option(SPLASH_DEVICEN "include support for DeviceN rasterization" OFF)
+if (SPLASH_DEVICEN)
+  set(SPLASH_CMYK ON)
+endif ()
+option(USE_LCMS "enable color management using lcms2" OFF)
+option(HIGHLIGHTED_REGIONS "include support for highlighted regions" OFF)
+option(SYSTEM_XPDFRC "full path for system-wide xpdfrc file" "")
+if (SYSTEM_XPDFRC)
+  set(SYSTEM_XPDFRC_DEFINE "#define SYSTEM_XPDFRC \"${SYSTEM_XPDFRC}\"")
+else ()
+  set(SYSTEM_XPDFRC_DEFINE "/* #undef SYSTEM_XPDFRC */")
+endif ()
+option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" OFF)
+option(EVAL_MODE "enable evaluation mode" OFF)
+option(BUILDING_XPDFREADER "enable closed source XpdfReader build" OFF)
+
+#--- check for various library functions
+check_function_exists(mkstemp HAVE_MKSTEMP)
+check_function_exists(mkstemps HAVE_MKSTEMPS)
+check_function_exists(popen HAVE_POPEN)
+check_cxx_source_compiles(
+    "#include <algorithm>
+    bool cmp(const int &x, const int &y) { return x < y; }
+    int a[100];
+    int main() { std::sort(a, a+100, &cmp); }"
+  HAVE_STD_SORT)
+
+#--- set up 64-bit file seeks
+check_function_exists(fseeko HAVE_FSEEKO)
+check_function_exists(fseek64 HAVE_FSEEK64)
+check_function_exists(_fseeki64 HAVE_FSEEKI64)
+
+#--- look for FreeType
+# This could use cmake's FindFreetype, except that it would require
+# a newer version of cmake -- because FreeType changed their include
+# paths around.  Older versions of FreeType require two separate
+# -I switches (typically ..../include and ..../include/freetype2);
+# while newer versions require just one (typically ..../include/freetype2)
+find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
+  HINTS
+  ${FREETYPE_DIR}
+  PATHS
+  /usr/local/include
+  /usr/local/X11R6/include
+  /usr/local/X11/include
+  /usr/freeware/include
+  PATH_SUFFIXES freetype2 include/freetype2 include
+)
+find_path(FREETYPE_INCLUDE_DIR_freetype freetype.h
+  HINTS
+  ${FREETYPE_DIR}
+  PATHS
+  /usr/local/include
+  /usr/local/X11R6/include
+  /usr/local/X11/include
+  /usr/freeware/include
+  PATH_SUFFIXES freetype2 include/freetype2 include
+)
+find_path(FREETYPE_INCLUDE_DIR_freetype_freetype freetype/freetype.h
+  HINTS
+  ${FREETYPE_DIR}
+  PATHS
+  /usr/local/include
+  /usr/local/X11R6/include
+  /usr/local/X11/include
+  /usr/freeware/include
+  PATH_SUFFIXES freetype2 include/freetype2 include
+)
+find_library(FREETYPE_LIBRARY
+  NAMES freetype libfreetype freetype2 freetype219
+  HINTS
+  ${FREETYPE_DIR}
+  PATH_SUFFIXES lib64 lib
+  PATHS
+  /usr/local
+  /usr/local/X11R6
+  /usr/local/X11
+  /usr/freeware
+)
+if (FREETYPE_INCLUDE_DIR_ft2build
+    AND FREETYPE_INCLUDE_DIR_freetype
+    AND (FREETYPE_INCLUDE_DIR_ft2build STREQUAL FREETYPE_INCLUDE_DIR_freetype)
+    AND FREETYPE_LIBRARY)
+  set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build}")
+  set(HAVE_FREETYPE_H TRUE)
+  message(STATUS "Found FreeType (new-style includes): ${FREETYPE_LIBRARY}")
+elseif (FREETYPE_INCLUDE_DIR_ft2build
+        AND FREETYPE_INCLUDE_DIR_freetype_freetype
+        AND FREETYPE_LIBRARY)
+  set(FREETYPE_INCLUDE_DIRS
+      "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype_freetype}")
+  set(HAVE_FREETYPE_H TRUE)
+  message(STATUS "Found FreeType (old-style includes): ${FREETYPE_LIBRARY}")
+else ()
+  message(STATUS "FreeType not found")
+endif ()
+if (HAVE_FREETYPE_H)
+  set(HAVE_SPLASH TRUE)
+endif ()
+
+#--- look for D-Type
+if (DTYPE_INCLUDE_DIR AND DTYPE_LIBRARY)
+  set(HAVE_DTYPE4_H TRUE)
+  message(STATUS "Found D-Type: ${DTYPE_LIBRARY}")
+endif ()
+
+#--- look for zlib
+find_package(ZLIB)
+
+#--- look for libpng
+find_package(PNG)
+
+#--- look for libjpeg
+find_package(JPEG)
+
+#--- look for libtiff
+find_package(TIFF)
+
+#--- look for lcms2
+if (USE_LCMS)
+  find_path(LCMS_INCLUDE_DIR lcms2.h
+    HINTS
+    ${LCMS_DIR}
+    PATHS
+    /usr/local/include
+    /usr/freeware/include
+    PATH_SUFFIXES include
+  )
+  find_library(LCMS_LIBRARY
+    NAMES lcms2 liblcms2
+    HINTS
+    ${LCMS_DIR}
+    PATHS
+    /usr/local
+    /usr/freeware
+  )
+endif ()
+if (USE_LCMS AND LCMS_INCLUDE_DIR AND LCMS_LIBRARY)
+  set(HAVE_LCMS TRUE)
+  message(STATUS "Found lcms2: ${LCMS_LIBRARY}")
+else ()
+  set(HAVE_LCMS FALSE)
+  message(STATUS "lcms2 not found")
+endif ()
+
+#--- look for Qt
+find_package(Qt5Widgets QUIET)
+if (Qt5Widgets_FOUND)
+  find_package(Qt5PrintSupport)
+else ()
+  find_package(Qt4)
+endif ()
+if(Qt5Widgets_FOUND)
+  message(STATUS "Qt5 found")
+  if (XPDFWIDGET_PRINTING)
+    set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}")
+    set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS}")
+    if (APPLE)
+      set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport "-framework ApplicationServices")
+    elseif (UNIX)
+      set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport cups)
+    else ()
+      set(QT_LIBRARIES Qt5::Widgets Qt5::PrintSupport)
+    endif ()
+  else ()
+    set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
+    set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS}")
+    set(QT_LIBRARIES Qt5::Widgets)
+  endif ()
+  if (XPDFWIDGET_PRINTING)
+    if (APPLE)
+      set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
+    elseif (UNIX)
+      set(EXTRA_QT_LIBRARIES cups)
+    else ()
+      set(EXTRA_QT_LIBRARIES "")
+    endif ()
+  endif ()
+  # remove "-fPIE" here because we added "-fPIC" above
+  string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
+  if (POLICY CMP0020)
+    # do not link to qtmain.lib
+    cmake_policy(SET CMP0020 OLD)
+  endif ()
+elseif(QT4_FOUND)
+  message(STATUS "Qt4 found")
+  if (XPDFWIDGET_PRINTING)
+    if (APPLE)
+      set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
+    elseif (UNIX)
+      set(EXTRA_QT_LIBRARIES cups)
+    else ()
+      set(EXTRA_QT_LIBRARIES "")
+    endif ()
+  endif ()
+else()
+  message(STATUS "No Qt library found")
+endif()
+
+#--- look for libpaper
+find_library(HAVE_PAPER_H
+             NAMES paper libpaper
+             PATH_SUFFIXES lib64 lib
+)
+
+#--- look for pthreads
+find_package(Threads)
+
+#--- create aconf.h
+configure_file("aconf.h.in" "aconf.h")


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/cmake-config.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/configure
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/configure	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/configure	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,9386 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69.
-#
-#
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# Use a proper internal environment variable to ensure we don't fall
-  # into an infinite loop, continuously re-executing ourselves.
-  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-    _as_can_reexec=no; export _as_can_reexec;
-    # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
-  fi
-  # We don't want this to propagate to other subprocesses.
-          { _as_can_reexec=; unset _as_can_reexec;}
-if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
-else
-  case \`(set -o) 2>/dev/null\` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-"
-  as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
-  exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
-  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
-  as_have_required=yes
-else
-  as_have_required=no
-fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  as_found=:
-  case $as_dir in #(
-	 /*)
-	   for as_base in sh bash ksh sh5; do
-	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
-	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  break 2
-fi
-fi
-	   done;;
-       esac
-  as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-  CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
-      if test "x$CONFIG_SHELL" != x; then :
-  export CONFIG_SHELL
-             # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
-fi
-
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-  else
-    $as_echo "$0: Please tell bug-autoconf at gnu.org about your system,
-$0: including any error possibly output before this
-$0: message. Then install a modern shell, or manually run
-$0: the script under such a shell if you do have one."
-  fi
-  exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
-  as_lineno_1=$LINENO as_lineno_1a=$LINENO
-  as_lineno_2=$LINENO as_lineno_2a=$LINENO
-  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
-  sed -n '
-    p
-    /[$]LINENO/=
-  ' <$as_myself |
-    sed '
-      s/[$]LINENO.*/&-/
-      t lineno
-      b
-      :lineno
-      N
-      :loop
-      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-      t loop
-      s/-\n.*//
-    ' >$as_me.lineno &&
-  chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
-  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-  # already done that, so ensure we don't try to do so again and fall
-  # in an infinite loop.  This has already happened in practice.
-  _as_can_reexec=no; export _as_can_reexec
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensitive to this).
-  . "./$as_me.lineno"
-  # Exit status is that of the last command.
-  exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -pR'
-  fi
-else
-  as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-PACKAGE_URL=
-
-ac_unique_file="xpdf/Gfx.cc"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='LTLIBOBJS
-LIBOBJS
-EXTRA_CFLAGS
-EXTRA_LIBS
-XPDF_TARGET
-X
-libpaper_CFLAGS
-libpaper_LIBS
-libpng_CFLAGS
-libpng_LIBS
-freetype2_CFLAGS
-freetype2_LIBS
-Sgm_CFLAGS
-Sgm_LIBS
-Xm_CFLAGS
-Xm_LIBS
-Xt_CFLAGS
-Xt_LIBS
-Xp_CFLAGS
-Xp_LIBS
-Xext_CFLAGS
-Xext_LIBS
-Xpm_CFLAGS
-Xpm_LIBS
-EGREP
-GREP
-X_EXTRA_LIBS
-X_LIBS
-X_PRE_LIBS
-X_CFLAGS
-CPP
-XMKMF
-UP_DIR
-AR
-LIBPREFIX
-EXE
-RANLIB
-INSTALL_DATA
-INSTALL_SCRIPT
-INSTALL_PROGRAM
-ac_ct_CXX
-CXXFLAGS
-CXX
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-enable_a4_paper
-enable_no_text_select
-enable_opi
-enable_multithreaded
-enable_exceptions
-enable_fixedpoint
-enable_cmyk
-with_appdef_dir
-with_x
-enable_largefile
-with_Xpm_library
-with_Xpm_includes
-with_Xext_library
-with_Xext_includes
-with_Xp_library
-with_Xp_includes
-with_Xt_library
-with_Xt_includes
-with_Xm_library
-with_Xm_includes
-with_Sgm_library
-with_Sgm_includes
-with_freetype2_library
-with_freetype2_includes
-with_libpng_library
-with_libpng_includes
-with_libpaper_library
-with_libpaper_includes
-'
-      ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS
-CXX
-CXXFLAGS
-CCC
-XMKMF
-CPP'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval $ac_prev=\$ac_option
-    ac_prev=
-    continue
-  fi
-
-  case $ac_option in
-  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *=)   ac_optarg= ;;
-  *)    ac_optarg=yes ;;
-  esac
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case $ac_dashdash$ac_option in
-  --)
-    ac_dashdash=yes ;;
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir=$ac_optarg ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build_alias ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build_alias=$ac_optarg ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file=$ac_optarg ;;
-
-  --config-cache | -C)
-    cache_file=config.cache ;;
-
-  -datadir | --datadir | --datadi | --datad)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=*)
-    datadir=$ac_optarg ;;
-
-  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
-  | --dataroo | --dataro | --datar)
-    ac_prev=datarootdir ;;
-  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
-  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
-    datarootdir=$ac_optarg ;;
-
-  -disable-* | --disable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=no ;;
-
-  -docdir | --docdir | --docdi | --doc | --do)
-    ac_prev=docdir ;;
-  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
-    docdir=$ac_optarg ;;
-
-  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
-    ac_prev=dvidir ;;
-  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
-    dvidir=$ac_optarg ;;
-
-  -enable-* | --enable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=\$ac_optarg ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix=$ac_optarg ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he | -h)
-    ac_init_help=long ;;
-  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
-    ac_init_help=recursive ;;
-  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
-    ac_init_help=short ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host_alias ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host_alias=$ac_optarg ;;
-
-  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
-    ac_prev=htmldir ;;
-  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
-  | --ht=*)
-    htmldir=$ac_optarg ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir=$ac_optarg ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir=$ac_optarg ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir=$ac_optarg ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir=$ac_optarg ;;
-
-  -localedir | --localedir | --localedi | --localed | --locale)
-    ac_prev=localedir ;;
-  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
-    localedir=$ac_optarg ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst | --locals)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
-    localstatedir=$ac_optarg ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir=$ac_optarg ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c | -n)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir=$ac_optarg ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix=$ac_optarg ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix=$ac_optarg ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix=$ac_optarg ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name=$ac_optarg ;;
-
-  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
-    ac_prev=pdfdir ;;
-  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
-    pdfdir=$ac_optarg ;;
-
-  -psdir | --psdir | --psdi | --psd | --ps)
-    ac_prev=psdir ;;
-  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
-    psdir=$ac_optarg ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir=$ac_optarg ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir=$ac_optarg ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site=$ac_optarg ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir=$ac_optarg ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir=$ac_optarg ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target_alias ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target_alias=$ac_optarg ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers | -V)
-    ac_init_version=: ;;
-
-  -with-* | --with-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=\$ac_optarg ;;
-
-  -without-* | --without-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=no ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes=$ac_optarg ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries=$ac_optarg ;;
-
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
-    ;;
-
-  *=*)
-    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
-    # Reject names that are not valid shell variable names.
-    case $ac_envvar in #(
-      '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-    esac
-    eval $ac_envvar=\$ac_optarg
-    export $ac_envvar ;;
-
-  *)
-    # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
-  case $enable_option_checking in
-    no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
-  esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
-		datadir sysconfdir sharedstatedir localstatedir includedir \
-		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
-do
-  eval ac_val=\$$ac_var
-  # Remove trailing slashes.
-  case $ac_val in
-    */ )
-      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
-      eval $ac_var=\$ac_val;;
-  esac
-  # Be sure to have absolute directory names.
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* )  continue;;
-    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
-  esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
-  if test "x$build_alias" = x; then
-    cross_compiling=maybe
-  elif test "x$build_alias" != "x$host_alias"; then
-    cross_compiling=yes
-  fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then the parent directory.
-  ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_myself" : 'X\(//\)[^/]' \| \
-	 X"$as_myself" : 'X\(//\)$' \| \
-	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  srcdir=$ac_confdir
-  if test ! -r "$srcdir/$ac_unique_file"; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
-  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
-	pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
-  srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
-  eval ac_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_env_${ac_var}_value=\$${ac_var}
-  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
-  # Omit some internal or obsolete options to make the list less imposing.
-  # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE.  See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
-  -h, --help              display this help and exit
-      --help=short        display options specific to this package
-      --help=recursive    display the short help of all the included packages
-  -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
-      --cache-file=FILE   cache test results in FILE [disabled]
-  -C, --config-cache      alias for \`--cache-file=config.cache'
-  -n, --no-create         do not create output files
-      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
-
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR            user executables [EPREFIX/bin]
-  --sbindir=DIR           system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR        program executables [EPREFIX/libexec]
-  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --libdir=DIR            object code libraries [EPREFIX/lib]
-  --includedir=DIR        C header files [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
-  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR           info documentation [DATAROOTDIR/info]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
-  --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
-  --htmldir=DIR           html documentation [DOCDIR]
-  --dvidir=DIR            dvi documentation [DOCDIR]
-  --pdfdir=DIR            pdf documentation [DOCDIR]
-  --psdir=DIR             ps documentation [DOCDIR]
-_ACEOF
-
-  cat <<\_ACEOF
-
-X features:
-  --x-includes=DIR    X include files are in DIR
-  --x-libraries=DIR   X library files are in DIR
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-
-  cat <<\_ACEOF
-
-Optional Features:
-  --disable-option-checking  ignore unrecognized --enable/--with options
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-a4-paper       use A4 paper size instead of Letter for PostScript
-                          output
-  --enable-no-text-select do not allow text selection
-  --enable-opi            include support for OPI comments
-  --enable-multithreaded  include support for multithreading
-  --enable-exceptions     use C++ exceptions
-  --enable-fixedpoint     use fixed point (instead of floating point)
-                          arithmetic
-  --enable-cmyk           include support for CMYK rasterization
-  --disable-largefile     omit support for large files
-
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-appdef-dir       set app-defaults directory
-  --with-x                use the X Window System
-  --with-Xpm-library=PATH
-                          use Xpm library (pixmap library - used only for icon)
-  --with-Xpm-includes=DIR
-                          set directory for Xpm headers
-  --with-Xext-library=PATH
-                          use Xext library (Motif library)
-  --with-Xext-includes=DIR
-                          set directory for Xext headers
-  --with-Xp-library=PATH
-                          use Xp library (Motif library)
-  --with-Xp-includes=DIR
-                          set directory for Xp headers
-  --with-Xt-library=PATH
-                          use Xt library (Motif library)
-  --with-Xt-includes=DIR
-                          set directory for Xt headers
-  --with-Xm-library=PATH
-                          use Xm library (Motif library)
-  --with-Xm-includes=DIR
-                          set directory for Xm headers
-  --with-Sgm-library=PATH
-                          use Sgm library (SGI Motif library)
-  --with-Sgm-includes=DIR
-                          set directory for Sgm headers
-  --with-freetype2-library=PATH
-                          use freetype2 library (FreeType2 font rasterizer - version 2.0.5+)
-  --with-freetype2-includes=DIR
-                          set directory for freetype2 headers
-  --with-libpng-library=PATH
-                          use libpng library (PNG library)
-  --with-libpng-includes=DIR
-                          set directory for libpng headers
-  --with-libpaper-library=PATH
-                          use libpaper library (Debian libpaper)
-  --with-libpaper-includes=DIR
-                          set directory for libpaper headers
-
-Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
-  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-              nonstandard directory <lib dir>
-  LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-              you have headers in a nonstandard directory <include dir>
-  CXX         C++ compiler command
-  CXXFLAGS    C++ compiler flags
-  XMKMF       Path to xmkmf, Makefile generator for X Window System
-  CPP         C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to the package provider.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
-  # If there are subdirs, report their specific --help.
-  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d "$ac_dir" ||
-      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
-      continue
-    ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-    cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
-    if test -f "$ac_srcdir/configure.gnu"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
-    elif test -f "$ac_srcdir/configure"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure" --help=recursive
-    else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi || ac_status=$?
-    cd "$ac_pwd" || { ac_status=$?; break; }
-  done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
-  cat <<\_ACEOF
-configure
-generated by GNU Autoconf 2.69
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
-  exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
-# ac_fn_cxx_try_compile LINENO
-# ----------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_compile
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_check_func LINENO FUNC VAR
-# ----------------------------------
-# Tests whether FUNC exists, setting the cache variable VAR accordingly
-ac_fn_c_check_func ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $2 innocuous_$2
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $2
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $2 ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$2 || defined __stub___$2
-choke me
-#endif
-
-int
-main ()
-{
-return $2 ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_func
-
-# ac_fn_cxx_try_link LINENO
-# -------------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_link
-
-# ac_fn_cxx_check_func LINENO FUNC VAR
-# ------------------------------------
-# Tests whether FUNC exists, setting the cache variable VAR accordingly
-ac_fn_cxx_check_func ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $2 innocuous_$2
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $2
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $2 ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$2 || defined __stub___$2
-choke me
-#endif
-
-int
-main ()
-{
-return $2 ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_cxx_check_func
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval \${$3+:} false; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by $as_me, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
-
-  $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
-  done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
-  for ac_arg
-  do
-    case $ac_arg in
-    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-    | -silent | --silent | --silen | --sile | --sil)
-      continue ;;
-    *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    case $ac_pass in
-    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
-    2)
-      as_fn_append ac_configure_args1 " '$ac_arg'"
-      if test $ac_must_keep_next = true; then
-	ac_must_keep_next=false # Got value, back to normal.
-      else
-	case $ac_arg in
-	  *=* | --config-cache | -C | -disable-* | --disable-* \
-	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
-	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
-	  | -with-* | --with-* | -without-* | --without-* | --x)
-	    case "$ac_configure_args0 " in
-	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
-	    esac
-	    ;;
-	  -* ) ac_must_keep_next=true ;;
-	esac
-      fi
-      as_fn_append ac_configure_args " '$ac_arg'"
-      ;;
-    esac
-  done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log.  We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
-  # Save into config.log some information that might help in debugging.
-  {
-    echo
-
-    $as_echo "## ---------------- ##
-## Cache variables. ##
-## ---------------- ##"
-    echo
-    # The following way of writing the cache mishandles newlines in values,
-(
-  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-  (set) 2>&1 |
-    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      sed -n \
-	"s/'\''/'\''\\\\'\'''\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
-      ;; #(
-    *)
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-)
-    echo
-
-    $as_echo "## ----------------- ##
-## Output variables. ##
-## ----------------- ##"
-    echo
-    for ac_var in $ac_subst_vars
-    do
-      eval ac_val=\$$ac_var
-      case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-      esac
-      $as_echo "$ac_var='\''$ac_val'\''"
-    done | sort
-    echo
-
-    if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
-## File substitutions. ##
-## ------------------- ##"
-      echo
-      for ac_var in $ac_subst_files
-      do
-	eval ac_val=\$$ac_var
-	case $ac_val in
-	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-	esac
-	$as_echo "$ac_var='\''$ac_val'\''"
-      done | sort
-      echo
-    fi
-
-    if test -s confdefs.h; then
-      $as_echo "## ----------- ##
-## confdefs.h. ##
-## ----------- ##"
-      echo
-      cat confdefs.h
-      echo
-    fi
-    test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
-  } >&5
-  rm -f core *.core core.conftest.* &&
-    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
-    exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
-elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
-else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
-    sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
-  fi
-done
-
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special files
-  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
-  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . "$cache_file";;
-      *)                      . "./$cache_file";;
-    esac
-  fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
-  eval ac_old_set=\$ac_cv_env_${ac_var}_set
-  eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val=\$ac_cv_env_${ac_var}_value
-  eval ac_new_val=\$ac_env_${ac_var}_value
-  case $ac_old_set,$ac_new_set in
-    set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,);;
-    *)
-      if test "x$ac_old_val" != "x$ac_new_val"; then
-	# differences in whitespace do not lead to failure.
-	ac_old_val_w=`echo x $ac_old_val`
-	ac_new_val_w=`echo x $ac_new_val`
-	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	  ac_cache_corrupted=:
-	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
-	  eval $ac_var=\$ac_old_val
-	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
-      fi;;
-  esac
-  # Pass precious variables to config.status.
-  if test "$ac_new_set" = set; then
-    case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
-    *) ac_arg=$ac_var=$ac_new_val ;;
-    esac
-    case " $ac_configure_args " in
-      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
-    esac
-  fi
-done
-if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-ac_config_headers="$ac_config_headers aconf.h"
-
-
-
-# Check whether --enable-a4-paper was given.
-if test "${enable_a4_paper+set}" = set; then :
-  enableval=$enable_a4_paper;
-fi
-
-if test "x$enable_a4_paper" = "xyes"; then :
-  $as_echo "#define A4_PAPER 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-no-text-select was given.
-if test "${enable_no_text_select+set}" = set; then :
-  enableval=$enable_no_text_select;
-fi
-
-if test "x$enable_no_text_select" = "xyes"; then :
-  $as_echo "#define NO_TEXT_SELECT 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-opi was given.
-if test "${enable_opi+set}" = set; then :
-  enableval=$enable_opi;
-fi
-
-if test "x$enable_opi" = "xyes"; then :
-  $as_echo "#define OPI_SUPPORT 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-multithreaded was given.
-if test "${enable_multithreaded+set}" = set; then :
-  enableval=$enable_multithreaded;
-fi
-
-if test "x$enable_multithreaded" = "xyes"; then :
-  $as_echo "#define MULTITHREADED 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-exceptions was given.
-if test "${enable_exceptions+set}" = set; then :
-  enableval=$enable_exceptions;
-fi
-
-if test "x$enable_exceptions" = "xyes"; then :
-  $as_echo "#define USE_EXCEPTIONS 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-fixedpoint was given.
-if test "${enable_fixedpoint+set}" = set; then :
-  enableval=$enable_fixedpoint;
-fi
-
-if test "x$enable_fixedpoint" = "xyes"; then :
-  $as_echo "#define USE_FIXEDPOINT 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-cmyk was given.
-if test "${enable_cmyk+set}" = set; then :
-  enableval=$enable_cmyk;
-fi
-
-if test "x$enable_cmyk" = "xyes"; then :
-  $as_echo "#define SPLASH_CMYK 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-appdef-dir was given.
-if test "${with_appdef_dir+set}" = set; then :
-  withval=$with_appdef_dir;
-fi
-
-if test "x$with_appdef_dir" != "xno"; then :
-  cat >>confdefs.h <<_ACEOF
-#define APPDEFDIR "$with_appdef_dir"
-_ACEOF
-
-fi
-
-if test "$sysconfdir" = '${prefix}/etc'; then
-  if test "x$prefix" = xNONE; then
-    system_xpdfrc="$ac_default_prefix/etc/xpdfrc"
-  else
-    system_xpdfrc="$prefix/etc/xpdfrc"
-  fi
-else
-  system_xpdfrc="$sysconfdir/xpdfrc"
-fi
-cat >>confdefs.h <<_ACEOF
-#define SYSTEM_XPDFRC "$system_xpdfrc"
-_ACEOF
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
-          if test -n "$ac_tool_prefix"; then
-    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  fi
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl.exe
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$CC" && break
-  done
-fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl.exe
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_CC" && break
-done
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
-  esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link_default") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile.  We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
-	;;
-    [ab].out )
-	# We found the default executable, but exeext='' is most
-	# certainly right.
-	break;;
-    *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-	then :; else
-	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	fi
-	# We set ac_cv_exeext here because the later test for it is not
-	# safe: cross compilers may not add the suffix if given an `-o'
-	# argument, so we may need to know it at that point already.
-	# Even if this section looks crufty: it has the advantage of
-	# actually working.
-	break;;
-    * )
-	break;;
-  esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
-  ac_file=''
-fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  break;;
-    * ) break;;
-  esac
-done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  for ac_file in conftest.o conftest.obj conftest.*; do
-  test -f "$ac_file" || continue;
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
-done
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GCC=yes
-else
-  GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
-	 CFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5
-$as_echo_n "checking for library containing strerror... " >&6; }
-if ${ac_cv_search_strerror+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char strerror ();
-int
-main ()
-{
-return strerror ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' cposix; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_strerror=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_strerror+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_strerror+:} false; then :
-
-else
-  ac_cv_search_strerror=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5
-$as_echo "$ac_cv_search_strerror" >&6; }
-ac_res=$ac_cv_search_strerror
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-   case $ac_cv_prog_cc_stdc in #(
-  no) :
-    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
-  *) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
-$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
-if ${ac_cv_prog_cc_c99+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c99=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
-
-// Check varargs macros.  These examples are taken from C99 6.10.3.5.
-#define debug(...) fprintf (stderr, __VA_ARGS__)
-#define showlist(...) puts (#__VA_ARGS__)
-#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
-static void
-test_varargs_macros (void)
-{
-  int x = 1234;
-  int y = 5678;
-  debug ("Flag");
-  debug ("X = %d\n", x);
-  showlist (The first, second, and third items.);
-  report (x>y, "x is %d but y is %d", x, y);
-}
-
-// Check long long types.
-#define BIG64 18446744073709551615ull
-#define BIG32 4294967295ul
-#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
-#if !BIG_OK
-  your preprocessor is broken;
-#endif
-#if BIG_OK
-#else
-  your preprocessor is broken;
-#endif
-static long long int bignum = -9223372036854775807LL;
-static unsigned long long int ubignum = BIG64;
-
-struct incomplete_array
-{
-  int datasize;
-  double data[];
-};
-
-struct named_init {
-  int number;
-  const wchar_t *name;
-  double average;
-};
-
-typedef const char *ccp;
-
-static inline int
-test_restrict (ccp restrict text)
-{
-  // See if C++-style comments work.
-  // Iterate through items via the restricted pointer.
-  // Also check for declarations in for loops.
-  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
-    continue;
-  return 0;
-}
-
-// Check varargs and va_copy.
-static void
-test_varargs (const char *format, ...)
-{
-  va_list args;
-  va_start (args, format);
-  va_list args_copy;
-  va_copy (args_copy, args);
-
-  const char *str;
-  int number;
-  float fnumber;
-
-  while (*format)
-    {
-      switch (*format++)
-	{
-	case 's': // string
-	  str = va_arg (args_copy, const char *);
-	  break;
-	case 'd': // int
-	  number = va_arg (args_copy, int);
-	  break;
-	case 'f': // float
-	  fnumber = va_arg (args_copy, double);
-	  break;
-	default:
-	  break;
-	}
-    }
-  va_end (args_copy);
-  va_end (args);
-}
-
-int
-main ()
-{
-
-  // Check bool.
-  _Bool success = false;
-
-  // Check restrict.
-  if (test_restrict ("String literal") == 0)
-    success = true;
-  char *restrict newvar = "Another string";
-
-  // Check varargs.
-  test_varargs ("s, d' f .", "string", 65, 34.234);
-  test_varargs_macros ();
-
-  // Check flexible array members.
-  struct incomplete_array *ia =
-    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
-  ia->datasize = 10;
-  for (int i = 0; i < ia->datasize; ++i)
-    ia->data[i] = i * 1.234;
-
-  // Check named initializers.
-  struct named_init ni = {
-    .number = 34,
-    .name = L"Test wide string",
-    .average = 543.34343,
-  };
-
-  ni.number = 58;
-
-  int dynamic_array[ni.number];
-  dynamic_array[ni.number - 1] = 543;
-
-  // work around unused variable warnings
-  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
-	  || dynamic_array[ni.number - 1] != 543);
-
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c99=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c99" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c99" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c99"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
-$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c99" != xno; then :
-  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
-else
-  ac_cv_prog_cc_stdc=no
-fi
-
-fi
- ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
-$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
-  if ${ac_cv_prog_cc_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-
-  case $ac_cv_prog_cc_stdc in #(
-  no) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;; #(
-  '') :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;; #(
-  *) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
-$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
-esac
-
-#if test -z "$CXX" -a "$CC" = "gcc"; then
-#  CXX="gcc"
-#fi
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -z "$CXX"; then
-  if test -n "$CCC"; then
-    CXX=$CCC
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
-$as_echo "$CXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$CXX" && break
-  done
-fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
-$as_echo "$ac_ct_CXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_CXX" && break
-done
-
-  if test "x$ac_ct_CXX" = x; then
-    CXX="g++"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CXX=$ac_ct_CXX
-  fi
-fi
-
-  fi
-fi
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
-$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
-if ${ac_cv_cxx_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
-$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GXX=yes
-else
-  GXX=
-fi
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
-$as_echo_n "checking whether $CXX accepts -g... " >&6; }
-if ${ac_cv_prog_cxx_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-else
-  CXXFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-
-else
-  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-	 CXXFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
-$as_echo "$ac_cv_prog_cxx_g" >&6; }
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-
-
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if ${ac_cv_path_install+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
-  ./ | .// | /[cC]/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # by default.
-    for ac_prog in ginstall scoinst install; do
-      for ac_exec_ext in '' $ac_executable_extensions; do
-	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
-	  if test $ac_prog = install &&
-	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # AIX install.  It has an incompatible calling convention.
-	    :
-	  elif test $ac_prog = install &&
-	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # program-specific install script used by HP pwplus--don't use.
-	    :
-	  else
-	    rm -rf conftest.one conftest.two conftest.dir
-	    echo one > conftest.one
-	    echo two > conftest.two
-	    mkdir conftest.dir
-	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
-	      test -s conftest.one && test -s conftest.two &&
-	      test -s conftest.dir/conftest.one &&
-	      test -s conftest.dir/conftest.two
-	    then
-	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	      break 3
-	    fi
-	  fi
-	fi
-      done
-    done
-    ;;
-esac
-
-  done
-IFS=$as_save_IFS
-
-rm -rf conftest.one conftest.two conftest.dir
-
-fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    INSTALL=$ac_install_sh
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-
-EXE=""
-LIBPREFIX="lib"
-AR="ar rc"
-UP_DIR=""
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OS/2 (with EMX)" >&5
-$as_echo_n "checking for OS/2 (with EMX)... " >&6; }
-if ${xpdf_cv_sys_os2+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-__EMX__
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  xpdf_cv_sys_os2=yes
-else
-  xpdf_cv_sys_os2=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_sys_os2" >&5
-$as_echo "$xpdf_cv_sys_os2" >&6; }
-if test "$xpdf_cv_sys_os2" = yes; then
-  EXE=".exe"
-  LIBPREFIX=""
-  AR="ar -rc"
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DOS (with DJGPP)" >&5
-$as_echo_n "checking for DOS (with DJGPP)... " >&6; }
-if ${xpdf_cv_sys_dos+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-__DJGPP__
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  xpdf_cv_sys_dos=yes
-else
-  xpdf_cv_sys_dos=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_sys_dos" >&5
-$as_echo "$xpdf_cv_sys_dos" >&6; }
-if test "$xpdf_cv_sys_dos" = yes; then
-  EXE=".exe"
-  LIBPREFIX="lib"
-  AR="ar -rc"
-  UP_DIR="../"
-fi
-
-
-
-
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5
-$as_echo_n "checking for X... " >&6; }
-
-
-# Check whether --with-x was given.
-if test "${with_x+set}" = set; then :
-  withval=$with_x;
-fi
-
-# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
-if test "x$with_x" = xno; then
-  # The user explicitly disabled X.
-  have_x=disabled
-else
-  case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
-    *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -f -r conftest.dir
-if mkdir conftest.dir; then
-  cd conftest.dir
-  cat >Imakefile <<'_ACEOF'
-incroot:
-	@echo incroot='${INCROOT}'
-usrlibdir:
-	@echo usrlibdir='${USRLIBDIR}'
-libdir:
-	@echo libdir='${LIBDIR}'
-_ACEOF
-  if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
-    for ac_var in incroot usrlibdir libdir; do
-      eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
-    done
-    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
-    for ac_extension in a so sl dylib la dll; do
-      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
-	 test -f "$ac_im_libdir/libX11.$ac_extension"; then
-	ac_im_usrlibdir=$ac_im_libdir; break
-      fi
-    done
-    # Screen out bogus values from the imake configuration.  They are
-    # bogus both because they are the default anyway, and because
-    # using them would break gcc on systems where it needs fixed includes.
-    case $ac_im_incroot in
-	/usr/include) ac_x_includes= ;;
-	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
-    esac
-    case $ac_im_usrlibdir in
-	/usr/lib | /usr/lib64 | /lib | /lib64) ;;
-	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
-    esac
-  fi
-  cd ..
-  rm -f -r conftest.dir
-fi
-
-# Standard set of common directories for X headers.
-# Check X11 before X11Rn because it is often a symlink to the current release.
-ac_x_header_dirs='
-/usr/X11/include
-/usr/X11R7/include
-/usr/X11R6/include
-/usr/X11R5/include
-/usr/X11R4/include
-
-/usr/include/X11
-/usr/include/X11R7
-/usr/include/X11R6
-/usr/include/X11R5
-/usr/include/X11R4
-
-/usr/local/X11/include
-/usr/local/X11R7/include
-/usr/local/X11R6/include
-/usr/local/X11R5/include
-/usr/local/X11R4/include
-
-/usr/local/include/X11
-/usr/local/include/X11R7
-/usr/local/include/X11R6
-/usr/local/include/X11R5
-/usr/local/include/X11R4
-
-/usr/X386/include
-/usr/x386/include
-/usr/XFree86/include/X11
-
-/usr/include
-/usr/local/include
-/usr/unsupported/include
-/usr/athena/include
-/usr/local/x11r5/include
-/usr/lpp/Xamples/include
-
-/usr/openwin/include
-/usr/openwin/share/include'
-
-if test "$ac_x_includes" = no; then
-  # Guess where to find include files, by looking for Xlib.h.
-  # First, try using that file with no special directory specified.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # We can compile using X headers with no special include directory.
-ac_x_includes=
-else
-  for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Xlib.h"; then
-    ac_x_includes=$ac_dir
-    break
-  fi
-done
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-fi # $ac_x_includes = no
-
-if test "$ac_x_libraries" = no; then
-  # Check for the libraries.
-  # See if we find them without any special options.
-  # Don't add to $LIBS permanently.
-  ac_save_LIBS=$LIBS
-  LIBS="-lX11 $LIBS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize ()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  LIBS=$ac_save_LIBS
-# We can link X programs with no special library path.
-ac_x_libraries=
-else
-  LIBS=$ac_save_LIBS
-for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
-do
-  # Don't even attempt the hair of trying to link an X program!
-  for ac_extension in a so sl dylib la dll; do
-    if test -r "$ac_dir/libX11.$ac_extension"; then
-      ac_x_libraries=$ac_dir
-      break 2
-    fi
-  done
-done
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi # $ac_x_libraries = no
-
-case $ac_x_includes,$ac_x_libraries in #(
-  no,* | *,no | *\'*)
-    # Didn't find X, or a directory has "'" in its name.
-    ac_cv_have_x="have_x=no";; #(
-  *)
-    # Record where we found X for the cache.
-    ac_cv_have_x="have_x=yes\
-	ac_x_includes='$ac_x_includes'\
-	ac_x_libraries='$ac_x_libraries'"
-esac
-fi
-;; #(
-    *) have_x=yes;;
-  esac
-  eval "$ac_cv_have_x"
-fi # $with_x != no
-
-if test "$have_x" != yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
-$as_echo "$have_x" >&6; }
-  no_x=yes
-else
-  # If each of the values was on the command line, it overrides each guess.
-  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
-  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
-  # Update the cache value to reflect the command line values.
-  ac_cv_have_x="have_x=yes\
-	ac_x_includes='$x_includes'\
-	ac_x_libraries='$x_libraries'"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
-$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
-fi
-
-if test "$no_x" = yes; then
-  # Not all programs may use this symbol, but it does not hurt to define it.
-
-$as_echo "#define X_DISPLAY_MISSING 1" >>confdefs.h
-
-  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
-else
-  if test -n "$x_includes"; then
-    X_CFLAGS="$X_CFLAGS -I$x_includes"
-  fi
-
-  # It would also be nice to do this for all -L options, not just this one.
-  if test -n "$x_libraries"; then
-    X_LIBS="$X_LIBS -L$x_libraries"
-    # For Solaris; some versions of Sun CC require a space after -R and
-    # others require no space.  Words are not sufficient . . . .
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -R must be followed by a space" >&5
-$as_echo_n "checking whether -R must be followed by a space... " >&6; }
-    ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
-    ac_xsave_c_werror_flag=$ac_c_werror_flag
-    ac_c_werror_flag=yes
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-       X_LIBS="$X_LIBS -R$x_libraries"
-else
-  LIBS="$ac_xsave_LIBS -R $x_libraries"
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	  X_LIBS="$X_LIBS -R $x_libraries"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: neither works" >&5
-$as_echo "neither works" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    ac_c_werror_flag=$ac_xsave_c_werror_flag
-    LIBS=$ac_xsave_LIBS
-  fi
-
-  # Check for system-dependent libraries X programs must link with.
-  # Do this before checking for the system-independent R6 libraries
-  # (-lICE), since we may need -lsocket or whatever for X linking.
-
-  if test "$ISC" = yes; then
-    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
-  else
-    # Martyn Johnson says this is needed for Ultrix, if the X
-    # libraries were built with DECnet support.  And Karl Berry says
-    # the Alpha needs dnet_stub (dnet does not exist).
-    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XOpenDisplay ();
-int
-main ()
-{
-return XOpenDisplay ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5
-$as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; }
-if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_ntoa ();
-int
-main ()
-{
-return dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dnet_dnet_ntoa=yes
-else
-  ac_cv_lib_dnet_dnet_ntoa=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
-$as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
-fi
-
-    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5
-$as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; }
-if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet_stub  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_ntoa ();
-int
-main ()
-{
-return dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dnet_stub_dnet_ntoa=yes
-else
-  ac_cv_lib_dnet_stub_dnet_ntoa=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
-$as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
-fi
-
-    fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    LIBS="$ac_xsave_LIBS"
-
-    # msh at cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
-    # to get the SysV transport functions.
-    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
-    # needs -lnsl.
-    # The nsl library prevents programs from opening the X display
-    # on Irix 5.2, according to T.E. Dickey.
-    # The functions gethostbyname, getservbyname, and inet_addr are
-    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
-    ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
-if test "x$ac_cv_func_gethostbyname" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_gethostbyname = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
-$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
-if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnsl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_nsl_gethostbyname=yes
-else
-  ac_cv_lib_nsl_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5
-$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
-if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
-fi
-
-      if test $ac_cv_lib_nsl_gethostbyname = no; then
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5
-$as_echo_n "checking for gethostbyname in -lbsd... " >&6; }
-if ${ac_cv_lib_bsd_gethostbyname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_bsd_gethostbyname=yes
-else
-  ac_cv_lib_bsd_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5
-$as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; }
-if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
-fi
-
-      fi
-    fi
-
-    # lieder at skyler.mavd.honeywell.com says without -lsocket,
-    # socket/setsockopt and other routines are undefined under SCO ODT
-    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
-    # on later versions), says Simon Leinen: it contains gethostby*
-    # variants that don't use the name server (or something).  -lsocket
-    # must be given before -lnsl if both are needed.  We assume that
-    # if connect needs -lnsl, so does gethostbyname.
-    ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
-if test "x$ac_cv_func_connect" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_connect = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5
-$as_echo_n "checking for connect in -lsocket... " >&6; }
-if ${ac_cv_lib_socket_connect+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char connect ();
-int
-main ()
-{
-return connect ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_socket_connect=yes
-else
-  ac_cv_lib_socket_connect=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5
-$as_echo "$ac_cv_lib_socket_connect" >&6; }
-if test "x$ac_cv_lib_socket_connect" = xyes; then :
-  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
-fi
-
-    fi
-
-    # Guillermo Gomez says -lposix is necessary on A/UX.
-    ac_fn_c_check_func "$LINENO" "remove" "ac_cv_func_remove"
-if test "x$ac_cv_func_remove" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_remove = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5
-$as_echo_n "checking for remove in -lposix... " >&6; }
-if ${ac_cv_lib_posix_remove+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lposix  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char remove ();
-int
-main ()
-{
-return remove ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_posix_remove=yes
-else
-  ac_cv_lib_posix_remove=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5
-$as_echo "$ac_cv_lib_posix_remove" >&6; }
-if test "x$ac_cv_lib_posix_remove" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
-fi
-
-    fi
-
-    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
-    ac_fn_c_check_func "$LINENO" "shmat" "ac_cv_func_shmat"
-if test "x$ac_cv_func_shmat" = xyes; then :
-
-fi
-
-    if test $ac_cv_func_shmat = no; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5
-$as_echo_n "checking for shmat in -lipc... " >&6; }
-if ${ac_cv_lib_ipc_shmat+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lipc  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char shmat ();
-int
-main ()
-{
-return shmat ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ipc_shmat=yes
-else
-  ac_cv_lib_ipc_shmat=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5
-$as_echo "$ac_cv_lib_ipc_shmat" >&6; }
-if test "x$ac_cv_lib_ipc_shmat" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
-fi
-
-    fi
-  fi
-
-  # Check for libraries that X11R6 Xt/Xaw programs need.
-  ac_save_LDFLAGS=$LDFLAGS
-  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
-  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
-  # check for ICE first), but we must link in the order -lSM -lICE or
-  # we get undefined symbols.  So assume we have SM if we have ICE.
-  # These have to be linked with before -lX11, unlike the other
-  # libraries we check for below, so use a different variable.
-  # John Interrante, Karl Berry
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5
-$as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; }
-if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lICE $X_EXTRA_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char IceConnectionNumber ();
-int
-main ()
-{
-return IceConnectionNumber ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ICE_IceConnectionNumber=yes
-else
-  ac_cv_lib_ICE_IceConnectionNumber=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
-$as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; }
-if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then :
-  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
-fi
-
-  LDFLAGS=$ac_save_LDFLAGS
-
-fi
-
-ac_header_dirent=no
-for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
-$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
-if eval \${$as_ac_Header+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <$ac_hdr>
-
-int
-main ()
-{
-if ((DIR *) 0)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$as_ac_Header=yes"
-else
-  eval "$as_ac_Header=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$as_ac_Header
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
-_ACEOF
-
-ac_header_dirent=$ac_hdr; break
-fi
-
-done
-# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
-if test $ac_header_dirent = dirent.h; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
-$as_echo_n "checking for library containing opendir... " >&6; }
-if ${ac_cv_search_opendir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char opendir ();
-int
-main ()
-{
-return opendir ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' dir; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_opendir=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_opendir+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_opendir+:} false; then :
-
-else
-  ac_cv_search_opendir=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
-$as_echo "$ac_cv_search_opendir" >&6; }
-ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
-$as_echo_n "checking for library containing opendir... " >&6; }
-if ${ac_cv_search_opendir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char opendir ();
-int
-main ()
-{
-return opendir ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' x; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_opendir=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_opendir+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_opendir+:} false; then :
-
-else
-  ac_cv_search_opendir=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
-$as_echo "$ac_cv_search_opendir" >&6; }
-ac_res=$ac_cv_search_opendir
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-fi
-
-fi
-
-
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
-if test "x$ac_cv_func_gethostbyname" = xyes; then :
-
-fi
-
-if test $ac_cv_func_gethostbyname = no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5
-$as_echo_n "checking for gethostbyname in -lbsd... " >&6; }
-if ${ac_cv_lib_bsd_gethostbyname+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyname ();
-int
-main ()
-{
-return gethostbyname ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  ac_cv_lib_bsd_gethostbyname=yes
-else
-  ac_cv_lib_bsd_gethostbyname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5
-$as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; }
-if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then :
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
-fi
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking select() and fd_set in sys/select.h and sys/bsdtypes.h" >&5
-$as_echo_n "checking select() and fd_set in sys/select.h and sys/bsdtypes.h... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-int
-main ()
-{
-fd_set fds;
-select(0, NULL, NULL, NULL, NULL);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-if test $xpdf_ok = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed" >&5
-$as_echo "not needed" >&6; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/select.h>
-int
-main ()
-{
-fd_set fds;
-select(0, NULL, NULL, NULL, NULL);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  if test $xpdf_ok = yes; then
-    $as_echo "#define HAVE_SYS_SELECT_H 1" >>confdefs.h
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: need sys/select.h" >&5
-$as_echo "need sys/select.h" >&6; }
-  else
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/bsdtypes.h>
-int
-main ()
-{
-fd_set fds;
-select(0, NULL, NULL, NULL, NULL);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    if test $xpdf_ok = yes; then
-      $as_echo "#define HAVE_SYS_BSDTYPES_H 1" >>confdefs.h
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: need sys/bsdtypes.h" >&5
-$as_echo "need sys/bsdtypes.h" >&6; }
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: problem" >&5
-$as_echo "problem" >&6; }
-    fi
-  fi
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking FD_ZERO and strings.h or bstring.h" >&5
-$as_echo_n "checking FD_ZERO and strings.h or bstring.h... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-int
-main ()
-{
-fd_set fds; FD_ZERO(&fds);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-if test $xpdf_ok = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed" >&5
-$as_echo "not needed" >&6; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <sys/types.h>
-#include <strings.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-int
-main ()
-{
-fd_set fds; FD_ZERO(&fds);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  if test $xpdf_ok = yes; then
-    $as_echo "#define HAVE_STRINGS_H 1" >>confdefs.h
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: need strings.h" >&5
-$as_echo "need strings.h" >&6; }
-  else
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <sys/types.h>
-#include <bstring.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-int
-main ()
-{
-fd_set fds; FD_ZERO(&fds);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_ok=yes
-else
-  xpdf_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    if test $xpdf_ok = yes; then
-      $as_echo "#define HAVE_BSTRING_H 1" >>confdefs.h
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: need bstring.h" >&5
-$as_echo "need bstring.h" >&6; }
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: problem" >&5
-$as_echo "problem" >&6; }
-    fi
-  fi
-fi
-
-for ac_func in rewinddir
-do :
-  ac_fn_cxx_check_func "$LINENO" "rewinddir" "ac_cv_func_rewinddir"
-if test "x$ac_cv_func_rewinddir" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_REWINDDIR 1
-_ACEOF
-
-fi
-done
-
-if test $ac_cv_func_rewinddir = no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rewinddir in -lcposix" >&5
-$as_echo_n "checking for rewinddir in -lcposix... " >&6; }
-if ${ac_cv_lib_cposix_rewinddir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcposix  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char rewinddir ();
-int
-main ()
-{
-return rewinddir ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  ac_cv_lib_cposix_rewinddir=yes
-else
-  ac_cv_lib_cposix_rewinddir=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cposix_rewinddir" >&5
-$as_echo "$ac_cv_lib_cposix_rewinddir" >&6; }
-if test "x$ac_cv_lib_cposix_rewinddir" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBCPOSIX 1
-_ACEOF
-
-  LIBS="-lcposix $LIBS"
-
-fi
-
-fi
-
-for ac_func in popen
-do :
-  ac_fn_cxx_check_func "$LINENO" "popen" "ac_cv_func_popen"
-if test "x$ac_cv_func_popen" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_POPEN 1
-_ACEOF
-
-fi
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mkstemp" >&5
-$as_echo_n "checking for mkstemp... " >&6; }
-if ${xpdf_cv_func_mkstemp+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <unistd.h>
-int
-main ()
-{
-mkstemp("foo");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  xpdf_cv_func_mkstemp=yes
-else
-  xpdf_cv_func_mkstemp=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_func_mkstemp" >&5
-$as_echo "$xpdf_cv_func_mkstemp" >&6; }
-if test "$xpdf_cv_func_mkstemp" = yes; then
-  $as_echo "#define HAVE_MKSTEMP 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mkstemps" >&5
-$as_echo_n "checking for mkstemps... " >&6; }
-if ${xpdf_cv_func_mkstemps+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <unistd.h>
-int
-main ()
-{
-mkstemps("foo", 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  xpdf_cv_func_mkstemps=yes
-else
-  xpdf_cv_func_mkstemps=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_func_mkstemps" >&5
-$as_echo "$xpdf_cv_func_mkstemps" >&6; }
-if test "$xpdf_cv_func_mkstemps" = yes; then
-  $as_echo "#define HAVE_MKSTEMPS 1" >>confdefs.h
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether select takes fd_set arguments" >&5
-$as_echo_n "checking whether select takes fd_set arguments... " >&6; }
-if ${xpdf_cv_func_select_arg+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-int
-main ()
-{
-fd_set fds;
-select(1, &fds, &fds, &fds, 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_cv_func_select_arg=yes
-else
-  xpdf_cv_func_select_arg=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_func_select_arg" >&5
-$as_echo "$xpdf_cv_func_select_arg" >&6; }
-if test "$xpdf_cv_func_select_arg" != yes; then
-  $as_echo "#define SELECT_TAKES_INT 1" >>confdefs.h
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::sort" >&5
-$as_echo_n "checking for std::sort... " >&6; }
-if ${xpdf_cv_func_std_sort+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <algorithm>
-struct functor {
-  bool operator()(const int &i0, const int &i1) { return i0 < i1; }
-};
-int
-main ()
-{
-int a[100];
-std::sort(a, a+100, functor());
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  xpdf_cv_func_std_sort=yes
-else
-  xpdf_cv_func_std_sort=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xpdf_cv_func_std_sort" >&5
-$as_echo "$xpdf_cv_func_std_sort" >&6; }
-if test "$xpdf_cv_func_std_sort" = yes; then
-  $as_echo "#define HAVE_STD_SORT 1" >>confdefs.h
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Check whether --enable-largefile was given.
-if test "${enable_largefile+set}" = set; then :
-  enableval=$enable_largefile;
-fi
-
-if test "$enable_largefile" != no; then
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
-$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if ${ac_cv_sys_largefile_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_sys_largefile_CC=no
-     if test "$GCC" != yes; then
-       ac_save_CC=$CC
-       while :; do
-	 # IRIX 6.2 and later do not support large files by default,
-	 # so use the C compiler's -n32 option if that helps.
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-	 if ac_fn_c_try_compile "$LINENO"; then :
-  break
-fi
-rm -f core conftest.err conftest.$ac_objext
-	 CC="$CC -n32"
-	 if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_largefile_CC=' -n32'; break
-fi
-rm -f core conftest.err conftest.$ac_objext
-	 break
-       done
-       CC=$ac_save_CC
-       rm -f conftest.$ac_ext
-    fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5
-$as_echo "$ac_cv_sys_largefile_CC" >&6; }
-  if test "$ac_cv_sys_largefile_CC" != no; then
-    CC=$CC$ac_cv_sys_largefile_CC
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
-$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if ${ac_cv_sys_file_offset_bits+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_file_offset_bits=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_file_offset_bits=64; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_file_offset_bits=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5
-$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
-case $ac_cv_sys_file_offset_bits in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
-_ACEOF
-;;
-esac
-rm -rf conftest*
-  if test $ac_cv_sys_file_offset_bits = unknown; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
-$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if ${ac_cv_sys_large_files+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_large_files=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _LARGE_FILES 1
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_large_files=1; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_large_files=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5
-$as_echo "$ac_cv_sys_large_files" >&6; }
-case $ac_cv_sys_large_files in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGE_FILES $ac_cv_sys_large_files
-_ACEOF
-;;
-esac
-rm -rf conftest*
-  fi
-
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
-$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
-if ${ac_cv_sys_largefile_source+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_sys_largefile_source=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_sys_largefile_source=1; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  ac_cv_sys_largefile_source=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5
-$as_echo "$ac_cv_sys_largefile_source" >&6; }
-case $ac_cv_sys_largefile_source in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
-_ACEOF
-;;
-esac
-rm -rf conftest*
-
-# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
-# in glibc 2.1.3, but that breaks too many other things.
-# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-if test $ac_cv_sys_largefile_source != unknown; then
-
-$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
-
-fi
-
-for ac_func in fseek64
-do :
-  ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64"
-if test "x$ac_cv_func_fseek64" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_FSEEK64 1
-_ACEOF
- xpdf_cv_func_fseek64=yes
-else
-  xpdf_cv_func_fseek64=no
-fi
-done
-
-for ac_func in ftell64
-do :
-  ac_fn_c_check_func "$LINENO" "ftell64" "ac_cv_func_ftell64"
-if test "x$ac_cv_func_ftell64" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_FTELL64 1
-_ACEOF
- xpdf_cv_func_ftell64=yes
-else
-  xpdf_cv_func_ftell64=no
-fi
-done
-
-if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then
-  $as_echo "#define HAVE_FSEEK64 1" >>confdefs.h
-
-fi
-
-if test -z "$no_x"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Xpm-library was given.
-if test "${with_Xpm_library+set}" = set; then :
-  withval=$with_Xpm_library; smr_cv_with_Xpm_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Xpm library" >&5
-$as_echo_n "checking whether to use Xpm library... " >&6; }
-if ${smr_cv_with_Xpm_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xpm_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xpm_library" >&5
-$as_echo "$smr_cv_with_Xpm_library" >&6; }
-
-
-  case x"$smr_cv_with_Xpm_library" in
-      xyes | xmaybe)
-          Xpm_LIBS="-lXpm"
-          with_Xpm=$smr_cv_with_Xpm_library
-          ;;
-      xno)
-          Xpm_LIBS=
-          with_Xpm=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Xpm_library"; then
-            Xpm_LIBS=$smr_cv_with_Xpm_library
-          elif test -d "$smr_cv_with_Xpm_library"; then
-            Xpm_LIBS="-L$smr_cv_with_Xpm_library -lXpm"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Xpm=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Xpm" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Xpm-includes was given.
-if test "${with_Xpm_includes+set}" = set; then :
-  withval=$with_Xpm_includes; smr_cv_with_Xpm_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Xpm header files" >&5
-$as_echo_n "checking where to find the Xpm header files... " >&6; }
-if ${smr_cv_with_Xpm_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xpm_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xpm_includes" >&5
-$as_echo "$smr_cv_with_Xpm_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Xpm_includes" = x; then
-    if test -d "$smr_cv_with_Xpm_includes"; then
-      Xpm_CFLAGS="-I$smr_cv_with_Xpm_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Xpm_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Xpm_CFLAGS $X_CFLAGS"
-
-      for ac_header in X11/xpm.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_xpm_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_X11_XPM_H 1
-_ACEOF
- smr_have_Xpm_header=yes
-else
-  smr_have_Xpm_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Xpm_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmCreatePixmapFromData in -lXpm" >&5
-$as_echo_n "checking for XpmCreatePixmapFromData in -lXpm... " >&6; }
-if ${ac_cv_lib_Xpm_XpmCreatePixmapFromData+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXpm $Xpm_CFLAGS $X_CFLAGS $Xpm_LIBS $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XpmCreatePixmapFromData ();
-int
-main ()
-{
-return XpmCreatePixmapFromData ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xpm_XpmCreatePixmapFromData=yes
-else
-  ac_cv_lib_Xpm_XpmCreatePixmapFromData=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&5
-$as_echo "$ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&6; }
-if test "x$ac_cv_lib_Xpm_XpmCreatePixmapFromData" = xyes; then :
-  smr_have_Xpm_library=yes
-else
-  smr_have_Xpm_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Xpm_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Xpm library" >&5
-$as_echo "using Xpm library" >&6; }
-    else
-      Xpm_LIBS=
-      Xpm_CFLAGS=
-
-      if test x"$with_Xpm" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Xpm library" >&5
-$as_echo "not using Xpm library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Xpm library not found!" >&5
-$as_echo "$as_me: WARNING: requested Xpm library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-fi
-
-if test -z "$no_x"; then
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Xext-library was given.
-if test "${with_Xext_library+set}" = set; then :
-  withval=$with_Xext_library; smr_cv_with_Xext_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Xext library" >&5
-$as_echo_n "checking whether to use Xext library... " >&6; }
-if ${smr_cv_with_Xext_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xext_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xext_library" >&5
-$as_echo "$smr_cv_with_Xext_library" >&6; }
-
-
-  case x"$smr_cv_with_Xext_library" in
-      xyes | xmaybe)
-          Xext_LIBS="-lXext"
-          with_Xext=$smr_cv_with_Xext_library
-          ;;
-      xno)
-          Xext_LIBS=
-          with_Xext=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Xext_library"; then
-            Xext_LIBS=$smr_cv_with_Xext_library
-          elif test -d "$smr_cv_with_Xext_library"; then
-            Xext_LIBS="-L$smr_cv_with_Xext_library -lXext"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Xext=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Xext" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Xext-includes was given.
-if test "${with_Xext_includes+set}" = set; then :
-  withval=$with_Xext_includes; smr_cv_with_Xext_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Xext header files" >&5
-$as_echo_n "checking where to find the Xext header files... " >&6; }
-if ${smr_cv_with_Xext_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xext_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xext_includes" >&5
-$as_echo "$smr_cv_with_Xext_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Xext_includes" = x; then
-    if test -d "$smr_cv_with_Xext_includes"; then
-      Xext_CFLAGS="-I$smr_cv_with_Xext_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Xext_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Xext_CFLAGS $X_CFLAGS"
-
-      for ac_header in X11/Xlib.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "X11/Xlib.h" "ac_cv_header_X11_Xlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_Xlib_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_X11_XLIB_H 1
-_ACEOF
- smr_have_Xext_header=yes
-else
-  smr_have_Xext_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Xext_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XextAddDisplay in -lXext" >&5
-$as_echo_n "checking for XextAddDisplay in -lXext... " >&6; }
-if ${ac_cv_lib_Xext_XextAddDisplay+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXext $Xext_CFLAGS $X_CFLAGS $Xext_LIBS $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XextAddDisplay ();
-int
-main ()
-{
-return XextAddDisplay ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xext_XextAddDisplay=yes
-else
-  ac_cv_lib_Xext_XextAddDisplay=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xext_XextAddDisplay" >&5
-$as_echo "$ac_cv_lib_Xext_XextAddDisplay" >&6; }
-if test "x$ac_cv_lib_Xext_XextAddDisplay" = xyes; then :
-  smr_have_Xext_library=yes
-else
-  smr_have_Xext_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Xext_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Xext library" >&5
-$as_echo "using Xext library" >&6; }
-    else
-      Xext_LIBS=
-      Xext_CFLAGS=
-
-      if test x"$with_Xext" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Xext library" >&5
-$as_echo "not using Xext library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Xext library not found!" >&5
-$as_echo "$as_me: WARNING: requested Xext library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Xp-library was given.
-if test "${with_Xp_library+set}" = set; then :
-  withval=$with_Xp_library; smr_cv_with_Xp_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Xp library" >&5
-$as_echo_n "checking whether to use Xp library... " >&6; }
-if ${smr_cv_with_Xp_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xp_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xp_library" >&5
-$as_echo "$smr_cv_with_Xp_library" >&6; }
-
-
-  case x"$smr_cv_with_Xp_library" in
-      xyes | xmaybe)
-          Xp_LIBS="-lXp"
-          with_Xp=$smr_cv_with_Xp_library
-          ;;
-      xno)
-          Xp_LIBS=
-          with_Xp=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Xp_library"; then
-            Xp_LIBS=$smr_cv_with_Xp_library
-          elif test -d "$smr_cv_with_Xp_library"; then
-            Xp_LIBS="-L$smr_cv_with_Xp_library -lXp"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Xp=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Xp" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Xp-includes was given.
-if test "${with_Xp_includes+set}" = set; then :
-  withval=$with_Xp_includes; smr_cv_with_Xp_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Xp header files" >&5
-$as_echo_n "checking where to find the Xp header files... " >&6; }
-if ${smr_cv_with_Xp_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xp_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xp_includes" >&5
-$as_echo "$smr_cv_with_Xp_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Xp_includes" = x; then
-    if test -d "$smr_cv_with_Xp_includes"; then
-      Xp_CFLAGS="-I$smr_cv_with_Xp_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Xp_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Xp_CFLAGS $X_CFLAGS"
-
-      for ac_header in X11/extensions/Print.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "X11/extensions/Print.h" "ac_cv_header_X11_extensions_Print_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_extensions_Print_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_X11_EXTENSIONS_PRINT_H 1
-_ACEOF
- smr_have_Xp_header=yes
-else
-  smr_have_Xp_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Xp_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpStartPage in -lXp" >&5
-$as_echo_n "checking for XpStartPage in -lXp... " >&6; }
-if ${ac_cv_lib_Xp_XpStartPage+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXp $Xp_CFLAGS $X_CFLAGS $Xp_LIBS $X_LIBS $X_PRE_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XpStartPage ();
-int
-main ()
-{
-return XpStartPage ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xp_XpStartPage=yes
-else
-  ac_cv_lib_Xp_XpStartPage=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xp_XpStartPage" >&5
-$as_echo "$ac_cv_lib_Xp_XpStartPage" >&6; }
-if test "x$ac_cv_lib_Xp_XpStartPage" = xyes; then :
-  smr_have_Xp_library=yes
-else
-  smr_have_Xp_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Xp_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Xp library" >&5
-$as_echo "using Xp library" >&6; }
-    else
-      Xp_LIBS=
-      Xp_CFLAGS=
-
-      if test x"$with_Xp" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Xp library" >&5
-$as_echo "not using Xp library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Xp library not found!" >&5
-$as_echo "$as_me: WARNING: requested Xp library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Xt-library was given.
-if test "${with_Xt_library+set}" = set; then :
-  withval=$with_Xt_library; smr_cv_with_Xt_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Xt library" >&5
-$as_echo_n "checking whether to use Xt library... " >&6; }
-if ${smr_cv_with_Xt_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xt_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xt_library" >&5
-$as_echo "$smr_cv_with_Xt_library" >&6; }
-
-
-  case x"$smr_cv_with_Xt_library" in
-      xyes | xmaybe)
-          Xt_LIBS="-lXt"
-          with_Xt=$smr_cv_with_Xt_library
-          ;;
-      xno)
-          Xt_LIBS=
-          with_Xt=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Xt_library"; then
-            Xt_LIBS=$smr_cv_with_Xt_library
-          elif test -d "$smr_cv_with_Xt_library"; then
-            Xt_LIBS="-L$smr_cv_with_Xt_library -lXt"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Xt=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Xt" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Xt-includes was given.
-if test "${with_Xt_includes+set}" = set; then :
-  withval=$with_Xt_includes; smr_cv_with_Xt_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Xt header files" >&5
-$as_echo_n "checking where to find the Xt header files... " >&6; }
-if ${smr_cv_with_Xt_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xt_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xt_includes" >&5
-$as_echo "$smr_cv_with_Xt_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Xt_includes" = x; then
-    if test -d "$smr_cv_with_Xt_includes"; then
-      Xt_CFLAGS="-I$smr_cv_with_Xt_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Xt_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Xt_CFLAGS $X_CFLAGS"
-
-      for ac_header in X11/Intrinsic.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "X11/Intrinsic.h" "ac_cv_header_X11_Intrinsic_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_Intrinsic_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_X11_INTRINSIC_H 1
-_ACEOF
- smr_have_Xt_header=yes
-else
-  smr_have_Xt_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Xt_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XtAppInitialize in -lXt" >&5
-$as_echo_n "checking for XtAppInitialize in -lXt... " >&6; }
-if ${ac_cv_lib_Xt_XtAppInitialize+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXt $Xt_CFLAGS $X_CFLAGS $Xt_LIBS $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XtAppInitialize ();
-int
-main ()
-{
-return XtAppInitialize ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xt_XtAppInitialize=yes
-else
-  ac_cv_lib_Xt_XtAppInitialize=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
-$as_echo "$ac_cv_lib_Xt_XtAppInitialize" >&6; }
-if test "x$ac_cv_lib_Xt_XtAppInitialize" = xyes; then :
-  smr_have_Xt_library=yes
-else
-  smr_have_Xt_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Xt_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Xt library" >&5
-$as_echo "using Xt library" >&6; }
-    else
-      Xt_LIBS=
-      Xt_CFLAGS=
-
-      if test x"$with_Xt" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Xt library" >&5
-$as_echo "not using Xt library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Xt library not found!" >&5
-$as_echo "$as_me: WARNING: requested Xt library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Xm-library was given.
-if test "${with_Xm_library+set}" = set; then :
-  withval=$with_Xm_library; smr_cv_with_Xm_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Xm library" >&5
-$as_echo_n "checking whether to use Xm library... " >&6; }
-if ${smr_cv_with_Xm_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xm_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xm_library" >&5
-$as_echo "$smr_cv_with_Xm_library" >&6; }
-
-
-  case x"$smr_cv_with_Xm_library" in
-      xyes | xmaybe)
-          Xm_LIBS="-lXm"
-          with_Xm=$smr_cv_with_Xm_library
-          ;;
-      xno)
-          Xm_LIBS=
-          with_Xm=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Xm_library"; then
-            Xm_LIBS=$smr_cv_with_Xm_library
-          elif test -d "$smr_cv_with_Xm_library"; then
-            Xm_LIBS="-L$smr_cv_with_Xm_library -lXm"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Xm=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Xm" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Xm-includes was given.
-if test "${with_Xm_includes+set}" = set; then :
-  withval=$with_Xm_includes; smr_cv_with_Xm_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Xm header files" >&5
-$as_echo_n "checking where to find the Xm header files... " >&6; }
-if ${smr_cv_with_Xm_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Xm_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Xm_includes" >&5
-$as_echo "$smr_cv_with_Xm_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Xm_includes" = x; then
-    if test -d "$smr_cv_with_Xm_includes"; then
-      Xm_CFLAGS="-I$smr_cv_with_Xm_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Xm_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Xm_CFLAGS $X_CFLAGS"
-
-      for ac_header in Xm/XmAll.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "Xm/XmAll.h" "ac_cv_header_Xm_XmAll_h" "$ac_includes_default"
-if test "x$ac_cv_header_Xm_XmAll_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_XM_XMALL_H 1
-_ACEOF
- smr_have_Xm_header=yes
-else
-  smr_have_Xm_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Xm_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XmCreateForm in -lXm" >&5
-$as_echo_n "checking for XmCreateForm in -lXm... " >&6; }
-if ${ac_cv_lib_Xm_XmCreateForm+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXm $Xm_CFLAGS $X_CFLAGS $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XmCreateForm ();
-int
-main ()
-{
-return XmCreateForm ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xm_XmCreateForm=yes
-else
-  ac_cv_lib_Xm_XmCreateForm=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xm_XmCreateForm" >&5
-$as_echo "$ac_cv_lib_Xm_XmCreateForm" >&6; }
-if test "x$ac_cv_lib_Xm_XmCreateForm" = xyes; then :
-  smr_have_Xm_library=yes
-else
-  smr_have_Xm_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Xm_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Xm library" >&5
-$as_echo "using Xm library" >&6; }
-    else
-      Xm_LIBS=
-      Xm_CFLAGS=
-
-      if test x"$with_Xm" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Xm library" >&5
-$as_echo "not using Xm library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Xm library not found!" >&5
-$as_echo "$as_me: WARNING: requested Xm library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-Sgm-library was given.
-if test "${with_Sgm_library+set}" = set; then :
-  withval=$with_Sgm_library; smr_cv_with_Sgm_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use Sgm library" >&5
-$as_echo_n "checking whether to use Sgm library... " >&6; }
-if ${smr_cv_with_Sgm_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Sgm_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Sgm_library" >&5
-$as_echo "$smr_cv_with_Sgm_library" >&6; }
-
-
-  case x"$smr_cv_with_Sgm_library" in
-      xyes | xmaybe)
-          Sgm_LIBS="-lSgm"
-          with_Sgm=$smr_cv_with_Sgm_library
-          ;;
-      xno)
-          Sgm_LIBS=
-          with_Sgm=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_Sgm_library"; then
-            Sgm_LIBS=$smr_cv_with_Sgm_library
-          elif test -d "$smr_cv_with_Sgm_library"; then
-            Sgm_LIBS="-L$smr_cv_with_Sgm_library -lSgm"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_Sgm=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_Sgm" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-Sgm-includes was given.
-if test "${with_Sgm_includes+set}" = set; then :
-  withval=$with_Sgm_includes; smr_cv_with_Sgm_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the Sgm header files" >&5
-$as_echo_n "checking where to find the Sgm header files... " >&6; }
-if ${smr_cv_with_Sgm_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_Sgm_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_Sgm_includes" >&5
-$as_echo "$smr_cv_with_Sgm_includes" >&6; }
-
-  if test ! x"$smr_cv_with_Sgm_includes" = x; then
-    if test -d "$smr_cv_with_Sgm_includes"; then
-      Sgm_CFLAGS="-I$smr_cv_with_Sgm_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    Sgm_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $Sgm_CFLAGS $X_CFLAGS"
-
-      for ac_header in Sgm/HPanedW.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "Sgm/HPanedW.h" "ac_cv_header_Sgm_HPanedW_h" "$ac_includes_default"
-if test "x$ac_cv_header_Sgm_HPanedW_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SGM_HPANEDW_H 1
-_ACEOF
- smr_have_Sgm_header=yes
-else
-  smr_have_Sgm_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_Sgm_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SgCreateHorzPanedWindow in -lSgm" >&5
-$as_echo_n "checking for SgCreateHorzPanedWindow in -lSgm... " >&6; }
-if ${ac_cv_lib_Sgm_SgCreateHorzPanedWindow+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lSgm $Sgm_CFLAGS $X_CFLAGS $Sgm_LIBS $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char SgCreateHorzPanedWindow ();
-int
-main ()
-{
-return SgCreateHorzPanedWindow ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Sgm_SgCreateHorzPanedWindow=yes
-else
-  ac_cv_lib_Sgm_SgCreateHorzPanedWindow=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Sgm_SgCreateHorzPanedWindow" >&5
-$as_echo "$ac_cv_lib_Sgm_SgCreateHorzPanedWindow" >&6; }
-if test "x$ac_cv_lib_Sgm_SgCreateHorzPanedWindow" = xyes; then :
-  smr_have_Sgm_library=yes
-else
-  smr_have_Sgm_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_Sgm_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using Sgm library" >&5
-$as_echo "using Sgm library" >&6; }
-    else
-      Sgm_LIBS=
-      Sgm_CFLAGS=
-
-      if test x"$with_Sgm" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using Sgm library" >&5
-$as_echo "not using Sgm library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested Sgm library not found!" >&5
-$as_echo "$as_me: WARNING: requested Sgm library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    if test "x$smr_have_Xt_library" = xyes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XtAppSetExitFlag in -lXt" >&5
-$as_echo_n "checking for XtAppSetExitFlag in -lXt... " >&6; }
-if ${ac_cv_lib_Xt_XtAppSetExitFlag+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXt $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XtAppSetExitFlag ();
-int
-main ()
-{
-return XtAppSetExitFlag ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xt_XtAppSetExitFlag=yes
-else
-  ac_cv_lib_Xt_XtAppSetExitFlag=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xt_XtAppSetExitFlag" >&5
-$as_echo "$ac_cv_lib_Xt_XtAppSetExitFlag" >&6; }
-if test "x$ac_cv_lib_Xt_XtAppSetExitFlag" = xyes; then :
-  $as_echo "#define HAVE_XTAPPSETEXITFLAG 1" >>confdefs.h
-
-fi
-
-  fi
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-freetype2-library was given.
-if test "${with_freetype2_library+set}" = set; then :
-  withval=$with_freetype2_library; smr_cv_with_freetype2_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use freetype2 library" >&5
-$as_echo_n "checking whether to use freetype2 library... " >&6; }
-if ${smr_cv_with_freetype2_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_freetype2_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_freetype2_library" >&5
-$as_echo "$smr_cv_with_freetype2_library" >&6; }
-
-
-  case x"$smr_cv_with_freetype2_library" in
-      xyes | xmaybe)
-          freetype2_LIBS="-lfreetype"
-          with_freetype2=$smr_cv_with_freetype2_library
-          ;;
-      xno)
-          freetype2_LIBS=
-          with_freetype2=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_freetype2_library"; then
-            freetype2_LIBS=$smr_cv_with_freetype2_library
-          elif test -d "$smr_cv_with_freetype2_library"; then
-            freetype2_LIBS="-L$smr_cv_with_freetype2_library -lfreetype"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_freetype2=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_freetype2" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-freetype2-includes was given.
-if test "${with_freetype2_includes+set}" = set; then :
-  withval=$with_freetype2_includes; smr_cv_with_freetype2_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the freetype2 header files" >&5
-$as_echo_n "checking where to find the freetype2 header files... " >&6; }
-if ${smr_cv_with_freetype2_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_freetype2_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_freetype2_includes" >&5
-$as_echo "$smr_cv_with_freetype2_includes" >&6; }
-
-  if test ! x"$smr_cv_with_freetype2_includes" = x; then
-    if test -d "$smr_cv_with_freetype2_includes"; then
-      freetype2_CFLAGS="-I$smr_cv_with_freetype2_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    freetype2_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $freetype2_CFLAGS "
-
-      for ac_header in ft2build.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "ft2build.h" "ac_cv_header_ft2build_h" "$ac_includes_default"
-if test "x$ac_cv_header_ft2build_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_FT2BUILD_H 1
-_ACEOF
- smr_have_freetype2_header=yes
-else
-  smr_have_freetype2_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_freetype2_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Get_Name_Index in -lfreetype" >&5
-$as_echo_n "checking for FT_Get_Name_Index in -lfreetype... " >&6; }
-if ${ac_cv_lib_freetype_FT_Get_Name_Index+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lfreetype $freetype2_CFLAGS  $freetype2_LIBS -lm $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char FT_Get_Name_Index ();
-int
-main ()
-{
-return FT_Get_Name_Index ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_freetype_FT_Get_Name_Index=yes
-else
-  ac_cv_lib_freetype_FT_Get_Name_Index=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Get_Name_Index" >&5
-$as_echo "$ac_cv_lib_freetype_FT_Get_Name_Index" >&6; }
-if test "x$ac_cv_lib_freetype_FT_Get_Name_Index" = xyes; then :
-  smr_have_freetype2_library=yes
-else
-  smr_have_freetype2_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_freetype2_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using freetype2 library" >&5
-$as_echo "using freetype2 library" >&6; }
-    else
-      freetype2_LIBS=
-      freetype2_CFLAGS=
-
-      if test x"$with_freetype2" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using freetype2 library" >&5
-$as_echo "not using freetype2 library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested freetype2 library not found!" >&5
-$as_echo "$as_me: WARNING: requested freetype2 library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-if test "x$smr_have_freetype2_library" = xyes; then
-  $as_echo "#define HAVE_FREETYPE_FREETYPE_H 1" >>confdefs.h
-
-  $as_echo "#define HAVE_SPLASH 1" >>confdefs.h
-
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-libpng-library was given.
-if test "${with_libpng_library+set}" = set; then :
-  withval=$with_libpng_library; smr_cv_with_libpng_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libpng library" >&5
-$as_echo_n "checking whether to use libpng library... " >&6; }
-if ${smr_cv_with_libpng_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_libpng_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_libpng_library" >&5
-$as_echo "$smr_cv_with_libpng_library" >&6; }
-
-
-  case x"$smr_cv_with_libpng_library" in
-      xyes | xmaybe)
-          libpng_LIBS="-lpng"
-          with_libpng=$smr_cv_with_libpng_library
-          ;;
-      xno)
-          libpng_LIBS=
-          with_libpng=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_libpng_library"; then
-            libpng_LIBS=$smr_cv_with_libpng_library
-          elif test -d "$smr_cv_with_libpng_library"; then
-            libpng_LIBS="-L$smr_cv_with_libpng_library -lpng"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_libpng=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_libpng" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-libpng-includes was given.
-if test "${with_libpng_includes+set}" = set; then :
-  withval=$with_libpng_includes; smr_cv_with_libpng_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the libpng header files" >&5
-$as_echo_n "checking where to find the libpng header files... " >&6; }
-if ${smr_cv_with_libpng_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_libpng_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_libpng_includes" >&5
-$as_echo "$smr_cv_with_libpng_includes" >&6; }
-
-  if test ! x"$smr_cv_with_libpng_includes" = x; then
-    if test -d "$smr_cv_with_libpng_includes"; then
-      libpng_CFLAGS="-I$smr_cv_with_libpng_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    libpng_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $libpng_CFLAGS "
-
-      for ac_header in png.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "png.h" "ac_cv_header_png_h" "$ac_includes_default"
-if test "x$ac_cv_header_png_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_PNG_H 1
-_ACEOF
- smr_have_libpng_header=yes
-else
-  smr_have_libpng_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_libpng_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_write_row in -lpng" >&5
-$as_echo_n "checking for png_write_row in -lpng... " >&6; }
-if ${ac_cv_lib_png_png_write_row+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpng $libpng_CFLAGS  $libpng_LIBS -lz $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char png_write_row ();
-int
-main ()
-{
-return png_write_row ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_png_png_write_row=yes
-else
-  ac_cv_lib_png_png_write_row=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_write_row" >&5
-$as_echo "$ac_cv_lib_png_png_write_row" >&6; }
-if test "x$ac_cv_lib_png_png_write_row" = xyes; then :
-  smr_have_libpng_library=yes
-else
-  smr_have_libpng_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_libpng_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using libpng library" >&5
-$as_echo "using libpng library" >&6; }
-    else
-      libpng_LIBS=
-      libpng_CFLAGS=
-
-      if test x"$with_libpng" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using libpng library" >&5
-$as_echo "not using libpng library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested libpng library not found!" >&5
-$as_echo "$as_me: WARNING: requested libpng library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-libpaper-library was given.
-if test "${with_libpaper_library+set}" = set; then :
-  withval=$with_libpaper_library; smr_cv_with_libpaper_library=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libpaper library" >&5
-$as_echo_n "checking whether to use libpaper library... " >&6; }
-if ${smr_cv_with_libpaper_library+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_libpaper_library=maybe
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_libpaper_library" >&5
-$as_echo "$smr_cv_with_libpaper_library" >&6; }
-
-
-  case x"$smr_cv_with_libpaper_library" in
-      xyes | xmaybe)
-          libpaper_LIBS="-lpaper"
-          with_libpaper=$smr_cv_with_libpaper_library
-          ;;
-      xno)
-          libpaper_LIBS=
-          with_libpaper=no
-          ;;
-      *)
-          if test -f "$smr_cv_with_libpaper_library"; then
-            libpaper_LIBS=$smr_cv_with_libpaper_library
-          elif test -d "$smr_cv_with_libpaper_library"; then
-            libpaper_LIBS="-L$smr_cv_with_libpaper_library -lpaper"
-          else
-            as_fn_error $? "argument must be boolean, file, or directory" "$LINENO" 5
-          fi
-          with_libpaper=yes
-          ;;
-  esac
-
-
-
-
-
-
-
-  if test ! x"$with_libpaper" = xno; then
-
-    # If we got this far, then the user didn't explicitly ask not to use
-    # the library.
-
-
-
-
-
-
-
-
-# Check whether --with-libpaper-includes was given.
-if test "${with_libpaper_includes+set}" = set; then :
-  withval=$with_libpaper_includes; smr_cv_with_libpaper_includes=$withval
-fi
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the libpaper header files" >&5
-$as_echo_n "checking where to find the libpaper header files... " >&6; }
-if ${smr_cv_with_libpaper_includes+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  smr_cv_with_libpaper_includes=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $smr_cv_with_libpaper_includes" >&5
-$as_echo "$smr_cv_with_libpaper_includes" >&6; }
-
-  if test ! x"$smr_cv_with_libpaper_includes" = x; then
-    if test -d "$smr_cv_with_libpaper_includes"; then
-      libpaper_CFLAGS="-I$smr_cv_with_libpaper_includes"
-    else
-      as_fn_error $? "argument must be a directory" "$LINENO" 5
-    fi
-  else
-    libpaper_CFLAGS=
-  fi
-
-        smr_test_CPPFLAGS="${CPPFLAGS+set}"
-  smr_save_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $libpaper_CFLAGS "
-
-      for ac_header in paper.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "paper.h" "ac_cv_header_paper_h" "$ac_includes_default"
-if test "x$ac_cv_header_paper_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_PAPER_H 1
-_ACEOF
- smr_have_libpaper_header=yes
-else
-  smr_have_libpaper_header=no
-fi
-
-done
-
-
-  if test x"$smr_test_CPPFLAGS" = xset; then
-    CPPFLAGS=$smr_save_CPPFLAGS
-  else
-    unset CPPFLAGS
-  fi
-
-
-
-
-
-
-
-    # We need only look for the library if the header has been found
-    # (or no header is needed).
-    if test $smr_have_libpaper_header != no; then
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for paperinit in -lpaper" >&5
-$as_echo_n "checking for paperinit in -lpaper... " >&6; }
-if ${ac_cv_lib_paper_paperinit+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpaper $libpaper_CFLAGS  $libpaper_LIBS  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char paperinit ();
-int
-main ()
-{
-return paperinit ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_paper_paperinit=yes
-else
-  ac_cv_lib_paper_paperinit=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_paper_paperinit" >&5
-$as_echo "$ac_cv_lib_paper_paperinit" >&6; }
-if test "x$ac_cv_lib_paper_paperinit" = xyes; then :
-  smr_have_libpaper_library=yes
-else
-  smr_have_libpaper_library=no
-fi
-
-    fi
-
-    if test x"$smr_have_libpaper_library" = xyes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using libpaper library" >&5
-$as_echo "using libpaper library" >&6; }
-    else
-      libpaper_LIBS=
-      libpaper_CFLAGS=
-
-      if test x"$with_libpaper" = xmaybe; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: not using libpaper library" >&5
-$as_echo "not using libpaper library" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: requested libpaper library not found!" >&5
-$as_echo "$as_me: WARNING: requested libpaper library not found!" >&2;}
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
-  X="#"
-  XPDF_TARGET="all-no-x"
-else
-  X=""
-  XPDF_TARGET="all"
-fi
-
-
-
-EXTRA_LIBS=
-EXTRA_CFLAGS=
-
-
-
-ac_config_files="$ac_config_files Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
-  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-
-  (set) 2>&1 |
-    case $as_nl`(ac_space=' '; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;; #(
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-) |
-  sed '
-     /^ac_cv_env_/b end
-     t clear
-     :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-  if test -w "$cache_file"; then
-    if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
-      if test ! -f "$cache_file" || test -h "$cache_file"; then
-	cat confcache >"$cache_file"
-      else
-        case $cache_file in #(
-        */* | ?:*)
-	  mv -f confcache "$cache_file"$$ &&
-	  mv -f "$cache_file"$$ "$cache_file" ;; #(
-        *)
-	  mv -f confcache "$cache_file" ;;
-	esac
-      fi
-    fi
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-U=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -pR'
-  fi
-else
-  as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by $as_me, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
-  -q, --quiet, --silent
-                   do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-      --file=FILE[:TEMPLATE]
-                   instantiate the configuration file FILE
-      --header=FILE[:TEMPLATE]
-                   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to the package provider."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-config.status
-configured by $0, generated by GNU Autoconf 2.69,
-  with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=?*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
-    esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --he | --h)
-    # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
-  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
-  *) as_fn_append ac_config_targets " $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
-  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-  shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-  CONFIG_SHELL='$SHELL'
-  export CONFIG_SHELL
-  exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "aconf.h") CONFIG_HEADERS="$CONFIG_HEADERS aconf.h" ;;
-    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-    "goo/Makefile") CONFIG_FILES="$CONFIG_FILES goo/Makefile" ;;
-    "fofi/Makefile") CONFIG_FILES="$CONFIG_FILES fofi/Makefile" ;;
-    "splash/Makefile") CONFIG_FILES="$CONFIG_FILES splash/Makefile" ;;
-    "xpdf/Makefile") CONFIG_FILES="$CONFIG_FILES xpdf/Makefile" ;;
-
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp= ac_tmp=
-  trap 'exit_status=$?
-  : "${ac_tmp:=$tmp}"
-  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
-  trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
-else
-  ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
-  echo "cat >conf$$subs.awk <<_ACEOF" &&
-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-  echo "_ACEOF"
-} >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
-  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-  if test $ac_delim_n = $ac_delim_num; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
-  N
-  s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
-  for (key in S) S_is_set[key] = 1
-  FS = ""
-
-}
-{
-  line = $ 0
-  nfields = split(line, field, "@")
-  substed = 0
-  len = length(field[1])
-  for (i = 2; i < nfields; i++) {
-    key = field[i]
-    keylen = length(key)
-    if (S_is_set[key]) {
-      value = S[key]
-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
-      len += length(value) + length(field[++i])
-      substed = 1
-    } else
-      len += 1 + keylen
-  }
-
-  print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
-  cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[	 ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
-  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_tt"; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any.  Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  for (key in D) D_is_set[key] = 1
-  FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
-  line = \$ 0
-  split(line, arg, " ")
-  if (arg[1] == "#") {
-    defundef = arg[2]
-    mac1 = arg[3]
-  } else {
-    defundef = substr(arg[1], 2)
-    mac1 = arg[2]
-  }
-  split(mac1, mac2, "(") #)
-  macro = mac2[1]
-  prefix = substr(line, 1, index(line, defundef) - 1)
-  if (D_is_set[macro]) {
-    # Preserve the white space surrounding the "#".
-    print prefix "define", macro P[macro] D[macro]
-    next
-  } else {
-    # Replace #undef with comments.  This is necessary, for example,
-    # in the case of _POSIX_SOURCE, which is predefined and required
-    # on some systems where configure will not decide to define it.
-    if (defundef == "undef") {
-      print "/*", prefix defundef, macro, "*/"
-      next
-    }
-  }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
-shift
-for ac_tag
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$ac_tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
-	 # because $ac_f cannot contain `:'.
-	 test -f "$ac_f" ||
-	   case $ac_f in
-	   [\\/$]*) false;;
-	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-      esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
-	`' by configure.'
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
-    fi
-    # Neutralize special characters interpreted by sed in replacement strings.
-    case $configure_input in #(
-    *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
-       sed 's/[\\\\&|]/\\\\&/g'`;; #(
-    *) ac_sed_conf_input=$configure_input;;
-    esac
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$ac_tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
-  ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
-  case $ac_mode in
-  :F)
-  #
-  # CONFIG_FILE
-  #
-
-  case $INSTALL in
-  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
-  esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
-  p
-  q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  ac_datarootdir_hack='
-  s&@datadir@&$datadir&g
-  s&@docdir@&$docdir&g
-  s&@infodir@&$infodir&g
-  s&@localedir@&$localedir&g
-  s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
-      "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
-
-  rm -f "$ac_tmp/stdin"
-  case $ac_file in
-  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
-  esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
-  :H)
-  #
-  # CONFIG_HEADER
-  #
-  if test x"$ac_file" != x-; then
-    {
-      $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
-    } >"$ac_tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
-    else
-      rm -f "$ac_file"
-      mv "$ac_tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    fi
-  else
-    $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
-  fi
- ;;
-
-
-  esac
-
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
-
-if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
-  if test -n "$no_x"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Couldn't find X" >&5
-$as_echo "$as_me: WARNING: Couldn't find X" >&2;};
-  fi
-  if test "x$smr_have_Xm_library" != xyes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Couldn't find Motif" >&5
-$as_echo "$as_me: WARNING: Couldn't find Motif" >&2;};
-  fi
-  if test "x$smr_have_freetype2_library" != xyes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Couldn't find FreeType" >&5
-$as_echo "$as_me: WARNING: Couldn't find FreeType" >&2;};
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: -- You will be able to compile pdftops, pdftotext,
-        pdfinfo, pdffonts, pdfdetach, and pdfimages, but not xpdf
-        or pdftoppm" >&5
-$as_echo "$as_me: WARNING: -- You will be able to compile pdftops, pdftotext,
-        pdfinfo, pdffonts, pdfdetach, and pdfimages, but not xpdf
-        or pdftoppm" >&2;}
-fi
-
-if test "x$smr_have_libpng_library" != xyes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Couldn't find libpng -- you will not be able to build pdftohtml or pdftopng" >&5
-$as_echo "$as_me: WARNING: Couldn't find libpng -- you will not be able to build pdftohtml or pdftopng" >&2;}
-fi

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/configure.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/configure.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/configure.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,398 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-dnl Copyright 1998-2013 Glyph & Cog, LLC
-
-AC_PREREQ(2.57)
-
-AC_INIT(xpdf/Gfx.cc)
-AC_CONFIG_HEADER(aconf.h)
-
-dnl ##### Optional features.
-
-AC_ARG_ENABLE([a4-paper],
-  AS_HELP_STRING([--enable-a4-paper],
-                 [use A4 paper size instead of Letter for PostScript output]))
-AS_IF([test "x$enable_a4_paper" = "xyes"],
-      [AC_DEFINE(A4_PAPER)])
-
-AC_ARG_ENABLE([no-text-select],
-  AS_HELP_STRING([--enable-no-text-select],
-                 [do not allow text selection]))
-AS_IF([test "x$enable_no_text_select" = "xyes"],
-      [AC_DEFINE(NO_TEXT_SELECT)])
-
-AC_ARG_ENABLE([opi],
-  AS_HELP_STRING([--enable-opi],
-                 [include support for OPI comments]))
-AS_IF([test "x$enable_opi" = "xyes"],
-      [AC_DEFINE(OPI_SUPPORT)])
-
-AC_ARG_ENABLE([multithreaded],
-  AS_HELP_STRING([--enable-multithreaded],
-                 [include support for multithreading]))
-AS_IF([test "x$enable_multithreaded" = "xyes"],
-      [AC_DEFINE(MULTITHREADED)])
-
-AC_ARG_ENABLE([exceptions],
-  AS_HELP_STRING([--enable-exceptions],
-                 [use C++ exceptions]))
-AS_IF([test "x$enable_exceptions" = "xyes"],
-      [AC_DEFINE(USE_EXCEPTIONS)])
-
-AC_ARG_ENABLE([fixedpoint],
-  AS_HELP_STRING([--enable-fixedpoint],
-                 [use fixed point (instead of floating point) arithmetic]))
-AS_IF([test "x$enable_fixedpoint" = "xyes"],
-      [AC_DEFINE(USE_FIXEDPOINT)])
-
-AC_ARG_ENABLE([cmyk],
-  AS_HELP_STRING([--enable-cmyk],
-                 [include support for CMYK rasterization]))
-AS_IF([test "x$enable_cmyk" = "xyes"],
-      [AC_DEFINE(SPLASH_CMYK)])
-
-AC_ARG_WITH([appdef-dir],
-  AS_HELP_STRING([--with-appdef-dir],
-                 [set app-defaults directory]))
-AS_IF([test "x$with_appdef_dir" != "xno"],
-      [AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir")])
-
-dnl ##### Path to xpdfrc.
-dnl This ugly kludge to get the sysconfdir path is needed because
-dnl autoconf doesn't actually set the prefix variable until later.
-if test "$sysconfdir" = '${prefix}/etc'; then
-  if test "x$prefix" = xNONE; then
-    system_xpdfrc="$ac_default_prefix/etc/xpdfrc"
-  else
-    system_xpdfrc="$prefix/etc/xpdfrc"
-  fi
-else
-  system_xpdfrc="$sysconfdir/xpdfrc"
-fi
-AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc")
-
-dnl ##### Checks for programs.
-AC_PROG_CC
-AC_ISC_POSIX
-AC_PROG_CC_STDC
-#if test -z "$CXX" -a "$CC" = "gcc"; then
-#  CXX="gcc"
-#fi
-AC_PROG_CXX
-AC_PROG_INSTALL
-AC_PROG_RANLIB
-
-dnl ##### Default values for Unix.
-EXE=""
-LIBPREFIX="lib"
-AR="ar rc"
-UP_DIR=""
-
-dnl ##### Check for OS/2.
-AC_CACHE_CHECK([for OS/2 (with EMX)],
-xpdf_cv_sys_os2,
-[AC_TRY_COMPILE([],
-[__EMX__],
-xpdf_cv_sys_os2=yes, xpdf_cv_sys_os2=no)])
-if test "$xpdf_cv_sys_os2" = yes; then
-  EXE=".exe"
-  LIBPREFIX=""
-  AR="ar -rc"
-fi
-
-dnl ##### Check for DOS (with DJGPP).
-AC_CACHE_CHECK([for DOS (with DJGPP)],
-xpdf_cv_sys_dos,
-[AC_TRY_COMPILE([],
-[__DJGPP__],
-xpdf_cv_sys_dos=yes, xpdf_cv_sys_dos=no)])
-if test "$xpdf_cv_sys_dos" = yes; then
-  EXE=".exe"
-  LIBPREFIX="lib"
-  AR="ar -rc"
-  UP_DIR="../"
-fi
-
-dnl ##### Do substitutions.
-AC_SUBST(EXE)
-AC_SUBST(LIBPREFIX)
-AC_SUBST(AR)
-AC_SUBST(UP_DIR)
-
-dnl ##### Checks for header files.
-AC_PATH_XTRA
-AC_HEADER_DIRENT
-
-dnl ##### Switch over to C++.  This will make the checks below a little
-dnl ##### bit stricter (requiring function prototypes in include files).
-dnl ##### (99% of xpdf is written in C++.)
-AC_LANG_CPLUSPLUS
-
-dnl ##### Check for extra libraries needed by X.  (LynxOS needs this.)
-AC_CHECK_FUNC(gethostbyname)
-if test $ac_cv_func_gethostbyname = no; then
-  AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd")
-fi
-
-dnl ##### Look for header that defines select() and fd_set.
-AC_MSG_CHECKING([select() and fd_set in sys/select.h and sys/bsdtypes.h])
-AC_TRY_COMPILE([#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>],
-  [fd_set fds;
-select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
-if test $xpdf_ok = yes; then
-  AC_MSG_RESULT([not needed])
-else
-  AC_TRY_COMPILE([#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/select.h>],
-    [fd_set fds;
-select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
-  if test $xpdf_ok = yes; then
-    AC_DEFINE(HAVE_SYS_SELECT_H)
-    AC_MSG_RESULT([need sys/select.h])
-  else
-    AC_TRY_COMPILE([#include <stdlib.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/bsdtypes.h>],
-      [fd_set fds;
-select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
-    if test $xpdf_ok = yes; then
-      AC_DEFINE(HAVE_SYS_BSDTYPES_H)
-      AC_MSG_RESULT([need sys/bsdtypes.h])
-    else
-      AC_MSG_RESULT([problem])
-    fi
-  fi
-fi
-
-dnl ##### Look for header that defines FD_ZERO.
-AC_MSG_CHECKING([FD_ZERO and strings.h or bstring.h])
-AC_TRY_COMPILE([#include <stdlib.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif],
-[fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
-if test $xpdf_ok = yes; then
-  AC_MSG_RESULT([not needed])
-else
-  AC_TRY_COMPILE([#include <stdlib.h>
-#include <sys/types.h>
-#include <strings.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif],
-    [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
-  if test $xpdf_ok = yes; then
-    AC_DEFINE(HAVE_STRINGS_H)
-    AC_MSG_RESULT([need strings.h])
-  else
-    AC_TRY_COMPILE([#include <stdlib.h>
-#include <sys/types.h>
-#include <bstring.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif],
-      [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
-    if test $xpdf_ok = yes; then
-      AC_DEFINE(HAVE_BSTRING_H)
-      AC_MSG_RESULT([need bstring.h])
-    else
-      AC_MSG_RESULT([problem])
-    fi
-  fi
-fi
-
-dnl ##### Look for rewinddir.
-AC_CHECK_FUNCS(rewinddir)
-if test $ac_cv_func_rewinddir = no; then
-  AC_CHECK_LIB(cposix, rewinddir)
-fi
-
-dnl ##### Checks for library functions.
-AC_CHECK_FUNCS(popen)
-dnl # This should use 'AC_CHECK_FUNCS(mkstemp)' but that fails if
-dnl # the mkstemp exists in the library but isn't declared in the
-dnl # include file (e.g., in cygwin 1.1.2).
-AC_CACHE_CHECK([for mkstemp],
-xpdf_cv_func_mkstemp,
-[AC_TRY_LINK([#include <stdlib.h>
-#include <unistd.h>],
-[mkstemp("foo");],
-xpdf_cv_func_mkstemp=yes, xpdf_cv_func_mkstemp=no)])
-if test "$xpdf_cv_func_mkstemp" = yes; then
-  AC_DEFINE(HAVE_MKSTEMP)
-fi
-dnl # Check for mkstemps, just like mkstemp.
-AC_CACHE_CHECK([for mkstemps],
-xpdf_cv_func_mkstemps,
-[AC_TRY_LINK([#include <stdlib.h>
-#include <unistd.h>],
-[mkstemps("foo", 0);],
-xpdf_cv_func_mkstemps=yes, xpdf_cv_func_mkstemps=no)])
-if test "$xpdf_cv_func_mkstemps" = yes; then
-  AC_DEFINE(HAVE_MKSTEMPS)
-fi
-
-dnl ##### Check select argument type: on HP-UX before version 10, select
-dnl ##### takes (int *) instead of (fd_set *).
-AC_CACHE_CHECK([whether select takes fd_set arguments],
-xpdf_cv_func_select_arg,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif],
-[fd_set fds;
-select(1, &fds, &fds, &fds, 0);],
-xpdf_cv_func_select_arg=yes, xpdf_cv_func_select_arg=no)])
-if test "$xpdf_cv_func_select_arg" != yes; then
-  AC_DEFINE(SELECT_TAKES_INT)
-fi
-
-dnl ##### Check for std::sort.
-AC_CACHE_CHECK([for std::sort],
-xpdf_cv_func_std_sort,
-[AC_COMPILE_IFELSE(
-  [AC_LANG_PROGRAM([[#include <algorithm>
-struct functor {
-  bool operator()(const int &i0, const int &i1) { return i0 < i1; }
-};]],
-                  [[int a[100];
-std::sort(a, a+100, functor());]])],
-xpdf_cv_func_std_sort=yes, xpdf_cv_func_std_sort=no)])
-if test "$xpdf_cv_func_std_sort" = yes; then
-  AC_DEFINE(HAVE_STD_SORT)
-fi
-
-dnl ##### Back to C for the library tests.
-AC_LANG_C
-
-dnl ##### Check for fseeko/ftello or fseek64/ftell64
-dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode.
-AC_SYS_LARGEFILE
-AC_FUNC_FSEEKO
-AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no)
-AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no)
-if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then
-  AC_DEFINE(HAVE_FSEEK64)
-fi
-
-dnl ##### Check for libXpm.
-if test -z "$no_x"; then
-  smr_CHECK_LIB(Xpm, Xpm, [pixmap library - used only for icon], 
-                XpmCreatePixmapFromData, X11/xpm.h,
-                $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
-  AC_SUBST(Xpm_LIBS)
-  AC_SUBST(Xpm_CFLAGS)
-fi
-
-dnl ##### Check for Motif (libXm).
-if test -z "$no_x"; then
-  dnl # XextAddDisplay isn't defined in any header file, so we provide a
-  dnl # bogus prototype (so the compiler doesn't complain) and a bogus
-  dnl # header file (so the smr macro doesn't break).
-  smr_CHECK_LIB(Xext, Xext, [Motif library], 
-                XextAddDisplay, X11/Xlib.h,
-                $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS,
-                [int XextAddDisplay();])
-  AC_SUBST(Xext_LIBS)
-  AC_SUBST(Xext_CFLAGS)
-  smr_CHECK_LIB(Xp, Xp, [Motif library], 
-                XpStartPage, X11/extensions/Print.h,
-                $X_LIBS $X_PRE_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
-  AC_SUBST(Xp_LIBS)
-  AC_SUBST(Xp_CFLAGS)
-  smr_CHECK_LIB(Xt, Xt, [Motif library], 
-                XtAppInitialize, X11/Intrinsic.h,
-                $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
-  AC_SUBST(Xt_LIBS)
-  AC_SUBST(Xt_CFLAGS)
-  smr_CHECK_LIB(Xm, Xm, [Motif library], 
-                XmCreateForm, Xm/XmAll.h,
-                $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
-  AC_SUBST(Xm_LIBS)
-  AC_SUBST(Xm_CFLAGS)
-  smr_CHECK_LIB(Sgm, Sgm, [SGI Motif library],
-                SgCreateHorzPanedWindow, Sgm/HPanedW.h,
-                $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
-  AC_SUBST(Sgm_LIBS)
-  AC_SUBST(Sgm_CFLAGS)
-
-  dnl # check for XtAppSetExitFlag, which didn't exist prior to X11R6 (?)
-  if test "x$smr_have_Xt_library" = xyes; then
-    AC_CHECK_LIB(Xt, XtAppSetExitFlag,
-		 AC_DEFINE(HAVE_XTAPPSETEXITFLAG), ,
-                 [$Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11])
-  fi
-fi
-
-dnl ##### Check for FreeType 2.x.
-dnl ##### (Note: FT_Get_Name_Index was added in FT 2.0.5, and is
-dnl ##### the reason that Xpdf requires 2.0.5+.)
-smr_CHECK_LIB(freetype2, freetype, [FreeType2 font rasterizer - version 2.0.5+],
-              FT_Get_Name_Index, ft2build.h, -lm)
-AC_SUBST(freetype2_LIBS)
-AC_SUBST(freetype2_CFLAGS)
-if test "x$smr_have_freetype2_library" = xyes; then
-  AC_DEFINE(HAVE_FREETYPE_FREETYPE_H)
-  AC_DEFINE(HAVE_SPLASH)
-fi
-
-dnl ##### Check for libpng.
-smr_CHECK_LIB(libpng, png, [PNG library], png_write_row, png.h, -lz)
-AC_SUBST(libpng_LIBS)
-AC_SUBST(libpng_CFLAGS)
-
-dnl ##### Check for libpaper (Debian).
-smr_CHECK_LIB(libpaper, paper, [Debian libpaper], paperinit, paper.h)
-AC_SUBST(libpaper_LIBS)
-AC_SUBST(libpaper_CFLAGS)
-
-dnl ##### Disable X-specific stuff in top-level Makefile.
-if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
-  X="#"
-  XPDF_TARGET="all-no-x"
-else
-  X=""
-  XPDF_TARGET="all"
-fi
-AC_SUBST(X)
-AC_SUBST(XPDF_TARGET)
-
-dnl ##### Extra libraries.
-EXTRA_LIBS=
-EXTRA_CFLAGS=
-AC_SUBST(EXTRA_LIBS)
-AC_SUBST(EXTRA_CFLAGS)
-
-dnl ##### Write the makefiles.
-AC_OUTPUT(Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile)
-
-dnl ##### Warn user if X is missing.
-if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
-  if test -n "$no_x"; then
-    AC_MSG_WARN([Couldn't find X]);
-  fi
-  if test "x$smr_have_Xm_library" != xyes; then
-    AC_MSG_WARN([Couldn't find Motif]);
-  fi
-  if test "x$smr_have_freetype2_library" != xyes; then
-    AC_MSG_WARN([Couldn't find FreeType]);
-  fi
-  AC_MSG_WARN([-- You will be able to compile pdftops, pdftotext,
-        pdfinfo, pdffonts, pdfdetach, and pdfimages, but not xpdf
-        or pdftoppm])
-fi
-
-dnl ##### Warn user if libpng is missing.
-if test "x$smr_have_libpng_library" != xyes; then
-  AC_MSG_WARN([Couldn't find libpng -- you will not be able to build pdftohtml or pdftopng])
-fi

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/dj_make.bat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/dj_make.bat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/dj_make.bat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,91 +0,0 @@
-set CC=gcc
-set CFLAGS=-g -O2 -I.. -I..\splash -I..\fofi -I..\goo
-set CXX=gpp
-set CXXFLAGS=%CFLAGS%
-set LIBPROG=ar
-
-copy aconf-dj.h aconf.h
-
-cd goo
-%CXX% %CXXFLAGS% -c GHash.cc
-%CXX% %CXXFLAGS% -c GList.cc
-%CXX% %CXXFLAGS% -c GString.cc
-%CXX% %CXXFLAGS% -c gmem.cc
-%CXX% %CXXFLAGS% -c gmempp.cc
-%CXX% %CXXFLAGS% -c gfile.cc
-%CC% %CFLAGS% -c parseargs.c
-del libGoo.a
-%LIBPROG% -rc libGoo.a GHash.o GList.o GString.o gmempp.o gfile.o gmem.o parseargs.o
-
-cd ..\fofi
-%CXX% %CXXFLAGS% -c FoFiBase.cc
-%CXX% %CXXFLAGS% -c FoFiEncodings.cc
-%CXX% %CXXFLAGS% -c FoFiIdentifier.cc
-%CXX% %CXXFLAGS% -c FoFiTrueType.cc
-%CXX% %CXXFLAGS% -c FoFiType1.cc
-%CXX% %CXXFLAGS% -c FoFiType1C.cc
-%LIBPROG% -rc libfofi.a FoFiBase.o FoFiEncodings.o FoFiIdentifier.o FoFiTrueType.o FoFiType1.o FoFiType1C.o
-
-cd ..\xpdf
-del *.o
-%CXX% %CXXFLAGS% -c AcroForm.cc
-%CXX% %CXXFLAGS% -c Annot.cc
-%CXX% %CXXFLAGS% -c Array.cc
-%CXX% %CXXFLAGS% -c BuiltinFont.cc
-%CXX% %CXXFLAGS% -c BuiltinFontTables.cc
-%CXX% %CXXFLAGS% -c CMap.cc
-%CXX% %CXXFLAGS% -c Catalog.cc
-%CXX% %CXXFLAGS% -c CharCodeToUnicode.cc
-%CXX% %CXXFLAGS% -c Decrypt.cc
-%CXX% %CXXFLAGS% -c Dict.cc
-%CXX% %CXXFLAGS% -c Error.cc
-%CXX% %CXXFLAGS% -c FontEncodingTables.cc
-%CXX% %CXXFLAGS% -c Form.cc
-%CXX% %CXXFLAGS% -c Function.cc
-%CXX% %CXXFLAGS% -c Gfx.cc
-%CXX% %CXXFLAGS% -c GfxFont.cc
-%CXX% %CXXFLAGS% -c GfxState.cc
-%CXX% %CXXFLAGS% -c GlobalParams.cc
-%CXX% %CXXFLAGS% -c ImageOutputDev.cc
-%CXX% %CXXFLAGS% -c JArithmeticDecoder.cc
-%CXX% %CXXFLAGS% -c JBIG2Stream.cc
-%CXX% %CXXFLAGS% -c JPXStream.cc
-%CXX% %CXXFLAGS% -c Lexer.cc
-%CXX% %CXXFLAGS% -c Link.cc
-%CXX% %CXXFLAGS% -c NameToCharCode.cc
-%CXX% %CXXFLAGS% -c Object.cc
-%CXX% %CXXFLAGS% -c OptionalContent.cc
-%CXX% %CXXFLAGS% -c Outline.cc
-%CXX% %CXXFLAGS% -c OutputDev.cc
-%CXX% %CXXFLAGS% -c PDFDoc.cc
-%CXX% %CXXFLAGS% -c PDFDocEncoding.cc
-%CXX% %CXXFLAGS% -c PSOutputDev.cc
-%CXX% %CXXFLAGS% -c PSTokenizer.cc
-%CXX% %CXXFLAGS% -c Page.cc
-%CXX% %CXXFLAGS% -c Parser.cc
-%CXX% %CXXFLAGS% -c PreScanOutputDev.cc
-%CXX% %CXXFLAGS% -c SecurityHandler.cc
-%CXX% %CXXFLAGS% -c Stream.cc
-%CXX% %CXXFLAGS% -c TextOutputDev.cc
-%CXX% %CXXFLAGS% -c TextString.cc
-%CXX% %CXXFLAGS% -c UnicodeMap.cc
-%CXX% %CXXFLAGS% -c UnicodeTypeTable.cc
-%CXX% %CXXFLAGS% -c XFAForm.cc
-%CXX% %CXXFLAGS% -c XRef.cc
-%CXX% %CXXFLAGS% -c Zoox.cc
-del libxpdf.a
-%LIBPROG% -rc libxpdf.a *.o
-
-%CXX% %CXXFLAGS% -o pdftops.exe pdftops.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-%CXX% %CXXFLAGS% -o pdftotext.exe pdftotext.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-%CXX% %CXXFLAGS% -o pdfinfo.exe pdfinfo.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-%CXX% %CXXFLAGS% -o pdffonts.exe pdffonts.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-%CXX% %CXXFLAGS% -o pdfdetach.exe pdfdetach.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-%CXX% %CXXFLAGS% -o pdfimages.exe pdfimages.cc libxpdf.a ..\fofi\libfofi.a ..\goo\libGoo.a
-
-cd ..

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 2013-2014 Glyph & Cog, LLC
-.TH pdfdetach 1 "28 May 2014"
+.\" Copyright 2013-2017 Glyph & Cog, LLC
+.TH pdfdetach 1 "10 Aug 2017"
 .SH NAME
 pdfdetach \- Portable Document Format (PDF) document embedded file
-extractor (version 3.04)
+extractor (version 4.00)
 .SH SYNOPSIS
 .B pdfdetach
 [options]
@@ -90,7 +90,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdfinfo software and documentation are copyright 1996-2014 Glyph &
+The pdfinfo software and documentation are copyright 1996-2017 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -104,4 +104,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfdetach.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdfdetach(1)                                                      pdfdetach(1)
+pdfdetach(1)                General Commands Manual               pdfdetach(1)
 
 
 
 NAME
        pdfdetach  -  Portable  Document  Format  (PDF)  document embedded file
-       extractor (version 3.04)
+       extractor (version 4.00)
 
 SYNOPSIS
        pdfdetach [options] [PDF-file]
@@ -79,14 +79,14 @@
        99     Other error.
 
 AUTHOR
-       The pdfinfo software and documentation are copyright 1996-2014 Glyph  &
+       The pdfinfo software and documentation are copyright 1996-2017 Glyph  &
        Cog, LLC.
 
 SEE ALSO
        xpdf(1),   pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),  pdf-
        fonts(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                     pdfdetach(1)
+                                  10 Aug 2017                     pdfdetach(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1999-2014 Glyph & Cog, LLC
-.TH pdffonts 1 "28 May 2014"
+.\" Copyright 1999-2017 Glyph & Cog, LLC
+.TH pdffonts 1 "10 Aug 2017"
 .SH NAME
 pdffonts \- Portable Document Format (PDF) font analyzer (version
-3.04)
+4.00)
 .SH SYNOPSIS
 .B pdffonts
 [options]
@@ -32,6 +32,10 @@
 absence of a ToUnicode map doesn't necessarily mean that the text
 can't be converted to Unicode)
 .TP
+.B prob
+"X" if this font is likely to be problematic when converting text to
+Unicode
+.TP
 .B object ID
 the font dictionary object ID (number and generation)
 .TP
@@ -143,7 +147,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdffonts software and documentation are copyright 1996-2014 Glyph
+The pdffonts software and documentation are copyright 1996-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -157,4 +161,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdffonts.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,9 +1,9 @@
-pdffonts(1)                                                        pdffonts(1)
+pdffonts(1)                 General Commands Manual                pdffonts(1)
 
 
 
 NAME
-       pdffonts - Portable Document Format (PDF) font analyzer (version 3.04)
+       pdffonts - Portable Document Format (PDF) font analyzer (version 4.00)
 
 SYNOPSIS
        pdffonts [options] [PDF-file]
@@ -27,6 +27,9 @@
               (the absence of a ToUnicode map doesn't  necessarily  mean  that
               the text can't be converted to Unicode)
 
+       prob   "X"  if  this  font  is likely to be problematic when converting
+              text to Unicode
+
        object ID
               the font dictionary object ID (number and generation)
 
@@ -49,13 +52,13 @@
 
 CONFIGURATION FILE
        Pdffonts reads a configuration file at startup.  It first tries to find
-       the user's private config file, ~/.xpdfrc.  If that doesn't  exist,  it
-       looks  for  a  system-wide config file, typically /usr/local/etc/xpdfrc
-       (but this location can be changed when pdffonts  is  built).   See  the
+       the  user's  private config file, ~/.xpdfrc.  If that doesn't exist, it
+       looks for a system-wide config  file,  typically  /usr/local/etc/xpdfrc
+       (but  this  location  can  be changed when pdffonts is built).  See the
        xpdfrc(5) man page for details.
 
 OPTIONS
-       Many  of  the following options can be set with configuration file com-
+       Many of the following options can be set with configuration  file  com-
        mands.  These are listed in square brackets with the description of the
        corresponding command line option.
 
@@ -62,12 +65,12 @@
        -f number
               Specifies the first page to analyze.
 
-       -loc   Shows  additional  information  on the location of the font that
-              will be used  when  the  PDF  file  is  rasterized  (with  xpdf,
+       -loc   Shows additional information on the location of  the  font  that
+              will  be  used  when  the  PDF  file  is  rasterized (with xpdf,
               pdftoppm, etc.).
 
-       -locPS Shows  additional  information  on the location of the font that
-              will be used when the PDF file is converted to PostScript  (with
+       -locPS Shows additional information on the location of  the  font  that
+              will  be used when the PDF file is converted to PostScript (with
               pdftops).
 
        -l number
@@ -74,7 +77,7 @@
               Specifies the last page to analyze.
 
        -opw password
-              Specify  the  owner  password  for the PDF file.  Providing this
+              Specify the owner password for the  PDF  file.   Providing  this
               will bypass all security restrictions.
 
        -upw password
@@ -102,14 +105,14 @@
        99     Other error.
 
 AUTHOR
-       The pdffonts software and documentation are copyright 1996-2014 Glyph &
+       The pdffonts software and documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
-       xpdf(1), pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),  pdfde-
+       xpdf(1),  pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1), pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                      pdffonts(1)
+                                  10 Aug 2017                      pdffonts(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1998-2014 Glyph & Cog, LLC
-.TH pdfimages 1 "28 May 2014"
+.\" Copyright 1998-2017 Glyph & Cog, LLC
+.TH pdfimages 1 "10 Aug 2017"
 .SH NAME
 pdfimages \- Portable Document Format (PDF) image extractor
-(version 3.04)
+(version 4.00)
 .SH SYNOPSIS
 .B pdfimages
 [options]
@@ -10,17 +10,18 @@
 .SH DESCRIPTION
 .B Pdfimages
 saves images from a Portable Document Format (PDF) file as Portable
-Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
+Pixmap (PPM), Portable Graymap (PGM), Portable Bitmap (PBM), or JPEG
+files.
 .PP
 Pdfimages reads the PDF file, scans one or more pages,
 .IR PDF-file ,
-and writes one PPM, PBM, or JPEG file for each image,
+and writes one PPM, PGM, PBM, or JPEG file for each image,
 .IR image-root - nnnn . xxx ,
 where
 .I nnnn
 is the image number and
 .I xxx
-is the image type (.ppm, .pbm, .jpg).
+is the image type (.ppm, .pgm, .pbm, .jpg).
 .PP
 NB: pdfimages extracts the raw image data from the PDF file, without
 performing any additional transforms.  Any rotation, clipping,
@@ -45,11 +46,24 @@
 Specifies the last page to scan.
 .TP
 .B \-j
-Normally, all images are written as PBM (for monochrome images) or PPM
-(for non-monochrome images) files.  With this option, images in DCT
-format are saved as JPEG files.  All non-DCT images are saved in
-PBM/PPM format as usual.
+Normally, all images are written as PBM (for monochrome images), PGM
+(for grayscale images), or PPM (for color images) files.  With this
+option, images in DCT format are saved as JPEG files.  All non-DCT
+images are saved in PBM/PGM/PPM format as usual.  (Inline images are
+always saved in PBM/PGM/PPM format.)
 .TP
+.B \-raw
+Write all images in PDF-native formats.  Most of the formats are not
+standard image formats, so this option is primarily useful as input to
+a tool that generates PDF files.  (Inline images are always saved in
+PBM/PGM/PPM format.)
+.TP
+.B \-list
+Write a one-line summary to stdout for each image.  The summary
+provides the image file name, the page number, the image width and
+height, the horizontal and vertical resolution (DPI) as drawn, the
+color space type, and the number of bits per component (BPC).
+.TP
 .BI \-opw " password"
 Specify the owner password for the PDF file.  Providing this will
 bypass all security restrictions.
@@ -88,7 +102,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdfimages software and documentation are copyright 1998-2014 Glyph
+The pdfimages software and documentation are copyright 1998-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -102,4 +116,4 @@
 .BR pdftopng (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfimages.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdfimages(1)                                                      pdfimages(1)
+pdfimages(1)                General Commands Manual               pdfimages(1)
 
 
 
 NAME
        pdfimages  -  Portable  Document  Format (PDF) image extractor (version
-       3.04)
+       4.00)
 
 SYNOPSIS
        pdfimages [options] PDF-file image-root
@@ -11,26 +11,27 @@
 
 DESCRIPTION
        Pdfimages saves images from a Portable Document Format  (PDF)  file  as
-       Portable Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
+       Portable  Pixmap  (PPM), Portable Graymap (PGM), Portable Bitmap (PBM),
+       or JPEG files.
 
-       Pdfimages  reads  the  PDF file, scans one or more pages, PDF-file, and
-       writes one PPM, PBM, or JPEG file for each image,  image-root-nnnn.xxx,
-       where  nnnn  is the image number and xxx is the image type (.ppm, .pbm,
-       .jpg).
+       Pdfimages reads the PDF file, scans one or more  pages,  PDF-file,  and
+       writes  one  PPM,  PGM,  PBM,  or JPEG file for each image, image-root-
+       nnnn.xxx, where nnnn is the image number and  xxx  is  the  image  type
+       (.ppm, .pgm, .pbm, .jpg).
 
-       NB: pdfimages extracts the raw image data from the  PDF  file,  without
-       performing  any  additional  transforms.  Any rotation, clipping, color
+       NB:  pdfimages  extracts  the raw image data from the PDF file, without
+       performing any additional transforms.  Any  rotation,  clipping,  color
        inversion, etc. done by the PDF content stream is ignored.
 
 CONFIGURATION FILE
-       Pdfimages reads a configuration file at startup.   It  first  tries  to
+       Pdfimages  reads  a  configuration  file at startup.  It first tries to
        find the user's private config file, ~/.xpdfrc.  If that doesn't exist,
        it looks for a system-wide config file, typically /usr/local/etc/xpdfrc
-       (but  this  location  can be changed when pdfimages is built).  See the
+       (but this location can be changed when pdfimages is  built).   See  the
        xpdfrc(5) man page for details.
 
 OPTIONS
-       Many of the following options can be set with configuration  file  com-
+       Many  of  the following options can be set with configuration file com-
        mands.  These are listed in square brackets with the description of the
        corresponding command line option.
 
@@ -40,13 +41,25 @@
        -l number
               Specifies the last page to scan.
 
-       -j     Normally, all images are written as PBM (for monochrome  images)
-              or  PPM  (for  non-monochrome  images) files.  With this option,
-              images in DCT format are  saved  as  JPEG  files.   All  non-DCT
-              images are saved in PBM/PPM format as usual.
+       -j     Normally, all images are written as PBM (for monochrome images),
+              PGM (for grayscale images), or PPM  (for  color  images)  files.
+              With  this option, images in DCT format are saved as JPEG files.
+              All non-DCT images are saved in  PBM/PGM/PPM  format  as  usual.
+              (Inline images are always saved in PBM/PGM/PPM format.)
 
+       -raw   Write all images in PDF-native formats.  Most of the formats are
+              not standard image formats, so this option is  primarily  useful
+              as input to a tool that generates PDF files.  (Inline images are
+              always saved in PBM/PGM/PPM format.)
+
+       -list  Write a one-line summary to stdout for each image.  The  summary
+              provides  the  image file name, the page number, the image width
+              and height, the horizontal  and  vertical  resolution  (DPI)  as
+              drawn,  the  color space type, and the number of bits per compo-
+              nent (BPC).
+
        -opw password
-              Specify  the  owner  password  for the PDF file.  Providing this
+              Specify the owner password for the  PDF  file.   Providing  this
               will bypass all security restrictions.
 
        -upw password
@@ -72,14 +85,14 @@
        99     Other error.
 
 AUTHOR
-       The pdfimages software and documentation are copyright 1998-2014  Glyph
+       The  pdfimages software and documentation are copyright 1998-2017 Glyph
        & Cog, LLC.
 
 SEE ALSO
-       xpdf(1),   pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),  pdf-
+       xpdf(1),  pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),   pdf-
        fonts(1), pdfdetach(1), pdftoppm(1), pdftopng(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                     pdfimages(1)
+                                  10 Aug 2017                     pdfimages(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1999-2014 Glyph & Cog, LLC
-.TH pdfinfo 1 "28 May 2014"
+.\" Copyright 1999-2017 Glyph & Cog, LLC
+.TH pdfinfo 1 "10 Aug 2017"
 .SH NAME
 pdfinfo \- Portable Document Format (PDF) document information
-extractor (version 3.04)
+extractor (version 4.00)
 .SH SYNOPSIS
 .B pdfinfo
 [options]
@@ -45,7 +45,7 @@
 tagged (yes/no)
 .RE
 .RS
-form (AcroForm / XFA / none)
+form (AcroForm / static XFA / dynamic XFA / none)
 .RE
 .RS
 page count
@@ -150,7 +150,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdfinfo software and documentation are copyright 1996-2014 Glyph &
+The pdfinfo software and documentation are copyright 1996-2017 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -164,4 +164,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdfinfo.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdfinfo(1)                                                          pdfinfo(1)
+pdfinfo(1)                  General Commands Manual                 pdfinfo(1)
 
 
 
 NAME
        pdfinfo - Portable Document Format (PDF) document information extractor
-       (version 3.04)
+       (version 4.00)
 
 SYNOPSIS
        pdfinfo [options] [PDF-file]
@@ -27,7 +27,7 @@
        In addition, the following information is printed:
 
               tagged (yes/no)
-              form (AcroForm / XFA / none)
+              form (AcroForm / static XFA / dynamic XFA / none)
               page count
               encrypted flag (yes/no)
               print and copy permissions (if encrypted)
@@ -104,14 +104,14 @@
        99     Other error.
 
 AUTHOR
-       The  pdfinfo software and documentation are copyright 1996-2014 Glyph &
+       The  pdfinfo software and documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
        xpdf(1), pdftops(1), pdftotext(1),  pdftohtml(1),  pdffonts(1),  pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                       pdfinfo(1)
+                                  10 Aug 2017                       pdfinfo(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1997-2014 Glyph & Cog, LLC
-.TH pdftohtml 1 "28 May 2014"
+.\" Copyright 1997-2017 Glyph & Cog, LLC
+.TH pdftohtml 1 "10 Aug 2017"
 .SH NAME
 pdftohtml \- Portable Document Format (PDF) to HTML converter
-(version 3.04)
+(version 4.00)
 .SH SYNOPSIS
 .B pdftohtml
 [options]
@@ -38,10 +38,30 @@
 .BI \-l " number"
 Specifies the last page to convert.
 .TP
-.B \-r
-Specifies the resolution, in DPI, for background images.  The default
-is 150 DPI.
+.BI \-z " number"
+Specifies the initial zoom level.  The default is 1.0, which means
+72dpi, i.e., 1 point in the PDF file will be 1 pixel in the HTML.
+Using \'-z 1.5', for example, will make the initial view 50% larger.
 .TP
+.BI \-r " number"
+Specifies the resolution, in DPI, for background images.  This
+controls the pixel size of the background image files.  The initial
+zoom level is controlled by the \'-z' option.  Specifying a larger
+\'-r' value will allow the viewer to zoom in farther without upscaling
+artifacts in the background.
+.TP
+.B \-skipinvisible
+Don't draw invisible text.  By default, invisible text (commonly used
+in OCR'ed PDF files) is drawn as transparent (alpha=0) HTML text.
+This option tells pdftohtml to discard invisible text entirely.
+.TP
+.B \-allinvisible
+Treat all text as invisible.  By default, regular (non-invisible) text
+is not drawn in the background image, and is instead drawn with HTML
+on top of the image.  This option tells pdftohtml to include the
+regular text in the background image, and then draw it as transparent
+(alpha=0) HTML text.
+.TP
 .BI \-opw " password"
 Specify the owner password for the PDF file.  Providing this will
 bypass all security restrictions.
@@ -89,7 +109,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdftohtml software and documentation are copyright 1996-2014 Glyph
+The pdftohtml software and documentation are copyright 1996-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -103,4 +123,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftohtml.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdftohtml(1)                                                      pdftohtml(1)
+pdftohtml(1)                General Commands Manual               pdftohtml(1)
 
 
 
 NAME
        pdftohtml  -  Portable Document Format (PDF) to HTML converter (version
-       3.04)
+       4.00)
 
 SYNOPSIS
        pdftohtml [options] PDF-file HTML-dir
@@ -35,11 +35,34 @@
        -l number
               Specifies the last page to convert.
 
-       -r     Specifies  the  resolution,  in DPI, for background images.  The
-              default is 150 DPI.
+       -z number
+              Specifies  the  initial  zoom  level.  The default is 1.0, which
+              means 72dpi, i.e., 1 point in the PDF file will be  1  pixel  in
+              the  HTML.   Using  '-z 1.5', for example, will make the initial
+              view 50% larger.
 
+       -r number
+              Specifies the resolution, in DPI, for background  images.   This
+              controls the pixel size of the background image files.  The ini-
+              tial zoom level is controlled by the '-z' option.  Specifying  a
+              larger '-r' value will allow the viewer to zoom in farther with-
+              out upscaling artifacts in the background.
+
+       -skipinvisible
+              Don't draw invisible text.  By default, invisible text (commonly
+              used in OCR'ed PDF files) is drawn as transparent (alpha=0) HTML
+              text.  This option tells pdftohtml  to  discard  invisible  text
+              entirely.
+
+       -allinvisible
+              Treat  all  text as invisible.  By default, regular (non-invisi-
+              ble) text is not drawn in the background image, and  is  instead
+              drawn  with  HTML on top of the image.  This option tells pdfto-
+              html to include the regular text in the  background  image,  and
+              then draw it as transparent (alpha=0) HTML text.
+
        -opw password
-              Specify the owner password for the  PDF  file.   Providing  this
+              Specify  the  owner  password  for the PDF file.  Providing this
               will bypass all security restrictions.
 
        -upw password
@@ -56,7 +79,7 @@
        -h     Print usage information.  (-help and --help are equivalent.)
 
 BUGS
-       Some PDF files contain fonts whose encodings have been  mangled  beyond
+       Some  PDF  files contain fonts whose encodings have been mangled beyond
        recognition.  There is no way (short of OCR) to extract text from these
        files.
 
@@ -74,14 +97,14 @@
        99     Other error.
 
 AUTHOR
-       The pdftohtml software and documentation are copyright 1996-2014  Glyph
+       The  pdftohtml software and documentation are copyright 1996-2017 Glyph
        & Cog, LLC.
 
 SEE ALSO
        xpdf(1),  pdftops(1),  pdftotext(1),  pdfinfo(1),  pdffonts(1),  pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                     pdftohtml(1)
+                                  10 Aug 2017                     pdftohtml(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 2014 Glyph & Cog, LLC
-.TH pdftopng 1 "28 May 2014"
+.\" Copyright 2017 Glyph & Cog, LLC
+.TH pdftopng 1 "10 Aug 2017"
 .SH NAME
 pdftopng \- Portable Document Format (PDF) to Portable Network Graphics
-(PNG) converter (version 3.04)
+(PNG) converter (version 4.00)
 .SH SYNOPSIS
 .B pdftopng
 [options]
@@ -51,6 +51,11 @@
 .B \-gray
 Generate a grayscale image (instead of a color image).
 .TP
+.B \-alpha
+Generate an alpha channel in the PNG file.  This is only useful with
+PDF files that have been constructed with a transparent background.
+The \-alpha flag cannot be used with \-mono.
+.TP
 .BI \-freetype " yes | no"
 Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
 This defaults to "yes".
@@ -102,7 +107,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdftopng software and documentation are copyright 1996-2014 Glyph
+The pdftopng software and documentation are copyright 1996-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -116,4 +121,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftopng.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdftopng(1)                                                        pdftopng(1)
+pdftopng(1)                 General Commands Manual                pdftopng(1)
 
 
 
 NAME
        pdftopng  - Portable Document Format (PDF) to Portable Network Graphics
-       (PNG) converter (version 3.04)
+       (PNG) converter (version 4.00)
 
 SYNOPSIS
        pdftopng [options] PDF-file PNG-root
@@ -44,6 +44,10 @@
 
        -gray  Generate a grayscale image (instead of a color image).
 
+       -alpha Generate  an alpha channel in the PNG file.  This is only useful
+              with PDF files that have been  constructed  with  a  transparent
+              background.  The -alpha flag cannot be used with -mono.
+
        -freetype yes | no
               Enable  or  disable  FreeType  (a TrueType / Type 1 font raster-
               izer).  This defaults to "yes".  [config file: enableFreeType]
@@ -83,14 +87,14 @@
        99     Other error.
 
 AUTHOR
-       The pdftopng software and documentation are copyright 1996-2014 Glyph &
+       The pdftopng software and documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
        xpdf(1),  pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),   pdf-
        fonts(1), pdfdetach(1), pdftoppm(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                      pdftopng(1)
+                                  10 Aug 2017                      pdftopng(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 2005-2014 Glyph & Cog, LLC
-.TH pdftoppm 1 "28 May 2014"
+.\" Copyright 2005-2017 Glyph & Cog, LLC
+.TH pdftoppm 1 "10 Aug 2017"
 .SH NAME
 pdftoppm \- Portable Document Format (PDF) to Portable Pixmap (PPM)
-converter (version 3.04)
+converter (version 4.00)
 .SH SYNOPSIS
 .B pdftoppm
 [options]
@@ -48,11 +48,14 @@
 Specifies the resolution, in DPI.  The default is 150 DPI.
 .TP
 .B \-mono
-Generate a monochrome PBM file (instead of a color PPM file).
+Generate a monochrome PBM file (instead of an RGB PPM file).
 .TP
 .B \-gray
-Generate a grayscale PGM file (instead of a color PPM file).
+Generate a grayscale PGM file (instead of an RGB PPM file).
 .TP
+.B \-cmyk
+Generate a CMYK PAM file (instead of an RGB PPM file).
+.TP
 .BI \-freetype " yes | no"
 Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
 This defaults to "yes".
@@ -104,7 +107,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdftoppm software and documentation are copyright 1996-2014 Glyph
+The pdftoppm software and documentation are copyright 1996-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -118,4 +121,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftoppm.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdftoppm(1)                                                        pdftoppm(1)
+pdftoppm(1)                 General Commands Manual                pdftoppm(1)
 
 
 
 NAME
        pdftoppm - Portable Document Format (PDF) to Portable Pixmap (PPM) con-
-       verter (version 3.04)
+       verter (version 4.00)
 
 SYNOPSIS
        pdftoppm [options] PDF-file PPM-root
@@ -41,10 +41,12 @@
        -r number
               Specifies the resolution, in DPI.  The default is 150 DPI.
 
-       -mono  Generate a monochrome PBM file (instead of a color PPM file).
+       -mono  Generate a monochrome PBM file (instead of an RGB PPM file).
 
-       -gray  Generate a grayscale PGM file (instead of a color PPM file).
+       -gray  Generate a grayscale PGM file (instead of an RGB PPM file).
 
+       -cmyk  Generate a CMYK PAM file (instead of an RGB PPM file).
+
        -freetype yes | no
               Enable or disable FreeType (a TrueType /  Type  1  font  raster-
               izer).  This defaults to "yes".  [config file: enableFreeType]
@@ -84,14 +86,14 @@
        99     Other error.
 
 AUTHOR
-       The pdftoppm software and documentation are copyright 1996-2014 Glyph &
+       The pdftoppm software and documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
        xpdf(1),   pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),  pdf-
        fonts(1), pdfdetach(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                      pdftoppm(1)
+                                  10 Aug 2017                      pdftoppm(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1996-2014 Glyph & Cog, LLC
-.TH pdftops 1 "28 May 2014"
+.\" Copyright 1996-2017 Glyph & Cog, LLC
+.TH pdftops 1 "10 Aug 2017"
 .SH NAME
 pdftops \- Portable Document Format (PDF) to PostScript converter
-(version 3.04)
+(version 4.00)
 .SH SYNOPSIS
 .B pdftops
 [options]
@@ -65,6 +65,11 @@
 compression.  This is the default setting.
 .RB "[config file: " psLevel ]
 .TP
+.B \-level2gray
+Generate grayscale Level 2 PostScript.  All colors, including images,
+are converted to grayscale.
+.RB "[config file: " psLevel ]
+.TP
 .B \-level2sep
 Generate Level 2 separable PostScript.  All colors are converted to
 CMYK.  The PostScript separation convention operators are used to
@@ -76,6 +81,11 @@
 CID font embedding and masked image generation.
 .RB "[config file: " psLevel ]
 .TP
+.B \-level3gray
+Generate grayscale Level 3 PostScript.  All colors, including images,
+are converted to grayscale.
+.RB "[config file: " psLevel ]
+.TP
 .B \-level3Sep
 Generate Level 3 separable PostScript.  The separation handling is the
 same as for \-level2Sep.
@@ -174,6 +184,10 @@
 used as the page size.
 .RB "[config file: " psUseCropBoxAsPage ]
 .TP
+.B \-userunit
+Honor the UserUnit settings on PDF pages when computing page/paper
+size.  By default, pdftops ignores UserUnit.
+.TP
 .B \-duplex
 Set the Duplex pagedevice entry in the PostScript file.  This tells
 duplex-capable printers to enable duplexing.
@@ -222,7 +236,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdftops software and documentation are copyright 1996-2014 Glyph &
+The pdftops software and documentation are copyright 1996-2017 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -236,4 +250,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftops.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdftops(1)                                                          pdftops(1)
+pdftops(1)                  General Commands Manual                 pdftops(1)
 
 
 
 NAME
        pdftops  - Portable Document Format (PDF) to PostScript converter (ver-
-       sion 3.04)
+       sion 4.00)
 
 SYNOPSIS
        pdftops [options] [PDF-file [PS-file]]
@@ -54,16 +54,24 @@
               image compression.  This is the default setting.  [config  file:
               psLevel]
 
+       -level2gray
+              Generate  grayscale  Level  2 PostScript.  All colors, including
+              images, are converted to grayscale.  [config file: psLevel]
+
        -level2sep
               Generate Level 2 separable PostScript.  All colors are converted
-              to CMYK.  The PostScript  separation  convention  operators  are
+              to  CMYK.   The  PostScript  separation convention operators are
               used to handle custom (spot) colors.  [config file: psLevel]
 
        -level3
-              Generate  Level 3 PostScript.  This enables all Level 2 features
-              plus CID font embedding and masked  image  generation.   [config
+              Generate Level 3 PostScript.  This enables all Level 2  features
+              plus  CID  font  embedding and masked image generation.  [config
               file: psLevel]
 
+       -level3gray
+              Generate grayscale Level 3 PostScript.   All  colors,  including
+              images, are converted to grayscale.  [config file: psLevel]
+
        -level3Sep
               Generate  Level 3 separable PostScript.  The separation handling
               is the same as for -level2Sep.  [config file: psLevel]
@@ -153,13 +161,17 @@
               Treat  the CropBox as the PDF page size.  By default, the Media-
               Box is used as the page size.  [config file: psUseCropBoxAsPage]
 
+       -userunit
+              Honor  the  UserUnit  settings  on  PDF  pages  when   computing
+              page/paper size.  By default, pdftops ignores UserUnit.
+
        -duplex
-              Set the Duplex pagedevice entry in the  PostScript  file.   This
-              tells  duplex-capable  printers  to  enable  duplexing.  [config
+              Set  the  Duplex  pagedevice entry in the PostScript file.  This
+              tells duplex-capable  printers  to  enable  duplexing.   [config
               file: psDuplex]
 
        -opw password
-              Specify the owner password for the  PDF  file.   Providing  this
+              Specify  the  owner  password  for the PDF file.  Providing this
               will bypass all security restrictions.
 
        -upw password
@@ -189,14 +201,14 @@
        99     Other error.
 
 AUTHOR
-       The pdftops software and documentation are copyright 1996-2014 Glyph  &
+       The  pdftops software and documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
-       xpdf(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1), pdffonts(1), pdfde-
+       xpdf(1), pdftotext(1), pdftohtml(1),  pdfinfo(1),  pdffonts(1),  pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                       pdftops(1)
+                                  10 Aug 2017                       pdftops(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,8 +1,8 @@
-.\" Copyright 1997-2014 Glyph & Cog, LLC
-.TH pdftotext 1 "28 May 2014"
+.\" Copyright 1997-2017 Glyph & Cog, LLC
+.TH pdftotext 1 "10 Aug 2017"
 .SH NAME
 pdftotext \- Portable Document Format (PDF) to text converter
-(version 3.04)
+(version 4.00)
 .SH SYNOPSIS
 .B pdftotext
 [options]
@@ -52,6 +52,13 @@
 option is given, character spacing within each line will be determined
 by the specified character pitch.
 .TP
+.B \-simple
+Similar to
+.BR \-layout ,
+but optimized for simple one-column pages.  This mode will do a better
+job of maintaining horizontal spacing, but it will only work properly
+with a single column of text.
+.TP
 .B \-table
 Table mode is similar to physical layout mode, but optimized for
 tabular data, with the goal of keeping rows and columns aligned (at
@@ -92,6 +99,11 @@
 layout, and then added back in.  This can be helpful for tables where
 clipped (invisible) text would overlap the next column.
 .TP
+.B \-nodiag
+Diagonal text, i.e., text that is not close to one of the 0, 90, 180,
+or 270 degree axes, is discarded.  This is useful to skip watermarks
+drawn on top of body text, etc.
+.TP
 .BI \-enc " encoding-name"
 Sets the encoding to use for text output.  The
 .I encoding\-name
@@ -109,6 +121,10 @@
 Don't insert page breaks (form feed characters) between pages.
 .RB "[config file: " textPageBreaks ]
 .TP
+.B \-bom
+Insert a Unicode byte order marker (BOM) at the start of the text
+output.
+.TP
 .BI \-opw " password"
 Specify the owner password for the PDF file.  Providing this will
 bypass all security restrictions.
@@ -156,7 +172,7 @@
 99
 Other error.
 .SH AUTHOR
-The pdftotext software and documentation are copyright 1996-2014 Glyph
+The pdftotext software and documentation are copyright 1996-2017 Glyph
 & Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -170,4 +186,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/pdftotext.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,10 +1,10 @@
-pdftotext(1)                                                      pdftotext(1)
+pdftotext(1)                General Commands Manual               pdftotext(1)
 
 
 
 NAME
        pdftotext  -  Portable Document Format (PDF) to text converter (version
-       3.04)
+       4.00)
 
 SYNOPSIS
        pdftotext [options] [PDF-file [text-file]]
@@ -41,21 +41,27 @@
               -fixed  option is given, character spacing within each line will
               be determined by the specified character pitch.
 
+       -simple
+              Similar to -layout, but optimized for simple  one-column  pages.
+              This  mode  will do a better job of maintaining horizontal spac-
+              ing, but it will only work properly  with  a  single  column  of
+              text.
+
        -table Table mode is similar to physical layout mode, but optimized for
-              tabular  data, with the goal of keeping rows and columns aligned
-              (at the expense of inserting extra whitespace).  If  the  -fixed
-              option  is  given,  character  spacing  within each line will be
+              tabular data, with the goal of keeping rows and columns  aligned
+              (at  the  expense of inserting extra whitespace).  If the -fixed
+              option is given, character spacing  within  each  line  will  be
               determined by the specified character pitch.
 
        -lineprinter
               Line  printer  mode  uses  a  strict  fixed-character-pitch  and
-              -height  layout.   That  is, the page is broken into a grid, and
-              characters are placed into that grid.  If the  grid  spacing  is
-              too  small for the actual characters, the result is extra white-
-              space.  If the grid spacing is too large, the result is  missing
-              whitespace.   The grid spacing can be specified using the -fixed
-              and -linespacing options.  If one or both are not given  on  the
-              command  line,  pdftotext  will  attempt  to compute appropriate
+              -height layout.  That is, the page is broken into  a  grid,  and
+              characters  are  placed  into that grid.  If the grid spacing is
+              too small for the actual characters, the result is extra  white-
+              space.   If the grid spacing is too large, the result is missing
+              whitespace.  The grid spacing can be specified using the  -fixed
+              and  -linespacing  options.  If one or both are not given on the
+              command line, pdftotext  will  attempt  to  compute  appropriate
               value(s).
 
        -raw   Keep the text in content stream order.  Depending on how the PDF
@@ -62,22 +68,27 @@
               file was generated, this may or may not be useful.
 
        -fixed number
-              Specify  the  character  pitch (character width), in points, for
-              physical layout, table, or line printer mode.  This  is  ignored
+              Specify the character pitch (character width),  in  points,  for
+              physical  layout,  table, or line printer mode.  This is ignored
               in all other modes.
 
        -linespacing number
-              Specify  the  line  spacing,  in  points, for line printer mode.
+              Specify the line spacing, in  points,  for  line  printer  mode.
               This is ignored in all other modes.
 
        -clip  Text which is hidden because of clipping is removed before doing
-              layout,  and then added back in.  This can be helpful for tables
+              layout, and then added back in.  This can be helpful for  tables
               where clipped (invisible) text would overlap the next column.
 
+       -nodiag
+              Diagonal text, i.e., text that is not close to one of the 0, 90,
+              180, or 270 degree axes, is discarded.  This is useful  to  skip
+              watermarks drawn on top of body text, etc.
+
        -enc encoding-name
-              Sets the encoding to use for  text  output.   The  encoding-name
-              must  be  defined  with  the unicodeMap command (see xpdfrc(5)).
-              The encoding name is case-sensitive.  This defaults to  "Latin1"
+              Sets  the  encoding  to  use for text output.  The encoding-name
+              must be defined with the  unicodeMap  command  (see  xpdfrc(5)).
+              The  encoding name is case-sensitive.  This defaults to "Latin1"
               (which is a built-in encoding).  [config file: textEncoding]
 
        -eol unix | dos | mac
@@ -85,9 +96,12 @@
               file: textEOL]
 
        -nopgbrk
-              Don't insert page breaks (form feed characters)  between  pages.
+              Don't  insert  page breaks (form feed characters) between pages.
               [config file: textPageBreaks]
 
+       -bom   Insert a Unicode byte order marker (BOM) at  the  start  of  the
+              text output.
+
        -opw password
               Specify  the  owner  password  for the PDF file.  Providing this
               will bypass all security restrictions.
@@ -124,14 +138,14 @@
        99     Other error.
 
 AUTHOR
-       The  pdftotext software and documentation are copyright 1996-2014 Glyph
+       The  pdftotext software and documentation are copyright 1996-2017 Glyph
        & Cog, LLC.
 
 SEE ALSO
        xpdf(1),  pdftops(1),  pdftohtml(1),  pdfinfo(1),  pdffonts(1),  pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                     pdftotext(1)
+                                  10 Aug 2017                     pdftotext(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/sample-xpdfrc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/sample-xpdfrc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/sample-xpdfrc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,7 +16,7 @@
 # Also, the Xpdf language support packages each include a set of
 # options to be added to the xpdfrc file.
 #
-# http://www.foolabs.com/xpdf/
+# http://www.xpdfreader.com/
 #
 #========================================================================
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.1
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.1	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.1	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,20 +1,20 @@
-.\" Copyright 1996-2014 Glyph & Cog, LLC
-.TH xpdf 1 "28 May 2014"
+.\" Copyright 1996-2017 Glyph & Cog, LLC
+.TH xpdf 1 "10 Aug 2017"
 .SH NAME
-xpdf \- Portable Document Format (PDF) file viewer for X (version 3.04)
+xpdf \- Portable Document Format (PDF) file viewer (version 4.00)
 .SH SYNOPSIS
 .B xpdf
 [options]
 .RI [ PDF-file
-.RI [ page " | +" dest ]]
+.RI [: page " | +" dest "]] ..."
 .SH DESCRIPTION
 .B Xpdf
 is a viewer for Portable Document Format (PDF) files.  (These are also
 sometimes also called \'Acrobat' files, from the name of Adobe's PDF
-software.)  Xpdf runs under the X Window System on UNIX, VMS, and
-OS/2.
+software.)  Xpdf uses the Qt GUI toolkit and runs on Unix, OS X, and
+Windows.
 .PP
-To run xpdf, simply type:
+To run xpdf, type:
 .PP
 .RS
 xpdf file.pdf
@@ -22,17 +22,27 @@
 .PP
 where
 .I file.pdf
-is your PDF file.  The file name can be followed by a number
-specifying the page which should be displayed first, e.g.:
+is your PDF file.  The file name can be followed by a page number to
+be displayed, prefixed with a colon:
 .PP
 .RS
-xpdf file.pdf 18
+xpdf file.pdf :18
 .RE
 .PP
-You can also give a named destination, prefixed with \'+' in place of
-the page number.  (This is only useful with PDF files that provide
-named destination targets.)
+or by a named destination, prefixed with \'+' (this is only useful
+with PDF files that provide named destination targets):
 .PP
+.RS
+xpdf file.pdf +destinationA
+.RE
+.PP
+If you specify multiple files, they will each be opened in a separate
+tab:
+.PP
+.RS
+xpdf file1.pdf file2.pdf :18 file3.pdf
+.RE
+.PP
 You can also start xpdf without opening any files:
 .PP
 .RS
@@ -46,67 +56,50 @@
 .BR xpdfrc (5)
 man page for details.
 .SH OPTIONS
-Many of the following options can be set with configuration file
-commands or X resources.  These are listed in square brackets with the
-description of the corresponding command line option.
+The following command line options are available.  All command line
+options must come before any PDF files to be opened.
+.PP
+Many of the options can be set with configuration file commands.
+These are listed in square brackets with the description of the
+corresponding command line option.
 .TP
-.BI \-g " geometry"
+.BI \-geometry " geometry"
 Set the initial window geometry.
-.RB ( \-geometry
-is equivalent.)
-.RB "[X resource: " xpdf.geometry ]
 .TP
 .BI \-title " title"
 Set the window title.  By default, the title will be "xpdf: foo.pdf".
-.RB "[X resource: " xpdf.title ]
 .TP
-.B \-cmap
-Install a private colormap.  This is ignored on TrueColor visuals.
-.RB "[X resource: " xpdf.installCmap ]
-.TP
-.BI \-rgb " number"
-Set the size of largest RGB cube xpdf will try to allocate.  The
-default is 5 (for a 5x5x5 cube); set to a smaller number to conserve
-color table entries.  This is ignored with private colormaps and on
-TrueColor visuals.
-.RB "[X resource: " xpdf.rgbCubeSize ]
-.TP
 .B \-rv
 Set reverse video mode.  This reverses the colors of everything except
 images.  It may not always produce great results for PDF files which
 do weird things with color.  This also causes the paper color to
 default to black.
-.RB "[X resource: " xpdf.reverseVideo ]
 .TP
 .BI \-papercolor " color"
-Set the "paper color", i.e., the background of the page display.  This
-will not work too well with PDF files that do things like filling in
-white behind the text.
-.RB "[X resource: " xpdf.paperColor ]
+Set the "paper color", i.e., the background of the page display.  The
+color can be #RRGGBB (hexadecimal) or a named color.  This option will
+not work well with PDF files that do things like filling in white
+behind the text.
+.RB "[config file: " paperColor ]
 .TP
 .BI \-mattecolor " color"
 Set the matte color, i.e., the color used for background outside the
-actual page area.  (There is a separate setting,
-xpdf.fullScreenMatteColor, for full-screen mode.)
-.RB "[X resource: " xpdf.matteColor ]
+actual page area.  The color can be #RRGGBB (hexadecimal) or a named
+color.
+.RB "[config file: " matteColor ]
 .TP
+.BI \-fsmattecolor " color"
+Set the matte color for full-screen mode.  The color can be #RRGGBB
+(hexadecimal) or a named color.
+.RB "[config file: " fullScreenMatteColor ]
+.TP
 .BI \-z " zoom"
 Set the initial zoom factor.  A number specifies a zoom percentage,
 where 100 means 72 dpi.  You may also specify \'page', to fit the page
 to the window size, or \'width', to fit the page width to the window
 width.
-.RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ]
+.RB "[config file: " initialZoom ]
 .TP
-.B \-cont
-Start in continuous view mode, i.e., with one vertical scroll bar for
-the whole document.
-.RB "[config file: " continuousView ]
-.TP
-.BI \-freetype " yes | no"
-Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
-This defaults to "yes".
-.RB "[config file: " enableFreeType ]
-.TP
 .BI \-aa " yes | no"
 Enable or disable font anti-aliasing.  This defaults to "yes".
 .RB "[config file: " antialias ]
@@ -115,32 +108,6 @@
 Enable or disable vector anti-aliasing.  This defaults to "yes".
 .RB "[config file: " vectorAntialias ]
 .TP
-.BI \-ps " PS-file"
-Set the default file name for PostScript output (i.e., the name which
-will appear in the print dialog).  This can also be of the form
-\'|command' to pipe the PostScript through a command.
-.RB "[config file: " psFile ]
-.TP
-.BI \-paper " size"
-Set the paper size to one of "letter", "legal", "A4", or "A3".  This
-can also be set to "match", which will set the paper size to match the
-size specified in the PDF file.
-.RB "[config file: " psPaperSize ]
-.TP
-.BI \-paperw " size"
-Set the paper width, in points.
-.RB "[config file: " psPaperSize ]
-.TP
-.BI \-paperh " size"
-Set the paper height, in points.
-.RB "[config file: " psPaperSize ]
-.TP
-.B \-level1
-Generate Level 1 PostScript.  The resulting PostScript files will be
-significantly larger (if they contain images), but will print on Level
-1 printers.  This also converts all images to black and white.
-.RB "[config file: " psLevel ]
-.TP
 .BI \-enc " encoding-name"
 Sets the encoding to use for text output.  The
 .I encoding\-name
@@ -149,47 +116,21 @@
 This defaults to "Latin1" (which is a built-in encoding).
 .RB "[config file: " textEncoding ]
 .TP
-.BI \-eol " unix | dos | mac"
-Sets the end-of-line convention to use for text output.
-.RB "[config file: " textEOL ]
+.BI \-pw " password"
+Specify the password for the PDF file.  This can be either the owner
+password (which will bypass all security restrictions) or the user
+password.
 .TP
-.BI \-opw " password"
-Specify the owner password for the PDF file.  Providing this will
-bypass all security restrictions.
-.TP
-.BI \-upw " password"
-Specify the user password for the PDF file.
-.TP
 .B \-fullscreen
 Open xpdf in full-screen mode, useful for presentations.
 .TP
-.BI \-remote " name"
-Start/contact xpdf remote server with specified name (see the
-.B "REMOTE SERVER MODE"
-section below).
+.BI \-display " display"
+Set the X display (only available with X11).
 .TP
-.BI \-exec " command"
-Execute a command (see the
-.B COMMANDS
-section below) in an xpdf remote server window (with \-remote only).
-.TP
-.B \-reload
-Reload xpdf remote server window (with \-remote only).
-.TP
-.B \-raise
-Raise xpdf remote server window (with \-remote only).
-.TP
-.B \-quit
-Kill xpdf remote server (with \-remote only).
-.TP
 .B \-cmd
 Print commands as they're executed (useful for debugging).
 .RB "[config file: " printCommands ]
 .TP
-.B \-q
-Don't print any messages or errors.
-.RB "[config file: " errQuiet ]
-.TP
 .BI \-cfg " config-file"
 Read
 .I config-file
@@ -205,440 +146,404 @@
 .B \-\-help
 are equivalent.)
 .PP
-Several other standard X options and resources will work as expected:
+.SH CONTROLS
+.SS Tool bar
 .TP
-.BI \-display " display"
-.RB "[X resource: " xpdf.display ]
+.B "\'page' entry box"
+Move to a specific page number.  Click in the box to activate it, type
+the page number, then hit return.
 .TP
-.BI \-fg " color"
-.RB ( \-foreground
-is equivalent.)
-.RB "[X resource: " xpdf*Foreground ]
-.TP
-.BI \-bg " color"
-.RB ( \-background
-is equivalent.)
-.RB "[X resource: " xpdf*Background ]
-.TP
-.BI \-font " font"
-.RB ( \-fn
-is equivalent.)
-.RB "[X resource: " xpdf*fontList ]
-.PP
-The color and font options only affect the user interface elements,
-not the PDF display (the \'paper').
-.PP
-The following X resources do not have command line option equivalents:
-.TP
-.B xpdf.toolTipEnable
-Enables (if set to true) or disables (if set to false) the tool-tips
-on the toolbar buttons.
-.TP
-.B xpdf.fullScreenMatteColor
-Sets the matte color to be used in full-screen mode.  The default
-setting is "black".
-.SH CONTROLS
-.SS On-screen controls, at the bottom of the xpdf window
-.TP
 .B "left/right arrow buttons"
-Move to the previous/next page.
+Go backward or forward along the history path.
 .TP
-.B "double left/right arrow buttons"
-Move backward or forward by ten pages.
+.B "zoom out/in buttons"
+Zoom out or in (i.e., change magnification) incrementally.
 .TP
-.B "dashed left/right arrow buttons"
-Move backward or forward along the history path.
-.TP
-.B "\'Page' entry box"
-Move to a specific page number.  Click in the box to activate it, type
-the page number, then hit return.
-.TP
 .B "zoom popup menu"
 Change the zoom factor (see the description of the \-z option above).
 .TP
-.B "binoculars button"
-Find a text string.
+.B "fit width button"
+Change the zoom factor to fit the page width to the window width.
 .TP
-.B "print button"
-Bring up a dialog for generating a PostScript file.  The dialog has
-options to set the pages to be printed and the PostScript file name.
-The file name can be \'-' for stdout or \'|command' to pipe the
-PostScript through a command, e.g., \'|lpr'.
+.B "fit page button"
+Change the zoom factor to fit the page to the window size.
 .TP
-.B "\'?' button"
-Bring up the \'about xpdf' window.
+.B "working/error indicator"
+This icon is animated while Xpdf is rendering a page.  It turns red
+when an error or warning has been issued.  Clicking on it opens the
+error dialog.
 .TP
-.B "link info"
-The space between the \'?' and \'Quit' buttons is used to show the URL
-or external file name when the mouse is over a link.
+.B "\'find' box"
+Find a text string.  Click in the box to activate it, type a search
+string, then hit return.
 .TP
-.B "\'Quit' button"
-Quit xpdf.
-.PP
-.SS Menu
-Pressing the right mouse button will post a popup menu with the
-following commands:
+.B "find next button"
+Find the next occurrence of the search string.
 .TP
-.B "Open..."
-Open a new PDF file via a file requester.
+.B "find previous button"
+Find the previous occurrence of the search string.
 .TP
-.B "Open in new window..."
-Create a new window and open a new PDF file via a file requester.
-.TP
-.B "Reload"
-Reload the current PDF file.  Note that Xpdf will reload the file
-automatically (on a page change or redraw) if it has changed since it
-was last loaded.
-.TP
-.B "Save as..."
-Save the current file via a file requester.
-.TP
-.B "Continuous view"
-Toggles between single page and continuous view modes.
-.TP
-.B "Rotate counterclockwise"
-Rotate the page 90 degrees counterclockwise.
-.TP
-.B "Rotate clockwise"
-Rotate the page 90 degrees clockwise.  The two rotate commands are
-intended primarily for PDF files where the rotation isn't correctly
-specified in the file.
-.TP
-.B "Zoom to selection"
-Zoom in to the currently selected rectangle.
-.TP
-.B "Close"
-Close the current window.  If this is the only open window, the
-document is closed, but the window is left open (i.e., this menu
-command won't quit xpdf).
-.TP
-.B "Quit"
-Quit xpdf.
+.B "find settings button"
+Display the current find settings: case sensitive (on/off), find whole
+words (on/off).
 .PP
-.SS Outline
-If the PDF contains an outline (a.k.a., bookmarks), there will be an
-outline pane on the left side of the window.  The width of the outline
-pane is adjustable with a vertical split bar via the knob near its
-bottom end.
+.SS Menu bar
+The menu bar is above the tool bar.  The menu items should be
+self-explanatory.
 .PP
+.SS Tab list
+The tab list is on the left, just below the tool bar.  It lists all
+open tabs.
+.PP
+.SS Outline/layers/attachments pane
+This pane is on the left, below the tab list.  The popup allows you to
+select from outline, layers, or attachments.
+.PP
+The outline is a tree-like structure of bookmarks that allows moving
+within the PDF file.  Not all PDF files have outlines.
+.PP
+Layers (a.k.a. optional content) allow parts of the PDF content to be
+shown or hidden.  Not all PDF files have layers.
+.PP
+Attachments are other files embedded within the PDF file.  There is
+a 'save' button for each attached file.  Not all PDF files have
+attachments.
+.PP
 .SS Text selection
 Dragging the mouse with the left button held down will highlight an
-arbitrary rectangle.  Any text inside this rectangle will be copied to
-the X selection buffer.
+arbitrary rectangle.  Selected text can be copied to the clipboard
+(with the edit/copy menu item).  On X11, selected text will be
+available in the X selection buffer.
 .PP
 .SS Links
+When the mouse is over a hyperlink, the link target will be shown in a
+popup near the bottom of the window.
+.PP
 Clicking on a hyperlink will jump to the link's destination.  A link
 to another PDF document will make xpdf load that document.  A
 \'launch' link to an executable program will display a dialog, and if
-you click \'ok', execute the program.  URL links call an external
-command (see the
-.B WEB BROWSERS
-section below).
+you click \'ok', execute the program.  URL links are opened in a
+system-dependent way.  (On UNIX, Qt uses the $BROWSER environment
+variable.)
 .PP
-.SS Panning
+.SS Mouse bindings
+The left mouse button is used to select text (see above).
+.PP
+Clicking on a link with the middle button opens the link in a new tab.
+.PP
 Dragging the mouse with the middle button held down pans the window.
 .PP
+The right mouse button opens a popup menu (see
+.BR popupMenuCmd " in " xpdfrc (5)).
+.PP
 .SS Key bindings
+This section lists the default key bindings.  Bindings can be changed
+using the config file (see
+.BR xpdfrc (5)).
 .TP
-.B o
+.B control-o
 Open a new PDF file via a file requester.
 .TP
-.B r
+.B control-r
 Reload the current PDF file.  Note that Xpdf will reload the file
 automatically (on a page change or redraw) if it has changed since it
 was last loaded.
 .TP
-.B control-L
-Redraw the current page.
+.B control-f
+Find a text string.  This sets keyboard focus to the \'find' box.
 .TP
-.B control-W
-Close the current window.
-.TP
-.B f or control-F
-Find a text string.
-.TP
 .B control-G
 Find next occurrence.
 .TP
+.B control-C
+Copy selected text to the clipboard.
+.TP
 .B control-P
 Print.
 .TP
-.B n
-Move to the next page.  Scrolls to the top of the page, unless scroll
-lock is turned on.
+.BR control-0 " (control-zero)"
+Set the zoom factor to 125%.
 .TP
-.B p
-Move to the previous page.  Scrolls to the top of the page, unless
-scroll lock is turned on.
+.BR control-+ " (control-plus)"
+Zoom in (increment the zoom factor by 1).
 .TP
-.BR <Space> " or " <PageDown> " or " <Next>
+.BR control-- " (control-minus)"
+Zoom out (decrement the zoom factor by 1).
+.TP
+.B control-s
+Save PDF via a file requester.
+.TP
+.B control-t
+Open a new tab.
+.TP
+.B control-n
+Open a new window.
+.TP
+.B control-w
+Close the current tab.  Closes the window if this was the last open
+tab.  Quits the application if this was the last open window.
+.TP
+.B control-q
+Quit.
+.TP
+.B control-<tab>
+Next tab.
+.TP
+.B control-shift-<tab>
+Previous tab.
+.TP
+.B control-?
+Help.
+.TP
+.B alt-<left-arrow>
+Go backward along the history path.
+.TP
+.B alt-<right-arrow>
+Go forward along the history path.
+.TP
+.B home
+Go to the top left of current page.
+.TP
+.B control-<home>
+Go to the first page.
+.TP
+.B end
+Go to the bottom right of current page.
+.TP
+.B control-<end>
+Go to the last page.
+.TP
+.BR <space> " or " <PageDown>
 Scroll down on the current page; if already at bottom, move to next
 page.
 .TP
-.BR <Backspace> " or " <Delete> " or " <PageUp> " or " <Previous>
+.BR control-<PageDown> " or " control-<down-arrow>
+Go to the next page.  If <ScrollLock> is active, this maintains the
+relative position on the page.
+.TP
+.B <PageUp>
 Scroll up on the current page; if already at top, move to previous
 page.
 .TP
-.B v
-Move forward along the history path.
+.BR control-<PageUp> " or " control-<up-arrow>
+Go to the previous page.  If <ScrollLock> is active, this maintains
+the relative position on the page.
 .TP
-.B b
-Move backward along the history path.
+.B <esc>
+Exit full-screen mode.
 .TP
-.B <Home>
-Scroll to top of current page.
-.TP
-.B <End>
-Scroll to bottom of current page.
-.TP
-.B control-<Home>
-Scroll to first page of document.
-.TP
-.B control-<End>
-Scroll to last page of document.
-.TP
 .B arrows
 Scroll the current page.
 .TP
 .B g
-Activate the page number text field ("goto page").
+Set keyboard focus to the page number entry box.
 .TP
-.B 0
-Set the zoom factor to 125%.
-.TP
-.B +
-Zoom in (increment the zoom factor by 1).
-.TP
-.B -
-Zoom out (decrement the zoom factor by 1).
-.TP
 .B z
-Set the zoom factor to 'page' (fit page to window).
+Set the zoom factor to \'page' (fit page to window).
 .TP
 .B w
-Set the zoom factor to 'width' (fit page width to window).
-.TP
-.B alt-F
-Toggle full-screen mode.
-.TP
-.B q
-Quit xpdf.
-.SH "WEB BROWSERS"
-If you want to run xpdf automatically from netscape or mosaic (and
-probably other browsers) when you click on a link to a PDF file, you
-need to edit (or create) the files
-.I .mime.types
-and
-.I .mailcap
-in your home directory.  In
-.I .mime.types
-add the line:
+Set the zoom factor to \'width' (fit page width to window).
+.SH Full-screen mode
+Xpdf can be placed into full-screen mode via the
+.B \-fullscreen
+command line option, the \'full screen' menu item, or a binding to the
+.B fullScreenMode
+or
+.BR toggleFullScreenMode command .
 .PP
-.RS
-application/pdf pdf
-.RE
+Entering full-screen mode automatically switches to single-page view
+mode and to the fit-page zoom factor.
 .PP
-In
-.I .mailcap
-add the lines:
-.PP
-.RS
-# Use xpdf to view PDF files.
-.RE
-.RS
-application/pdf; xpdf \-q %s
-.RE
-.PP
-Make sure that xpdf is on your executable search path.
-.PP
-When you click on a URL link in a PDF file, xpdf will execute the
-command specified by the urlCommand config file option, replacing an
-occurrence of \'%s' with the URL.  For example, to call netscape with
-the URL, add this line to your config file:
-.PP
-.RS
-urlCommand "netscape \-remote 'openURL(%s)'"
-.RE
+Full-screen mode can be exited via the default <esc> key binding,
+or via a binding to the
+.B windowMode
+or
+.BR toggleFullScreenMode command .
 .SH COMMANDS
-Xpdf's key and mouse bindings are user-configurable, using the bind and
-unbind options in the config file (see
+Xpdf's key and mouse bindings are user-configurable, using the bind
+and unbind commands in the config file (see
 .BR xpdfrc (5)).
 The bind command allows you to bind a key or mouse button to a
 sequence of one or more commands.
-.SS Available Commands
+.PP
 The following commands are supported:
 .TP
-.BI gotoPage( page )
-Go to the specified page.
+.B about
+Open the \'about' dialog.
 .TP
-.BI gotoPageNoScroll( page )
-Go to the specified page, with the current relative scroll position.
+.B blockSelectMode
+Set block selection mode.  In this mode, the selection is a simple
+rectangle.  Any part of the page can be selected, regardless of the
+content on the page.
 .TP
-.BI gotoDest( dest )
-Go to a named destination.
+.B closeSidebar
+Close the sidebar.
 .TP
-.B gotoLastPage
-Go to the last page in the PDF file.
+.B closeSidebarMoveResizeWin
+Close the sidebar, resizing the window so that the document size
+doesn't change, and moving the window so that the document stays in
+the same place on the screen.
 .TP
-.B gotoLastPageNoScroll
-Go to the last page in the PDF file, with the current relative scroll
-position.
+.B closeSidebarResizeWin
+Close the sidebar, resizing the window so that the document size
+doesn't change.
 .TP
-.B nextPage
-Go to the next page.
+.B closeTabOrQuit
+Close the tab.  If this was the last open tab, close the window.  If
+this was the last window open, quit.
 .TP
-.B nextPageNoScroll
-Go to the next page, with the current relative scroll position.
+.B closeWindowOrQuit
+Close the window.  If this was the last open window, quit.
 .TP
-.B prevPage
-Go to the previous page.
+.B continuousMode
+Switch to continuous view mode.
 .TP
-.B prevPageNoScroll
-Go to the previous page, with the current relative scroll position.
+.B copy
+Copy selected text to the clipboard.
 .TP
-.B pageUp
-Scroll up by one screenful.
+.B endPan
+End a pan operation.
 .TP
-.B pageDown
-Scroll down by one screenful.
+.B endSelection
+End a selection.
 .TP
-.BI scrollLeft( n )
-Scroll left by
-.I n
-pixels.
+.B find
+Set keyboard focus to the \'find' box.
 .TP
-.BI scrollRight( n )
-Scroll right by
-.I n
-pixels.
+.B findFirst
+Find the first occurrence of the search string.
 .TP
-.BI scrollUp( n )
-Scroll up by
-.I n
-pixels.
+.B findNext
+Find the next occurrence of the search string.
 .TP
-.BI scrollDown( n )
-Scroll down by
-.I n
-pixels.
+.B findPrevious
+Find the previous occurrence of the search string.
 .TP
-.BI scrollUpPrevPage( n )
-Scroll up by
-.I n
-pixels, moving to the previous page if appropriate.
+.B focusToDocWin
+Set keyboard focus to the main document window.
 .TP
-.BI scrollDownPrevPage( n )
-Scroll down by
-.I n
-pixels, moving to the next page if appropriate.
+.B focusToPageNum
+Set keyboard focus to the page number text box.
 .TP
-.B scrollToTopEdge
-Scroll to the top edge of the current page, with no horizontal
-movement.
+.B followLink
+Follow a hyperlink (does nothing if the mouse is not over a link).
 .TP
-.B scrollToBottomEdge
-Scroll to the bottom edge of the current page, with no horizontal
-movement.
+.B followLinkInNewTab
+Follow a hyperlink, opening PDF files in a new tab (does nothing if
+the mouse is not over a link).  For links to non-PDF files, this
+command is identical to followLink.
 .TP
-.B scrollToLeftEdge
-Scroll to the left edge of the current page, with no vertical
-movement.
+.B followLinkInNewTabNoSel
+Same as followLinkInNewTab, but does nothing if there is a non-empty
+selection.  (This is useful as a mouse button binding.)
 .TP
-.B scrollToRightEdge
-Scroll to the right edge of the current page, with no vertical
-movement.
+.B followLinkInNewWin
+Follow a hyperlink, opening PDF files in a new window (does nothing if
+the mouse is not over a link).  For links to non-PDF files, this
+command is identical to followLink.
 .TP
-.B scrollToTopLeft
-Scroll to the top-left corner of the current page.
+.B followLinkInNewWinNoSel
+Same as followLinkInNewWin, but does nothing if there is a non-empty
+selection.  (This is useful as a mouse button binding.)
 .TP
-.B scrollToBottomRight
-Scroll to the bottom-right corner of the current page.
+.B followLinkNoSel
+Same as followLink, but does nothing if there is a non-empty selection.
+(This is useful as a mouse button binding.)
 .TP
-.B goForward
-Move forward along the history path.
+.B fullScreenMode
+Go to full-screen mode.
 .TP
 .B goBackward
 Move backward along the history path.
 .TP
-.BI zoomPercent( z )
-Set the zoom factor to
-.IR z %.
+.B goForward
+Move forward along the history path.
 .TP
-.B zoomFitPage
-Set the zoom factor to fit-page.
+.BI gotoDest( dest )
+Go to a named destination.
 .TP
-.B zoomFitWidth
-Set the zoom factor to fit-width.
+.B gotoLastPage
+Go to the last page in the PDF file.
 .TP
-.B zoomIn
-Zoom in - go to the next higher zoom factor.
+.BI gotoPage( page )
+Go to the specified page.
 .TP
-.B zoomOut
-Zoom out - go the next lower zoom factor.
+.BI help
+Open the help URL.
 .TP
-.B rotateCW
-Rotate the page 90 degrees clockwise.
+.B horizontalContinuousMode
+Switch to horizontal continuous view mode.
 .TP
-.B rotateCCW
-Rotate the page 90 degrees counterclockwise.
+.B linearSelectMode
+Set linear selection mode.  In this mode, the selection follows text.
+Non-text regions cannot be selected.
 .TP
-.BI setSelection( pg , ulx , uly , lrx , lry )
-Set the selection to the specified coordinates on the specified page.
+.B newTab
+Open an empty new tab.
 .TP
-.B continuousMode
-Go to continuous view mode.
+.B newWindow
+Open an empty new window.
 .TP
-.B singlePageMode
-Go to single-page view mode.
+.B nextPage
+Go to the next page.
 .TP
-.B toggleContinuousMode
-Toggle between continuous and single page view modes.
+.B nextPageNoScroll
+Go to the next page, with the current relative scroll position.
 .TP
-.B fullScreenMode
-Go to full-screen mode.
+.B nextTab
+Switch to the next tab.
 .TP
-.B windowMode
-Go to window (non-full-screen) mode.
+.B open
+Open a PDF file in this tab, using the open dialog.
 .TP
-.B toggleFullScreenMode
-Toggle between full-screen and window modes.
+.B openErrorWindow
+Open the error window.
 .TP
-.B open
-Open a PDF file in this window, using the open dialog.
+.B openSidebar
+Open the sidebar.
 .TP
-.B openInNewWin
-Open a PDF file in a new window, using the open dialog.
+.B openSidebarMoveResizeWin
+Open the sidebar, resizing the window so that the document size
+doesn't change, and moving the window so that the document stays in
+the same place on the screen.
 .TP
-.BI openFile( file )
-Open a specified PDF file in this window.
+.B openSidebarResizeWin
+Open the sidebar, resizing the window so that the document size
+doesn't change.
 .TP
-.BI openFileInNewWin( file )
-Open a specified PDF file in a new window.
+.B pageDown
+Scroll down by one screenful.
 .TP
-.BI openFileAtDest( file , dest )
-Open a specified PDF file in this window and go to a named
-destination.
+.B pageUp
+Scroll up by one screenful.
 .TP
-.BI openFileAtDestInNewWin( file , dest )
-Open a specified PDF file in a new window and go to a named
-destination.
+.B postPopupMenu
+Display the popup menu.
 .TP
+.B prevPage
+Go to the previous page.
+.TP
+.B prevPageNoScroll
+Go to the previous page, with the current relative scroll position.
+.TP
+.B prevTab
+Switch to the previous tab.
+.TP
+.B print
+Open the \'print' dialog.
+.TP
+.B quit
+Quit from xpdf.
+.TP
 .B reload
 Reload the current PDF file.
 .TP
-.B redraw
-Redraw the window.
+.B rotateCCW
+Rotate the page 90 degrees counterclockwise.
 .TP
-.B raise
-Raise the window to the front.
+.B rotateCW
+Rotate the page 90 degrees clockwise.
 .TP
-.B closeWindow
-Close the window.  If this was the last open window, clear the window,
-but don't quit from Xpdf.
-.TP
-.B closeWindowOrQuit
-Close the window.  If this was the last open window, quit from Xpdf.
-.TP
 .BI run( external-command-string )
 Run an external command.  The following escapes are allowed in the
 command string:
@@ -675,15 +580,27 @@
 
 .fi
 .TP
-.B openOutline
-Open the outline pane.
+.B saveAs
+Save PDF via a file requester.
 .TP
-.B closeOutline
-Close the outline pane.
+.B saveImage
+Open the \'save image' dialog.
 .TP
-.B toggleOutline
-Toggle the outline pane between open and closed.
+.BI scrollDown( n )
+Scroll down by
+.I n
+pixels.
 .TP
+.BI scrollDownPrevPage( n )
+Scroll down by
+.I n
+pixels, moving to the next page if appropriate.
+.TP
+.BI scrollLeft( n )
+Scroll left by
+.I n
+pixels.
+.TP
 .BI scrollOutlineDown( n )
 Scroll the outline down by
 .I n
@@ -694,163 +611,105 @@
 .I n
 increments.
 .TP
-.B focusToDocWin
-Set the keyboard focus to the main document window.
+.BI scrollRight( n )
+Scroll right by
+.I n
+pixels.
 .TP
-.B focusToPageNum
-Set the keyboard focus to the page number text box.
+.B scrollToBottomEdge
+Scroll to the bottom edge of the current page, with no horizontal
+movement.
 .TP
-.B find
-Open the 'find' dialog.
+.B scrollToBottomRight
+Scroll to the bottom-right corner of the current page.
 .TP
-.B findNext
-Finds the next occurrence of the search string (no dialog).
+.B scrollToLeftEdge
+Scroll to the left edge of the current page, with no vertical
+movement.
 .TP
-.B print
-Open the 'print' dialog.
+.B scrollToRightEdge
+Scroll to the right edge of the current page, with no vertical
+movement.
 .TP
-.B about
-Open the 'about' dialog.
+.B scrollToTopEdge
+Scroll to the top edge of the current page, with no horizontal
+movement.
 .TP
-.B quit
-Quit from xpdf.
-.PP
-The following commands depend on the current mouse position:
+.B scrollToTopLeft
+Scroll to the top-left corner of the current page.
 .TP
-.B startSelection
-Start a selection, which will be extended as the mouse moves.
+.BI scrollUp( n )
+Scroll up by
+.I n
+pixels.
 .TP
-.B endSelection
-End a selection.
+.BI scrollUpPrevPage( n )
+Scroll up by
+.I n
+pixels, moving to the previous page if appropriate.
 .TP
+.BI setSelection( pg , ulx , uly , lrx , lry )
+Set the selection to the specified coordinates on the specified page.
+.TP
+.B sideBySideContinuousMode
+Switch to side-by-side continuous view mode.
+.TP
+.B sideBySideSingleMode
+Switch to side-by-side two-page view mode.
+.TP
+.B singlePageMode
+Switch to single-page view mode.
+.TP
 .B startPan
-Start a pan, which will scroll the document as the mouse moves
+Start a pan operation at the current mouse position, which will scroll
+the document as the mouse moves.
 .TP
-.B endPan
-End a pan.
+.B startSelection
+Start a selection at the current mouse position, which will be
+extended as the mouse moves.
 .TP
-.B postPopupMenu
-Display the popup menu.
+.B toggleContinuousMode
+Toggle between continuous and single page view modes.
 .TP
-.B followLink
-Follow a hyperlink (does nothing if the mouse is not over a link).
+.B toggleFullScreenMode
+Toggle between full-screen and window modes.
 .TP
-.B followLinkInNewWin
-Follow a hyperlink, opening PDF files in a new window (does nothing if
-the mouse is not over a link).  For links to non-PDF files, this
-command is identical to followLink.
+.B toggleSelectMode
+Toggle between block and linear selection mode.
 .TP
-.B followLinkNoSel
-Same as followLink, but does nothing if there is a non-empty selection.
-(This is useful as a mouse button binding.)
+.B toggleSidebar
+Toggle the sidebar between open and closed.
 .TP
-.B followLinkInNewWinNoSel
-Same as followLinkInNewWin, but does nothing if there is a non-empty
-selection.  (This is useful as a mouse button binding.)
-.SS Default Bindings
-The default mouse bindings are as follows:
-.nf
-
-    bind mousePress1    any         startSelection
-    bind mouseRelease1  any         endSelection followLinkNoSel
-    bind mousePress2    any         startPan
-    bind mouseRelease2  any         endPan
-    bind mousePress3    any         postPopupMenu
-    bind mousePress4    any         scrollUpPrevPage(16)
-    bind mousePress5    any         scrollDownNextPage(16)
-    bind mousePress6    any         scrollLeft(16)
-    bind mousePress7    any         scrollRight(16)
-
-.fi
-The default key bindings are as follows:
-.nf
-
-    bind ctrl-home      any         gotoPage(1)
-    bind home           any         scrollToTopLeft
-    bind ctrl-end       any         gotoLastPage
-    bind end            any         scrollToBottomRight
-    bind pgup           any         pageUp
-    bind backspace      any         pageUp
-    bind delete         any         pageUp
-    bind pgdn           any         pageDown
-    bind space          any         pageDown
-    bind left           any         scrollLeft(16)
-    bind right          any         scrollRight(16)
-    bind up             any         scrollUp(16)
-    bind down           any         scrollDown(16)
-    bind o              any         open
-    bind O              any         open
-    bind r              any         reload
-    bind R              any         reload
-    bind f              any         find
-    bind F              any         find
-    bind ctrl-f         any         find
-    bind ctrl-g         any         findNext
-    bind ctrl-p         any         print
-    bind n              scrLockOff  nextPage
-    bind N              scrLockOff  nextPage
-    bind n              scrLockOn   nextPageNoScroll
-    bind N              scrLockOn   nextPageNoScroll
-    bind p              scrLockOff  prevPage
-    bind P              scrLockOff  prevPage
-    bind p              scrLockOn   prevPageNoScroll
-    bind P              scrLockOn   prevPageNoScroll
-    bind v              any         goForward
-    bind b              any         goBackward
-    bind g              any         focusToPageNum
-    bind 0              any         zoomPercent(125)
-    bind +              any         zoomIn
-    bind -              any         zoomOut
-    bind z              any         zoomFitPage
-    bind w              any         zoomFitWidth
-    bind alt-f          any         toggleFullScreenMode
-    bind ctrl-l         any         redraw
-    bind ctrl-w         any         closeWindowOrQuit
-    bind ?              any         about
-    bind q              any         quit
-    bind Q              any         quit
-
-.fi
-Previous versions of xpdf included a "viKeys" X resource.  It is no
-longer available, but the following bindings are equivalent:
-.nf
-
-    bind h any scrollLeft(16)
-    bind l any scrollRight(16)
-    bind k any scrollUp(16)
-    bind j any scrollDown(16)
-
-.fi
-.SH "REMOTE SERVER MODE"
-Xpdf can be started in remote server mode by specifying a server name
-(in addition to the file name and page number).  For example:
-.PP
-.RS
-xpdf \-remote myServer file.pdf
-.RE
-.PP
-If there is currently no xpdf running in server mode with the name
-\'myServer', a new xpdf window will be opened.  If another command:
-.PP
-.RS
-xpdf \-remote myServer another.pdf 9
-.RE
-.PP
-is issued, a new copy of xpdf will not be started.  Instead, the first
-xpdf (the server) will load
-.I another.pdf
-and display page nine.  If the file name is the same:
-.PP
-.RS
-xpdf \-remote myServer another.pdf 4
-.RE
-.PP
-the xpdf server will simply display the specified page.
-.PP
-The \-raise option tells the server to raise its window; it can be
-specified with or without a file name and page number.
-.PP
-The \-quit option tells the server to close its window and exit.
+.B toggleSidebarMoveResizeWin
+Toggle the sidebar between open and closed, resizing the window so
+that the document size doesn't change, and moving the window so that
+the document stays in the same place on the screen.
+.TP
+.B toggleSidebarResizeWin
+Toggle the sidebar between open and closed, resizing the window so
+that the document size doesn't change.
+.TP
+.B windowMode
+Go to window (non-full-screen) mode.
+.TP
+.B zoomFitPage
+Set the zoom factor to fit-page.
+.TP
+.B zoomFitWidth
+Set the zoom factor to fit-width.
+.TP
+.B zoomIn
+Zoom in - go to the next higher zoom factor.
+.TP
+.B zoomOut
+Zoom out - go the next lower zoom factor.
+.TP
+.BI zoomPercent( z )
+Set the zoom factor to
+.IR z %.
+.TP
+.B zoomToSelection
+Zoom to the current selection.
 .SH EXIT CODES
 The Xpdf tools use the following exit codes:
 .TP
@@ -869,7 +728,7 @@
 99
 Other error.
 .SH AUTHOR
-The xpdf software and documentation are copyright 1996-2014 Glyph &
+The xpdf software and documentation are copyright 1996-2017 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
 .BR pdftops (1),
@@ -883,4 +742,4 @@
 .BR pdfimages (1),
 .BR xpdfrc (5)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdf.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,32 +1,38 @@
-xpdf(1)                                                                xpdf(1)
+xpdf(1)                     General Commands Manual                    xpdf(1)
 
 
 
 NAME
-       xpdf - Portable Document Format (PDF) file viewer for X (version 3.04)
+       xpdf - Portable Document Format (PDF) file viewer (version 4.00)
 
 SYNOPSIS
-       xpdf [options] [PDF-file [page | +dest]]
+       xpdf [options] [PDF-file [:page | +dest]] ...
 
 DESCRIPTION
        Xpdf  is a viewer for Portable Document Format (PDF) files.  (These are
        also sometimes also called 'Acrobat' files, from the  name  of  Adobe's
-       PDF  software.)   Xpdf runs under the X Window System on UNIX, VMS, and
-       OS/2.
+       PDF  software.)   Xpdf  uses the Qt GUI toolkit and runs on Unix, OS X,
+       and Windows.
 
-       To run xpdf, simply type:
+       To run xpdf, type:
 
               xpdf file.pdf
 
        where file.pdf is your PDF file.  The file name can be  followed  by  a
-       number specifying the page which should be displayed first, e.g.:
+       page number to be displayed, prefixed with a colon:
 
-              xpdf file.pdf 18
+              xpdf file.pdf :18
 
-       You  can  also  give a named destination, prefixed with '+' in place of
-       the page number.  (This is only useful  with  PDF  files  that  provide
-       named destination targets.)
+       or  by a named destination, prefixed with '+' (this is only useful with
+       PDF files that provide named destination targets):
 
+              xpdf file.pdf +destinationA
+
+       If you specify multiple files, they will each be opened in  a  separate
+       tab:
+
+              xpdf file1.pdf file2.pdf :18 file3.pdf
+
        You can also start xpdf without opening any files:
 
               xpdf
@@ -39,58 +45,47 @@
        man page for details.
 
 OPTIONS
-       Many  of  the following options can be set with configuration file com-
-       mands or X resources.  These are listed in  square  brackets  with  the
-       description of the corresponding command line option.
+       The  following  command  line  options are available.  All command line
+       options must come before any PDF files to be opened.
 
-       -g geometry
-              Set the initial window geometry.  (-geometry is equivalent.)  [X
-              resource: xpdf.geometry]
+       Many of the options can be set with configuration file commands.  These
+       are listed in square brackets with the description of the corresponding
+       command line option.
 
+       -geometry geometry
+              Set the initial window geometry.
+
        -title title
               Set the window title.  By default,  the  title  will  be  "xpdf:
-              foo.pdf".  [X resource: xpdf.title]
+              foo.pdf".
 
-       -cmap  Install  a private colormap.  This is ignored on TrueColor visu-
-              als.  [X resource: xpdf.installCmap]
-
-       -rgb number
-              Set the size of largest RGB cube xpdf will try to allocate.  The
-              default is 5 (for a 5x5x5 cube); set to a smaller number to con-
-              serve color table entries.  This is ignored  with  private  col-
-              ormaps and on TrueColor visuals.  [X resource: xpdf.rgbCubeSize]
-
        -rv    Set  reverse video mode.  This reverses the colors of everything
               except images.  It may not always produce great results for  PDF
               files  which  do  weird things with color.  This also causes the
-              paper color to default to black.   [X  resource:  xpdf.reverseV-
-              ideo]
+              paper color to default to black.
 
        -papercolor color
               Set the "paper color", i.e., the background of the page display.
-              This will not work too well with PDF files that do  things  like
-              filling in white behind the text.  [X resource: xpdf.paperColor]
+              The  color  can be #RRGGBB (hexadecimal) or a named color.  This
+              option will not work well with PDF files  that  do  things  like
+              filling in white behind the text.  [config file: paperColor]
 
        -mattecolor color
               Set the matte color, i.e., the color used for background outside
-              the  actual  page  area.   (There   is   a   separate   setting,
-              xpdf.fullScreenMatteColor,  for full-screen mode.)  [X resource:
-              xpdf.matteColor]
+              the actual page area.  The color can be #RRGGBB (hexadecimal) or
+              a named color.  [config file: matteColor]
 
+       -fsmattecolor color
+              Set  the  matte  color  for  full-screen mode.  The color can be
+              #RRGGBB  (hexadecimal)  or  a  named   color.    [config   file:
+              fullScreenMatteColor]
+
        -z zoom
               Set the initial zoom factor.  A number specifies a zoom percent-
-              age,  where  100  means 72 dpi.  You may also specify 'page', to
-              fit the page to the window size, or 'width',  to  fit  the  page
-              width  to  the  window  width.   [config file: initialZoom; or X
-              resource: xpdf.initialZoom]
+              age, where 100 means 72 dpi.  You may also  specify  'page',  to
+              fit  the  page  to  the window size, or 'width', to fit the page
+              width to the window width.  [config file: initialZoom]
 
-       -cont  Start in continuous view mode, i.e., with  one  vertical  scroll
-              bar for the whole document.  [config file: continuousView]
-
-       -freetype yes | no
-              Enable  or  disable  FreeType  (a TrueType / Type 1 font raster-
-              izer).  This defaults to "yes".  [config file: enableFreeType]
-
        -aa yes | no
               Enable or disable font anti-aliasing.  This defaults  to  "yes".
               [config file: antialias]
@@ -99,70 +94,26 @@
               Enable or disable vector anti-aliasing.  This defaults to "yes".
               [config file: vectorAntialias]
 
-       -ps PS-file
-              Set the default file name for PostScript output (i.e., the  name
-              which will appear in the print dialog).  This can also be of the
-              form '|command' to pipe the PostScript through a command.  [con-
-              fig file: psFile]
-
-       -paper size
-              Set  the  paper size to one of "letter", "legal", "A4", or "A3".
-              This can also be set to "match", which will set the  paper  size
-              to  match  the  size  specified  in the PDF file.  [config file:
-              psPaperSize]
-
-       -paperw size
-              Set the paper width, in points.  [config file: psPaperSize]
-
-       -paperh size
-              Set the paper height, in points.  [config file: psPaperSize]
-
-       -level1
-              Generate Level 1 PostScript.   The  resulting  PostScript  files
-              will  be significantly larger (if they contain images), but will
-              print on Level 1 printers.  This also  converts  all  images  to
-              black and white.  [config file: psLevel]
-
        -enc encoding-name
-              Sets  the  encoding  to  use for text output.  The encoding-name
-              must be defined with the  unicodeMap  command  (see  xpdfrc(5)).
+              Sets the encoding to use for  text  output.   The  encoding-name
+              must  be  defined  with  the unicodeMap command (see xpdfrc(5)).
               This defaults to "Latin1" (which is a built-in encoding).  [con-
               fig file: textEncoding]
 
-       -eol unix | dos | mac
-              Sets the end-of-line convention to use for text output.  [config
-              file: textEOL]
+       -pw password
+              Specify  the  password for the PDF file.  This can be either the
+              owner password (which will bypass all security restrictions)  or
+              the user password.
 
-       -opw password
-              Specify  the  owner  password  for the PDF file.  Providing this
-              will bypass all security restrictions.
-
-       -upw password
-              Specify the user password for the PDF file.
-
        -fullscreen
               Open xpdf in full-screen mode, useful for presentations.
 
-       -remote name
-              Start/contact xpdf remote server with specified  name  (see  the
-              REMOTE SERVER MODE section below).
+       -display display
+              Set the X display (only available with X11).
 
-       -exec command
-              Execute  a  command  (see the COMMANDS section below) in an xpdf
-              remote server window (with -remote only).
-
-       -reload
-              Reload xpdf remote server window (with -remote only).
-
-       -raise Raise xpdf remote server window (with -remote only).
-
-       -quit  Kill xpdf remote server (with -remote only).
-
-       -cmd   Print commands  as  they're  executed  (useful  for  debugging).
+       -cmd   Print  commands  as  they're  executed  (useful  for debugging).
               [config file: printCommands]
 
-       -q     Don't print any messages or errors.  [config file: errQuiet]
-
        -cfg config-file
               Read config-file in place of ~/.xpdfrc or the system-wide config
               file.
@@ -171,388 +122,385 @@
 
        -h     Print usage information.  (-help and --help are equivalent.)
 
-       Several other standard X options and resources will work as expected:
+CONTROLS
+   Tool bar
+       'page' entry box
+              Move  to  a  specific page number.  Click in the box to activate
+              it, type the page number, then hit return.
 
-       -display display
-              [X resource: xpdf.display]
-
-       -fg color
-              (-foreground is equivalent.)  [X resource: xpdf*Foreground]
-
-       -bg color
-              (-background is equivalent.)  [X resource: xpdf*Background]
-
-       -font font
-              (-fn is equivalent.)  [X resource: xpdf*fontList]
-
-       The color and font options only affect the user interface elements, not
-       the PDF display (the 'paper').
-
-       The following X resources do not have command line option equivalents:
-
-       xpdf.toolTipEnable
-              Enables (if set to true) or disables (if set to false) the tool-
-              tips on the toolbar buttons.
-
-       xpdf.fullScreenMatteColor
-              Sets the matte color  to  be  used  in  full-screen  mode.   The
-              default setting is "black".
-
-CONTROLS
-   On-screen controls, at the bottom of the xpdf window
        left/right arrow buttons
-              Move to the previous/next page.
+              Go backward or forward along the history path.
 
-       double left/right arrow buttons
-              Move backward or forward by ten pages.
+       zoom out/in buttons
+              Zoom out or in (i.e., change magnification) incrementally.
 
-       dashed left/right arrow buttons
-              Move backward or forward along the history path.
-
-       'Page' entry box
-              Move  to  a  specific page number.  Click in the box to activate
-              it, type the page number, then hit return.
-
        zoom popup menu
               Change the zoom factor (see the description  of  the  -z  option
               above).
 
-       binoculars button
-              Find a text string.
+       fit width button
+              Change  the  zoom  factor  to  fit  the page width to the window
+              width.
 
-       print button
-              Bring  up a dialog for generating a PostScript file.  The dialog
-              has options to set the pages to be printed  and  the  PostScript
-              file name.  The file name can be '-' for stdout or '|command' to
-              pipe the PostScript through a command, e.g., '|lpr'.
+       fit page button
+              Change the zoom factor to fit the page to the window size.
 
-       '?' button
-              Bring up the 'about xpdf' window.
+       working/error indicator
+              This icon is animated while Xpdf is rendering a page.  It  turns
+              red  when  an  error or warning has been issued.  Clicking on it
+              opens the error dialog.
 
-       link info
-              The space between the '?' and 'Quit' buttons is used to show the
-              URL or external file name when the mouse is over a link.
+       'find' box
+              Find a text string.  Click in the box to  activate  it,  type  a
+              search string, then hit return.
 
-       'Quit' button
-              Quit xpdf.
+       find next button
+              Find the next occurrence of the search string.
 
-   Menu
-       Pressing the right mouse button will post a popup menu with the follow-
-       ing commands:
+       find previous button
+              Find the previous occurrence of the search string.
 
-       Open...
-              Open a new PDF file via a file requester.
+       find settings button
+              Display the current find settings: case sensitive (on/off), find
+              whole words (on/off).
 
-       Open in new window...
-              Create a new  window  and  open  a  new  PDF  file  via  a  file
-              requester.
+   Menu bar
+       The menu bar is above the tool bar.  The menu  items  should  be  self-
+       explanatory.
 
-       Reload Reload  the  current  PDF  file.  Note that Xpdf will reload the
-              file automatically (on a  page  change  or  redraw)  if  it  has
-              changed since it was last loaded.
+   Tab list
+       The  tab  list  is  on the left, just below the tool bar.  It lists all
+       open tabs.
 
-       Save as...
-              Save the current file via a file requester.
+   Outline/layers/attachments pane
+       This pane is on the left, below the tab list.  The popup allows you  to
+       select from outline, layers, or attachments.
 
-       Continuous view
-              Toggles between single page and continuous view modes.
+       The  outline  is  a tree-like structure of bookmarks that allows moving
+       within the PDF file.  Not all PDF files have outlines.
 
-       Rotate counterclockwise
-              Rotate the page 90 degrees counterclockwise.
+       Layers (a.k.a. optional content) allow parts of the PDF content  to  be
+       shown or hidden.  Not all PDF files have layers.
 
-       Rotate clockwise
-              Rotate  the  page 90 degrees clockwise.  The two rotate commands
-              are intended primarily for PDF files where  the  rotation  isn't
-              correctly specified in the file.
+       Attachments  are  other files embedded within the PDF file.  There is a
+       'save' button for each attached file.  Not all PDF files  have  attach-
+       ments.
 
-       Zoom to selection
-              Zoom in to the currently selected rectangle.
+   Text selection
+       Dragging  the  mouse  with  the left button held down will highlight an
+       arbitrary rectangle.  Selected text can  be  copied  to  the  clipboard
+       (with  the  edit/copy menu item).  On X11, selected text will be avail-
+       able in the X selection buffer.
 
-       Close  Close  the current window.  If this is the only open window, the
-              document is closed, but the window is left open (i.e., this menu
-              command won't quit xpdf).
+   Links
+       When the mouse is over a hyperlink, the link target will be shown in  a
+       popup near the bottom of the window.
 
-       Quit   Quit xpdf.
+       Clicking on a hyperlink will jump to the link's destination.  A link to
+       another PDF document will make xpdf load  that  document.   A  'launch'
+       link  to  an executable program will display a dialog, and if you click
+       'ok', execute the program.  URL links are opened in a  system-dependent
+       way.  (On UNIX, Qt uses the $BROWSER environment variable.)
 
-   Outline
-       If  the  PDF  contains an outline (a.k.a., bookmarks), there will be an
-       outline pane on the left side of the window.  The width of the  outline
-       pane is adjustable with a vertical split bar via the knob near its bot-
-       tom end.
+   Mouse bindings
+       The left mouse button is used to select text (see above).
 
-   Text selection
-       Dragging the mouse with the left button held  down  will  highlight  an
-       arbitrary  rectangle.  Any text inside this rectangle will be copied to
-       the X selection buffer.
+       Clicking on a link with the middle button opens the link in a new tab.
 
-   Links
-       Clicking on a hyperlink will jump to the link's destination.  A link to
-       another  PDF  document  will  make xpdf load that document.  A 'launch'
-       link to an executable program will display a dialog, and if  you  click
-       'ok', execute the program.  URL links call an external command (see the
-       WEB BROWSERS section below).
-
-   Panning
        Dragging the mouse with the middle button held down pans the window.
 
+       The  right  mouse  button  opens  a  popup  menu  (see  popupMenuCmd in
+       xpdfrc(5)).
+
    Key bindings
-       o      Open a new PDF file via a file requester.
+       This section lists the default key bindings.  Bindings can  be  changed
+       using the config file (see xpdfrc(5)).
 
-       r      Reload the current PDF file.  Note that  Xpdf  will  reload  the
-              file  automatically  (on  a  page  change  or  redraw) if it has
+       control-o
+              Open a new PDF file via a file requester.
+
+       control-r
+              Reload  the  current  PDF  file.  Note that Xpdf will reload the
+              file automatically (on a  page  change  or  redraw)  if  it  has
               changed since it was last loaded.
 
-       control-L
-              Redraw the current page.
+       control-f
+              Find a text string.  This sets keyboard focus to the 'find' box.
 
-       control-W
-              Close the current window.
-
-       f or control-F
-              Find a text string.
-
        control-G
               Find next occurrence.
 
+       control-C
+              Copy selected text to the clipboard.
+
        control-P
               Print.
 
-       n      Move to the next page.  Scrolls to the top of the  page,  unless
-              scroll lock is turned on.
+       control-0 (control-zero)
+              Set the zoom factor to 125%.
 
-       p      Move  to  the  previous  page.   Scrolls to the top of the page,
-              unless scroll lock is turned on.
+       control-+ (control-plus)
+              Zoom in (increment the zoom factor by 1).
 
-       <Space> or <PageDown> or <Next>
-              Scroll down on the current page; if already at bottom,  move  to
-              next page.
+       control-- (control-minus)
+              Zoom out (decrement the zoom factor by 1).
 
-       <Backspace> or <Delete> or <PageUp> or <Previous>
-              Scroll up on the current page; if already at top, move to previ-
-              ous page.
+       control-s
+              Save PDF via a file requester.
 
-       v      Move forward along the history path.
+       control-t
+              Open a new tab.
 
-       b      Move backward along the history path.
+       control-n
+              Open a new window.
 
-       <Home> Scroll to top of current page.
+       control-w
+              Close  the  current tab.  Closes the window if this was the last
+              open tab.  Quits the application if this was the last open  win-
+              dow.
 
-       <End>  Scroll to bottom of current page.
+       control-q
+              Quit.
 
-       control-<Home>
-              Scroll to first page of document.
+       control-<tab>
+              Next tab.
 
-       control-<End>
-              Scroll to last page of document.
+       control-shift-<tab>
+              Previous tab.
 
-       arrows Scroll the current page.
+       control-?
+              Help.
 
-       g      Activate the page number text field ("goto page").
+       alt-<left-arrow>
+              Go backward along the history path.
 
-       0      Set the zoom factor to 125%.
+       alt-<right-arrow>
+              Go forward along the history path.
 
-       +      Zoom in (increment the zoom factor by 1).
+       home   Go to the top left of current page.
 
-       -      Zoom out (decrement the zoom factor by 1).
+       control-<home>
+              Go to the first page.
 
-       z      Set the zoom factor to 'page' (fit page to window).
+       end    Go to the bottom right of current page.
 
-       w      Set the zoom factor to 'width' (fit page width to window).
+       control-<end>
+              Go to the last page.
 
-       alt-F  Toggle full-screen mode.
+       <space> or <PageDown>
+              Scroll  down  on the current page; if already at bottom, move to
+              next page.
 
-       q      Quit xpdf.
+       control-<PageDown> or control-<down-arrow>
+              Go to the next page.  If <ScrollLock> is active, this  maintains
+              the relative position on the page.
 
-WEB BROWSERS
-       If you want to run xpdf automatically  from  netscape  or  mosaic  (and
-       probably  other  browsers)  when you click on a link to a PDF file, you
-       need to edit (or create) the files .mime.types  and  .mailcap  in  your
-       home directory.  In .mime.types add the line:
+       <PageUp>
+              Scroll up on the current page; if already at top, move to previ-
+              ous page.
 
-              application/pdf pdf
+       control-<PageUp> or control-<up-arrow>
+              Go to the previous page.  If <ScrollLock> is active, this  main-
+              tains the relative position on the page.
 
-       In .mailcap add the lines:
+       <esc>  Exit full-screen mode.
 
-              # Use xpdf to view PDF files.
-              application/pdf; xpdf -q %s
+       arrows Scroll the current page.
 
-       Make sure that xpdf is on your executable search path.
+       g      Set keyboard focus to the page number entry box.
 
-       When  you click on a URL link in a PDF file, xpdf will execute the com-
-       mand specified by the  urlCommand  config  file  option,  replacing  an
-       occurrence  of  '%s'  with the URL.  For example, to call netscape with
-       the URL, add this line to your config file:
+       z      Set the zoom factor to 'page' (fit page to window).
 
-              urlCommand "netscape -remote 'openURL(%s)'"
+       w      Set the zoom factor to 'width' (fit page width to window).
 
+Full-screen mode
+       Xpdf  can  be  placed into full-screen mode via the -fullscreen command
+       line option,  the  'full  screen'  menu  item,  or  a  binding  to  the
+       fullScreenMode or toggleFullScreenModecommand.
+
+       Entering  full-screen  mode  automatically switches to single-page view
+       mode and to the fit-page zoom factor.
+
+       Full-screen mode can be exited via the default <esc>  key  binding,  or
+       via a binding to the windowMode or toggleFullScreenModecommand.
+
 COMMANDS
        Xpdf's key and mouse bindings are user-configurable, using the bind and
-       unbind  options  in  the config file (see xpdfrc(5)).  The bind command
-       allows you to bind a key or mouse button to a sequence of one  or  more
+       unbind commands in the config file (see xpdfrc(5)).  The  bind  command
+       allows  you  to bind a key or mouse button to a sequence of one or more
        commands.
 
-   Available Commands
        The following commands are supported:
 
-       gotoPage(page)
-              Go to the specified page.
+       about  Open the 'about' dialog.
 
-       gotoPageNoScroll(page)
-              Go to the specified page, with the current relative scroll posi-
-              tion.
+       blockSelectMode
+              Set block selection mode.  In this mode, the selection is a sim-
+              ple rectangle.  Any part of the page can be selected, regardless
+              of the content on the page.
 
-       gotoDest(dest)
-              Go to a named destination.
+       closeSidebar
+              Close the sidebar.
 
-       gotoLastPage
-              Go to the last page in the PDF file.
+       closeSidebarMoveResizeWin
+              Close the sidebar, resizing the window so that the document size
+              doesn't change, and moving the window so that the document stays
+              in the same place on the screen.
 
-       gotoLastPageNoScroll
-              Go to the last page in the PDF file, with the  current  relative
-              scroll position.
+       closeSidebarResizeWin
+              Close the sidebar, resizing the window so that the document size
+              doesn't change.
 
-       nextPage
-              Go to the next page.
+       closeTabOrQuit
+              Close the tab.  If this was the last open tab, close the window.
+              If this was the last window open, quit.
 
-       nextPageNoScroll
-              Go to the next page, with the current relative scroll position.
+       closeWindowOrQuit
+              Close the window.  If this was the last open window, quit.
 
-       prevPage
-              Go to the previous page.
+       continuousMode
+              Switch to continuous view mode.
 
-       prevPageNoScroll
-              Go  to the previous page, with the current relative scroll posi-
-              tion.
+       copy   Copy selected text to the clipboard.
 
-       pageUp Scroll up by one screenful.
+       endPan End a pan operation.
 
-       pageDown
-              Scroll down by one screenful.
+       endSelection
+              End a selection.
 
-       scrollLeft(n)
-              Scroll left by n pixels.
+       find   Set keyboard focus to the 'find' box.
 
-       scrollRight(n)
-              Scroll right by n pixels.
+       findFirst
+              Find the first occurrence of the search string.
 
-       scrollUp(n)
-              Scroll up by n pixels.
+       findNext
+              Find the next occurrence of the search string.
 
-       scrollDown(n)
-              Scroll down by n pixels.
+       findPrevious
+              Find the previous occurrence of the search string.
 
-       scrollUpPrevPage(n)
-              Scroll up by n pixels, moving to the previous page if  appropri-
-              ate.
+       focusToDocWin
+              Set keyboard focus to the main document window.
 
-       scrollDownPrevPage(n)
-              Scroll down by n pixels, moving to the next page if appropriate.
+       focusToPageNum
+              Set keyboard focus to the page number text box.
 
-       scrollToTopEdge
-              Scroll  to  the top edge of the current page, with no horizontal
-              movement.
+       followLink
+              Follow a hyperlink (does nothing if the  mouse  is  not  over  a
+              link).
 
-       scrollToBottomEdge
-              Scroll to the bottom edge of the current page, with no  horizon-
-              tal movement.
+       followLinkInNewTab
+              Follow a hyperlink, opening PDF files in a new tab (does nothing
+              if the mouse is not over a link).  For links to  non-PDF  files,
+              this command is identical to followLink.
 
-       scrollToLeftEdge
-              Scroll  to  the  left edge of the current page, with no vertical
-              movement.
+       followLinkInNewTabNoSel
+              Same  as followLinkInNewTab, but does nothing if there is a non-
+              empty selection.  (This is useful as a mouse button binding.)
 
-       scrollToRightEdge
-              Scroll to the right edge of the current page, with  no  vertical
-              movement.
+       followLinkInNewWin
+              Follow a hyperlink, opening PDF files  in  a  new  window  (does
+              nothing  if the mouse is not over a link).  For links to non-PDF
+              files, this command is identical to followLink.
 
-       scrollToTopLeft
-              Scroll to the top-left corner of the current page.
+       followLinkInNewWinNoSel
+              Same as followLinkInNewWin, but does nothing if there is a  non-
+              empty selection.  (This is useful as a mouse button binding.)
 
-       scrollToBottomRight
-              Scroll to the bottom-right corner of the current page.
+       followLinkNoSel
+              Same  as  followLink,  but  does nothing if there is a non-empty
+              selection.  (This is useful as a mouse button binding.)
 
-       goForward
-              Move forward along the history path.
+       fullScreenMode
+              Go to full-screen mode.
 
        goBackward
               Move backward along the history path.
 
-       zoomPercent(z)
-              Set the zoom factor to z%.
+       goForward
+              Move forward along the history path.
 
-       zoomFitPage
-              Set the zoom factor to fit-page.
+       gotoDest(dest)
+              Go to a named destination.
 
-       zoomFitWidth
-              Set the zoom factor to fit-width.
+       gotoLastPage
+              Go to the last page in the PDF file.
 
-       zoomIn Zoom in - go to the next higher zoom factor.
+       gotoPage(page)
+              Go to the specified page.
 
-       zoomOut
-              Zoom out - go the next lower zoom factor.
+       help   Open the help URL.
 
-       rotateCW
-              Rotate the page 90 degrees clockwise.
+       horizontalContinuousMode
+              Switch to horizontal continuous view mode.
 
-       rotateCCW
-              Rotate the page 90 degrees counterclockwise.
+       linearSelectMode
+              Set linear selection mode.  In this mode, the selection  follows
+              text.  Non-text regions cannot be selected.
 
-       setSelection(pg,ulx,uly,lrx,lry)
-              Set  the selection to the specified coordinates on the specified
-              page.
+       newTab Open an empty new tab.
 
-       continuousMode
-              Go to continuous view mode.
+       newWindow
+              Open an empty new window.
 
-       singlePageMode
-              Go to single-page view mode.
+       nextPage
+              Go to the next page.
 
-       toggleContinuousMode
-              Toggle between continuous and single page view modes.
+       nextPageNoScroll
+              Go to the next page, with the current relative scroll position.
 
-       fullScreenMode
-              Go to full-screen mode.
+       nextTab
+              Switch to the next tab.
 
-       windowMode
-              Go to window (non-full-screen) mode.
+       open   Open a PDF file in this tab, using the open dialog.
 
-       toggleFullScreenMode
-              Toggle between full-screen and window modes.
+       openErrorWindow
+              Open the error window.
 
-       open   Open a PDF file in this window, using the open dialog.
+       openSidebar
+              Open the sidebar.
 
-       openInNewWin
-              Open a PDF file in a new window, using the open dialog.
+       openSidebarMoveResizeWin
+              Open  the sidebar, resizing the window so that the document size
+              doesn't change, and moving the window so that the document stays
+              in the same place on the screen.
 
-       openFile(file)
-              Open a specified PDF file in this window.
+       openSidebarResizeWin
+              Open  the sidebar, resizing the window so that the document size
+              doesn't change.
 
-       openFileInNewWin(file)
-              Open a specified PDF file in a new window.
+       pageDown
+              Scroll down by one screenful.
 
-       openFileAtDest(file,dest)
-              Open a specified PDF file in this window and go to a named  des-
-              tination.
+       pageUp Scroll up by one screenful.
 
-       openFileAtDestInNewWin(file,dest)
-              Open a specified PDF file in a new window and go to a named des-
-              tination.
+       postPopupMenu
+              Display the popup menu.
 
-       reload Reload the current PDF file.
+       prevPage
+              Go to the previous page.
 
-       redraw Redraw the window.
+       prevPageNoScroll
+              Go to the previous page, with the current relative scroll  posi-
+              tion.
 
-       raise  Raise the window to the front.
+       prevTab
+              Switch to the previous tab.
 
-       closeWindow
-              Close the window.  If this was the last open window,  clear  the
-              window, but don't quit from Xpdf.
+       print  Open the 'print' dialog.
 
-       closeWindowOrQuit
-              Close  the  window.  If this was the last open window, quit from
-              Xpdf.
+       quit   Quit from xpdf.
 
+       reload Reload the current PDF file.
+
+       rotateCCW
+              Rotate the page 90 degrees counterclockwise.
+
+       rotateCW
+              Rotate the page 90 degrees clockwise.
+
        run(external-command-string)
-              Run an external command.  The following escapes are  allowed  in
+              Run  an  external command.  The following escapes are allowed in
               the command string:
 
                   %f => PDF file name (or an empty string if no
@@ -577,21 +525,26 @@
                   %k => y coordinate of the mouse pointer
                   %% => %
 
-              The  external  command  string will often contain spaces, so the
+              The external command string will often contain  spaces,  so  the
               whole command must be quoted in the xpdfrc file:
 
                   bind x "run(ls -l)"
 
 
-       openOutline
-              Open the outline pane.
+       saveAs Save PDF via a file requester.
 
-       closeOutline
-              Close the outline pane.
+       saveImage
+              Open the 'save image' dialog.
 
-       toggleOutline
-              Toggle the outline pane between open and closed.
+       scrollDown(n)
+              Scroll down by n pixels.
 
+       scrollDownPrevPage(n)
+              Scroll down by n pixels, moving to the next page if appropriate.
+
+       scrollLeft(n)
+              Scroll left by n pixels.
+
        scrollOutlineDown(n)
               Scroll the outline down by n increments.
 
@@ -598,149 +551,100 @@
        scrollOutlineUp(n)
               Scroll the outline up by n increments.
 
-       focusToDocWin
-              Set the keyboard focus to the main document window.
+       scrollRight(n)
+              Scroll right by n pixels.
 
-       focusToPageNum
-              Set the keyboard focus to the page number text box.
+       scrollToBottomEdge
+              Scroll  to the bottom edge of the current page, with no horizon-
+              tal movement.
 
-       find   Open the 'find' dialog.
+       scrollToBottomRight
+              Scroll to the bottom-right corner of the current page.
 
-       findNext
-              Finds the next occurrence of the search string (no dialog).
+       scrollToLeftEdge
+              Scroll to the left edge of the current page,  with  no  vertical
+              movement.
 
-       print  Open the 'print' dialog.
+       scrollToRightEdge
+              Scroll  to  the right edge of the current page, with no vertical
+              movement.
 
-       about  Open the 'about' dialog.
+       scrollToTopEdge
+              Scroll to the top edge of the current page, with  no  horizontal
+              movement.
 
-       quit   Quit from xpdf.
+       scrollToTopLeft
+              Scroll to the top-left corner of the current page.
 
-       The following commands depend on the current mouse position:
+       scrollUp(n)
+              Scroll up by n pixels.
 
-       startSelection
-              Start a selection, which will be extended as the mouse moves.
+       scrollUpPrevPage(n)
+              Scroll  up by n pixels, moving to the previous page if appropri-
+              ate.
 
-       endSelection
-              End a selection.
+       setSelection(pg,ulx,uly,lrx,lry)
+              Set the selection to the specified coordinates on the  specified
+              page.
 
-       startPan
-              Start a pan, which will scroll the document as the mouse moves
+       sideBySideContinuousMode
+              Switch to side-by-side continuous view mode.
 
-       endPan End a pan.
+       sideBySideSingleMode
+              Switch to side-by-side two-page view mode.
 
-       postPopupMenu
-              Display the popup menu.
+       singlePageMode
+              Switch to single-page view mode.
 
-       followLink
-              Follow a hyperlink (does nothing if the  mouse  is  not  over  a
-              link).
+       startPan
+              Start  a pan operation at the current mouse position, which will
+              scroll the document as the mouse moves.
 
-       followLinkInNewWin
-              Follow  a  hyperlink,  opening  PDF  files in a new window (does
-              nothing if the mouse is not over a link).  For links to  non-PDF
-              files, this command is identical to followLink.
+       startSelection
+              Start a selection at the current mouse position, which  will  be
+              extended as the mouse moves.
 
-       followLinkNoSel
-              Same  as  followLink,  but  does nothing if there is a non-empty
-              selection.  (This is useful as a mouse button binding.)
+       toggleContinuousMode
+              Toggle between continuous and single page view modes.
 
-       followLinkInNewWinNoSel
-              Same as followLinkInNewWin, but does nothing if there is a  non-
-              empty selection.  (This is useful as a mouse button binding.)
+       toggleFullScreenMode
+              Toggle between full-screen and window modes.
 
-   Default Bindings
-       The default mouse bindings are as follows:
+       toggleSelectMode
+              Toggle between block and linear selection mode.
 
-           bind mousePress1    any         startSelection
-           bind mouseRelease1  any         endSelection followLinkNoSel
-           bind mousePress2    any         startPan
-           bind mouseRelease2  any         endPan
-           bind mousePress3    any         postPopupMenu
-           bind mousePress4    any         scrollUpPrevPage(16)
-           bind mousePress5    any         scrollDownNextPage(16)
-           bind mousePress6    any         scrollLeft(16)
-           bind mousePress7    any         scrollRight(16)
+       toggleSidebar
+              Toggle the sidebar between open and closed.
 
-       The default key bindings are as follows:
+       toggleSidebarMoveResizeWin
+              Toggle  the sidebar between open and closed, resizing the window
+              so that the document size doesn't change, and moving the  window
+              so that the document stays in the same place on the screen.
 
-           bind ctrl-home      any         gotoPage(1)
-           bind home           any         scrollToTopLeft
-           bind ctrl-end       any         gotoLastPage
-           bind end            any         scrollToBottomRight
-           bind pgup           any         pageUp
-           bind backspace      any         pageUp
-           bind delete         any         pageUp
-           bind pgdn           any         pageDown
-           bind space          any         pageDown
-           bind left           any         scrollLeft(16)
-           bind right          any         scrollRight(16)
-           bind up             any         scrollUp(16)
-           bind down           any         scrollDown(16)
-           bind o              any         open
-           bind O              any         open
-           bind r              any         reload
-           bind R              any         reload
-           bind f              any         find
-           bind F              any         find
-           bind ctrl-f         any         find
-           bind ctrl-g         any         findNext
-           bind ctrl-p         any         print
-           bind n              scrLockOff  nextPage
-           bind N              scrLockOff  nextPage
-           bind n              scrLockOn   nextPageNoScroll
-           bind N              scrLockOn   nextPageNoScroll
-           bind p              scrLockOff  prevPage
-           bind P              scrLockOff  prevPage
-           bind p              scrLockOn   prevPageNoScroll
-           bind P              scrLockOn   prevPageNoScroll
-           bind v              any         goForward
-           bind b              any         goBackward
-           bind g              any         focusToPageNum
-           bind 0              any         zoomPercent(125)
-           bind +              any         zoomIn
-           bind -              any         zoomOut
-           bind z              any         zoomFitPage
-           bind w              any         zoomFitWidth
-           bind alt-f          any         toggleFullScreenMode
-           bind ctrl-l         any         redraw
-           bind ctrl-w         any         closeWindowOrQuit
-           bind ?              any         about
-           bind q              any         quit
-           bind Q              any         quit
+       toggleSidebarResizeWin
+              Toggle  the sidebar between open and closed, resizing the window
+              so that the document size doesn't change.
 
-       Previous  versions  of  xpdf  included a "viKeys" X resource.  It is no
-       longer available, but the following bindings are equivalent:
+       windowMode
+              Go to window (non-full-screen) mode.
 
-           bind h any scrollLeft(16)
-           bind l any scrollRight(16)
-           bind k any scrollUp(16)
-           bind j any scrollDown(16)
+       zoomFitPage
+              Set the zoom factor to fit-page.
 
+       zoomFitWidth
+              Set the zoom factor to fit-width.
 
-REMOTE SERVER MODE
-       Xpdf can be started in remote server mode by specifying a  server  name
-       (in addition to the file name and page number).  For example:
+       zoomIn Zoom in - go to the next higher zoom factor.
 
-              xpdf -remote myServer file.pdf
+       zoomOut
+              Zoom out - go the next lower zoom factor.
 
-       If  there  is  currently  no  xpdf running in server mode with the name
-       'myServer', a new xpdf window will be opened.  If another command:
+       zoomPercent(z)
+              Set the zoom factor to z%.
 
-              xpdf -remote myServer another.pdf 9
+       zoomToSelection
+              Zoom to the current selection.
 
-       is issued, a new copy of xpdf will not be started.  Instead, the  first
-       xpdf  (the server) will load another.pdf and display page nine.  If the
-       file name is the same:
-
-              xpdf -remote myServer another.pdf 4
-
-       the xpdf server will simply display the specified page.
-
-       The -raise option tells the server to raise its window; it can be spec-
-       ified with or without a file name and page number.
-
-       The -quit option tells the server to close its window and exit.
-
 EXIT CODES
        The Xpdf tools use the following exit codes:
 
@@ -755,14 +659,14 @@
        99     Other error.
 
 AUTHOR
-       The  xpdf  software  and  documentation are copyright 1996-2014 Glyph &
+       The xpdf software and documentation are  copyright  1996-2017  Glyph  &
        Cog, LLC.
 
 SEE ALSO
        pdftops(1), pdftotext(1), pdftohtml(1), pdfinfo(1), pdffonts(1), pdfde-
        tach(1), pdftoppm(1), pdftopng(1), pdfimages(1), xpdfrc(5)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                          xpdf(1)
+                                  10 Aug 2017                          xpdf(1)

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.5
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.5	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.5	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,7 +1,7 @@
-.\" Copyright 2002-2014 Glyph & Cog, LLC
-.TH xpdfrc 5 "28 May 2014"
+.\" Copyright 2002-2017 Glyph & Cog, LLC
+.TH xpdfrc 5 "10 Aug 2017"
 .SH NAME
-xpdfrc \- configuration file for Xpdf tools (version 3.04)
+xpdfrc \- configuration file for Xpdf tools (version 4.00)
 .SH DESCRIPTION
 All of the Xpdf tools read a single configuration file.  If you have a
 .I .xpdfrc
@@ -31,114 +31,6 @@
 directly into the parent config file in place of the
 .I include
 command.  Config files can be nested arbitrarily deeply.
-.SH CHARACTER MAPPING
-.TP
-.BI nameToUnicode " map\-file"
-Specifies a file with the mapping from character names to Unicode.
-This is used to handle PDF fonts that have valid encodings but no
-ToUnicode entry.  Each line of a nameToUnicode file looks like this:
-
-.I "    " hex\-string name
-
-The
-.I hex\-string
-is the Unicode (UCS-2) character index, and
-.I name
-is the corresponding character name.  Multiple nameToUnicode files can
-be used; if a character name is given more than once, the code in the
-last specified file is used.  There is a built-in default
-nameToUnicode table with all of Adobe's standard character names.
-.TP
-.BI cidToUnicode " registry\-ordering map\-file"
-Specifies the file with the mapping from character collection to
-Unicode.  Each line of a cidToUnicode file represents one character:
-
-.I "    " hex\-string
-
-The
-.I hex\-string
-is the Unicode (UCS-2) index for that character.  The first line maps
-CID 0, the second line CID 1, etc.  File size is determined by size of
-the character collection.  Only one file is allowed per character
-collection; the last specified file is used.  There are no built-in
-cidToUnicode mappings.
-.TP
-.BI unicodeToUnicode " font\-name\-substring map\-file"
-This is used to work around PDF fonts which have incorrect Unicode
-information.  It specifies a file which maps from the given
-(incorrect) Unicode indexes to the correct ones.  The mapping will be
-used for any font whose name contains
-.IR font\-name\-substring .
-Each line of a unicodeToUnicode file represents one Unicode character:
-
-.RI "    " in\-hex " " out\-hex1 " " out\-hex2 " ..."
-
-The
-.I in\-hex
-field is an input (incorrect) Unicode index, and the rest of the
-fields are one or more output (correct) Unicode indexes.  Each
-occurrence of
-.I in\-hex
-will be converted to the specified output sequence.
-.TP
-.BI unicodeMap " encoding\-name map\-file"
-Specifies the file with mapping from Unicode to
-.IR encoding\-name .
-These encodings are used for text output (see below).  Each line of a
-unicodeMap file represents a range of one or more Unicode characters
-which maps linearly to a range in the output encoding:
-.nf
-
-.I "    " in\-start\-hex in\-end\-hex out\-start\-hex
-
-.fi
-Entries for single characters can be abbreviated to:
-.nf
-
-.I "    " in\-hex out\-hex
-
-.fi
-The
-.I in\-start\-hex
-and
-.I in\-end\-hex
-fields (or the single
-.I in\-hex
-field) specify the Unicode range.  The
-.I out\-start\-hex
-field (or the
-.I out\-hex
-field) specifies the start of the output encoding range.  The length
-of the
-.I out\-start\-hex
-(or
-.IR out\-hex )
-string determines the length of the output characters (e.g., UTF-8
-uses different numbers of bytes to represent characters in different
-ranges).  Entries must be given in increasing Unicode order.  Only one
-file is allowed per encoding; the last specified file is used.  The
-.IR Latin1 ,
-.IR ASCII7 ,
-.IR Symbol ,
-.IR ZapfDingbats ,
-.IR UTF-8 ,
-and
-.I UCS-2
-encodings are predefined.
-.TP
-.BI cMapDir " registry\-ordering dir"
-Specifies a search directory,
-.IR dir ,
-for CMaps for the
-.I registry\-ordering
-character collection.  There can be multiple directories for a
-particular collection.  There are no default CMap directories.
-.TP
-.BI toUnicodeDir " dir"
-Specifies a search directory,
-.IR dir ,
-for ToUnicode CMaps.  There can be multiple ToUnicode directories.
-There are no default ToUnicode directories.
 .SH GENERAL FONT CONFIGURATION
 .TP
 .BI fontFile " PDF\-font\-name font\-file"
@@ -195,7 +87,7 @@
 is used (without embedding) in a PDF file, it will be translated to
 the PostScript font
 .IR PS\-font\-name ,
-which is assumbed to be resident in the printer.  The writing mode
+which is assumed to be resident in the printer.  The writing mode
 must be either \'H' for horizontal or \'V' for vertical.  The resident
 font is assumed to use the specified encoding (which must have been
 defined with the unicodeMap command).
@@ -208,7 +100,7 @@
 writing mode is used (without embedding) in a PDF file, the PostScript
 font,
 .IR PS\-font\-name ,
-is substituted for it.  The substituted font is assumbed to be
+is substituted for it.  The substituted font is assumed to be
 resident in the printer.  The writing mode must be either \'H' for
 horizontal or \'V' for vertical.  The resident font is assumed to use
 the specified encoding (which must have been defined with the
@@ -268,7 +160,7 @@
 .TP
 .BR psExpandSmaller " yes | no"
 If set to "yes", PDF pages smaller than the PostScript imageable area
-are expanded to fill the imageable area.  Otherwise, no scalling is
+are expanded to fill the imageable area.  Otherwise, no scaling is
 done on smaller pages.  This defaults to "no".
 .TP
 .BR psShrinkLarger " yes | no"
@@ -287,7 +179,7 @@
 pagedevice entry.  This tells duplex-capable printers to enable
 duplexing.  This defaults to "no".
 .TP
-.BR psLevel " level1 | level1sep | level2 | level2sep | level3 | level3Sep"
+.BR psLevel " level1 | level1sep | level2 | level2gray | level2sep | level3 | level3gray | level3Sep"
 Sets the PostScript level to generate.  This defaults to "level2".
 .TP
 .BR psPreload " yes | no"
@@ -341,6 +233,12 @@
 If set to "yes", all PostScript output will be rasterized.  This
 defaults to "no".
 .TP
+.BR psNeverRasterize " yes | no"
+If set to "yes", PostScript output will never be rasterized.  This
+will likely result in incorrect output for PDF files that use
+transparency.  (If both psAlwaysRasterize and psNeverRasterize are set
+to "yes", the psAlwaysRasterize setting wins.)  This defaults to "no".
+.TP
 .BI psFile " file\-or\-command"
 Sets the default PostScript file or print command for xpdf.  Commands
 start with a \'|' character; anything else is a file.  If the file
@@ -350,7 +248,7 @@
 .TP
 .BI fontDir " dir"
 See the description above, in the DISPLAY FONTS section.
-.SH TEXT CONTROL
+.SH TEXT CONTROL AND CHARACTER MAPPING
 .TP
 .BI textEncoding " encoding\-name"
 Sets the encoding to use for text output.  (This can be overridden
@@ -383,25 +281,139 @@
 characters after the first 50000 per page, avoiding extremely slow run
 times for PDF files that use special fonts to do shading or
 cross-hatching.  This defaults to "yes".
-.SH MISCELLANEOUS SETTINGS
 .TP
-.BR initialZoom " \fIpercentage\fR | page | width"
-Sets the initial zoom factor.  A number specifies a zoom percentage,
-where 100 means 72 dpi.  You may also specify \'page', to fit the page
-to the window size, or \'width', to fit the page width to the window
-width.
+.BI nameToUnicode " map\-file"
+Specifies a file with the mapping from character names to Unicode.
+This is used to handle PDF fonts that have valid encodings but no
+ToUnicode entry.  Each line of a nameToUnicode file looks like this:
+
+.I "    " hex\-string name
+
+The
+.I hex\-string
+is the Unicode (UCS-2) character index, and
+.I name
+is the corresponding character name.  Multiple nameToUnicode files can
+be used; if a character name is given more than once, the code in the
+last specified file is used.  There is a built-in default
+nameToUnicode table with all of Adobe's standard character names.
 .TP
-.BR continuousView " yes | no"
-If set to "yes", xpdf will start in continuous view mode, i.e., with
-one vertical screoll bar for the whole document.  This defaults to
-"no".
+.BI cidToUnicode " registry\-ordering map\-file"
+Specifies the file with the mapping from character collection to
+Unicode.  Each line of a cidToUnicode file represents one character:
+
+.I "    " hex\-string
+
+The
+.I hex\-string
+is the Unicode (UCS-2) index for that character.  The first line maps
+CID 0, the second line CID 1, etc.  File size is determined by size of
+the character collection.  Only one file is allowed per character
+collection; the last specified file is used.  There are no built-in
+cidToUnicode mappings.
 .TP
-.BR enableFreeType " yes | no"
-Enables or disables use of FreeType (a TrueType / Type 1 font
-rasterizer).  This is only relevant if the Xpdf tools were built with
-FreeType support.  ("enableFreeType" replaces the old
-"freetypeControl" option.)  This option defaults to "yes".
+.BI unicodeToUnicode " font\-name\-substring map\-file"
+This is used to work around PDF fonts which have incorrect Unicode
+information.  It specifies a file which maps from the given
+(incorrect) Unicode indexes to the correct ones.  The mapping will be
+used for any font whose name contains
+.IR font\-name\-substring .
+Each line of a unicodeToUnicode file represents one Unicode character:
+
+.RI "    " in\-hex " " out\-hex1 " " out\-hex2 " ..."
+
+The
+.I in\-hex
+field is an input (incorrect) Unicode index, and the rest of the
+fields are one or more output (correct) Unicode indexes.  Each
+occurrence of
+.I in\-hex
+will be converted to the specified output sequence.
 .TP
+.BI unicodeMap " encoding\-name map\-file"
+Specifies the file with mapping from Unicode to
+.IR encoding\-name .
+These encodings are used for text output (see below).  Each line of a
+unicodeMap file represents a range of one or more Unicode characters
+which maps linearly to a range in the output encoding:
+.nf
+
+.I "    " in\-start\-hex in\-end\-hex out\-start\-hex
+
+.fi
+Entries for single characters can be abbreviated to:
+.nf
+
+.I "    " in\-hex out\-hex
+
+.fi
+The
+.I in\-start\-hex
+and
+.I in\-end\-hex
+fields (or the single
+.I in\-hex
+field) specify the Unicode range.  The
+.I out\-start\-hex
+field (or the
+.I out\-hex
+field) specifies the start of the output encoding range.  The length
+of the
+.I out\-start\-hex
+(or
+.IR out\-hex )
+string determines the length of the output characters (e.g., UTF-8
+uses different numbers of bytes to represent characters in different
+ranges).  Entries must be given in increasing Unicode order.  Only one
+file is allowed per encoding; the last specified file is used.  The
+.IR Latin1 ,
+.IR ASCII7 ,
+.IR Symbol ,
+.IR ZapfDingbats ,
+.IR UTF-8 ,
+and
+.I UCS-2
+encodings are predefined.
+.TP
+.BI cMapDir " registry\-ordering dir"
+Specifies a search directory,
+.IR dir ,
+for CMaps for the
+.I registry\-ordering
+character collection.  There can be multiple directories for a
+particular collection.  There are no default CMap directories.
+.TP
+.BI toUnicodeDir " dir"
+Specifies a search directory,
+.IR dir ,
+for ToUnicode CMaps.  There can be multiple ToUnicode directories.
+There are no default ToUnicode directories.
+.TP
+.BI mapNumericCharNames " yes | no"
+If set to "yes", the Xpdf tools will attempt to map various numeric
+character names sometimes used in font subsets.  In some cases this
+leads to usable text, and in other cases it leads to gibberish --
+there is no way for Xpdf to tell.  This defaults to "yes".
+.TP
+.BI mapUnknownCharNames " yes | no"
+If set to "yes", and mapNumericCharNames is set to "no", the Xpdf
+tools will apply a simple pass-through mapping (Unicode index =
+character code) for all unrecognized glyph names.  (For CID fonts,
+setting mapNumericCharNames to "no" is unnecessary.)  In some cases,
+this leads to usable text, and in other cases it leads to gibberish --
+there is no way for Xpdf to tell.  This defaults to "no".
+.TP
+.BI mapExtTrueTypeFontsViaUnicode " yes | no"
+When rasterizing text using an external TrueType font, there are two
+options for handling character codes.  If
+mapExtTrueTypeFontsViaUnicode is set to "yes", Xpdf will use the font
+encoding/ToUnicode info to map character codes to Unicode, and then
+use the font's Unicode cmap to map Unicode to GIDs.  If
+mapExtTrueTypeFontsViaUnicode is set to "no", Xpdf will assume the
+character codes are GIDs (i.e., use an identity mapping).  This
+defaults to "yes".
+.SH RASTERIZER SETTINGS
+.TP
 .BR enableFreeType " yes | no"
 Enables or disables use of FreeType (a TrueType / Type 1 font
 rasterizer).  This is only relevant if the Xpdf tools were built with
@@ -428,11 +440,15 @@
 this is "no", printed bitmaps will not be antialiased.  This defaults
 to "no".
 .TP
-.BR strokeAdjust " yes | no"
-Enables or disables stroke adjustment.  Stroke adjustment moves
-horizontal and vertical lines by up to half a pixel to make them look
-"cleaner" when vector anti-aliasing is enabled.  This defaults to
-"yes".
+.BR strokeAdjust " yes | no | cad"
+Sets the stroke adjustment mode.  If set to "no", no stroke adjustment
+will be done.  If set to "yes", normal stroke adjustment will be done:
+horizontal and vertical lines will be moved by up to half a pixel to
+make them look cleaner when vector anti-aliasing is enabled.  If set
+to "cad", a slightly different stroke adjustment algorithm will be
+used to ensure that lines of the same original width will always have
+the same adjusted width (at the expense of allowing gaps and overlaps
+between adjacent lines).  This defaults to "yes".
 .TP
 .BR screenType " dispersed | clustered | stochasticClustered"
 Sets the halftone screen type, which will be used when generating a
@@ -474,15 +490,76 @@
 rasterization to handle transparency).  The default value is 0 (no
 minimum).
 .TP
-.BI drawAnnotations " yes | no"
-If set to "no", annotations will not be drawn or printed.  The default
-value is "yes".
+.BI enablePathSimplification " yes | no"
+If set to "yes", simplify paths by removing points where it won't make
+a significant difference to the shape.  The default value is "no".
 .TP
 .BI overprintPreview " yes | no"
 If set to "yes", generate overprint preview output, honoring the
 OP/op/OPM settings in the PDF file.  Ignored for non-CMYK output.  The
 default value is "no".
+.SH VIEWER SETTINGS
+These settings only apply to the Xpdf GUI PDF viewer.
 .TP
+.BR initialZoom " \fIpercentage\fR | page | width"
+Sets the initial zoom factor.  A number specifies a zoom percentage,
+where 100 means 72 dpi.  You may also specify \'page', to fit the page
+to the window size, or \'width', to fit the page width to the window
+width.
+.TP
+.BI defaultFitZoom " percentage"
+If xpdf is started with fit-page or fit-width zoom and no window
+geometry, it will calculate a desired window size based on the PDF
+page size and this defaultFitZoom value.  I.e., the window size will
+be chosen such that exactly one page will fit in the window at this
+zoom factor (which must be a percentage).  The default value is
+based on the screen resolution.
+.TP
+.BI initialSidebarState " yes | no"
+If set to "yes", xpdf opens with the sidebar (tabs, outline, etc.)
+visible.  If set to "no", xpdf opens with the sidebar collapsed.  The
+default is "no".
+.TP
+.BI paperColor " color"
+Set the "paper color", i.e., the background of the page display.  The
+color can be #RRGGBB (hexadecimal) or a named color.  This option will
+not work well with PDF files that do things like filling in white
+behind the text.
+.TP
+.BI matteColor " color"
+Set the matte color, i.e., the color used for background outside the
+actual page area.  The color can be #RRGGBB (hexadecimal) or a named
+color.
+.TP
+.BI fullScreenMatteColor " color"
+Set the matte color for full-screen mode.  The color can be #RRGGBB
+(hexadecimal) or a named color.
+.TP
+.BI popupMenuCmd " title command ..."
+Add a command to the popup menu.
+.I Title
+is the text to be displayed in the menu.
+.I Command
+is an Xpdf command (see the COMMANDS section of the
+.BR xpdf (1)
+man page for details).  Multiple commands are separated by whitespace.
+.TP
+.BI maxTileWidth " pixels"
+Set the maximum width of tiles to be used by xpdf when rasterizing
+pages.  This defaults to 1500.
+.TP
+.BI maxTileHeight " pixels"
+Set the maximum height of tiles to be used by xpdf when rasterizing
+pages.  This defaults to 1500.
+.TP
+.BI tileCacheSize " tiles"
+Set the maximum number of tiles to be cached by xpdf when rasterizing
+pages.  This defaults to 10.
+.TP
+.BI workerThreads " numThreads"
+Set the number of worker threads to be used by xpdf when rasterizing
+pages.  This defaults to 1.
+.TP
 .BI launchCommand " command"
 Sets the command executed when you click on a "launch"-type link.  The
 intent is for the command to be a program/script which determines the
@@ -492,45 +569,11 @@
 this is unset, and Xpdf will simply try to execute the file (after
 prompting the user).
 .TP
-.BI urlCommand " command"
-Sets the command executed when you click on a URL link.  The string
-"%s" will be replaced with the URL.  (See the example below.)  This
-has no default value.
-.TP
 .BI movieCommand " command"
 Sets the command executed when you click on a movie annotation.  The
 string "%s" will be replaced with the movie file name.  This has no
 default value.
 .TP
-.BI mapNumericCharNames " yes | no"
-If set to "yes", the Xpdf tools will attempt to map various numeric
-character names sometimes used in font subsets.  In some cases this
-leads to usable text, and in other cases it leads to gibberish --
-there is no way for Xpdf to tell.  This defaults to "yes".
-.TP
-.BI mapUnknownCharNames " yes | no"
-If set to "yes", and mapNumericCharNames is set to "no", the Xpdf
-tools will apply a simple pass-through mapping (Unicode index =
-character code) for all unrecognized glyph names.  (For CID fonts,
-setting mapNumericCharNames to "no" is unnecessary.)  In some cases,
-this leads to usable text, and in other cases it leads to gibberish --
-there is no way for Xpdf to tell.  This defaults to "no".
-.TP
-.BI mapExtTrueTypeFontsViaUnicode " yes | no"
-When rasterizing text using an external TrueType font, there are two
-options for handling character codes.  If
-mapExtTrueTypeFontsViaUnicode is set to "yes", Xpdf will use the font
-encoding/ToUnicode info to map character codes to Unicode, and then
-use the font's Unicode cmap to map Unicode to GIDs.  If
-mapExtTrueTypeFontsViaUnicode is set to "no", Xpdf will assume the
-character codes are GIDs (i.e., use an identity mapping).  This
-defaults to "yes".
-.TP
-.BI enableXFA " yes | no"
-If set to "yes", an XFA form (if present) will be rendered in place of
-an AcroForm.  If "no", an XFA form will never be rendered.  This
-defaults to "yes".
-.TP
 .BI bind " modifiers-key context command ..."
 Add a key or mouse button binding.
 .I Modifiers
@@ -551,6 +594,7 @@
     return
     enter
     backspace
+    esc
     insert
     delete
     home
@@ -561,6 +605,7 @@
     f1 .. f35                       (function keys)
     mousePress1 .. mousePress7      (mouse buttons)
     mouseRelease1 .. mouseRelease7  (mouse buttons)
+    mouseClick1 .. mouseClick7      (mouse buttons)
 
 .fi
 .I Context
@@ -607,7 +652,21 @@
 useful to remove default key bindings before establishing new ones
 (e.g., if the default key binding is given for "any" context, and you
 want to create new key bindings for multiple contexts).
+.SH MISCELLANEOUS SETTINGS
 .TP
+.BI drawAnnotations " yes | no"
+If set to "no", annotations will not be drawn or printed.  The default
+value is "yes".
+.TP
+.BI drawFormFields " yes | no"
+If set to "no", form fields will not be drawn or printed.  The default
+value is "yes".
+.TP
+.BI enableXFA " yes | no"
+If set to "yes", an XFA form (if present) will be rendered in place of
+an AcroForm.  If "no", an XFA form will never be rendered.  This
+defaults to "yes".
+.TP
 .BI printCommands " yes | no"
 If set to "yes", drawing commands are printed as they're executed
 (useful for debugging).  This defaults to "no".
@@ -680,7 +739,7 @@
 This is the user's configuration file.  If it exists, it will be read
 in place of the system-wide file.
 .SH AUTHOR
-The Xpdf software and documentation are copyright 1996-2014 Glyph &
+The Xpdf software and documentation are copyright 1996-2017 Glyph &
 Cog, LLC.
 .SH "SEE ALSO"
 .BR xpdf (1),
@@ -694,4 +753,4 @@
 .BR pdftopng (1),
 .BR pdfimages (1)
 .br
-.B http://www.foolabs.com/xpdf/
+.B http://www.xpdfreader.com/

Modified: trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.cat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.cat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/doc/xpdfrc.cat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,9 +1,9 @@
-xpdfrc(5)                                                            xpdfrc(5)
+xpdfrc(5)                     File Formats Manual                    xpdfrc(5)
 
 
 
 NAME
-       xpdfrc - configuration file for Xpdf tools (version 3.04)
+       xpdfrc - configuration file for Xpdf tools (version 4.00)
 
 DESCRIPTION
        All  of the Xpdf tools read a single configuration file.  If you have a
@@ -30,85 +30,6 @@
               into the parent config file in place  of  the  include  command.
               Config files can be nested arbitrarily deeply.
 
-CHARACTER MAPPING
-       nameToUnicode map-file
-              Specifies  a  file with the mapping from character names to Uni-
-              code.  This is used to handle PDF fonts that have  valid  encod-
-              ings  but no ToUnicode entry.  Each line of a nameToUnicode file
-              looks like this:
-
-                   hex-string name
-
-              The hex-string is the Unicode (UCS-2) character index, and  name
-              is  the  corresponding  character  name.  Multiple nameToUnicode
-              files can be used; if a character name is given more than  once,
-              the  code in the last specified file is used.  There is a built-
-              in default nameToUnicode table  with  all  of  Adobe's  standard
-              character names.
-
-       cidToUnicode registry-ordering map-file
-              Specifies the file with the mapping from character collection to
-              Unicode.  Each line of a cidToUnicode file represents one  char-
-              acter:
-
-                   hex-string
-
-              The  hex-string is the Unicode (UCS-2) index for that character.
-              The first line maps CID 0, the second line  CID  1,  etc.   File
-              size  is  determined  by size of the character collection.  Only
-              one file is allowed per character collection; the last specified
-              file is used.  There are no built-in cidToUnicode mappings.
-
-       unicodeToUnicode font-name-substring map-file
-              This  is used to work around PDF fonts which have incorrect Uni-
-              code information.  It specifies a file which maps from the given
-              (incorrect)  Unicode  indexes  to the correct ones.  The mapping
-              will be used for any font  whose  name  contains  font-name-sub-
-              string.   Each  line  of  a unicodeToUnicode file represents one
-              Unicode character:
-
-                  in-hex out-hex1 out-hex2 ...
-
-              The in-hex field is an input (incorrect) Unicode index, and  the
-              rest  of  the  fields  are  one or more output (correct) Unicode
-              indexes.  Each occurrence of in-hex will  be  converted  to  the
-              specified output sequence.
-
-       unicodeMap encoding-name map-file
-              Specifies  the  file with mapping from Unicode to encoding-name.
-              These encodings are used for text output (see below).  Each line
-              of  a  unicodeMap file represents a range of one or more Unicode
-              characters which maps linearly to a range in the  output  encod-
-              ing:
-
-                   in-start-hex in-end-hex out-start-hex
-
-              Entries for single characters can be abbreviated to:
-
-                   in-hex out-hex
-
-              The  in-start-hex  and  in-end-hex  fields (or the single in-hex
-              field) specify the Unicode range.  The out-start-hex  field  (or
-              the  out-hex  field)  specifies the start of the output encoding
-              range.  The length of  the  out-start-hex  (or  out-hex)  string
-              determines the length of the output characters (e.g., UTF-8 uses
-              different numbers of bytes to represent characters in  different
-              ranges).   Entries  must  be  given in increasing Unicode order.
-              Only one file is allowed per encoding; the last  specified  file
-              is  used.   The Latin1, ASCII7, Symbol, ZapfDingbats, UTF-8, and
-              UCS-2 encodings are predefined.
-
-       cMapDir registry-ordering dir
-              Specifies a search  directory,  dir,  for  CMaps  for  the  reg-
-              istry-ordering  character  collection.   There  can  be multiple
-              directories for a particular collection.  There are  no  default
-              CMap directories.
-
-       toUnicodeDir dir
-              Specifies  a  search directory, dir, for ToUnicode CMaps.  There
-              can be multiple ToUnicode directories.   There  are  no  default
-              ToUnicode directories.
-
 GENERAL FONT CONFIGURATION
        fontFile PDF-font-name font-file
               Maps  a  PDF font, PDF-font-name, to a font for display or Post-
@@ -149,17 +70,17 @@
        psResidentFont16 PDF-font-name wMode PS-font-name encoding
               When the 16-bit (CID) font PDF-font-name with writing mode wMode
               is used (without embedding) in a PDF file, it will be translated
-              to  the  PostScript  font  PS-font-name, which is assumbed to be
-              resident in the printer.  The writing mode must  be  either  'H'
-              for  horizontal  or  'V'  for  vertical.   The  resident font is
-              assumed to use the specified  encoding  (which  must  have  been
-              defined with the unicodeMap command).
+              to the PostScript font PS-font-name, which is assumed to be res-
+              ident in the printer.  The writing mode must be either  'H'  for
+              horizontal or 'V' for vertical.  The resident font is assumed to
+              use the specified encoding (which must have  been  defined  with
+              the unicodeMap command).
 
        psResidentFontCC registry-ordering wMode PS-font-name encoding
               When  a  16-bit (CID) font using the registry-ordering character
               collection and wMode writing mode is used (without embedding) in
               a  PDF  file,  the PostScript font, PS-font-name, is substituted
-              for it.  The substituted font is assumbed to be resident in  the
+              for it.  The substituted font is assumed to be resident  in  the
               printer.   The writing mode must be either 'H' for horizontal or
               'V' for vertical.  The resident font is assumed to use the spec-
               ified encoding (which must have been defined with the unicodeMap
@@ -219,7 +140,7 @@
        psExpandSmaller yes | no
               If set to "yes", PDF pages smaller than the PostScript imageable
               area are expanded to fill the  imageable  area.   Otherwise,  no
-              scalling is done on smaller pages.  This defaults to "no".
+              scaling is done on smaller pages.  This defaults to "no".
 
        psShrinkLarger yes | no
               If  set  to  yes, PDF pages larger than the PostScript imageable
@@ -237,47 +158,48 @@
               pagedevice  entry.  This tells duplex-capable printers to enable
               duplexing.  This defaults to "no".
 
-       psLevel level1 | level1sep | level2 | level2sep | level3 | level3Sep
+       psLevel level1 | level1sep | level2 | level2gray | level2sep | level3 |
+       level3gray | level3Sep
               Sets  the  PostScript  level  to  generate.   This  defaults  to
               "level2".
 
        psPreload yes | no
-              If  set  to "yes", PDF forms are converted to PS procedures, and
-              image data is preloaded.  This uses more  memory  in  the  Post-
+              If set to "yes", PDF forms are converted to PS  procedures,  and
+              image  data  is  preloaded.   This uses more memory in the Post-
               Script interpreter, but generates significantly smaller PS files
               in situations where, e.g., the same image is drawn on every page
               of a long document.  This defaults to "no".
 
        psOPI yes | no
-              If  set  to  "yes",  generates  PostScript  OPI comments for all
-              images and forms which have OPI  information.   This  option  is
+              If set to "yes",  generates  PostScript  OPI  comments  for  all
+              images  and  forms  which  have OPI information.  This option is
               only available if the Xpdf tools were compiled with OPI support.
               This defaults to "no".
 
        psASCIIHex yes | no
-              If set to "yes", the ASCIIHexEncode filter will be used  instead
+              If  set to "yes", the ASCIIHexEncode filter will be used instead
               of ASCII85Encode for binary data.  This defaults to "no".
 
        psLZW yes | no
-              If  set to "yes", the LZWEncode filter will be used for lossless
+              If set to "yes", the LZWEncode filter will be used for  lossless
               compression in PostScript output; if set to "no", the RunLength-
-              Encode  filter  will be used instead.  LZW generates better com-
-              pression (smaller PS files), but may not be  supported  by  some
+              Encode filter will be used instead.  LZW generates  better  com-
+              pression  (smaller  PS  files), but may not be supported by some
               printers.  This defaults to "yes".
 
        psUncompressPreloadedImages yes | no
-              If  set  to  "yes", all preloaded images in PS files will uncom-
+              If set to "yes", all preloaded images in PS  files  will  uncom-
               pressed.  If set to "no", the original compressed images will be
-              used  when possible.  The "yes" setting is useful to work around
+              used when possible.  The "yes" setting is useful to work  around
               certain buggy PostScript interpreters.  This defaults to "no".
 
        psMinLineWidth float
-              Set the minimum line width, in points,  for  PostScript  output.
+              Set  the  minimum  line width, in points, for PostScript output.
               The default value is 0 (no minimum).
 
        psRasterResolution float
-              Set  the  resolution (in dpi) for rasterized pages in PostScript
-              output.  (Pdftops will rasterize pages which use  transparency.)
+              Set the resolution (in dpi) for rasterized pages  in  PostScript
+              output.   (Pdftops will rasterize pages which use transparency.)
               This defaults to 300.
 
        psRasterMono yes | no
@@ -285,8 +207,8 @@
               (8-bit gray) instead of color.  This defaults to "no".
 
        psRasterSliceSize pixels
-              When rasterizing pages, pdftops splits the page into  horizontal
-              "slices",  to  limit memory usage.  This option sets the maximum
+              When  rasterizing pages, pdftops splits the page into horizontal
+              "slices", to limit memory usage.  This option sets  the  maximum
               slice size, in pixels.  This defaults to 20000000 (20 million).
 
        psAlwaysRasterize yes | no
@@ -293,25 +215,32 @@
               If set to "yes", all PostScript output will be rasterized.  This
               defaults to "no".
 
+       psNeverRasterize yes | no
+              If set to "yes", PostScript output  will  never  be  rasterized.
+              This  will  likely result in incorrect output for PDF files that
+              use transparency.  (If both psAlwaysRasterize and psNeverRaster-
+              ize are set to "yes", the psAlwaysRasterize setting wins.)  This
+              defaults to "no".
+
        psFile file-or-command
-              Sets  the  default  PostScript  file  or print command for xpdf.
-              Commands start with a '|' character; anything else  is  a  file.
-              If  the  file name or command contains spaces it must be quoted.
-              This defaults to unset, which tells xpdf to generate a  name  of
+              Sets the default PostScript file  or  print  command  for  xpdf.
+              Commands  start  with  a '|' character; anything else is a file.
+              If the file name or command contains spaces it must  be  quoted.
+              This  defaults  to unset, which tells xpdf to generate a name of
               the form <file>.ps for a PDF file <file>.pdf.
 
        fontDir dir
               See the description above, in the DISPLAY FONTS section.
 
-TEXT CONTROL
+TEXT CONTROL AND CHARACTER MAPPING
        textEncoding encoding-name
               Sets the encoding to use for text output.  (This can be overrid-
-              den with the "-enc" switch on the  command  line.)   The  encod-
-              ing-name  must  be  defined  with  the  unicodeMap  command (see
+              den  with  the  "-enc"  switch on the command line.)  The encod-
+              ing-name must  be  defined  with  the  unicodeMap  command  (see
               above).  This defaults to "Latin1".
 
        textEOL unix | dos | mac
-              Sets the end-of-line convention to use  for  text  output.   The
+              Sets  the  end-of-line  convention  to use for text output.  The
               options are:
 
                   unix = LF
@@ -318,39 +247,126 @@
                   dos  = CR+LF
                   mac  = CR
 
-              (This  can  be  overridden with the "-eol" switch on the command
-              line.)  The default value is based on  the  OS  where  xpdf  and
+              (This can be overridden with the "-eol" switch  on  the  command
+              line.)   The  default  value  is  based on the OS where xpdf and
               pdftotext were built.
 
        textPageBreaks yes | no
-              If  set  to "yes", text extraction will insert page breaks (form
+              If set to "yes", text extraction will insert page  breaks  (form
               feed characters) between pages.  This defaults to "yes".
 
        textKeepTinyChars yes | no
-              If set to "yes", text extraction will keep all  characters.   If
-              set  to  "no", text extraction will discard tiny (smaller than 3
-              point) characters after  the  first  50000  per  page,  avoiding
+              If  set  to "yes", text extraction will keep all characters.  If
+              set to "no", text extraction will discard tiny (smaller  than  3
+              point)  characters  after  the  first  50000  per page, avoiding
               extremely slow run times for PDF files that use special fonts to
               do shading or cross-hatching.  This defaults to "yes".
 
-MISCELLANEOUS SETTINGS
-       initialZoom percentage | page | width
-              Sets the initial zoom factor.  A number specifies  a  zoom  per-
-              centage,  where  100 means 72 dpi.  You may also specify 'page',
-              to fit the page to the window size, or 'width', to fit the  page
-              width to the window width.
+       nameToUnicode map-file
+              Specifies  a  file with the mapping from character names to Uni-
+              code.  This is used to handle PDF fonts that have  valid  encod-
+              ings  but no ToUnicode entry.  Each line of a nameToUnicode file
+              looks like this:
 
-       continuousView yes | no
-              If  set to "yes", xpdf will start in continuous view mode, i.e.,
-              with one vertical screoll bar  for  the  whole  document.   This
+                   hex-string name
+
+              The hex-string is the Unicode (UCS-2) character index, and  name
+              is  the  corresponding  character  name.  Multiple nameToUnicode
+              files can be used; if a character name is given more than  once,
+              the  code in the last specified file is used.  There is a built-
+              in default nameToUnicode table  with  all  of  Adobe's  standard
+              character names.
+
+       cidToUnicode registry-ordering map-file
+              Specifies the file with the mapping from character collection to
+              Unicode.  Each line of a cidToUnicode file represents one  char-
+              acter:
+
+                   hex-string
+
+              The  hex-string is the Unicode (UCS-2) index for that character.
+              The first line maps CID 0, the second line  CID  1,  etc.   File
+              size  is  determined  by size of the character collection.  Only
+              one file is allowed per character collection; the last specified
+              file is used.  There are no built-in cidToUnicode mappings.
+
+       unicodeToUnicode font-name-substring map-file
+              This  is used to work around PDF fonts which have incorrect Uni-
+              code information.  It specifies a file which maps from the given
+              (incorrect)  Unicode  indexes  to the correct ones.  The mapping
+              will be used for any font  whose  name  contains  font-name-sub-
+              string.   Each  line  of  a unicodeToUnicode file represents one
+              Unicode character:
+
+                  in-hex out-hex1 out-hex2 ...
+
+              The in-hex field is an input (incorrect) Unicode index, and  the
+              rest  of  the  fields  are  one or more output (correct) Unicode
+              indexes.  Each occurrence of in-hex will  be  converted  to  the
+              specified output sequence.
+
+       unicodeMap encoding-name map-file
+              Specifies  the  file with mapping from Unicode to encoding-name.
+              These encodings are used for text output (see below).  Each line
+              of  a  unicodeMap file represents a range of one or more Unicode
+              characters which maps linearly to a range in the  output  encod-
+              ing:
+
+                   in-start-hex in-end-hex out-start-hex
+
+              Entries for single characters can be abbreviated to:
+
+                   in-hex out-hex
+
+              The  in-start-hex  and  in-end-hex  fields (or the single in-hex
+              field) specify the Unicode range.  The out-start-hex  field  (or
+              the  out-hex  field)  specifies the start of the output encoding
+              range.  The length of  the  out-start-hex  (or  out-hex)  string
+              determines the length of the output characters (e.g., UTF-8 uses
+              different numbers of bytes to represent characters in  different
+              ranges).   Entries  must  be  given in increasing Unicode order.
+              Only one file is allowed per encoding; the last  specified  file
+              is  used.   The Latin1, ASCII7, Symbol, ZapfDingbats, UTF-8, and
+              UCS-2 encodings are predefined.
+
+       cMapDir registry-ordering dir
+              Specifies a search  directory,  dir,  for  CMaps  for  the  reg-
+              istry-ordering  character  collection.   There  can  be multiple
+              directories for a particular collection.  There are  no  default
+              CMap directories.
+
+       toUnicodeDir dir
+              Specifies  a  search directory, dir, for ToUnicode CMaps.  There
+              can be multiple ToUnicode directories.   There  are  no  default
+              ToUnicode directories.
+
+       mapNumericCharNames yes | no
+              If  set  to  "yes",  the  Xpdf tools will attempt to map various
+              numeric character names sometimes used in font subsets.  In some
+              cases  this leads to usable text, and in other cases it leads to
+              gibberish -- there is no way for Xpdf to tell.  This defaults to
+              "yes".
+
+       mapUnknownCharNames yes | no
+              If  set  to  "yes",  and mapNumericCharNames is set to "no", the
+              Xpdf tools will apply a  simple  pass-through  mapping  (Unicode
+              index  = character code) for all unrecognized glyph names.  (For
+              CID fonts, setting mapNumericCharNames to "no" is  unnecessary.)
+              In  some cases, this leads to usable text, and in other cases it
+              leads to gibberish -- there is no way for Xpdf  to  tell.   This
               defaults to "no".
 
-       enableFreeType yes | no
-              Enables  or  disables  use of FreeType (a TrueType / Type 1 font
-              rasterizer).  This is only relevant if the Xpdf tools were built
-              with  FreeType  support.   ("enableFreeType"  replaces  the  old
-              "freetypeControl" option.)  This option defaults to "yes".
+       mapExtTrueTypeFontsViaUnicode yes | no
+              When rasterizing text using an external TrueType font, there are
+              two options for handling character  codes.   If  mapExtTrueType-
+              FontsViaUnicode  is  set to "yes", Xpdf will use the font encod-
+              ing/ToUnicode info to map character codes to Unicode,  and  then
+              use  the font's Unicode cmap to map Unicode to GIDs.  If mapExt-
+              TrueTypeFontsViaUnicode is set to "no",  Xpdf  will  assume  the
+              character  codes are GIDs (i.e., use an identity mapping).  This
+              defaults to "yes".
 
+RASTERIZER SETTINGS
        enableFreeType yes | no
               Enables or disables use of FreeType (a TrueType /  Type  1  font
               rasterizer).  This is only relevant if the Xpdf tools were built
@@ -377,57 +393,63 @@
               settings).  If  this  is  "no",  printed  bitmaps  will  not  be
               antialiased.  This defaults to "no".
 
-       strokeAdjust yes | no
-              Enables  or disables stroke adjustment.  Stroke adjustment moves
-              horizontal and vertical lines by up to half a pixel to make them
-              look  "cleaner"  when  vector  anti-aliasing  is  enabled.  This
-              defaults to "yes".
+       strokeAdjust yes | no | cad
+              Sets  the  stroke  adjustment  mode.   If set to "no", no stroke
+              adjustment will be done.  If set to "yes", normal stroke adjust-
+              ment  will  be done: horizontal and vertical lines will be moved
+              by up to half a pixel to make  them  look  cleaner  when  vector
+              anti-aliasing is enabled.  If set to "cad", a slightly different
+              stroke adjustment algorithm will be used to ensure that lines of
+              the same original width will always have the same adjusted width
+              (at the expense of allowing gaps and overlaps  between  adjacent
+              lines).  This defaults to "yes".
 
        screenType dispersed | clustered | stochasticClustered
-              Sets the halftone screen type, which will be used when  generat-
-              ing  a  monochrome  (1-bit)  bitmap.  The three options are dis-
-              persed-dot dithering, clustered-dot dithering (with a round  dot
-              and   45-degree  screen  angle),  and  stochastic  clustered-dot
-              dithering.  By default, "stochasticClustered" is used for  reso-
+              Sets  the halftone screen type, which will be used when generat-
+              ing a monochrome (1-bit) bitmap.  The  three  options  are  dis-
+              persed-dot  dithering, clustered-dot dithering (with a round dot
+              and  45-degree  screen  angle),  and  stochastic   clustered-dot
+              dithering.   By default, "stochasticClustered" is used for reso-
               lutions of 300 dpi and higher, and "dispersed" is used for reso-
               lutions lower then 300 dpi.
 
        screenSize integer
-              Sets the size of the (square) halftone screen threshold  matrix.
-              By  default, this is 4 for dispersed-dot dithering, 10 for clus-
-              tered-dot  dithering,  and  100  for  stochastic   clustered-dot
+              Sets  the size of the (square) halftone screen threshold matrix.
+              By default, this is 4 for dispersed-dot dithering, 10 for  clus-
+              tered-dot   dithering,  and  100  for  stochastic  clustered-dot
               dithering.
 
        screenDotRadius integer
-              Sets  the  halftone  screen  dot radius.  This is only used when
-              screenType is set to stochasticClustered, and it defaults to  2.
-              In  clustered-dot  mode,  the  dot  radius is half of the screen
+              Sets the halftone screen dot radius.  This  is  only  used  when
+              screenType  is set to stochasticClustered, and it defaults to 2.
+              In clustered-dot mode, the dot radius  is  half  of  the  screen
               size.  Dispersed-dot dithering doesn't have a dot radius.
 
        screenGamma float
               Sets the halftone screen gamma correction parameter.  Gamma val-
-              ues  greater  than 1 make the output brighter; gamma values less
+              ues greater than 1 make the output brighter; gamma  values  less
               than 1 make it darker.  The default value is 1.
 
        screenBlackThreshold float
-              When halftoning, all values below this threshold are  forced  to
+              When  halftoning,  all values below this threshold are forced to
               solid black.  This parameter is a floating point value between 0
               (black) and 1 (white).  The default value is 0.
 
        screenWhiteThreshold float
-              When halftoning, all values above this threshold are  forced  to
+              When  halftoning,  all values above this threshold are forced to
               solid white.  This parameter is a floating point value between 0
               (black) and 1 (white).  The default value is 1.
 
        minLineWidth float
-              Set the minimum line width, in device pixels.  This affects  the
-              rasterizer  only,  not  the PostScript converter (except when it
-              uses rasterization to handle transparency).  The  default  value
+              Set  the minimum line width, in device pixels.  This affects the
+              rasterizer only, not the PostScript converter  (except  when  it
+              uses  rasterization  to handle transparency).  The default value
               is 0 (no minimum).
 
-       drawAnnotations yes | no
-              If  set  to "no", annotations will not be drawn or printed.  The
-              default value is "yes".
+       enablePathSimplification yes | no
+              If set to "yes", simplify paths  by  removing  points  where  it
+              won't  make  a significant difference to the shape.  The default
+              value is "no".
 
        overprintPreview yes | no
               If set to "yes", generate overprint preview output, honoring the
@@ -434,56 +456,79 @@
               OP/op/OPM  settings  in the PDF file.  Ignored for non-CMYK out-
               put.  The default value is "no".
 
+VIEWER SETTINGS
+       These settings only apply to the Xpdf GUI PDF viewer.
+
+       initialZoom percentage | page | width
+              Sets the initial zoom factor.  A number specifies  a  zoom  per-
+              centage,  where  100 means 72 dpi.  You may also specify 'page',
+              to fit the page to the window size, or 'width', to fit the  page
+              width to the window width.
+
+       defaultFitZoom percentage
+              If xpdf is started with fit-page or fit-width zoom and no window
+              geometry, it will calculate a desired window size based  on  the
+              PDF  page  size and this defaultFitZoom value.  I.e., the window
+              size will be chosen such that exactly one page will fit  in  the
+              window  at  this  zoom factor (which must be a percentage).  The
+              default value is based on the screen resolution.
+
+       initialSidebarState yes | no
+              If set to "yes", xpdf opens with  the  sidebar  (tabs,  outline,
+              etc.)   visible.   If  set  to "no", xpdf opens with the sidebar
+              collapsed.  The default is "no".
+
+       paperColor color
+              Set the "paper color", i.e., the background of the page display.
+              The  color  can be #RRGGBB (hexadecimal) or a named color.  This
+              option will not work well with PDF files  that  do  things  like
+              filling in white behind the text.
+
+       matteColor color
+              Set the matte color, i.e., the color used for background outside
+              the actual page area.  The color can be #RRGGBB (hexadecimal) or
+              a named color.
+
+       fullScreenMatteColor color
+              Set  the  matte  color  for  full-screen mode.  The color can be
+              #RRGGBB (hexadecimal) or a named color.
+
+       popupMenuCmd title command ...
+              Add a command to the popup menu.  Title is the text to  be  dis-
+              played  in  the  menu.  Command is an Xpdf command (see the COM-
+              MANDS section of the xpdf(1) man page  for  details).   Multiple
+              commands are separated by whitespace.
+
+       maxTileWidth pixels
+              Set the maximum width of tiles to be used by xpdf when rasteriz-
+              ing pages.  This defaults to 1500.
+
+       maxTileHeight pixels
+              Set the maximum height of tiles to be used by xpdf when  raster-
+              izing pages.  This defaults to 1500.
+
+       tileCacheSize tiles
+              Set  the  maximum number of tiles to be cached by xpdf when ras-
+              terizing pages.  This defaults to 10.
+
+       workerThreads numThreads
+              Set the number of worker threads to be used by xpdf when raster-
+              izing pages.  This defaults to 1.
+
        launchCommand command
-              Sets the command executed when  you  click  on  a  "launch"-type
-              link.   The  intent  is  for  the command to be a program/script
-              which determines the file type and runs the appropriate  viewer.
-              The  command  line will consist of the file to be launched, fol-
-              lowed by any parameters specified with the  link.   Do  not  use
-              "%s"  in  "command".   By  default, this is unset, and Xpdf will
+              Sets  the  command  executed  when  you click on a "launch"-type
+              link.  The intent is for the  command  to  be  a  program/script
+              which  determines the file type and runs the appropriate viewer.
+              The command line will consist of the file to be  launched,  fol-
+              lowed  by  any  parameters  specified with the link.  Do not use
+              "%s" in "command".  By default, this is  unset,  and  Xpdf  will
               simply try to execute the file (after prompting the user).
 
-       urlCommand command
-              Sets the command executed when you click on  a  URL  link.   The
-              string  "%s"  will  be  replaced with the URL.  (See the example
-              below.)  This has no default value.
-
        movieCommand command
-              Sets the command executed when you click on a movie  annotation.
+              Sets  the command executed when you click on a movie annotation.
               The string "%s" will be replaced with the movie file name.  This
               has no default value.
 
-       mapNumericCharNames yes | no
-              If set to "yes", the Xpdf tools  will  attempt  to  map  various
-              numeric character names sometimes used in font subsets.  In some
-              cases this leads to usable text, and in other cases it leads  to
-              gibberish -- there is no way for Xpdf to tell.  This defaults to
-              "yes".
-
-       mapUnknownCharNames yes | no
-              If set to "yes", and mapNumericCharNames is  set  to  "no",  the
-              Xpdf  tools  will  apply  a simple pass-through mapping (Unicode
-              index = character code) for all unrecognized glyph names.   (For
-              CID  fonts, setting mapNumericCharNames to "no" is unnecessary.)
-              In some cases, this leads to usable text, and in other cases  it
-              leads  to  gibberish  -- there is no way for Xpdf to tell.  This
-              defaults to "no".
-
-       mapExtTrueTypeFontsViaUnicode yes | no
-              When rasterizing text using an external TrueType font, there are
-              two  options  for  handling character codes.  If mapExtTrueType-
-              FontsViaUnicode is set to "yes", Xpdf will use the  font  encod-
-              ing/ToUnicode  info  to map character codes to Unicode, and then
-              use the font's Unicode cmap to map Unicode to GIDs.  If  mapExt-
-              TrueTypeFontsViaUnicode  is  set  to  "no", Xpdf will assume the
-              character codes are GIDs (i.e., use an identity mapping).   This
-              defaults to "yes".
-
-       enableXFA yes | no
-              If  set  to  "yes", an XFA form (if present) will be rendered in
-              place of an AcroForm.  If "no", an XFA form will never  be  ren-
-              dered.  This defaults to "yes".
-
        bind modifiers-key context command ...
               Add  a  key  or  mouse button binding.  Modifiers can be zero or
               more of:
@@ -499,6 +544,7 @@
                   return
                   enter
                   backspace
+                  esc
                   insert
                   delete
                   home
@@ -509,6 +555,7 @@
                   f1 .. f35                       (function keys)
                   mousePress1 .. mousePress7      (mouse buttons)
                   mouseRelease1 .. mouseRelease7  (mouse buttons)
+                  mouseClick1 .. mouseClick7      (mouse buttons)
 
               Context is either "any" or a comma-separated combination of:
 
@@ -548,6 +595,20 @@
               "any" context, and you want to create new key bindings for  mul-
               tiple contexts).
 
+MISCELLANEOUS SETTINGS
+       drawAnnotations yes | no
+              If  set  to "no", annotations will not be drawn or printed.  The
+              default value is "yes".
+
+       drawFormFields yes | no
+              If set to "no", form fields will not be drawn or  printed.   The
+              default value is "yes".
+
+       enableXFA yes | no
+              If  set  to  "yes", an XFA form (if present) will be rendered in
+              place of an AcroForm.  If "no", an XFA form will never  be  ren-
+              dered.  This defaults to "yes".
+
        printCommands yes | no
               If  set  to  "yes", drawing commands are printed as they're exe-
               cuted (useful for debugging).  This defaults to "no".
@@ -620,14 +681,14 @@
               read in place of the system-wide file.
 
 AUTHOR
-       The  Xpdf  software  and  documentation are copyright 1996-2014 Glyph &
+       The  Xpdf  software  and  documentation are copyright 1996-2017 Glyph &
        Cog, LLC.
 
 SEE ALSO
        xpdf(1),  pdftops(1),  pdftotext(1),  pdftohtml(1),  pdfinfo(1),   pdf-
        fonts(1), pdfdetach(1), pdftoppm(1), pdftopng(1), pdfimages(1)
-       http://www.foolabs.com/xpdf/
+       http://www.xpdfreader.com/
 
 
 
-                                  28 May 2014                        xpdfrc(5)
+                                  10 Aug 2017                        xpdfrc(5)

Added: trunk/Build/source/libs/xpdf/xpdf-src/fofi/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/CMakeLists.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/CMakeLists.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,26 @@
+#========================================================================
+#
+# fofi/CMakeLists.txt
+#
+# CMake script for the fofi library.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+
+add_library(fofi_objs OBJECT
+  FoFiBase.cc
+  FoFiEncodings.cc
+  FoFiIdentifier.cc
+  FoFiTrueType.cc
+  FoFiType1.cc
+  FoFiType1C.cc
+)
+
+add_library(fofi
+  $<TARGET_OBJECTS:fofi_objs>
+)


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/fofi/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiBase.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiBase.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiBase.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <limits.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "FoFiBase.h"
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiEncodings.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiEncodings.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiEncodings.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -13,6 +13,7 @@
 #endif
 
 #include <stdlib.h>
+#include "gmempp.h"
 #include "FoFiEncodings.h"
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiIdentifier.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiIdentifier.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiIdentifier.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -17,6 +17,7 @@
 #include <limits.h>
 #include "gtypes.h"
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "FoFiIdentifier.h"

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -19,6 +19,7 @@
 #endif
 #include "gtypes.h"
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GHash.h"
 #include "FoFiType1C.h"
@@ -119,7 +120,7 @@
 #define os2Tag  0x4f532f32
 #define postTag 0x706f7374
 
-#ifdef HAVE_STD_SORT
+#if HAVE_STD_SORT
 
 struct cmpTrueTypeLocaOffsetFunctor {
   bool operator()(const TrueTypeLoca &loca1, const TrueTypeLoca &loca2) {
@@ -525,6 +526,119 @@
   delete ff;
 }
 
+struct FoFiTrueTypeTrickyFont {
+  int cvtLen;
+  Guint cvtChecksum;
+  int fpgmLen;
+  Guint fpgmChecksum;
+  int prepLen;
+  Guint prepChecksum;
+};
+
+// This data was taken from the FreeType project.
+static FoFiTrueTypeTrickyFont trickyFonts[] = {
+  { 0x000002e4, 0x05bcf058,	// MingLiU 1995
+    0x000087c4, 0x28233bf1,
+    0x000001e1, 0xa344a1ea },
+  { 0x000002e4, 0x05bcf058,	// MingLiU 1996-
+    0x000087c4, 0x28233bf1,
+    0x000001e1, 0xa344a1eb },
+  { 0x00000350, 0x11e5ead4,	// DFKaiShu
+    0x00009063, 0x5a30ca3b,
+    0x0000007e, 0x13a42602 },
+  { 0x00000350, 0x11e5ead4,	// DFKaiShu2
+    0x00008998, 0xa6e78c01,
+    0x0000007e, 0x13a42602 },
+  { 0x00000008, 0xfffbfffc,	// HuaTianKaiTi
+    0x0000bea2, 0x9c9e48b8,
+    0x00000008, 0x70020112 },
+  { 0x00000008, 0xfffbfffc,	// HuaTianSongTi
+    0x00017c39, 0x0a5a0483,
+    0x00000008, 0x70020112 },
+  { 0x00000000, 0x00000000,	// NEC fadpop7.ttf
+    0x000000e5, 0x40c92555,
+    0x0000117c, 0xa39b58e3 },
+  { 0x00000000, 0x00000000,	// NEC fadrei5.ttf
+    0x000000e5, 0x33c41652,
+    0x00000f6a, 0x26d6c52a },
+  { 0x00000000, 0x00000000,	// NEC fangot7.ttf
+    0x0000019d, 0x6db1651d,
+    0x00002492, 0x6c6e4b03 },
+  { 0x00000000, 0x00000000,	// NEC fangyo5.ttf
+    0x000000e5, 0x40c92555,
+    0x0000117c, 0xde51fad0 },
+  { 0x00000000, 0x00000000,	// NEC fankyo5.ttf
+    0x000000e5, 0x85e47664,
+    0x00001caa, 0xa6c62831 },
+  { 0x00000000, 0x00000000,	// NEC fanrgo5.ttf
+    0x0000019d, 0x2d891cfd,
+    0x00001de8, 0xa0604633 },
+  { 0x00000000, 0x00000000,	// NEC fangot5.ttc
+    0x000001cb, 0x40aa774c,
+    0x00001f9a, 0x9b5caa96 },
+  { 0x00000000, 0x00000000,	// NEC fanmin3.ttc
+    0x00000141, 0x0d3de9cb,
+    0x00002280, 0xd4127766 },
+  { 0x00000000, 0x00000000,	// NEC FA-Gothic, 1996
+    0x000001f0, 0x4a692698,
+    0x00001fca, 0x340d4346 },
+  { 0x00000000, 0x00000000,	// NEC FA-Minchou, 1996
+    0x00000166, 0xcd34c604,
+    0x000022b0, 0x6cf31046 },
+  { 0x00000000, 0x00000000,	// NEC FA-RoundGothicB, 1996
+    0x0000019d, 0x5da75315,
+    0x000022e0, 0x40745a5f },
+  { 0x00000000, 0x00000000,	// NEC FA-RoundGothicM, 1996
+    0x000001c2, 0xf055fc48,
+    0x00001e18, 0x3900ded3 }
+};
+
+#define nTrickyFonts ((int)(sizeof(trickyFonts) / sizeof(FoFiTrueTypeTrickyFont)))
+
+// This looks at the length and checksum values for the cvt, fpgm, and
+// prep tables.  The theory is that those tables will be the same,
+// even if the font is renamed and/or subsetted.
+GBool FoFiTrueType::checkForTrickyCJK() {
+  int cvtIdx, fpgmIdx, prepIdx;
+  int cvtLen, fpgmLen, prepLen;
+  Guint cvtChecksum, fpgmChecksum, prepChecksum;
+  int i;
+
+  if ((cvtIdx = seekTable("cvt ")) >= 0) {
+    cvtLen = tables[cvtIdx].len;
+    cvtChecksum = tables[cvtIdx].checksum;
+  } else {
+    cvtLen = 0;
+    cvtChecksum = 0;
+  }
+  if ((fpgmIdx = seekTable("fpgm")) >= 0) {
+    fpgmLen = tables[fpgmIdx].len;
+    fpgmChecksum = tables[fpgmIdx].checksum;
+  } else {
+    fpgmLen = 0;
+    fpgmChecksum = 0;
+  }
+  if ((prepIdx = seekTable("prep")) >= 0) {
+    prepLen = tables[prepIdx].len;
+    prepChecksum = tables[prepIdx].checksum;
+  } else {
+    prepLen = 0;
+    prepChecksum = 0;
+  }
+
+  for (i = 0; i < nTrickyFonts; ++i) {
+    if (cvtLen == trickyFonts[i].cvtLen &&
+	cvtChecksum == trickyFonts[i].cvtChecksum &&
+	fpgmLen == trickyFonts[i].fpgmLen &&
+	fpgmChecksum == trickyFonts[i].fpgmChecksum &&
+	prepLen == trickyFonts[i].prepLen &&
+	prepChecksum == trickyFonts[i].prepChecksum) {
+      return gTrue;
+    }
+  }
+  return gFalse;
+}
+
 void FoFiTrueType::convertToType42(char *psName, char **encoding,
 				   int *codeToGID,
 				   FoFiOutputFunc outputFunc,
@@ -966,6 +1080,7 @@
   unsortedLoca = gFalse;
   i = seekTable("loca");
   pos = tables[i].offset;
+  glyfLen = tables[seekTable("glyf")].len;
   ok = gTrue;
   for (i = 0; i <= nGlyphs; ++i) {
     if (locaFmt) {
@@ -973,6 +1088,11 @@
     } else {
       locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok);
     }
+    if (locaTable[i].origOffset < 0 ||
+	locaTable[i].origOffset > glyfLen) {
+      locaTable[i].origOffset = glyfLen;
+      unsortedLoca = gTrue;
+    }
     if (i > 0 && locaTable[i].origOffset < locaTable[i-1].origOffset) {
       unsortedLoca = gTrue;
     }
@@ -1562,11 +1682,6 @@
   (*outputFunc)(outputStream, "/CharStrings 256 dict dup begin\n", 32);
   (*outputFunc)(outputStream, "/.notdef 0 def\n", 15);
 
-  // if there's no 'cmap' table, punt
-  if (nCmaps == 0) {
-    goto err;
-  }
-
   // map char name to glyph index:
   // 1. use encoding to map name to char code
   // 2. use codeToGID to map char code to glyph index
@@ -1597,7 +1712,6 @@
     }
   }
 
- err:
   (*outputFunc)(outputStream, "end readonly def\n", 17);
 }
 
@@ -2115,8 +2229,8 @@
     return;
   }
 
-  // make sure the loca table is sane (correct length and entries are
-  // in bounds)
+  // make sure the loca table is sane (correct length)
+  // NB: out-of-bounds entries are handled in writeTTF()
   if (!openTypeCFF) {
     i = seekTable("loca");
     if (tables[i].len < 0) {
@@ -2126,16 +2240,6 @@
     if (tables[i].len < (nGlyphs + 1) * (locaFmt ? 4 : 2)) {
       nGlyphs = tables[i].len / (locaFmt ? 4 : 2) - 1;
     }
-    for (j = 0; j <= nGlyphs; ++j) {
-      if (locaFmt) {
-	pos = (int)getU32BE(tables[i].offset + j*4, &parsedOk);
-      } else {
-	pos = getU16BE(tables[i].offset + j*2, &parsedOk);
-      }
-      if (pos < 0 || pos > len) {
-	parsedOk = gFalse;
-      }
-    }
     if (!parsedOk) {
       return;
     }
@@ -2245,6 +2349,7 @@
     stringIdx = 0;
     stringPos = tablePos + 34 + 2*n;
     for (i = 0; i < n; ++i) {
+      ok = gTrue;
       j = getU16BE(tablePos + 34 + 2*i, &ok);
       if (j < 258) {
 	nameToGID->removeInt(macGlyphNames[j]);
@@ -2256,12 +2361,12 @@
 	       stringIdx < j;
 	       ++stringIdx, stringPos += 1 + getU8(stringPos, &ok)) ;
 	  if (!ok) {
-	    goto err;
+	    continue;
 	  }
 	}
 	m = getU8(stringPos, &ok);
 	if (!ok || !checkRegion(stringPos + 1, m)) {
-	  goto err;
+	  continue;
 	}
 	name = new GString((char *)&file[stringPos + 1], m);
 	nameToGID->removeInt(name);
@@ -2275,7 +2380,7 @@
     for (i = 0; i < nGlyphs; ++i) {
       j = getU8(tablePos + 32 + i, &ok);
       if (!ok) {
-	goto err;
+	continue;
       }
       if (j < 258) {
 	nameToGID->removeInt(macGlyphNames[j]);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -95,6 +95,10 @@
   // for OpenType CFF fonts.)
   void getFontMatrix(double *mat);
 
+  // Returns true if this looks like a CJK font that uses bytecode
+  // instructions to assemble glyphs.
+  GBool checkForTrickyCJK();
+
   // Convert to a Type 42 font, suitable for embedding in a PostScript
   // file.  <psName> will be used as the PostScript font name (so we
   // don't need to depend on the 'name' table in the font).  The

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "FoFiEncodings.h"
 #include "FoFiType1.h"
 
@@ -198,7 +199,7 @@
 
   gotMatrix = gFalse;
   for (i = 1, line = (char *)file;
-       i <= 100 && line && (!name || !encoding);
+       i <= 100 && line && (!name || !encoding || !gotMatrix);
        ++i) {
 
     // get font name
@@ -255,6 +256,7 @@
 	    if (code >= 0 && code < 256) {
 	      c = *p2;
 	      *p2 = '\0';
+	      gfree(encoding[code]);
 	      encoding[code] = copyString(p);
 	      *p2 = c;
 	    }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,6 +16,7 @@
 #include <string.h>
 #include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "FoFiEncodings.h"
 #include "FoFiType1C.h"
@@ -25,6 +26,44 @@
 static char hexChars[17] = "0123456789ABCDEF";
 
 //------------------------------------------------------------------------
+
+GBool Type1COp::isZero() {
+  switch (kind) {
+  case type1COpInteger:  return intgr == 0;
+  case type1COpFloat:    return flt == 0;
+  case type1COpRational: return rat.num == 0;
+  default:               return gFalse;   // shouldn't happen
+  }
+}
+
+GBool Type1COp::isNegative() {
+  switch (kind) {
+  case type1COpInteger:  return intgr < 0;
+  case type1COpFloat:    return flt < 0;
+  case type1COpRational: return (rat.num < 0) != (rat.den < 0);
+  default:               return gFalse;   // shouldn't happen
+  }
+}
+
+int Type1COp::toInt() {
+  switch (kind) {
+  case type1COpInteger:  return intgr;
+  case type1COpFloat:    return (int)flt;
+  case type1COpRational: return rat.num / rat.den;
+  default:               return 0;   // shouldn't happen
+  }
+}
+
+double Type1COp::toFloat() {
+  switch (kind) {
+  case type1COpInteger:  return (double)intgr;
+  case type1COpFloat:    return flt;
+  case type1COpRational: return (double)rat.num / (double)rat.den;
+  default:               return 0.0;   // shouldn't happen
+  }
+}
+
+//------------------------------------------------------------------------
 // FoFiType1C
 //------------------------------------------------------------------------
 
@@ -744,7 +783,7 @@
 	  break;
 	}
       }
-      if (j == privateDicts[0].nStemSnapH) {
+      if (j == privateDicts[i].nStemSnapH) {
 	(*outputFunc)(outputStream, "/StemSnapH [", 12);
 	for (j = 0; j < privateDicts[i].nStemSnapH; ++j) {
 	  buf = GString::format("{0:s}{1:.4g}",
@@ -763,7 +802,7 @@
 	  break;
 	}
       }
-      if (j == privateDicts[0].nStemSnapV) {
+      if (j == privateDicts[i].nStemSnapV) {
 	(*outputFunc)(outputStream, "/StemSnapV [", 12);
 	for (j = 0; j < privateDicts[i].nStemSnapV; ++j) {
 	  buf = GString::format("{0:s}{1:.4g}",
@@ -1060,7 +1099,7 @@
 	  break;
 	}
       }
-      if (k == privateDicts[0].nStemSnapH) {
+      if (k == privateDicts[fd].nStemSnapH) {
 	eexecWrite(&eb, "/StemSnapH [");
 	for (k = 0; k < privateDicts[fd].nStemSnapH; ++k) {
 	  buf = GString::format("{0:s}{1:.4g}",
@@ -1080,7 +1119,7 @@
 	  break;
 	}
       }
-      if (k == privateDicts[0].nStemSnapV) {
+      if (k == privateDicts[fd].nStemSnapV) {
 	eexecWrite(&eb, "/StemSnapV [");
 	for (k = 0; k < privateDicts[fd].nStemSnapV; ++k) {
 	  buf = GString::format("{0:s}{1:.4g}",
@@ -1228,11 +1267,12 @@
 			  Type1CIndex *subrIdx, Type1CPrivateDict *pDict,
 			  GBool top) {
   Type1CIndexVal val;
-  GBool ok, dFP;
+  Type1COp zero, tmp;
+  GBool ok, dInt;
   double d, dx, dy;
   Gushort r2;
   Guchar byte;
-  int pos, subrBias, start, i, k;
+  int pos, subrBias, start, num, den, i, k;
 
   start = charBuf->getLength();
   if (top) {
@@ -1246,6 +1286,9 @@
     openPath = gFalse;
   }
 
+  zero.kind = type1COpInteger;
+  zero.intgr = 0;
+
   pos = offset;
   while (pos < offset + nBytes) {
     ok = gTrue;
@@ -1253,7 +1296,7 @@
     if (!ok) {
       break;
     }
-    if (!ops[nOps - 1].isNum) {
+    if (ops[nOps - 1].kind == type1COpOperator) {
       --nOps; // drop the operator
       switch (ops[nOps].op) {
       case 0x0001:		// hstem
@@ -1265,21 +1308,47 @@
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hstem", nOps);
 	}
 	d = 0;
-	dFP = gFalse;
-	for (k = 0; k < nOps; k += 2) {
+	dInt = gTrue;
+	for (k = 0; k+1 < nOps; k += 2) {
 	  // convert Type 2 edge hints (-20 or -21) to Type 1 ghost hints
-	  if (ops[k+1].num < 0) {
-	    d += ops[k].num + ops[k+1].num;
-	    dFP |= ops[k].isFP | ops[k+1].isFP;
-	    cvtNum(d, dFP, charBuf);
-	    cvtNum(-ops[k+1].num, ops[k+1].isFP, charBuf);
+	  if (ops[k+1].isNegative()) {
+	    d += ops[k].toFloat() + ops[k+1].toFloat();
+	    dInt &= ops[k].kind == type1COpInteger;
+	    dInt &= ops[k+1].kind == type1COpInteger;
+	    if (dInt) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = (int)(d + 0.5);
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = d;
+	    }
+	    cvtNum(tmp, charBuf);
+	    if (ops[k+1].kind == type1COpInteger) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = -ops[k+1].intgr;
+	    } else if (ops[k+1].kind == type1COpRational) {
+	      tmp.kind = type1COpRational;
+	      tmp.rat.num = -ops[k+1].rat.num;
+	      tmp.rat.den = ops[k+1].rat.den;
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = -ops[k+1].toFloat();
+	    }
+	    cvtNum(tmp, charBuf);
 	  } else {
-	    d += ops[k].num;
-	    dFP |= ops[k].isFP;
-	    cvtNum(d, dFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    d += ops[k+1].num;
-	    dFP |= ops[k+1].isFP;
+	    d += ops[k].toFloat();
+	    dInt &= ops[k].kind == type1COpInteger;
+	    if (dInt) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = (int)(d + 0.5);
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = d;
+	    }
+	    cvtNum(tmp, charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    d += ops[k+1].toFloat();
+	    dInt &= ops[k+1].kind == type1COpInteger;
 	  }
 	  charBuf->append((char)1);
 	}
@@ -1295,21 +1364,47 @@
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 vstem", nOps);
 	}
 	d = 0;
-	dFP = gFalse;
-	for (k = 0; k < nOps; k += 2) {
+	dInt = gTrue;
+	for (k = 0; k+1 < nOps; k += 2) {
 	  // convert Type 2 edge hints (-20 or -21) to Type 1 ghost hints
-	  if (ops[k+1].num < 0) {
-	    d += ops[k].num + ops[k+1].num;
-	    dFP |= ops[k].isFP | ops[k+1].isFP;
-	    cvtNum(d, dFP, charBuf);
-	    cvtNum(-ops[k+1].num, ops[k+1].isFP, charBuf);
+	  if (ops[k+1].isNegative()) {
+	    d += ops[k].toFloat() + ops[k+1].toFloat();
+	    dInt &= ops[k].kind == type1COpInteger;
+	    dInt &= ops[k+1].kind == type1COpInteger;
+	    if (dInt) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = (int)(d + 0.5);
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = d;
+	    }
+	    cvtNum(tmp, charBuf);
+	    if (ops[k+1].kind == type1COpInteger) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = -ops[k+1].intgr;
+	    } else if (ops[k+1].kind == type1COpRational) {
+	      tmp.kind = type1COpRational;
+	      tmp.rat.num = -ops[k+1].rat.num;
+	      tmp.rat.den = ops[k+1].rat.den;
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = -ops[k+1].toFloat();
+	    }
+	    cvtNum(tmp, charBuf);
 	  } else {
-	    d += ops[k].num;
-	    dFP |= ops[k].isFP;
-	    cvtNum(d, dFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    d += ops[k+1].num;
-	    dFP |= ops[k+1].isFP;
+	    d += ops[k].toFloat();
+	    dInt &= ops[k].kind == type1COpInteger;
+	    if (dInt) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = (int)(d + 0.5);
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = d;
+	    }
+	    cvtNum(tmp, charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    d += ops[k+1].toFloat();
+	    dInt &= ops[k+1].kind == type1COpInteger;
 	  }
 	  charBuf->append((char)3);
 	}
@@ -1328,7 +1423,7 @@
 	if (nOps != 1) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 vmoveto", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
+	cvtNum(ops[0], charBuf);
 	charBuf->append((char)4);
 	nOps = 0;
 	break;
@@ -1336,9 +1431,9 @@
 	if (nOps < 2 || nOps % 2 != 0) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 rlineto", nOps);
 	}
-	for (k = 0; k < nOps; k += 2) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
+	for (k = 0; k+1 < nOps; k += 2) {
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(ops[k+1], charBuf);
 	  charBuf->append((char)5);
 	}
 	nOps = 0;
@@ -1349,7 +1444,7 @@
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hlineto", nOps);
 	}
 	for (k = 0; k < nOps; ++k) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
+	  cvtNum(ops[k], charBuf);
 	  charBuf->append((char)((k & 1) ? 7 : 6));
 	}
 	nOps = 0;
@@ -1360,7 +1455,7 @@
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 vlineto", nOps);
 	}
 	for (k = 0; k < nOps; ++k) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
+	  cvtNum(ops[k], charBuf);
 	  charBuf->append((char)((k & 1) ? 6 : 7));
 	}
 	nOps = 0;
@@ -1371,12 +1466,12 @@
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 rrcurveto", nOps);
 	}
 	for (k = 0; k < nOps; k += 6) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	  cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	  cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	  cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
-	  cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf);
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(ops[k+1], charBuf);
+	  cvtNum(ops[k+2], charBuf);
+	  cvtNum(ops[k+3], charBuf);
+	  cvtNum(ops[k+4], charBuf);
+	  cvtNum(ops[k+5], charBuf);
 	  charBuf->append((char)8);
 	}
 	nOps = 0;
@@ -1386,7 +1481,7 @@
 	if (nOps >= 1) {
 	  subrBias = (subrIdx->len < 1240)
 	               ? 107 : (subrIdx->len < 33900) ? 1131 : 32768;
-	  k = subrBias + (int)ops[nOps - 1].num;
+	  k = subrBias + ops[nOps - 1].toInt();
 	  --nOps;
 	  ok = gTrue;
 	  getIndexVal(subrIdx, k, &val, &ok);
@@ -1411,11 +1506,11 @@
 	  openPath = gFalse;
 	}
 	if (nOps == 4) {
-	  cvtNum(0, gFalse, charBuf);
-	  cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	  cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	  cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	  cvtNum(ops[3].num, ops[3].isFP, charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
 	  charBuf->append((char)12)->append((char)6);
 	} else if (nOps == 0) {
 	  charBuf->append((char)14);
@@ -1492,8 +1587,8 @@
 	if (nOps != 2) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 rmoveto", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	cvtNum(ops[1].num, ops[1].isFP, charBuf);
+	cvtNum(ops[0], charBuf);
+	cvtNum(ops[1], charBuf);
 	charBuf->append((char)21);
 	nOps = 0;
 	break;
@@ -1509,7 +1604,7 @@
 	if (nOps != 1) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hmoveto", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
+	cvtNum(ops[0], charBuf);
 	charBuf->append((char)22);
 	nOps = 0;
 	break;
@@ -1529,17 +1624,17 @@
 	if (nOps < 8 || (nOps - 2) % 6 != 0) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 rcurveline", nOps);
 	}
-	for (k = 0; k < nOps - 2; k += 6) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	  cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	  cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	  cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
-	  cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf);
+	for (k = 0; k <= nOps - 8; k += 6) {
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(ops[k+1], charBuf);
+	  cvtNum(ops[k+2], charBuf);
+	  cvtNum(ops[k+3], charBuf);
+	  cvtNum(ops[k+4], charBuf);
+	  cvtNum(ops[k+5], charBuf);
 	  charBuf->append((char)8);
 	}
-	cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	cvtNum(ops[k+1].num, ops[k].isFP, charBuf);
+	cvtNum(ops[k], charBuf);
+	cvtNum(ops[k+1], charBuf);
 	charBuf->append((char)5);
 	nOps = 0;
 	openPath = gTrue;
@@ -1548,17 +1643,17 @@
 	if (nOps < 8 || (nOps - 6) % 2 != 0) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 rlinecurve", nOps);
 	}
-	for (k = 0; k < nOps - 6; k += 2) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(ops[k+1].num, ops[k].isFP, charBuf);
+	for (k = 0; k <= nOps - 8; k += 2) {
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(ops[k+1], charBuf);
 	  charBuf->append((char)5);
 	}
-	cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
-	cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf);
+	cvtNum(ops[k], charBuf);
+	cvtNum(ops[k+1], charBuf);
+	cvtNum(ops[k+2], charBuf);
+	cvtNum(ops[k+3], charBuf);
+	cvtNum(ops[k+4], charBuf);
+	cvtNum(ops[k+5], charBuf);
 	charBuf->append((char)8);
 	nOps = 0;
 	openPath = gTrue;
@@ -1567,25 +1662,25 @@
 	if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 vvcurveto", nOps);
 	}
-	if (nOps % 2 == 1) {
-	  cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	  cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	  cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	  cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	  cvtNum(0, gFalse, charBuf);
-	  cvtNum(ops[4].num, ops[4].isFP, charBuf);
+	if (nOps % 2 == 1 && nOps >= 5) {
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[4], charBuf);
 	  charBuf->append((char)8);
 	  k = 5;
 	} else {
 	  k = 0;
 	}
-	for (; k < nOps; k += 4) {
-	  cvtNum(0, gFalse, charBuf);
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	  cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	  cvtNum(0, gFalse, charBuf);
-	  cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	for (; k+3 < nOps; k += 4) {
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(ops[k+1], charBuf);
+	  cvtNum(ops[k+2], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[k+3], charBuf);
 	  charBuf->append((char)8);
 	}
 	nOps = 0;
@@ -1595,25 +1690,25 @@
 	if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hhcurveto", nOps);
 	}
-	if (nOps % 2 == 1) {
-	  cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	  cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	  cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	  cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	  cvtNum(ops[4].num, ops[4].isFP, charBuf);
-	  cvtNum(0, gFalse, charBuf);
+	if (nOps % 2 == 1 && nOps >= 5) {
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(ops[4], charBuf);
+	  cvtNum(zero, charBuf);
 	  charBuf->append((char)8);
 	  k = 5;
 	} else {
 	  k = 0;
 	}
-	for (; k < nOps; k += 4) {
-	  cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	  cvtNum(0, gFalse, charBuf);
-	  cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	  cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	  cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	  cvtNum(0, gFalse, charBuf);
+	for (; k+3 < nOps; k += 4) {
+	  cvtNum(ops[k], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[k+1], charBuf);
+	  cvtNum(ops[k+2], charBuf);
+	  cvtNum(ops[k+3], charBuf);
+	  cvtNum(zero, charBuf);
 	  charBuf->append((char)8);
 	}
 	nOps = 0;
@@ -1621,7 +1716,7 @@
 	break;
       case 0x001d:		// callgsubr
 	if (nOps >= 1) {
-	  k = gsubrBias + (int)ops[nOps - 1].num;
+	  k = gsubrBias + ops[nOps - 1].toInt();
 	  --nOps;
 	  ok = gTrue;
 	  getIndexVal(&gsubrIdx, k, &val, &ok);
@@ -1637,36 +1732,36 @@
 	if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 vhcurveto", nOps);
 	}
-	for (k = 0; k < nOps && k != nOps-5; k += 4) {
+	for (k = 0; k+3 < nOps && k != nOps-5; k += 4) {
 	  if (k % 8 == 0) {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	    charBuf->append((char)30);
 	  } else {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	    charBuf->append((char)31);
 	  }
 	}
 	if (k == nOps-5) {
 	  if (k % 8 == 0) {
-	    cvtNum(0, gFalse, charBuf);
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	    cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
+	    cvtNum(zero, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
+	    cvtNum(ops[k+4], charBuf);
 	  } else {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(0, gFalse, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(zero, charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+4], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	  }
 	  charBuf->append((char)8);
 	}
@@ -1677,36 +1772,36 @@
 	if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hvcurveto", nOps);
 	}
-	for (k = 0; k < nOps && k != nOps-5; k += 4) {
+	for (k = 0; k+3 < nOps && k != nOps-5; k += 4) {
 	  if (k % 8 == 0) {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	    charBuf->append((char)31);
 	  } else {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	    charBuf->append((char)30);
 	  }
 	}
 	if (k == nOps-5) {
 	  if (k % 8 == 0) {
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(0, gFalse, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(zero, charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+4], charBuf);
+	    cvtNum(ops[k+3], charBuf);
 	  } else {
-	    cvtNum(0, gFalse, charBuf);
-	    cvtNum(ops[k].num, ops[k].isFP, charBuf);
-	    cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf);
-	    cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf);
-	    cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf);
-	    cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf);
+	    cvtNum(zero, charBuf);
+	    cvtNum(ops[k], charBuf);
+	    cvtNum(ops[k+1], charBuf);
+	    cvtNum(ops[k+2], charBuf);
+	    cvtNum(ops[k+3], charBuf);
+	    cvtNum(ops[k+4], charBuf);
 	  }
 	  charBuf->append((char)8);
 	}
@@ -1717,6 +1812,18 @@
 	// ignored
 	nOps = 0;
 	break;
+      case 0x0c0c:		// div
+	if (nOps >= 2) {
+	  num = ops[nOps-2].toInt();
+	  den = ops[nOps-1].toInt();
+	  --nOps;
+	  ops[nOps-1].kind = type1COpRational;
+	  ops[nOps-1].rat.num = num;
+	  ops[nOps-1].rat.den = den;
+	} else {
+	  //~ error(-1, "Wrong number of args (%d) to Type 2 div", nOps);
+	}
+	break;
       case 0x0c03:		// and
       case 0x0c04:		// or
       case 0x0c05:		// not
@@ -1724,7 +1831,6 @@
       case 0x0c09:		// abs
       case 0x0c0a:		// add
       case 0x0c0b:		// sub
-      case 0x0c0c:		// div
       case 0x0c0d:		// load
       case 0x0c0e:		// neg
       case 0x0c0f:		// eq
@@ -1743,96 +1849,141 @@
 	nOps = 0;
 	break;
       case 0x0c22:		// hflex
-	if (nOps != 7) {
+	if (nOps == 7) {
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(zero, charBuf);
+	  charBuf->append((char)8);
+	  cvtNum(ops[4], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[5], charBuf);
+	  if (ops[2].kind == type1COpInteger) {
+	    tmp.kind = type1COpInteger;
+	    tmp.intgr = -ops[2].intgr;
+	  } else if (ops[2].kind == type1COpRational) {
+	    tmp.kind = type1COpRational;
+	    tmp.rat.num = -ops[2].rat.num;
+	    tmp.rat.den = ops[2].rat.den;
+	  } else {
+	    tmp.kind = type1COpFloat;
+	    tmp.flt = -ops[2].toFloat();
+	  }
+	  cvtNum(tmp, charBuf);
+	  cvtNum(ops[6], charBuf);
+	  cvtNum(zero, charBuf);
+	  charBuf->append((char)8);
+	} else {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hflex", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	charBuf->append((char)8);
-	cvtNum(ops[4].num, ops[4].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	cvtNum(ops[5].num, ops[5].isFP, charBuf);
-	cvtNum(-ops[2].num, ops[2].isFP, charBuf);
-	cvtNum(ops[6].num, ops[6].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	charBuf->append((char)8);
 	nOps = 0;
 	openPath = gTrue;
 	break;
       case 0x0c23:		// flex
-	if (nOps != 13) {
+	if (nOps == 13) {
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(ops[4], charBuf);
+	  cvtNum(ops[5], charBuf);
+	  charBuf->append((char)8);
+	  cvtNum(ops[6], charBuf);
+	  cvtNum(ops[7], charBuf);
+	  cvtNum(ops[8], charBuf);
+	  cvtNum(ops[9], charBuf);
+	  cvtNum(ops[10], charBuf);
+	  cvtNum(ops[11], charBuf);
+	  charBuf->append((char)8);
+	} else {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 flex", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	cvtNum(ops[4].num, ops[4].isFP, charBuf);
-	cvtNum(ops[5].num, ops[5].isFP, charBuf);
-	charBuf->append((char)8);
-	cvtNum(ops[6].num, ops[6].isFP, charBuf);
-	cvtNum(ops[7].num, ops[7].isFP, charBuf);
-	cvtNum(ops[8].num, ops[8].isFP, charBuf);
-	cvtNum(ops[9].num, ops[9].isFP, charBuf);
-	cvtNum(ops[10].num, ops[10].isFP, charBuf);
-	cvtNum(ops[11].num, ops[11].isFP, charBuf);
-	charBuf->append((char)8);
 	nOps = 0;
 	openPath = gTrue;
 	break;
       case 0x0c24:		// hflex1
-	if (nOps != 9) {
+	if (nOps == 9) {
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(ops[4], charBuf);
+	  cvtNum(zero, charBuf);
+	  charBuf->append((char)8);
+	  cvtNum(ops[5], charBuf);
+	  cvtNum(zero, charBuf);
+	  cvtNum(ops[6], charBuf);
+	  cvtNum(ops[7], charBuf);
+	  cvtNum(ops[8], charBuf);
+	  if (ops[1].kind == type1COpInteger &&
+	      ops[3].kind == type1COpInteger &&
+	      ops[7].kind == type1COpInteger) {
+	    tmp.kind = type1COpInteger;
+	    tmp.intgr = -(ops[1].intgr + ops[3].intgr + ops[7].intgr);
+	  } else {
+	    tmp.kind = type1COpFloat;
+	    tmp.flt = -(ops[1].toFloat() + ops[3].toFloat() + ops[7].toFloat());
+	  }
+	  cvtNum(tmp, charBuf);
+	  charBuf->append((char)8);
+	} else {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 hflex1", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	cvtNum(ops[4].num, ops[4].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	charBuf->append((char)8);
-	cvtNum(ops[5].num, ops[5].isFP, charBuf);
-	cvtNum(0, gFalse, charBuf);
-	cvtNum(ops[6].num, ops[6].isFP, charBuf);
-	cvtNum(ops[7].num, ops[7].isFP, charBuf);
-	cvtNum(ops[8].num, ops[8].isFP, charBuf);
-	cvtNum(-(ops[1].num + ops[3].num + ops[7].num),
-	       ops[1].isFP | ops[3].isFP | ops[7].isFP, charBuf);
-	charBuf->append((char)8);
 	nOps = 0;
 	openPath = gTrue;
 	break;
       case 0x0c25:		// flex1
-	if (nOps != 11) {
+	if (nOps == 11) {
+	  cvtNum(ops[0], charBuf);
+	  cvtNum(ops[1], charBuf);
+	  cvtNum(ops[2], charBuf);
+	  cvtNum(ops[3], charBuf);
+	  cvtNum(ops[4], charBuf);
+	  cvtNum(ops[5], charBuf);
+	  charBuf->append((char)8);
+	  cvtNum(ops[6], charBuf);
+	  cvtNum(ops[7], charBuf);
+	  cvtNum(ops[8], charBuf);
+	  cvtNum(ops[9], charBuf);
+	  dx = ops[0].toFloat() + ops[2].toFloat() + ops[4].toFloat()
+	       + ops[6].toFloat() + ops[8].toFloat();
+	  dy = ops[1].toFloat() + ops[3].toFloat() + ops[5].toFloat()
+	       + ops[7].toFloat() + ops[9].toFloat();
+	  if (fabs(dx) > fabs(dy)) {
+	    cvtNum(ops[10], charBuf);
+	    if (ops[1].kind == type1COpInteger &&
+		ops[3].kind == type1COpInteger &&
+		ops[5].kind == type1COpInteger &&
+		ops[7].kind == type1COpInteger &&
+		ops[9].kind == type1COpInteger) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = -(int)dy;
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = -dy;
+	    }
+	    cvtNum(tmp, charBuf);
+	  } else {
+	    if (ops[0].kind == type1COpInteger &&
+		ops[2].kind == type1COpInteger &&
+		ops[4].kind == type1COpInteger &&
+		ops[6].kind == type1COpInteger &&
+		ops[8].kind == type1COpInteger) {
+	      tmp.kind = type1COpInteger;
+	      tmp.intgr = -(int)dx;
+	    } else {
+	      tmp.kind = type1COpFloat;
+	      tmp.flt = -dx;
+	    }
+	    cvtNum(tmp, charBuf);
+	    cvtNum(ops[10], charBuf);
+	  }
+	  charBuf->append((char)8);
+	} else {
 	  //~ error(-1, "Wrong number of args (%d) to Type 2 flex1", nOps);
 	}
-	cvtNum(ops[0].num, ops[0].isFP, charBuf);
-	cvtNum(ops[1].num, ops[1].isFP, charBuf);
-	cvtNum(ops[2].num, ops[2].isFP, charBuf);
-	cvtNum(ops[3].num, ops[3].isFP, charBuf);
-	cvtNum(ops[4].num, ops[4].isFP, charBuf);
-	cvtNum(ops[5].num, ops[5].isFP, charBuf);
-	charBuf->append((char)8);
-	cvtNum(ops[6].num, ops[6].isFP, charBuf);
-	cvtNum(ops[7].num, ops[7].isFP, charBuf);
-	cvtNum(ops[8].num, ops[8].isFP, charBuf);
-	cvtNum(ops[9].num, ops[9].isFP, charBuf);
-	dx = ops[0].num + ops[2].num + ops[4].num + ops[6].num + ops[8].num;
-	dy = ops[1].num + ops[3].num + ops[5].num + ops[7].num + ops[9].num;
-	if (fabs(dx) > fabs(dy)) {
-	  cvtNum(ops[10].num, ops[10].isFP, charBuf);
-	  cvtNum(-dy, ops[1].isFP | ops[3].isFP | ops[5].isFP |
-		      ops[7].isFP | ops[9].isFP, charBuf);
-	} else {
-	  cvtNum(-dx, ops[0].isFP | ops[2].isFP | ops[4].isFP |
-		      ops[6].isFP | ops[8].isFP, charBuf);
-	  cvtNum(ops[10].num, ops[10].isFP, charBuf);
-	}
-	charBuf->append((char)8);
 	nOps = 0;
 	openPath = gTrue;
 	break;
@@ -1858,52 +2009,46 @@
 
 void FoFiType1C::cvtGlyphWidth(GBool useOp, GString *charBuf,
 			       Type1CPrivateDict *pDict) {
-  double w;
-  GBool wFP;
+  Type1COp zero, w;
   int i;
 
   if (useOp) {
-    w = pDict->nominalWidthX + ops[0].num;
-    wFP = pDict->nominalWidthXFP | ops[0].isFP;
+    if (pDict->nominalWidthXInt & (ops[0].kind == type1COpInteger)) {
+      w.kind = type1COpInteger;
+      w.intgr = (int)(pDict->nominalWidthX + ops[0].intgr);
+    } else {
+      w.kind = type1COpFloat;
+      w.flt = pDict->nominalWidthX + ops[0].toFloat();
+    }
     for (i = 1; i < nOps; ++i) {
       ops[i-1] = ops[i];
     }
     --nOps;
   } else {
-    w = pDict->defaultWidthX;
-    wFP = pDict->defaultWidthXFP;
+    if (pDict->defaultWidthXInt) {
+      w.kind = type1COpInteger;
+      w.intgr = (int)pDict->defaultWidthX;
+    } else {
+      w.kind = type1COpFloat;
+      w.flt = pDict->defaultWidthX;
+    }
   }
-  cvtNum(0, gFalse, charBuf);
-  cvtNum(w, wFP, charBuf);
+  zero.kind = type1COpInteger;
+  zero.intgr = 0;
+  cvtNum(zero, charBuf);
+  cvtNum(w, charBuf);
   charBuf->append((char)13);
 }
 
-void FoFiType1C::cvtNum(double x, GBool isFP, GString *charBuf) {
+void FoFiType1C::cvtNum(Type1COp op, GString *charBuf) {
+  Type1COp tmp;
   Guchar buf[12];
   int y, n;
 
   n = 0;
-  if (isFP) {
-    if (x >= -32768 && x < 32768) {
-      y = (int)(x * 256.0);
-      buf[0] = 255;
-      buf[1] = (Guchar)(y >> 24);
-      buf[2] = (Guchar)(y >> 16);
-      buf[3] = (Guchar)(y >> 8);
-      buf[4] = (Guchar)y;
-      buf[5] = 255;
-      buf[6] = 0;
-      buf[7] = 0;
-      buf[8] = 1;
-      buf[9] = 0;
-      buf[10] = 12;
-      buf[11] = 12;
-      n = 12;
-    } else {
-      //~ error(-1, "Type 2 fixed point constant out of range");
-    }
-  } else {
-    y = (int)x;
+  switch (op.kind) {
+  case type1COpInteger:
+    y = op.intgr;
     if (y >= -107 && y <= 107) {
       buf[0] = (Guchar)(y + 139);
       n = 1;
@@ -1925,6 +2070,39 @@
       buf[4] = (Guchar)y;
       n = 5;
     }
+    break;
+  case type1COpFloat:
+    if (op.flt >= -32768 && op.flt < 32768) {
+      y = (int)(op.flt * 256.0);
+      buf[0] = 255;
+      buf[1] = (Guchar)(y >> 24);
+      buf[2] = (Guchar)(y >> 16);
+      buf[3] = (Guchar)(y >> 8);
+      buf[4] = (Guchar)y;
+      buf[5] = 255;
+      buf[6] = 0;
+      buf[7] = 0;
+      buf[8] = 1;
+      buf[9] = 0;
+      buf[10] = 12;
+      buf[11] = 12;
+      n = 12;
+    } else {
+      //~ error(-1, "Type 2 fixed point constant out of range");
+    }
+    break;
+  case type1COpRational:
+    tmp.kind = type1COpInteger;
+    tmp.intgr = op.rat.num;
+    cvtNum(tmp, charBuf);
+    tmp.intgr = op.rat.den;
+    cvtNum(tmp, charBuf);
+    buf[0] = 0x0c;
+    buf[1] = 0x0c;
+    n = 2;
+    break;
+  default: // shouldn't happen
+    break;
   }
   charBuf->append((char *)buf, n);
 }
@@ -2161,47 +2339,51 @@
     if (!parsedOk) {
       break;
     }
-    if (!ops[nOps - 1].isNum) {
+    if (ops[nOps - 1].kind == type1COpOperator) {
       --nOps; // drop the operator
       if (topDict.firstOp < 0) {
 	topDict.firstOp = ops[nOps].op;
       }
       switch (ops[nOps].op) {
-      case 0x0000: topDict.versionSID = (int)ops[0].num; break;
-      case 0x0001: topDict.noticeSID = (int)ops[0].num; break;
-      case 0x0c00: topDict.copyrightSID = (int)ops[0].num; break;
-      case 0x0002: topDict.fullNameSID = (int)ops[0].num; break;
-      case 0x0003: topDict.familyNameSID = (int)ops[0].num; break;
-      case 0x0004: topDict.weightSID = (int)ops[0].num; break;
-      case 0x0c01: topDict.isFixedPitch = (int)ops[0].num; break;
-      case 0x0c02: topDict.italicAngle = ops[0].num; break;
-      case 0x0c03: topDict.underlinePosition = ops[0].num; break;
-      case 0x0c04: topDict.underlineThickness = ops[0].num; break;
-      case 0x0c05: topDict.paintType = (int)ops[0].num; break;
-      case 0x0c06: topDict.charstringType = (int)ops[0].num; break;
-      case 0x0c07: topDict.fontMatrix[0] = ops[0].num;
-	           topDict.fontMatrix[1] = ops[1].num;
-	           topDict.fontMatrix[2] = ops[2].num;
-	           topDict.fontMatrix[3] = ops[3].num;
-	           topDict.fontMatrix[4] = ops[4].num;
-	           topDict.fontMatrix[5] = ops[5].num;
-		   topDict.hasFontMatrix = gTrue; break;
-      case 0x000d: topDict.uniqueID = (int)ops[0].num; break;
-      case 0x0005: topDict.fontBBox[0] = ops[0].num;
-	           topDict.fontBBox[1] = ops[1].num;
-	           topDict.fontBBox[2] = ops[2].num;
-	           topDict.fontBBox[3] = ops[3].num; break;
-      case 0x0c08: topDict.strokeWidth = ops[0].num; break;
-      case 0x000f: topDict.charsetOffset = (int)ops[0].num; break;
-      case 0x0010: topDict.encodingOffset = (int)ops[0].num; break;
-      case 0x0011: topDict.charStringsOffset = (int)ops[0].num; break;
-      case 0x0012: topDict.privateSize = (int)ops[0].num;
-	           topDict.privateOffset = (int)ops[1].num; break;
-      case 0x0c1e: topDict.registrySID = (int)ops[0].num;
-	           topDict.orderingSID = (int)ops[1].num;
-		   topDict.supplement = (int)ops[2].num; break;
-      case 0x0c24: topDict.fdArrayOffset = (int)ops[0].num; break;
-      case 0x0c25: topDict.fdSelectOffset = (int)ops[0].num; break;
+      case 0x0000: topDict.versionSID = ops[0].toInt(); break;
+      case 0x0001: topDict.noticeSID = ops[0].toInt(); break;
+      case 0x0c00: topDict.copyrightSID = ops[0].toInt(); break;
+      case 0x0002: topDict.fullNameSID = ops[0].toInt(); break;
+      case 0x0003: topDict.familyNameSID = ops[0].toInt(); break;
+      case 0x0004: topDict.weightSID = ops[0].toInt(); break;
+      case 0x0c01: topDict.isFixedPitch = ops[0].toInt(); break;
+      case 0x0c02: topDict.italicAngle = ops[0].toFloat(); break;
+      case 0x0c03: topDict.underlinePosition = ops[0].toFloat(); break;
+      case 0x0c04: topDict.underlineThickness = ops[0].toFloat(); break;
+      case 0x0c05: topDict.paintType = ops[0].toInt(); break;
+      case 0x0c06: topDict.charstringType = ops[0].toInt(); break;
+      case 0x0c07: topDict.fontMatrix[0] = ops[0].toFloat();
+	           topDict.fontMatrix[1] = ops[1].toFloat();
+	           topDict.fontMatrix[2] = ops[2].toFloat();
+	           topDict.fontMatrix[3] = ops[3].toFloat();
+	           topDict.fontMatrix[4] = ops[4].toFloat();
+	           topDict.fontMatrix[5] = ops[5].toFloat();
+		   topDict.hasFontMatrix = gTrue;
+		   break;
+      case 0x000d: topDict.uniqueID = ops[0].toInt(); break;
+      case 0x0005: topDict.fontBBox[0] = ops[0].toFloat();
+	           topDict.fontBBox[1] = ops[1].toFloat();
+	           topDict.fontBBox[2] = ops[2].toFloat();
+	           topDict.fontBBox[3] = ops[3].toFloat();
+		   break;
+      case 0x0c08: topDict.strokeWidth = ops[0].toFloat(); break;
+      case 0x000f: topDict.charsetOffset = ops[0].toInt(); break;
+      case 0x0010: topDict.encodingOffset = ops[0].toInt(); break;
+      case 0x0011: topDict.charStringsOffset = ops[0].toInt(); break;
+      case 0x0012: topDict.privateSize = ops[0].toInt();
+	           topDict.privateOffset = ops[1].toInt();
+		   break;
+      case 0x0c1e: topDict.registrySID = ops[0].toInt();
+	           topDict.orderingSID = ops[1].toInt();
+		   topDict.supplement = ops[2].toInt();
+		   break;
+      case 0x0c24: topDict.fdArrayOffset = ops[0].toInt(); break;
+      case 0x0c25: topDict.fdSelectOffset = ops[0].toInt(); break;
       }
       nOps = 0;
     }
@@ -2227,22 +2409,22 @@
     if (!parsedOk) {
       return;
     }
-    if (!ops[nOps - 1].isNum) {
+    if (ops[nOps - 1].kind == type1COpOperator) {
       if (ops[nOps - 1].op == 0x0012) {
 	if (nOps < 3) {
 	  parsedOk = gFalse;
 	  return;
 	}
-	pSize = (int)ops[0].num;
-	pOffset = (int)ops[1].num;
+	pSize = ops[0].toInt();
+	pOffset = ops[1].toInt();
 	break;
       } else if (ops[nOps - 1].op == 0x0c07) {
-	fontMatrix[0] = ops[0].num;
-	fontMatrix[1] = ops[1].num;
-	fontMatrix[2] = ops[2].num;
-	fontMatrix[3] = ops[3].num;
-	fontMatrix[4] = ops[4].num;
-	fontMatrix[5] = ops[5].num;
+	fontMatrix[0] = ops[0].toFloat();
+	fontMatrix[1] = ops[1].toFloat();
+	fontMatrix[2] = ops[2].toFloat();
+	fontMatrix[3] = ops[3].toFloat();
+	fontMatrix[4] = ops[4].toFloat();
+	fontMatrix[5] = ops[5].toFloat();
 	hasFontMatrix = gTrue;
       }
       nOps = 0;
@@ -2283,9 +2465,9 @@
   pDict->initialRandomSeed = 0;
   pDict->subrsOffset = 0;
   pDict->defaultWidthX = 0;
-  pDict->defaultWidthXFP = gFalse;
+  pDict->defaultWidthXInt = gTrue;
   pDict->nominalWidthX = 0;
-  pDict->nominalWidthXFP = gFalse;
+  pDict->nominalWidthXInt = gTrue;
 
   // no dictionary
   if (offset == 0 || length == 0) {
@@ -2299,7 +2481,7 @@
     if (!parsedOk) {
       break;
     }
-    if (!ops[nOps - 1].isNum) {
+    if (ops[nOps - 1].kind == type1COpOperator) {
       --nOps; // drop the operator
       switch (ops[nOps].op) {
       case 0x0006:
@@ -2319,20 +2501,20 @@
 						    type1CMaxOtherBlues);
 	break;
       case 0x0c09:
-	pDict->blueScale = ops[0].num;
+	pDict->blueScale = ops[0].toFloat();
 	break;
       case 0x0c0a:
-	pDict->blueShift = (int)ops[0].num;
+	pDict->blueShift = ops[0].toInt();
 	break;
       case 0x0c0b:
-	pDict->blueFuzz = (int)ops[0].num;
+	pDict->blueFuzz = ops[0].toInt();
 	break;
       case 0x000a:
-	pDict->stdHW = ops[0].num;
+	pDict->stdHW = ops[0].toFloat();
 	pDict->hasStdHW = gTrue;
 	break;
       case 0x000b:
-	pDict->stdVW = ops[0].num;
+	pDict->stdVW = ops[0].toFloat();
 	pDict->hasStdVW = gTrue;
 	break;
       case 0x0c0c:
@@ -2344,31 +2526,31 @@
 					    type1CMaxStemSnap);
 	break;
       case 0x0c0e:
-	pDict->forceBold = ops[0].num != 0;
+	pDict->forceBold = !ops[0].isZero();
 	pDict->hasForceBold = gTrue;
 	break;
       case 0x0c0f:
-	pDict->forceBoldThreshold = ops[0].num;
+	pDict->forceBoldThreshold = ops[0].toFloat();
 	break;
       case 0x0c11:
-	pDict->languageGroup = (int)ops[0].num;
+	pDict->languageGroup = ops[0].toInt();
 	break;
       case 0x0c12:
-	pDict->expansionFactor = ops[0].num;
+	pDict->expansionFactor = ops[0].toFloat();
 	break;
       case 0x0c13:
-	pDict->initialRandomSeed = (int)ops[0].num;
+	pDict->initialRandomSeed = ops[0].toInt();
 	break;
       case 0x0013:
-	pDict->subrsOffset = offset + (int)ops[0].num;
+	pDict->subrsOffset = offset + ops[0].toInt();
 	break;
       case 0x0014:
-	pDict->defaultWidthX = ops[0].num;
-	pDict->defaultWidthXFP = ops[0].isFP;
+	pDict->defaultWidthX = ops[0].toFloat();
+	pDict->defaultWidthXInt = ops[0].kind == type1COpInteger;
 	break;
       case 0x0015:
-	pDict->nominalWidthX = ops[0].num;
-	pDict->nominalWidthXFP = ops[0].isFP;
+	pDict->nominalWidthX = ops[0].toFloat();
+	pDict->nominalWidthXInt = ops[0].kind == type1COpInteger;
 	break;
       }
       nOps = 0;
@@ -2584,8 +2766,6 @@
   int b0, b1, nyb0, nyb1, x, i;
 
   b0 = getU8(pos++, ok);
-  op.isNum = gTrue;
-  op.isFP = gFalse;
 
   if (b0 == 28) {
     x = getU8(pos++, ok);
@@ -2593,7 +2773,8 @@
     if (x & 0x8000) {
       x |= ~0xffff;
     }
-    op.num = x;
+    op.kind = type1COpInteger;
+    op.intgr = x;
 
   } else if (!charstring && b0 == 29) {
     x = getU8(pos++, ok);
@@ -2603,7 +2784,8 @@
     if (x & 0x80000000) {
       x |= ~0xffffffff;
     }
-    op.num = x;
+    op.kind = type1COpInteger;
+    op.intgr = x;
 
   } else if (!charstring && b0 == 30) {
     i = 0;
@@ -2636,17 +2818,20 @@
       }
     } while (i < 64);
     buf[i] = '\0';
-    op.num = atof(buf);
-    op.isFP = gTrue;
+    op.kind = type1COpFloat;
+    op.flt = atof(buf);
 
   } else if (b0 >= 32 && b0 <= 246) {
-    op.num = b0 - 139;
+    op.kind = type1COpInteger;
+    op.intgr = b0 - 139;
 
   } else if (b0 >= 247 && b0 <= 250) {
-    op.num = ((b0 - 247) << 8) + getU8(pos++, ok) + 108;
+    op.kind = type1COpInteger;
+    op.intgr = ((b0 - 247) << 8) + getU8(pos++, ok) + 108;
 
   } else if (b0 >= 251 && b0 <= 254) {
-    op.num = -((b0 - 251) << 8) - getU8(pos++, ok) - 108;
+    op.kind = type1COpInteger;
+    op.intgr = -((b0 - 251) << 8) - getU8(pos++, ok) - 108;
 
   } else if (charstring && b0 == 255) {
     x = getU8(pos++, ok);
@@ -2656,15 +2841,15 @@
     if (x & 0x80000000) {
       x |= ~0xffffffff;
     }
-    op.num = (double)x / 65536.0;
-    op.isFP = gTrue;
+    op.kind = type1COpFloat;
+    op.flt = (double)x / 65536.0;
 
   } else if (b0 == 12) {
-    op.isNum = gFalse;
+    op.kind = type1COpOperator;
     op.op = 0x0c00 + getU8(pos++, ok);
 
   } else {
-    op.isNum = gFalse;
+    op.kind = type1COpOperator;
     op.op = b0;
   }
 
@@ -2685,7 +2870,7 @@
   }
   x = 0;
   for (i = 0; i < n; ++i) {
-    x += (int)ops[i].num;
+    x += ops[i].toInt();
     arr[i] = x;
   }
   return n;
@@ -2701,7 +2886,7 @@
   }
   x = 0;
   for (i = 0; i < n; ++i) {
-    x += ops[i].num;
+    x += ops[i].toFloat();
     arr[i] = x;
   }
   return n;
@@ -2736,6 +2921,8 @@
   int pos0, pos1;
 
   if (i < 0 || i >= idx->len) {
+    val->pos = 0;
+    val->len = 0;
     *ok = gFalse;
     return;
   }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/FoFiType1C.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -105,18 +105,34 @@
   int initialRandomSeed;
   int subrsOffset;
   double defaultWidthX;
-  GBool defaultWidthXFP;
+  GBool defaultWidthXInt;
   double nominalWidthX;
-  GBool nominalWidthXFP;
+  GBool nominalWidthXInt;
 };
 
+// operand kind
+enum Type1COpKind {
+  type1COpOperator,
+  type1COpInteger,
+  type1COpFloat,
+  type1COpRational
+};
+
+// operand
 struct Type1COp {
-  GBool isNum;			// true -> number, false -> operator
-  GBool isFP;			// true -> floating point number, false -> int
+  Type1COpKind kind;
   union {
-    double num;			// if num is true
-    int op;			// if num is false
+    int op;			// type1COpOperator
+    int intgr;			// type1COpInteger
+    double flt;			// type1COpFloat
+    struct {
+      int num, den;		// type1COpRational
+    } rat;
   };
+  GBool isZero();
+  GBool isNegative();
+  int toInt();
+  double toFloat();
 };
 
 struct Type1CEexecBuf {
@@ -204,7 +220,7 @@
 		GBool top);
   void cvtGlyphWidth(GBool useOp, GString *charBuf,
 		     Type1CPrivateDict *pDict);
-  void cvtNum(double x, GBool isFP, GString *charBuf);
+  void cvtNum(Type1COp op, GString *charBuf);
   void eexecWrite(Type1CEexecBuf *eb, const char *s);
   void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
   void writePSString(char *s, FoFiOutputFunc outputFunc, void *outputStream);

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.dep
===================================================================
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/fofi/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,71 +0,0 @@
-#========================================================================
-#
-# FoFi library Makefile
-#
-# Copyright 2003 Glyph & Cog, LLC
-#
-#========================================================================
-
-SHELL = /bin/sh
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-GOOSRCDIR = $(srcdir)/../goo
-GOOLIBDIR = ../goo
-
-CXXFLAGS = @CXXFLAGS@ @DEFS@ -I.. -I$(srcdir)/.. -I$(GOOSRCDIR) -I$(srcdir)
-
-CXX = @CXX@
-AR = @AR@
-RANLIB = @RANLIB@
-
-LIBPREFIX = @LIBPREFIX@
-
-#------------------------------------------------------------------------
-
-.SUFFIXES: .cc
-
-.cc.o:
-	$(CXX) $(CXXFLAGS) -c $<
-
-#------------------------------------------------------------------------
-
-CXX_SRC = \
-	$(srcdir)/FoFiBase.cc \
-	$(srcdir)/FoFiEncodings.cc \
-	$(srcdir)/FoFiIdentifier.cc \
-	$(srcdir)/FoFiTrueType.cc \
-	$(srcdir)/FoFiType1.cc \
-	$(srcdir)/FoFiType1C.cc
-
-#------------------------------------------------------------------------
-
-all: $(LIBPREFIX)fofi.a
-
-#------------------------------------------------------------------------
-
-FOFI_OBJS = \
-	FoFiBase.o \
-	FoFiEncodings.o \
-	FoFiIdentifier.o \
-	FoFiTrueType.o \
-	FoFiType1.o \
-	FoFiType1C.o
-
-$(LIBPREFIX)fofi.a: $(FOFI_OBJS)
-	rm -f $(LIBPREFIX)fofi.a
-	$(AR) $(LIBPREFIX)fofi.a $(FOFI_OBJS)
-	$(RANLIB) $(LIBPREFIX)fofi.a
-
-#------------------------------------------------------------------------
-
-clean:
-	rm -f $(FOFI_OBJS) $(LIBPREFIX)fofi.a
-
-#------------------------------------------------------------------------
-
-depend:
-	$(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >Makefile.dep
-
--include Makefile.dep

Added: trunk/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,27 @@
+#========================================================================
+#
+# goo/CMakeLists.txt
+#
+# CMake script for the goo library.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+
+add_library(goo_objs OBJECT
+  FixedPoint.cc
+  GHash.cc
+  GList.cc
+  GString.cc
+  gfile.cc
+  gmem.cc
+  gmempp.cc
+  parseargs.c
+)
+
+add_library(goo
+  $<TARGET_OBJECTS:goo_objs>
+)


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/goo/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,6 +16,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "FixedPoint.h"
 
 #define ln2 ((FixedPoint)0.69314718)
@@ -113,7 +114,7 @@
       z >= ((FixPtInt64)1 << 31) || z < -((FixPtInt64)1 << 31)) {
     return gFalse;
   }
-  result->val = z;
+  result->val = (int)z;
   return gTrue;
 }
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/FixedPoint.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -49,35 +49,35 @@
 
   FixedPoint operator =(FixedPoint x) { val = x.val; return *this; }
 
-  int operator ==(FixedPoint x) const { return val == x.val; }
-  int operator ==(double x) const { return *this == (FixedPoint)x; }
-  int operator ==(int x) const { return *this == (FixedPoint)x; }
-  int operator ==(long x) const { return *this == (FixedPoint)x; }
+  bool operator ==(FixedPoint x) const { return val == x.val; }
+  bool operator ==(double x) const { return *this == (FixedPoint)x; }
+  bool operator ==(int x) const { return *this == (FixedPoint)x; }
+  bool operator ==(long x) const { return *this == (FixedPoint)x; }
 
-  int operator !=(FixedPoint x) const { return val != x.val; }
-  int operator !=(double x) const { return *this != (FixedPoint)x; }
-  int operator !=(int x) const { return *this != (FixedPoint)x; }
-  int operator !=(long x) const { return *this != (FixedPoint)x; }
+  bool operator !=(FixedPoint x) const { return val != x.val; }
+  bool operator !=(double x) const { return *this != (FixedPoint)x; }
+  bool operator !=(int x) const { return *this != (FixedPoint)x; }
+  bool operator !=(long x) const { return *this != (FixedPoint)x; }
 
-  int operator <(FixedPoint x) const { return val < x.val; }
-  int operator <(double x) const { return *this < (FixedPoint)x; }
-  int operator <(int x) const { return *this < (FixedPoint)x; }
-  int operator <(long x) const { return *this < (FixedPoint)x; }
+  bool operator <(FixedPoint x) const { return val < x.val; }
+  bool operator <(double x) const { return *this < (FixedPoint)x; }
+  bool operator <(int x) const { return *this < (FixedPoint)x; }
+  bool operator <(long x) const { return *this < (FixedPoint)x; }
 
-  int operator <=(FixedPoint x) const { return val <= x.val; }
-  int operator <=(double x) const { return *this <= (FixedPoint)x; }
-  int operator <=(int x) const { return *this <= (FixedPoint)x; }
-  int operator <=(long x) const { return *this <= (FixedPoint)x; }
+  bool operator <=(FixedPoint x) const { return val <= x.val; }
+  bool operator <=(double x) const { return *this <= (FixedPoint)x; }
+  bool operator <=(int x) const { return *this <= (FixedPoint)x; }
+  bool operator <=(long x) const { return *this <= (FixedPoint)x; }
 
-  int operator >(FixedPoint x) const { return val > x.val; }
-  int operator >(double x) const { return *this > (FixedPoint)x; }
-  int operator >(int x) const { return *this > (FixedPoint)x; }
-  int operator >(long x) const { return *this > (FixedPoint)x; }
+  bool operator >(FixedPoint x) const { return val > x.val; }
+  bool operator >(double x) const { return *this > (FixedPoint)x; }
+  bool operator >(int x) const { return *this > (FixedPoint)x; }
+  bool operator >(long x) const { return *this > (FixedPoint)x; }
 
-  int operator >=(FixedPoint x) const { return val >= x.val; }
-  int operator >=(double x) const { return *this >= (FixedPoint)x; }
-  int operator >=(int x) const { return *this >= (FixedPoint)x; }
-  int operator >=(long x) const { return *this >= (FixedPoint)x; }
+  bool operator >=(FixedPoint x) const { return val >= x.val; }
+  bool operator >=(double x) const { return *this >= (FixedPoint)x; }
+  bool operator >=(int x) const { return *this >= (FixedPoint)x; }
+  bool operator >=(long x) const { return *this >= (FixedPoint)x; }
 
   FixedPoint operator -() { return make(-val); }
 
@@ -136,7 +136,6 @@
   static FixedPoint avg(FixedPoint x, FixedPoint y)
     { return make((x.val >> 1) + (y.val >> 1) + ((x.val | y.val) & 1)); }
 
-
   static FixedPoint sqrt(FixedPoint x);
 
   static FixedPoint pow(FixedPoint x, FixedPoint y);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/GHash.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/GHash.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/GHash.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -13,6 +13,7 @@
 #endif
 
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GHash.h"
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/GList.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/GList.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/GList.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GList.h"
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/GMutex.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/GMutex.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/GMutex.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -3,8 +3,9 @@
 // GMutex.h
 //
 // Portable mutex macros.
+// Portable atomic increment/decrement.
 //
-// Copyright 2002-2003 Glyph & Cog, LLC
+// Copyright 2002-2014 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -11,6 +12,17 @@
 #ifndef GMUTEX_H
 #define GMUTEX_H
 
+#ifdef _WIN32
+#  include <windows.h>
+#  include <intrin.h>
+#else
+#  include <pthread.h>
+#endif
+
+//------------------------------------------------------------------------
+// GMutex
+//------------------------------------------------------------------------
+
 // Usage:
 //
 // GMutex m;
@@ -24,8 +36,6 @@
 
 #ifdef _WIN32
 
-#include <windows.h>
-
 typedef CRITICAL_SECTION GMutex;
 
 #define gInitMutex(m) InitializeCriticalSection(m)
@@ -35,8 +45,6 @@
 
 #else // assume pthreads
 
-#include <pthread.h>
-
 typedef pthread_mutex_t GMutex;
 
 #define gInitMutex(m) pthread_mutex_init(m, NULL)
@@ -46,4 +54,41 @@
 
 #endif
 
+//------------------------------------------------------------------------
+// atomic increment/decrement
+//------------------------------------------------------------------------
+
+// NB: this must be "long" to work on Windows
+typedef long GAtomicCounter;
+
+// Increment *counter by one and return the final value (after the
+// increment).
+static inline GAtomicCounter gAtomicIncrement(GAtomicCounter *counter) {
+  GAtomicCounter newVal;
+
+#if defined(_WIN32)
+  newVal = _InterlockedIncrement(counter);
+#elif defined(__GNUC__) // this also works for LLVM/clang
+  newVal = __sync_add_and_fetch(counter, 1);
+#else
+#  error "gAtomicIncrement is not defined for this compiler/platform"
 #endif
+  return newVal;
+}
+
+// Decrement *counter by one and return the final value (after the
+// decrement).
+static inline GAtomicCounter gAtomicDecrement(GAtomicCounter *counter) {
+  GAtomicCounter newVal;
+
+#if defined(_WIN32)
+  newVal = _InterlockedDecrement(counter);
+#elif defined(__GNUC__) // this also works for LLVM/clang
+  newVal = __sync_sub_and_fetch(counter, 1);
+#else
+#  error "gAtomicDecrement is not defined for this compiler/platform"
+#endif
+  return newVal;
+}
+
+#endif // GMUTEX_H

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/GString.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/GString.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/GString.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -21,6 +21,7 @@
 #include <math.h>
 #include <limits.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 
 //------------------------------------------------------------------------
@@ -755,8 +756,9 @@
   int i;
 
   for (i = 0; i < length; ++i) {
-    if (islower(s[i]))
-      s[i] = toupper(s[i]);
+    if (islower(s[i] & 0xff)) {
+      s[i] = toupper(s[i] & 0xff);
+    }
   }
   return this;
 }
@@ -765,8 +767,9 @@
   int i;
 
   for (i = 0; i < length; ++i) {
-    if (isupper(s[i]))
-      s[i] = tolower(s[i]);
+    if (isupper(s[i] & 0xff)) {
+      s[i] = tolower(s[i] & 0xff);
+    }
   }
   return this;
 }
@@ -778,7 +781,7 @@
   n1 = length;
   n2 = str->length;
   for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) {
-    x = *p1 - *p2;
+    x = (*p1 & 0xff) - (*p2 & 0xff);
     if (x != 0) {
       return x;
     }
@@ -795,7 +798,7 @@
   for (i = 0, p1 = s, p2 = str->s;
        i < n1 && i < n2 && i < n;
        ++i, ++p1, ++p2) {
-    x = *p1 - *p2;
+    x = (*p1 & 0xff) - (*p2 & 0xff);
     if (x != 0) {
       return x;
     }
@@ -812,7 +815,7 @@
 
   n1 = length;
   for (i = 0, p1 = s, p2 = sA; i < n1 && *p2; ++i, ++p1, ++p2) {
-    x = *p1 - *p2;
+    x = (*p1 & 0xff) - (*p2 & 0xff);
     if (x != 0) {
       return x;
     }
@@ -832,7 +835,7 @@
 
   n1 = length;
   for (i = 0, p1 = s, p2 = sA; i < n1 && *p2 && i < n; ++i, ++p1, ++p2) {
-    x = *p1 - *p2;
+    x = (*p1 & 0xff) - (*p2 & 0xff);
     if (x != 0) {
       return x;
     }

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.dep
===================================================================
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,71 +0,0 @@
-#========================================================================
-#
-# Goo library Makefile
-#
-# Copyright 1996-2003 Glyph & Cog, LLC
-#
-#========================================================================
-
-SHELL = /bin/sh
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-CFLAGS = @CFLAGS@ @DEFS@ -I.. -I$(srcdir)/.. -I$(srcdir)
-CXXFLAGS = @CXXFLAGS@ @DEFS@ -I.. -I$(srcdir)/.. -I$(srcdir)
-
-CC = @CC@
-CXX = @CXX@
-AR = @AR@
-RANLIB = @RANLIB@
-
-LIBPREFIX = @LIBPREFIX@
-
-#------------------------------------------------------------------------
-
-.SUFFIXES: .cc
-
-.cc.o:
-	$(CXX) $(CXXFLAGS) -c $<
-
-#------------------------------------------------------------------------
-
-CXX_SRC = \
-	$(srcdir)/GHash.cc \
-	$(srcdir)/GList.cc \
-	$(srcdir)/GString.cc \
-	$(srcdir)/gmem.cc \
-	$(srcdir)/gmempp.cc \
-	$(srcdir)/gfile.cc \
-	$(srcdir)/FixedPoint.cc
-
-C_SRC = \
-	$(srcdir)/parseargs.c
-
-#------------------------------------------------------------------------
-
-all: $(LIBPREFIX)Goo.a
-
-#------------------------------------------------------------------------
-
-GOO_CXX_OBJS = GHash.o GList.o GString.o gmem.o gmempp.o gfile.o FixedPoint.o
-GOO_C_OBJS = parseargs.o
-GOO_OBJS = $(GOO_CXX_OBJS) $(GOO_C_OBJS)
-
-$(LIBPREFIX)Goo.a: $(GOO_OBJS)
-	rm -f $(LIBPREFIX)Goo.a
-	$(AR) $(LIBPREFIX)Goo.a $(GOO_OBJS)
-	$(RANLIB) $(LIBPREFIX)Goo.a
-
-#------------------------------------------------------------------------
-
-clean:
-	rm -f $(GOO_OBJS) $(LIBPREFIX)Goo.a
-
-#------------------------------------------------------------------------
-
-depend:
-	$(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >Makefile.dep
-	$(CC) $(CFLAGS) -MM $(C_SRC) >>Makefile.dep
-
--include Makefile.dep

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -17,9 +17,7 @@
 #  include <time.h>
 #  include <direct.h>
 #else
-#  if defined(MACOS)
-#    include <sys/stat.h>
-#  elif !defined(ACORN)
+#  if !defined(ACORN)
 #    include <sys/types.h>
 #    include <sys/stat.h>
 #    include <fcntl.h>
@@ -27,7 +25,7 @@
 #  include <time.h>
 #  include <limits.h>
 #  include <string.h>
-#  if !defined(VMS) && !defined(ACORN) && !defined(MACOS)
+#  if !defined(VMS) && !defined(ACORN)
 #    include <pwd.h>
 #  endif
 #  if defined(VMS) && (__DECCXX_VER < 50200000)
@@ -34,6 +32,7 @@
 #    include <unixlib.h>
 #  endif
 #endif // _WIN32
+#include "gmempp.h"
 #include "GString.h"
 #include "gfile.h"
 
@@ -69,10 +68,6 @@
   //---------- RISCOS ----------
   return new GString("@");
 
-#elif defined(MACOS)
-  //---------- MacOS ----------
-  return new GString(":");
-
 #else
   //---------- Unix ----------
   char *s;
@@ -104,8 +99,6 @@
   if (GetCurrentDirectoryA(sizeof(buf), buf))
 #elif defined(ACORN)
   if (strcpy(buf, "@"))
-#elif defined(MACOS)
-  if (strcpy(buf, ":"))
 #else
   if (getcwd(buf, sizeof(buf)))
 #endif
@@ -186,23 +179,6 @@
   }
   return path;
 
-#elif defined(MACOS)
-  //---------- MacOS ----------
-  char *p;
-  int i;
-
-  path->append(":");
-  i = path->getLength();
-  path->append(fileName);
-  for (p = path->getCString() + i; *p; ++p) {
-    if (*p == '/') {
-      *p = ':';
-    } else if (*p == '.') {
-      *p = ':';
-    }
-  }
-  return path;
-
 #elif defined(__EMX__)
   //---------- OS/2+EMX ----------
   int i;
@@ -310,14 +286,6 @@
     return new GString(fileName, p - fileName);
   return new GString();
 
-#elif defined(MACOS)
-  //---------- MacOS ----------
-  char *p;
-
-  if ((p = strrchr(fileName, ':')))
-    return new GString(fileName, p - fileName);
-  return new GString();
-
 #else
   //---------- Unix ----------
   char *p;
@@ -342,10 +310,6 @@
   //---------- RISCOS ----------
   return path[0] == '$';
 
-#elif defined(MACOS)
-  //---------- MacOS ----------
-  return path[0] != ':';
-
 #else
   //---------- Unix ----------
   return path[0] == '/';
@@ -383,11 +347,6 @@
   path->insert(0, '@');
   return path;
 
-#elif defined(MACOS)
-  //---------- MacOS ----------
-  path->del(0, 1);
-  return path;
-
 #else
   //---------- Unix and OS/2+EMX ----------
   struct passwd *pw;
@@ -453,25 +412,29 @@
 		   const char *mode, const char *ext) {
 #if defined(_WIN32)
   //---------- Win32 ----------
-  char *tempDir;
+  char tempPath[MAX_PATH + 1];
   GString *s, *s2;
   FILE *f2;
+  DWORD n;
   int t, i;
 
   // this has the standard race condition problem, but I haven't found
   // a better way to generate temp file names with extensions on
   // Windows
-  if ((tempDir = getenv("TEMP"))) {
-    s = new GString(tempDir);
-    s->append('\\');
+  n = GetTempPathA(sizeof(tempPath), tempPath);
+  if (n > 0 && n <= sizeof(tempPath)) {
+    s = new GString(tempPath);
+    if (tempPath[n-1] != '\\') {
+      s->append('\\');
+    }
   } else {
-    s = new GString();
+    s = new GString(".\\");
   }
-  s->appendf("x_{0:d}_{1:d}_",
+  s->appendf("xpdf_{0:d}_{1:d}_",
 	     (int)GetCurrentProcessId(), (int)GetCurrentThreadId());
   t = (int)time(NULL);
   for (i = 0; i < 1000; ++i) {
-    s2 = s->copy()->appendf("{0:d}", t + i);
+    s2 = GString::format("{0:t}{1:d}", s, t + i);
     if (ext) {
       s2->append(ext);
     }
@@ -491,7 +454,7 @@
   }
   delete s;
   return gFalse;
-#elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
+#elif defined(VMS) || defined(__EMX__) || defined(ACORN)
   //---------- non-Unix ----------
   char *s;
 
@@ -730,152 +693,3 @@
   return ftell(f);
 #endif
 }
-
-//------------------------------------------------------------------------
-// GDir and GDirEntry
-//------------------------------------------------------------------------
-
-GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) {
-#ifdef VMS
-  char *p;
-#elif defined(_WIN32)
-  int fa;
-  GString *s;
-#elif defined(ACORN)
-#else
-  struct stat st;
-  GString *s;
-#endif
-
-  name = new GString(nameA);
-  dir = gFalse;
-  if (doStat) {
-#ifdef VMS
-    if (!strcmp(nameA, "-") ||
-	((p = strrchr(nameA, '.')) && !strncmp(p, ".DIR;", 5)))
-      dir = gTrue;
-#elif defined(ACORN)
-#else
-    s = new GString(dirPath);
-    appendToPath(s, nameA);
-#ifdef _WIN32
-    fa = GetFileAttributesA(s->getCString());
-    dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY));
-#else
-    if (stat(s->getCString(), &st) == 0)
-      dir = S_ISDIR(st.st_mode);
-#endif
-    delete s;
-#endif
-  }
-}
-
-GDirEntry::~GDirEntry() {
-  delete name;
-}
-
-GDir::GDir(char *name, GBool doStatA) {
-  path = new GString(name);
-  doStat = doStatA;
-#if defined(_WIN32)
-  GString *tmp;
-
-  tmp = path->copy();
-  tmp->append("/*.*");
-  hnd = FindFirstFileA(tmp->getCString(), &ffd);
-  delete tmp;
-#elif defined(ACORN)
-#elif defined(MACOS)
-#elif defined(ANDROID)
-#else
-  dir = opendir(name);
-#ifdef VMS
-  needParent = strchr(name, '[') != NULL;
-#endif
-#endif
-}
-
-GDir::~GDir() {
-  delete path;
-#if defined(_WIN32)
-  if (hnd) {
-    FindClose(hnd);
-    hnd = NULL;
-  }
-#elif defined(ACORN)
-#elif defined(MACOS)
-#elif defined(ANDROID)
-#else
-  if (dir)
-    closedir(dir);
-#endif
-}
-
-GDirEntry *GDir::getNextEntry() {
-  GDirEntry *e;
-
-#if defined(_WIN32)
-  if (hnd) {
-    e = new GDirEntry(path->getCString(), ffd.cFileName, doStat);
-    if (hnd  && !FindNextFileA(hnd, &ffd)) {
-      FindClose(hnd);
-      hnd = NULL;
-    }
-  } else {
-    e = NULL;
-  }
-#elif defined(ACORN)
-#elif defined(MACOS)
-#elif defined(ANDROID)
-#elif defined(VMS)
-  struct dirent *ent;
-  e = NULL;
-  if (dir) {
-    if (needParent) {
-      e = new GDirEntry(path->getCString(), "-", doStat);
-      needParent = gFalse;
-      return e;
-    }
-    ent = readdir(dir);
-    if (ent) {
-      e = new GDirEntry(path->getCString(), ent->d_name, doStat);
-    }
-  }
-#else
-  struct dirent *ent;
-  e = NULL;
-  if (dir) {
-    ent = (struct dirent *)readdir(dir);
-    if (ent && !strcmp(ent->d_name, ".")) {
-      ent = (struct dirent *)readdir(dir);
-    }
-    if (ent) {
-      e = new GDirEntry(path->getCString(), ent->d_name, doStat);
-    }
-  }
-#endif
-
-  return e;
-}
-
-void GDir::rewind() {
-#ifdef _WIN32
-  GString *tmp;
-
-  if (hnd)
-    FindClose(hnd);
-  tmp = path->copy();
-  tmp->append("/*.*");
-  hnd = FindFirstFileA(tmp->getCString(), &ffd);
-  delete tmp;
-#elif defined(ACORN)
-#elif defined(MACOS)
-#elif defined(ANDROID)
-#else
-  if (dir)
-    rewinddir(dir);
-#ifdef VMS
-  needParent = strchr(path->getCString(), '[') != NULL;
-#endif
-#endif
-}

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gfile.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -22,30 +22,10 @@
 #    include <windows.h>
 #  endif
 #elif defined(ACORN)
-#elif defined(MACOS)
-#  include <ctime.h>
 #elif defined(ANDROID)
 #else
 #  include <unistd.h>
 #  include <sys/types.h>
-#  ifdef VMS
-#    include "vms_dirent.h"
-#  elif HAVE_DIRENT_H
-#    include <dirent.h>
-#    define NAMLEN(d) strlen((d)->d_name)
-#  else
-#    define dirent direct
-#    define NAMLEN(d) (d)->d_namlen
-#    if HAVE_SYS_NDIR_H
-#      include <sys/ndir.h>
-#    endif
-#    if HAVE_SYS_DIR_H
-#      include <sys/dir.h>
-#    endif
-#    if HAVE_NDIR_H
-#      include <ndir.h>
-#    endif
-#  endif
 #endif
 #include "gtypes.h"
 
@@ -132,48 +112,4 @@
 // Like ftell, but returns a 64-bit file offset if available.
 extern GFileOffset gftell(FILE *f);
 
-//------------------------------------------------------------------------
-// GDir and GDirEntry
-//------------------------------------------------------------------------
-
-class GDirEntry {
-public:
-
-  GDirEntry(char *dirPath, char *nameA, GBool doStat);
-  ~GDirEntry();
-  GString *getName() { return name; }
-  GBool isDir() { return dir; }
-
-private:
-
-  GString *name;		// dir/file name
-  GBool dir;			// is it a directory?
-};
-
-class GDir {
-public:
-
-  GDir(char *name, GBool doStatA = gTrue);
-  ~GDir();
-  GDirEntry *getNextEntry();
-  void rewind();
-
-private:
-
-  GString *path;		// directory path
-  GBool doStat;			// call stat() for each entry?
-#if defined(_WIN32)
-  WIN32_FIND_DATAA ffd;
-  HANDLE hnd;
-#elif defined(ACORN)
-#elif defined(MACOS)
-#elif defined(ANDROID)
-#else
-  DIR *dir;			// the DIR structure from opendir()
-#ifdef VMS
-  GBool needParent;		// need to return an entry for [-]
 #endif
-#endif
-};
-
-#endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,9 @@
 #include <stddef.h>
 #include <string.h>
 #include <limits.h>
+#if MULTITHREADED && defined(_WIN32)
+#  include <windows.h>
+#endif
 #include "gmem.h"
 
 #ifdef DEBUG_MEM
@@ -28,7 +31,7 @@
 
 #define gMemMagic 0xabcd9999
 
-#if gmemTrlSize==8
+#if ULONG_MAX > 0xffffffffL
 #define gMemDeadVal 0xdeadbeefdeadbeefUL
 #else
 #define gMemDeadVal 0xdeadbeefUL
@@ -46,10 +49,36 @@
 static int gMemInUse = 0;
 static int gMaxMemInUse = 0;
 
+#if MULTITHREADED
+#  ifdef _WIN32
+     static CRITICAL_SECTION gMemMutex;
+     static INIT_ONCE gMemMutexInitStruct = INIT_ONCE_STATIC_INIT;
+     static BOOL CALLBACK gMemMutexInitFunc(PINIT_ONCE initOnce, PVOID param,
+					    PVOID *context) {
+       InitializeCriticalSection(&gMemMutex);
+       return TRUE;
+     }
+#    define gMemInitMutex InitOnceExecuteOnce(&gMemMutexInitStruct, \
+                                              &gMemMutexInitFunc, NULL, NULL)
+#    define gMemLock EnterCriticalSection(&gMemMutex);
+#    define gMemUnlock LeaveCriticalSection(&gMemMutex);
+#  else
+#    include <pthread.h>
+     static pthread_mutex_t gMemMutex = PTHREAD_MUTEX_INITIALIZER;
+#    define gMemInitMutex
+#    define gMemLock pthread_mutex_lock(&gMemMutex)
+#    define gMemUnlock pthread_mutex_unlock(&gMemMutex)
+#  endif
+#else
+#  define gMemInitMutex
+#  define gMemLock
+#  define gMemUnlock
+#endif
+
 #endif /* DEBUG_MEM */
 
-void *gmalloc(int size) GMEM_EXCEP {
 #ifdef DEBUG_MEM
+void *gmalloc(int size, int ignore) GMEM_EXCEP {
   int size1;
   char *mem;
   GMemHdr *hdr;
@@ -56,6 +85,7 @@
   void *data;
   unsigned long *trl, *p;
 
+  gMemInitMutex;
   if (size < 0) {
     gMemError("Invalid memory allocation size");
   }
@@ -71,7 +101,12 @@
   trl = (unsigned long *)(mem + gMemHdrSize + size1);
   hdr->magic = gMemMagic;
   hdr->size = size;
-  hdr->index = gMemIndex++;
+  if (ignore) {
+    hdr->index = -1;
+  } else {
+    hdr->index = gMemIndex++;
+  }
+  gMemLock;
   if (gMemTail) {
     gMemTail->next = hdr;
     hdr->prev = gMemTail;
@@ -86,11 +121,14 @@
   if (gMemInUse > gMaxMemInUse) {
     gMaxMemInUse = gMemInUse;
   }
+  gMemUnlock;
   for (p = (unsigned long *)data; p <= trl; ++p) {
     *p = gMemDeadVal;
   }
   return data;
+}
 #else
+void *gmalloc(int size) GMEM_EXCEP {
   void *p;
 
   if (size < 0) {
@@ -103,8 +141,8 @@
     gMemError("Out of memory");
   }
   return p;
+}
 #endif
-}
 
 void *grealloc(void *p, int size) GMEM_EXCEP {
 #ifdef DEBUG_MEM
@@ -192,6 +230,7 @@
 
   if (p) {
     hdr = (GMemHdr *)((char *)p - gMemHdrSize);
+    gMemLock;
     if (hdr->magic == gMemMagic &&
 	((hdr->prev == NULL) == (hdr == gMemHead)) &&
 	((hdr->next == NULL) == (hdr == gMemTail))) {
@@ -207,6 +246,7 @@
       }
       --gMemAlloc;
       gMemInUse -= hdr->size;
+      gMemUnlock;
       size = gMemDataSize(hdr->size);
       trl = (unsigned long *)((char *)hdr + gMemHdrSize + size);
       if (*trl != gMemDeadVal) {
@@ -218,6 +258,7 @@
       }
       free(hdr);
     } else {
+      gMemUnlock;
       fprintf(stderr, "Attempted to free bad address %p\n", p);
     }
   }
@@ -240,17 +281,25 @@
 #ifdef DEBUG_MEM
 void gMemReport(FILE *f) {
   GMemHdr *p;
+  int left;
 
   fprintf(f, "%d memory allocations in all\n", gMemIndex);
   fprintf(f, "maximum memory in use: %d bytes\n", gMaxMemInUse);
+  left = 0;
   if (gMemAlloc > 0) {
-    fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc);
-    fprintf(f, " index     size\n");
-    fprintf(f, "-------- --------\n");
     for (p = gMemHead; p; p = p->next) {
-      fprintf(f, "%8d %8d\n", p->index, p->size);
+      if (p->index >= 0) {
+	if (!left) {
+	  fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc);
+	  fprintf(f, " index     size\n");
+	  fprintf(f, "-------- --------\n");
+	  left = 1;
+	}
+	fprintf(f, "%8d %8d\n", p->index, p->size);
+      }
     }
-  } else {
+  }
+  if (!left) {
     fprintf(f, "No memory blocks left allocated\n");
   }
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gmem.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -36,7 +36,11 @@
  * Same as malloc, but prints error message and exits if malloc()
  * returns NULL.
  */
+#ifdef DEBUG_MEM
+extern void *gmalloc(int size, int ignore = 0) GMEM_EXCEP;
+#else
 extern void *gmalloc(int size) GMEM_EXCEP;
+#endif
 
 /*
  * Same as realloc, but prints error message and exits if realloc()

Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -10,23 +10,42 @@
 
 #include <aconf.h>
 #include "gmem.h"
+// NB: do not include gmempp.h here.
 
 #ifdef DEBUG_MEM
 
 void *operator new(size_t size) {
-  return gmalloc((int)size);
+  return gmalloc((int)size, 1);
 }
 
+void *operator new(size_t size, int dummy) {
+  return gmalloc((int)size, 0);
+}
+
 void *operator new[](size_t size) {
-  return gmalloc((int)size);
+  return gmalloc((int)size, 1);
 }
 
+void *operator new[](size_t size, int dummy) {
+  return gmalloc((int)size, 0);
+}
+
 void operator delete(void *p) {
   gfree(p);
 }
 
+// This is only called if a constructor throws an exception.
+void operator delete(void *p, int dummy) {
+  gfree(p);
+}
+
 void operator delete[](void *p) {
   gfree(p);
 }
 
+// This is only called if a constructor throws an exception.
+void operator delete[](void *p, int dummy) {
+  gfree(p);
+}
+
 #endif

Added: trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.h	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,48 @@
+//========================================================================
+//
+// gmempp.h
+//
+// Redefine the new and delete operators to call the debugging malloc.
+//
+// This is a hack: some libraries (Qt) allocate global objects and
+// never free them, so this file #define's new to have an argument, so
+// that we can differentiate our new calls from external library new
+// calls.  Calls from external libraries will not be counted when
+// un-freed memory is listed.  There's no guarantee that this will
+// work in all cases: if some external library also defines a new
+// operator that takes the same extra argument, things will break
+// horribly.
+//
+// This entire .h file is wrapped in '#ifdef DEBUG_MEM'.  I.e., if you
+// don't define DEBUG_MEM, this hack goes away and can't cause any
+// problems.  Do not define DEBUG_MEM in production code.
+//
+// To use this .h file, it must be #included *after* all system
+// includes.  Calls to new in any modules that do not include this .h
+// file will not be counted as un-freed memory.
+//
+//========================================================================
+
+#ifndef GMEMPP_H
+#define GMEMPP_H
+
+#ifdef DEBUG_MEM
+
+#include <stdlib.h>
+
+extern void *operator new(size_t size, int dummy);
+extern void *operator new[](size_t size, int dummy);
+
+// These have to be defined (and declared) to avoid a compiler warning
+// with Visual Studio.
+extern void operator delete(void *p, int dummy);
+extern void operator delete[](void *p, int dummy);
+
+// This transforms 'new Foo(...)' into 'new (1) Foo(...)', which
+// forces a call to the operator new variant with the 'int dummy' arg.
+#define debug_new new (1)
+#define new debug_new
+
+#endif // DEBUG_MEM
+
+#endif // GMEMPP_H


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/goo/gmempp.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/goo/parseargs.c
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/goo/parseargs.c	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/goo/parseargs.c	2017-08-13 07:14:48 UTC (rev 45031)
@@ -26,14 +26,19 @@
   while (i < *argc) {
     if (!strcmp(argv[i], "--")) {
       --*argc;
-      for (j = i; j < *argc; ++j)
+      for (j = i; j < *argc; ++j) {
 	argv[j] = argv[j+1];
+      }
       break;
     } else if ((arg = findArg(args, argv[i]))) {
-      if (!grabArg(arg, i, argc, argv))
+      if (!grabArg(arg, i, argc, argv)) {
 	ok = gFalse;
+      }
+    } else if (argv[i][0] == '-') {
+      ok = gFalse;
+      break;
     } else {
-      ++i;
+      break;
     }
   }
   return ok;
@@ -65,7 +70,7 @@
       break;
     case argFP:
     case argFPDummy:
-      typ = " <fp>";
+      typ = " <number>";
       break;
     case argString:
     case argStringDummy:

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/ms_make.bat
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/ms_make.bat	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/ms_make.bat	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,134 +0,0 @@
-set CC=cl
-set CXX=cl
-set FT2DIR=..\freetype-2.5.3
-rem *** Set PNGDIR and ZLIBDIR to build pdftohtml
-rem set PNGDIR=..\libpng-1.5.12
-rem set ZLIBDIR=..\zlib-1.2.7
-set CFLAGS=/I.. /I..\goo /I..\fofi /I..\splash /O2 /nologo /I%FT2DIR%\include
-set CXXFLAGS=%CFLAGS% /TP
-set LIBPROG=lib
-set LINKFLAGS=/MT /nologo
-
-copy aconf-win32.h aconf.h
-
-cd goo
-%CXX% %CXXFLAGS% /c GHash.cc
-%CXX% %CXXFLAGS% /c GList.cc
-%CXX% %CXXFLAGS% /c GString.cc
-%CXX% %CXXFLAGS% /c gmem.cc
-%CXX% %CXXFLAGS% /c gmempp.cc
-%CXX% %CXXFLAGS% /c gfile.cc
-%CC% %CFLAGS% /c parseargs.c
-%LIBPROG% /nologo /out:Goo.lib GHash.obj GList.obj GString.obj gmempp.obj gfile.obj gmem.obj parseargs.obj
-
-cd ..\fofi
-%CXX% %CXXFLAGS% /c FoFiBase.cc
-%CXX% %CXXFLAGS% /c FoFiEncodings.cc
-%CXX% %CXXFLAGS% /c FoFiIdentifier.cc
-%CXX% %CXXFLAGS% /c FoFiTrueType.cc
-%CXX% %CXXFLAGS% /c FoFiType1.cc
-%CXX% %CXXFLAGS% /c FoFiType1C.cc
-%LIBPROG% /nologo /out:fofi.lib FoFiBase.obj FoFiEncodings.obj FoFiIdentifier.obj FoFiTrueType.obj FoFiType1.obj FoFiType1C.obj
-
-cd ..\splash
-%CXX% %CXXFLAGS% /c Splash.cc
-%CXX% %CXXFLAGS% /c SplashBitmap.cc
-%CXX% %CXXFLAGS% /c SplashClip.cc
-%CXX% %CXXFLAGS% /c SplashFTFont.cc
-%CXX% %CXXFLAGS% /c SplashFTFontEngine.cc
-%CXX% %CXXFLAGS% /c SplashFTFontFile.cc
-%CXX% %CXXFLAGS% /c SplashFont.cc
-%CXX% %CXXFLAGS% /c SplashFontEngine.cc
-%CXX% %CXXFLAGS% /c SplashFontFile.cc
-%CXX% %CXXFLAGS% /c SplashFontFileID.cc
-%CXX% %CXXFLAGS% /c SplashPath.cc
-%CXX% %CXXFLAGS% /c SplashPattern.cc
-%CXX% %CXXFLAGS% /c SplashScreen.cc
-%CXX% %CXXFLAGS% /c SplashState.cc
-%CXX% %CXXFLAGS% /c SplashXPath.cc
-%CXX% %CXXFLAGS% /c SplashXPathScanner.cc
-%LIBPROG% /nologo /out:splash.lib Splash.obj SplashBitmap.obj SplashClip.obj SplashFTFont.obj SplashFTFontEngine.obj SplashFTFontFile.obj SplashFont.obj SplashFontEngine.obj SplashFontFile.obj SplashFontFileID.obj SplashPath.obj SplashPattern.obj SplashScreen.obj SplashState.obj SplashXPath.obj SplashXPathScanner.obj
-
-cd ..\xpdf
-%CXX% %CXXFLAGS% /c AcroForm.cc
-%CXX% %CXXFLAGS% /c Annot.cc
-%CXX% %CXXFLAGS% /c Array.cc
-%CXX% %CXXFLAGS% /c BuiltinFont.cc
-%CXX% %CXXFLAGS% /c BuiltinFontTables.cc
-%CXX% %CXXFLAGS% /c CMap.cc
-%CXX% %CXXFLAGS% /c Catalog.cc
-%CXX% %CXXFLAGS% /c CharCodeToUnicode.cc
-%CXX% %CXXFLAGS% /c Decrypt.cc
-%CXX% %CXXFLAGS% /c Dict.cc
-%CXX% %CXXFLAGS% /c Error.cc
-%CXX% %CXXFLAGS% /c FontEncodingTables.cc
-%CXX% %CXXFLAGS% /c Form.cc
-%CXX% %CXXFLAGS% /c Function.cc
-%CXX% %CXXFLAGS% /c Gfx.cc
-%CXX% %CXXFLAGS% /c GfxFont.cc
-%CXX% %CXXFLAGS% /c GfxState.cc
-%CXX% %CXXFLAGS% /c GlobalParams.cc
-%CXX% %CXXFLAGS% /c ImageOutputDev.cc
-%CXX% %CXXFLAGS% /c JArithmeticDecoder.cc
-%CXX% %CXXFLAGS% /c JBIG2Stream.cc
-%CXX% %CXXFLAGS% /c JPXStream.cc
-%CXX% %CXXFLAGS% /c Lexer.cc
-%CXX% %CXXFLAGS% /c Link.cc
-%CXX% %CXXFLAGS% /c NameToCharCode.cc
-%CXX% %CXXFLAGS% /c Object.cc
-%CXX% %CXXFLAGS% /c OptionalContent.cc
-%CXX% %CXXFLAGS% /c Outline.cc
-%CXX% %CXXFLAGS% /c OutputDev.cc
-%CXX% %CXXFLAGS% /c PDFDoc.cc
-%CXX% %CXXFLAGS% /c PDFDocEncoding.cc
-%CXX% %CXXFLAGS% /c PSOutputDev.cc
-%CXX% %CXXFLAGS% /c PSTokenizer.cc
-%CXX% %CXXFLAGS% /c Page.cc
-%CXX% %CXXFLAGS% /c Parser.cc
-%CXX% %CXXFLAGS% /c PreScanOutputDev.cc
-%CXX% %CXXFLAGS% /c SecurityHandler.cc
-%CXX% %CXXFLAGS% /c SplashOutputDev.cc
-%CXX% %CXXFLAGS% /c Stream.cc
-%CXX% %CXXFLAGS% /c TextOutputDev.cc
-%CXX% %CXXFLAGS% /c TextString.cc
-%CXX% %CXXFLAGS% /c UnicodeMap.cc
-%CXX% %CXXFLAGS% /c UnicodeTypeTable.cc
-%CXX% %CXXFLAGS% /c XFAForm.cc
-%CXX% %CXXFLAGS% /c XRef.cc
-%CXX% %CXXFLAGS% /c Zoox.cc
-%CXX% %CXXFLAGS% /c pdftops.cc
-%CXX% %CXXFLAGS% /c pdftotext.cc
-%CXX% %CXXFLAGS% /c pdftoppm.cc
-%CXX% %CXXFLAGS% /c pdfinfo.cc
-%CXX% %CXXFLAGS% /c pdffonts.cc
-%CXX% %CXXFLAGS% /c pdfdetach.cc
-%CXX% %CXXFLAGS% /c pdfimages.cc
-
-%CXX% %LINKFLAGS% /Fepdftops.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSOutputDev.obj PSTokenizer.obj PreScanOutputDev.obj SecurityHandler.obj SplashOutputDev.obj Stream.obj TextString.obj UnicodeMap.obj XFAForm.obj XRef.obj Zoox.obj pdftops.obj ..\splash\splash.lib ..\fofi\fofi.lib ..\goo\Goo.lib %FT2DIR%\freetype2.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdftotext.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextOutputDev.obj TextString.obj UnicodeMap.obj UnicodeTypeTable.obj XFAForm.obj XRef.obj Zoox.obj pdftotext.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdftoppm.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj SplashOutputDev.obj Stream.obj TextString.obj UnicodeMap.obj UnicodeTypeTable.obj XFAForm.obj XRef.obj Zoox.obj pdftoppm.obj ..\splash\splash.lib ..\fofi\fofi.lib ..\goo\Goo.lib %FT2DIR%\freetype2.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdfinfo.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextString.obj UnicodeMap.obj XFAForm.obj XRef.obj Zoox.obj pdfinfo.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdffonts.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextString.obj UnicodeMap.obj XFAForm.obj XRef.obj Zoox.obj pdffonts.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdfdetach.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextString.obj UnicodeMap.obj XFAForm.obj XRef.obj Zoox.obj pdfdetach.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-%CXX% %LINKFLAGS% /Fepdfimages.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj ImageOutputDev.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextString.obj UnicodeMap.obj XFAForm.obj XRef.obj Zoox.obj pdfimages.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-if x%PNGDIR% == x goto noHTML
-if x%ZLIBDIR% == x goto noHTML
-
-%CXX% %CXXFLAGS% /I%PNGDIR% /I%ZLIBDIR% /c pdftopng.cc
-%CXX% %LINKFLAGS% /Fepdftopng.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj SplashOutputDev.obj Stream.obj TextString.obj UnicodeMap.obj UnicodeTypeTable.obj XFAForm.obj XRef.obj Zoox.obj pdftopng.obj ..\splash\splash.lib ..\fofi\fofi.lib ..\goo\Goo.lib %FT2DIR%\freetype2.lib %PNGDIR%\libpng.lib %ZLIBDIR%\zlib.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-echo "building pdftohtml"
-%CXX% %CXXFLAGS% /I%PNGDIR% /I%ZLIBDIR% /c HTMLGen.cc
-%CXX% %CXXFLAGS% /I%PNGDIR% /I%ZLIBDIR% /c pdftohtml.cc
-%CXX% %LINKFLAGS% /Fepdftohtml.exe AcroForm.obj Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Form.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj HTMLGen.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj OptionalContent.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj SplashOutputDev.obj Stream.obj TextOutputDev.obj TextString.obj UnicodeMap.obj UnicodeTypeTable.obj XFAForm.obj XRef.obj Zoox.obj pdftohtml.obj ..\splash\splash.lib ..\fofi\fofi.lib ..\goo\Goo.lib %FT2DIR%\freetype2.lib %PNGDIR%\libpng.lib %ZLIBDIR%\zlib.lib shell32.lib user32.lib gdi32.lib advapi32.lib
-
-:noHTML
-
-cd ..

Added: trunk/Build/source/libs/xpdf/xpdf-src/splash/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/CMakeLists.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/CMakeLists.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,47 @@
+#========================================================================
+#
+# splash/CMakeLists.txt
+#
+# CMake script for the splash library.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+if (HAVE_SPLASH)
+  include_directories("${PROJECT_SOURCE_DIR}")
+  include_directories("${PROJECT_BINARY_DIR}")
+  include_directories("${PROJECT_SOURCE_DIR}/goo")
+  include_directories("${PROJECT_SOURCE_DIR}/fofi")
+  include_directories("${FREETYPE_INCLUDE_DIRS}")
+
+  if (HAVE_DTYPE4_H)
+    include_directories("${DTYPE_INCLUDE_DIR}")
+    set(DTYPE_SRCS
+        SplashDT4Font.cc SplashDT4FontEngine.cc SplashDT4FontFile.cc)
+  endif ()
+
+  add_library(splash_objs OBJECT
+    Splash.cc
+    SplashBitmap.cc
+    SplashClip.cc
+    SplashFTFont.cc
+    SplashFTFontEngine.cc
+    SplashFTFontFile.cc
+    SplashFont.cc
+    SplashFontEngine.cc
+    SplashFontFile.cc
+    SplashFontFileID.cc
+    SplashPath.cc
+    SplashPattern.cc
+    SplashScreen.cc
+    SplashState.cc
+    SplashXPath.cc
+    SplashXPathScanner.cc
+    ${DTYPE_SRCS}
+  )
+
+  add_library(splash
+    $<TARGET_OBJECTS:splash_objs>
+  )
+endif ()


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/splash/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.dep
===================================================================
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,93 +0,0 @@
-#========================================================================
-#
-# Splash library Makefile
-#
-# Copyright 2003 Glyph & Cog, LLC
-#
-#========================================================================
-
-SHELL = /bin/sh
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-GOOSRCDIR = $(srcdir)/../goo
-GOOLIBDIR = ../goo
-FOFISRCDIR = $(srcdir)/../fofi
-FOFILIBDIR = ../fofi
-
-CXXFLAGS = @CXXFLAGS@ @DEFS@ -I.. -I$(srcdir)/.. -I$(GOOSRCDIR) -I$(FOFISRCDIR) -I$(srcdir) @freetype2_CFLAGS@
-
-CXX = @CXX@
-AR = @AR@
-RANLIB = @RANLIB@
-
-LIBPREFIX = @LIBPREFIX@
-
-#------------------------------------------------------------------------
-
-.SUFFIXES: .cc
-
-.cc.o:
-	$(CXX) $(CXXFLAGS) -c $<
-
-#------------------------------------------------------------------------
-
-CXX_SRC = \
-	$(srcdir)/Splash.cc \
-	$(srcdir)/SplashBitmap.cc \
-	$(srcdir)/SplashClip.cc \
-	$(srcdir)/SplashFTFont.cc \
-	$(srcdir)/SplashFTFontEngine.cc \
-	$(srcdir)/SplashFTFontFile.cc \
-	$(srcdir)/SplashFont.cc \
-	$(srcdir)/SplashFontEngine.cc \
-	$(srcdir)/SplashFontFile.cc \
-	$(srcdir)/SplashFontFileID.cc \
-	$(srcdir)/SplashPath.cc \
-	$(srcdir)/SplashPattern.cc \
-	$(srcdir)/SplashScreen.cc \
-	$(srcdir)/SplashState.cc \
-	$(srcdir)/SplashXPath.cc \
-	$(srcdir)/SplashXPathScanner.cc
-
-#------------------------------------------------------------------------
-
-all: $(LIBPREFIX)splash.a
-
-#------------------------------------------------------------------------
-
-SPLASH_OBJS = \
-	Splash.o \
-	SplashBitmap.o \
-	SplashClip.o \
-	SplashFTFont.o \
-	SplashFTFontEngine.o \
-	SplashFTFontFile.o \
-	SplashFont.o \
-	SplashFontEngine.o \
-	SplashFontFile.o \
-	SplashFontFileID.o \
-	SplashPath.o \
-	SplashPattern.o \
-	SplashScreen.o \
-	SplashState.o \
-	SplashXPath.o \
-	SplashXPathScanner.o
-
-$(LIBPREFIX)splash.a: $(SPLASH_OBJS)
-	rm -f $(LIBPREFIX)splash.a
-	$(AR) $(LIBPREFIX)splash.a $(SPLASH_OBJS)
-	$(RANLIB) $(LIBPREFIX)splash.a
-
-#------------------------------------------------------------------------
-
-clean:
-	rm -f $(SPLASH_OBJS) $(LIBPREFIX)splash.a
-
-#------------------------------------------------------------------------
-
-depend:
-	$(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >Makefile.dep
-
--include Makefile.dep

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,7 +15,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashErrorCodes.h"
 #include "SplashMath.h"
 #include "SplashBitmap.h"
@@ -29,10 +31,13 @@
 #include "SplashGlyphBitmap.h"
 #include "Splash.h"
 
+// the MSVC math.h doesn't define this
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 //------------------------------------------------------------------------
 
-#define splashAAGamma 0.67
-
 // distance of Bezier control point from center for circle approximation
 // = (4 * (sqrt(2) - 1) / 3) * r
 #define bezierCircle ((SplashCoord)0.55228475)
@@ -123,17 +128,6 @@
 };
 
 //------------------------------------------------------------------------
-
-static void blendXor(SplashColorPtr src, SplashColorPtr dest,
-		     SplashColorPtr blend, SplashColorMode cm) {
-  int i;
-
-  for (i = 0; i < splashColorModeNComps[cm]; ++i) {
-    blend[i] = src[i] ^ dest[i];
-  }
-}
-
-//------------------------------------------------------------------------
 // modified region
 //------------------------------------------------------------------------
 
@@ -269,7 +263,7 @@
   Guchar shape, aSrc, aDest, alphaI, alphaIm1, alpha0, aResult;
   SplashColor cSrc, cDest, cBlend;
   Guchar shapeVal, cResult0, cResult1, cResult2, cResult3;
-  int cSrcStride, shapeStride, x, lastX, t, i;
+  int cSrcStride, shapeStride, x, lastX, t;
   SplashColorPtr destColorPtr;
   Guchar destColorMask;
   Guchar *destAlphaPtr;
@@ -396,49 +390,33 @@
       pipe->pattern->getColor(x, y, pipe->cSrcVal);
     }
 
+    cResult0 = cResult1 = cResult2 = cResult3 = 0; // make gcc happy
+
     if (pipe->noTransparency && !state->blendFunc) {
 
-      //----- write destination pixel
+      //----- result color
 
       switch (bitmap->mode) {
       case splashModeMono1:
+      case splashModeMono8:
 	cResult0 = state->grayTransfer[cSrcPtr[0]];
-	if (state->screen->test(x, y, cResult0)) {
-	  *destColorPtr |= destColorMask;
-	} else {
-	  *destColorPtr &= ~destColorMask;
-	}
-	destColorPtr += destColorMask & 1;
-	destColorMask = (destColorMask << 7) | (destColorMask >> 1);
 	break;
-      case splashModeMono8:
-	*destColorPtr++ = state->grayTransfer[cSrcPtr[0]];
-	break;
       case splashModeRGB8:
-	destColorPtr[0] = state->rgbTransferR[cSrcPtr[0]];
-	destColorPtr[1] = state->rgbTransferG[cSrcPtr[1]];
-	destColorPtr[2] = state->rgbTransferB[cSrcPtr[2]];
-	destColorPtr += 3;
-	break;
       case splashModeBGR8:
-	destColorPtr[0] = state->rgbTransferB[cSrcPtr[2]];
-	destColorPtr[1] = state->rgbTransferG[cSrcPtr[1]];
-	destColorPtr[2] = state->rgbTransferR[cSrcPtr[0]];
-	destColorPtr += 3;
+	cResult0 = state->rgbTransferR[cSrcPtr[0]];
+	cResult1 = state->rgbTransferG[cSrcPtr[1]];
+	cResult2 = state->rgbTransferB[cSrcPtr[2]];
 	break;
 #if SPLASH_CMYK
       case splashModeCMYK8:
-	destColorPtr[0] = state->cmykTransferC[cSrcPtr[0]];
-	destColorPtr[1] = state->cmykTransferM[cSrcPtr[1]];
-	destColorPtr[2] = state->cmykTransferY[cSrcPtr[2]];
-	destColorPtr[3] = state->cmykTransferK[cSrcPtr[3]];
-	destColorPtr += 4;
+	cResult0 = state->cmykTransferC[cSrcPtr[0]];
+	cResult1 = state->cmykTransferM[cSrcPtr[1]];
+	cResult2 = state->cmykTransferY[cSrcPtr[2]];
+	cResult3 = state->cmykTransferK[cSrcPtr[3]];
 	break;
 #endif
       }
-      if (destAlphaPtr) {
-	*destAlphaPtr++ = 255;
-      }
+      aResult = 255;
 
     } else { // if (noTransparency && !blendFunc)
 
@@ -516,17 +494,42 @@
 	aDest = 0xff;
       }
 
-      //----- overprint
+      //----- read source color; handle overprint
 
-      for (i = 0; i < bitmapComps; ++i) {
+      switch (bitmap->mode) {
+      case splashModeMono1:
+      case splashModeMono8:
+	cSrc[0] = state->grayTransfer[cSrcPtr[0]];
+	break;
+      case splashModeRGB8:
+      case splashModeBGR8:
+	cSrc[0] = state->rgbTransferR[cSrcPtr[0]];
+	cSrc[1] = state->rgbTransferG[cSrcPtr[1]];
+	cSrc[2] = state->rgbTransferB[cSrcPtr[2]];
+	break;
 #if SPLASH_CMYK
-	if (state->overprintMask & (1 << i)) {
-	  cSrc[i] = cSrcPtr[i];
+      case splashModeCMYK8:
+	if (state->overprintMask & 0x01) {
+	  cSrc[0] = state->cmykTransferC[cSrcPtr[0]];
 	} else {
-	  cSrc[i] = div255(aDest * cDest[i]);
+	  cSrc[0] = div255(aDest * cDest[0]);
 	}
-#else
-	cSrc[i] = cSrcPtr[i];
+	if (state->overprintMask & 0x02) {
+	  cSrc[1] = state->cmykTransferM[cSrcPtr[1]];
+	} else {
+	  cSrc[1] = div255(aDest * cDest[1]);
+	}
+	if (state->overprintMask & 0x04) {
+	  cSrc[2] = state->cmykTransferY[cSrcPtr[2]];
+	} else {
+	  cSrc[2] = div255(aDest * cDest[2]);
+	}
+	if (state->overprintMask & 0x08) {
+	  cSrc[3] = state->cmykTransferK[cSrcPtr[3]];
+	} else {
+	  cSrc[3] = div255(aDest * cDest[3]);
+	}
+	break;
 #endif
       }
 
@@ -629,32 +632,22 @@
 
       //----- result color
 
-      cResult0 = cResult1 = cResult2 = cResult3 = 0; // make gcc happy
-
       switch (pipe->resultColorCtrl) {
 
       case splashPipeResultColorNoAlphaBlendMono:
-	cResult0 = state->grayTransfer[div255((255 - aDest) * cSrc[0] +
-					      aDest * cBlend[0])];
+	cResult0 = div255((255 - aDest) * cSrc[0] + aDest * cBlend[0]);
 	break;
       case splashPipeResultColorNoAlphaBlendRGB:
-	cResult0 = state->rgbTransferR[div255((255 - aDest) * cSrc[0] +
-					      aDest * cBlend[0])];
-	cResult1 = state->rgbTransferG[div255((255 - aDest) * cSrc[1] +
-					      aDest * cBlend[1])];
-	cResult2 = state->rgbTransferB[div255((255 - aDest) * cSrc[2] +
-					      aDest * cBlend[2])];
+	cResult0 = div255((255 - aDest) * cSrc[0] + aDest * cBlend[0]);
+	cResult1 = div255((255 - aDest) * cSrc[1] + aDest * cBlend[1]);
+	cResult2 = div255((255 - aDest) * cSrc[2] + aDest * cBlend[2]);
 	break;
 #if SPLASH_CMYK
       case splashPipeResultColorNoAlphaBlendCMYK:
-	cResult0 = state->cmykTransferC[div255((255 - aDest) * cSrc[0] +
-					       aDest * cBlend[0])];
-	cResult1 = state->cmykTransferM[div255((255 - aDest) * cSrc[1] +
-					       aDest * cBlend[1])];
-	cResult2 = state->cmykTransferY[div255((255 - aDest) * cSrc[2] +
-					       aDest * cBlend[2])];
-	cResult3 = state->cmykTransferK[div255((255 - aDest) * cSrc[3] +
-					       aDest * cBlend[3])];
+	cResult0 = div255((255 - aDest) * cSrc[0] + aDest * cBlend[0]);
+	cResult1 = div255((255 - aDest) * cSrc[1] + aDest * cBlend[1]);
+	cResult2 = div255((255 - aDest) * cSrc[2] + aDest * cBlend[2]);
+	cResult3 = div255((255 - aDest) * cSrc[3] + aDest * cBlend[3]);
 	break;
 #endif
 
@@ -662,8 +655,7 @@
 	if (alphaI == 0) {
 	  cResult0 = 0;
 	} else {
-	  cResult0 = state->grayTransfer[((alphaI - aSrc) * cDest[0] +
-					  aSrc * cSrc[0]) / alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] + aSrc * cSrc[0]) / alphaI;
 	}
 	break;
       case splashPipeResultColorAlphaNoBlendRGB:
@@ -672,12 +664,9 @@
 	  cResult1 = 0;
 	  cResult2 = 0;
 	} else {
-	  cResult0 = state->rgbTransferR[((alphaI - aSrc) * cDest[0] +
-					  aSrc * cSrc[0]) / alphaI];
-	  cResult1 = state->rgbTransferG[((alphaI - aSrc) * cDest[1] +
-					  aSrc * cSrc[1]) / alphaI];
-	  cResult2 = state->rgbTransferB[((alphaI - aSrc) * cDest[2] +
-					  aSrc * cSrc[2]) / alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] + aSrc * cSrc[0]) / alphaI;
+	  cResult1 = ((alphaI - aSrc) * cDest[1] + aSrc * cSrc[1]) / alphaI;
+	  cResult2 = ((alphaI - aSrc) * cDest[2] + aSrc * cSrc[2]) / alphaI;
 	}
 	break;
 #if SPLASH_CMYK
@@ -688,14 +677,10 @@
 	  cResult2 = 0;
 	  cResult3 = 0;
 	} else {
-	  cResult0 = state->cmykTransferC[((alphaI - aSrc) * cDest[0] +
-					   aSrc * cSrc[0]) / alphaI];
-	  cResult1 = state->cmykTransferM[((alphaI - aSrc) * cDest[1] +
-					   aSrc * cSrc[1]) / alphaI];
-	  cResult2 = state->cmykTransferY[((alphaI - aSrc) * cDest[2] +
-					   aSrc * cSrc[2]) / alphaI];
-	  cResult3 = state->cmykTransferK[((alphaI - aSrc) * cDest[3] +
-					   aSrc * cSrc[3]) / alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] + aSrc * cSrc[0]) / alphaI;
+	  cResult1 = ((alphaI - aSrc) * cDest[1] + aSrc * cSrc[1]) / alphaI;
+	  cResult2 = ((alphaI - aSrc) * cDest[2] + aSrc * cSrc[2]) / alphaI;
+	  cResult3 = ((alphaI - aSrc) * cDest[3] + aSrc * cSrc[3]) / alphaI;
 	}
 	break;
 #endif
@@ -704,10 +689,10 @@
 	if (alphaI == 0) {
 	  cResult0 = 0;
 	} else {
-	  cResult0 = state->grayTransfer[((alphaI - aSrc) * cDest[0] +
-					  aSrc * ((255 - alphaIm1) * cSrc[0] +
-						  alphaIm1 * cBlend[0]) / 255) /
-					 alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] +
+		      aSrc * ((255 - alphaIm1) * cSrc[0] +
+			      alphaIm1 * cBlend[0]) / 255)
+	             / alphaI;
 	}
 	break;
       case splashPipeResultColorAlphaBlendRGB:
@@ -716,18 +701,18 @@
 	  cResult1 = 0;
 	  cResult2 = 0;
 	} else {
-	  cResult0 = state->rgbTransferR[((alphaI - aSrc) * cDest[0] +
-					  aSrc * ((255 - alphaIm1) * cSrc[0] +
-						  alphaIm1 * cBlend[0]) / 255) /
-					 alphaI];
-	  cResult1 = state->rgbTransferG[((alphaI - aSrc) * cDest[1] +
-					  aSrc * ((255 - alphaIm1) * cSrc[1] +
-						  alphaIm1 * cBlend[1]) / 255) /
-					 alphaI];
-	  cResult2 = state->rgbTransferB[((alphaI - aSrc) * cDest[2] +
-					  aSrc * ((255 - alphaIm1) * cSrc[2] +
-						  alphaIm1 * cBlend[2]) / 255) /
-					 alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] +
+		      aSrc * ((255 - alphaIm1) * cSrc[0] +
+			      alphaIm1 * cBlend[0]) / 255)
+	             / alphaI;
+	  cResult1 = ((alphaI - aSrc) * cDest[1] +
+		      aSrc * ((255 - alphaIm1) * cSrc[1] +
+			      alphaIm1 * cBlend[1]) / 255)
+	             / alphaI;
+	  cResult2 = ((alphaI - aSrc) * cDest[2] +
+		      aSrc * ((255 - alphaIm1) * cSrc[2] +
+			      alphaIm1 * cBlend[2]) / 255)
+	             / alphaI;
 	}
 	break;
 #if SPLASH_CMYK
@@ -738,74 +723,70 @@
 	  cResult2 = 0;
 	  cResult3 = 0;
 	} else {
-	  cResult0 =
-	    state->cmykTransferC[((alphaI - aSrc) * cDest[0] +
-				  aSrc * ((255 - alphaIm1) * cSrc[0] +
-					  alphaIm1 * cBlend[0]) / 255) /
-				 alphaI];
-	  cResult1 =
-	    state->cmykTransferM[((alphaI - aSrc) * cDest[1] +
-				  aSrc * ((255 - alphaIm1) * cSrc[1] +
-					  alphaIm1 * cBlend[1]) / 255) /
-				 alphaI];
-	  cResult2 =
-	    state->cmykTransferY[((alphaI - aSrc) * cDest[2] +
-				  aSrc * ((255 - alphaIm1) * cSrc[2] +
-					  alphaIm1 * cBlend[2]) / 255) /
-				 alphaI];
-	  cResult3 =
-	    state->cmykTransferK[((alphaI - aSrc) * cDest[3] +
-				  aSrc * ((255 - alphaIm1) * cSrc[3] +
-					  alphaIm1 * cBlend[3]) / 255) /
-				 alphaI];
+	  cResult0 = ((alphaI - aSrc) * cDest[0] +
+		      aSrc * ((255 - alphaIm1) * cSrc[0] +
+			      alphaIm1 * cBlend[0]) / 255)
+	             / alphaI;
+	  cResult1 = ((alphaI - aSrc) * cDest[1] +
+		      aSrc * ((255 - alphaIm1) * cSrc[1] +
+			      alphaIm1 * cBlend[1]) / 255)
+	             / alphaI;
+	  cResult2 = ((alphaI - aSrc) * cDest[2] +
+		      aSrc * ((255 - alphaIm1) * cSrc[2] +
+			      alphaIm1 * cBlend[2]) / 255)
+	             / alphaI;
+	  cResult3 = ((alphaI - aSrc) * cDest[3] +
+		      aSrc * ((255 - alphaIm1) * cSrc[3] +
+			      alphaIm1 * cBlend[3]) / 255)
+	             / alphaI;
 	}
 	break;
 #endif
       }
 
-      //----- write destination pixel
+    } // if (noTransparency && !blendFunc)
 
-      switch (bitmap->mode) {
-      case splashModeMono1:
-	if (state->screen->test(x, y, cResult0)) {
-	  *destColorPtr |= destColorMask;
-	} else {
-	  *destColorPtr &= ~destColorMask;
-	}
-	destColorPtr += destColorMask & 1;
-	destColorMask = (destColorMask << 7) | (destColorMask >> 1);
-	break;
-      case splashModeMono8:
-	*destColorPtr++ = cResult0;
-	break;
-      case splashModeRGB8:
-	destColorPtr[0] = cResult0;
-	destColorPtr[1] = cResult1;
-	destColorPtr[2] = cResult2;
-	destColorPtr += 3;
-	break;
-      case splashModeBGR8:
-	destColorPtr[0] = cResult2;
-	destColorPtr[1] = cResult1;
-	destColorPtr[2] = cResult0;
-	destColorPtr += 3;
-	break;
+    //----- write destination pixel
+
+    switch (bitmap->mode) {
+    case splashModeMono1:
+      if (state->screen->test(x, y, cResult0)) {
+	*destColorPtr |= destColorMask;
+      } else {
+	*destColorPtr &= ~destColorMask;
+      }
+      destColorPtr += destColorMask & 1;
+      destColorMask = (destColorMask << 7) | (destColorMask >> 1);
+      break;
+    case splashModeMono8:
+      *destColorPtr++ = cResult0;
+      break;
+    case splashModeRGB8:
+      destColorPtr[0] = cResult0;
+      destColorPtr[1] = cResult1;
+      destColorPtr[2] = cResult2;
+      destColorPtr += 3;
+      break;
+    case splashModeBGR8:
+      destColorPtr[0] = cResult2;
+      destColorPtr[1] = cResult1;
+      destColorPtr[2] = cResult0;
+      destColorPtr += 3;
+      break;
 #if SPLASH_CMYK
-      case splashModeCMYK8:
-	destColorPtr[0] = cResult0;
-	destColorPtr[1] = cResult1;
-	destColorPtr[2] = cResult2;
-	destColorPtr[3] = cResult3;
-	destColorPtr += 4;
-	break;
+    case splashModeCMYK8:
+      destColorPtr[0] = cResult0;
+      destColorPtr[1] = cResult1;
+      destColorPtr[2] = cResult2;
+      destColorPtr[3] = cResult3;
+      destColorPtr += 4;
+      break;
 #endif
-      }
-      if (destAlphaPtr) {
-	*destAlphaPtr++ = aResult;
-      }
+    }
+    if (destAlphaPtr) {
+      *destAlphaPtr++ = aResult;
+    }
 
-    } // if (noTransparency && !blendFunc)
-
     cSrcPtr += cSrcStride;
     shapePtr2 += shapeStride;
   } // for (x ...)
@@ -821,6 +802,7 @@
   Guchar cResult0;
   SplashColorPtr destColorPtr;
   Guchar destColorMask;
+  SplashScreenCursor screenCursor;
   int cSrcStride, x;
 
   if (cSrcPtr) {
@@ -839,11 +821,13 @@
   destColorPtr = &bitmap->data[y * bitmap->rowSize + (x0 >> 3)];
   destColorMask = 0x80 >> (x0 & 7);
 
+  screenCursor = state->screen->getTestCursor(y);
+
   for (x = x0; x <= x1; ++x) {
 
     //----- write destination pixel
     cResult0 = state->grayTransfer[cSrcPtr[0]];
-    if (state->screen->test(x, y, cResult0)) {
+    if (state->screen->testWithCursor(screenCursor, x, cResult0)) {
       *destColorPtr |= destColorMask;
     } else {
       *destColorPtr &= ~destColorMask;
@@ -1013,9 +997,10 @@
 // bitmap->mode == splashModeMono1 && !bitmap->alpha
 void Splash::pipeRunShapeMono1(SplashPipe *pipe, int x0, int x1, int y,
 			       Guchar *shapePtr, SplashColorPtr cSrcPtr) {
-  Guchar shape, aSrc, cDest0, cResult0;
+  Guchar shape, aSrc, cSrc0, cDest0, cResult0;
   SplashColorPtr destColorPtr;
   Guchar destColorMask;
+  SplashScreenCursor screenCursor;
   int cSrcStride, x, lastX;
 
   if (cSrcPtr) {
@@ -1041,6 +1026,8 @@
   destColorPtr = &bitmap->data[y * bitmap->rowSize + (x0 >> 3)];
   destColorMask = 0x80 >> (x0 & 7);
 
+  screenCursor = state->screen->getTestCursor(y);
+
   for (x = x0; x <= x1; ++x) {
 
     //----- shape
@@ -1054,19 +1041,27 @@
     }
     lastX = x;
 
-    //----- read destination pixel
-    cDest0 = (*destColorPtr & destColorMask) ? 0xff : 0x00;
+    //----- source color
+    cSrc0 = state->grayTransfer[cSrcPtr[0]];
 
     //----- source alpha
     aSrc = shape;
 
-    //----- result color
-    // note: aDest = alphaI = aResult = 0xff
-    cResult0 = state->grayTransfer[(Guchar)div255((0xff - aSrc) * cDest0 +
-						  aSrc * cSrcPtr[0])];
+    //----- special case for aSrc = 255
+    if (aSrc == 255) {
+      cResult0 = cSrc0;
+    } else {
 
+      //----- read destination pixel
+      cDest0 = (*destColorPtr & destColorMask) ? 0xff : 0x00;
+
+      //----- result color
+      // note: aDest = alphaI = aResult = 0xff
+      cResult0 = (Guchar)div255((0xff - aSrc) * cDest0 + aSrc * cSrc0);
+    }
+
     //----- write destination pixel
-    if (state->screen->test(x, y, cResult0)) {
+    if (state->screen->testWithCursor(screenCursor, x, cResult0)) {
       *destColorPtr |= destColorMask;
     } else {
       *destColorPtr &= ~destColorMask;
@@ -1086,7 +1081,7 @@
 // bitmap->mode == splashModeMono8 && bitmap->alpha
 void Splash::pipeRunShapeMono8(SplashPipe *pipe, int x0, int x1, int y,
 			       Guchar *shapePtr, SplashColorPtr cSrcPtr) {
-  Guchar shape, aSrc, aDest, alphaI, aResult, cDest0, cResult0;
+  Guchar shape, aSrc, aDest, alphaI, aResult, cSrc0, cDest0, cResult0;
   SplashColorPtr destColorPtr;
   Guchar *destAlphaPtr;
   int cSrcStride, x, lastX;
@@ -1127,23 +1122,37 @@
     }
     lastX = x;
 
-    //----- read destination pixel
-    cDest0 = *destColorPtr;
-    aDest = *destAlphaPtr;
+    //----- source color
+    cSrc0 = state->grayTransfer[cSrcPtr[0]];
 
     //----- source alpha
     aSrc = shape;
 
-    //----- result alpha and non-isolated group element correction
-    aResult = aSrc + aDest - div255(aSrc * aDest);
-    alphaI = aResult;
+    //----- special case for aSrc = 255
+    if (aSrc == 255) {
+      aResult = 255;
+      cResult0 = cSrc0;
+    } else {
 
-    //----- result color
-    if (alphaI == 0) {
-      cResult0 = 0;
-    } else {
-      cResult0 = state->grayTransfer[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
+      //----- read destination alpha
+      aDest = *destAlphaPtr;
+
+      //----- special case for aDest = 0
+      if (aDest == 0) {
+	aResult = aSrc;
+	cResult0 = cSrc0;
+      } else {
+
+	//----- read destination pixel
+	cDest0 = *destColorPtr;
+
+	//----- result alpha and non-isolated group element correction
+	aResult = aSrc + aDest - div255(aSrc * aDest);
+	alphaI = aResult;
+
+	//----- result color
+	cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+      }
     }
 
     //----- write destination pixel
@@ -1163,6 +1172,7 @@
 void Splash::pipeRunShapeRGB8(SplashPipe *pipe, int x0, int x1, int y,
 			      Guchar *shapePtr, SplashColorPtr cSrcPtr) {
   Guchar shape, aSrc, aDest, alphaI, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
   Guchar cDest0, cDest1, cDest2;
   Guchar cResult0, cResult1, cResult2;
   SplashColorPtr destColorPtr;
@@ -1205,31 +1215,47 @@
     }
     lastX = x;
 
-    //----- read destination pixel
-    cDest0 = destColorPtr[0];
-    cDest1 = destColorPtr[1];
-    cDest2 = destColorPtr[2];
-    aDest = *destAlphaPtr;
+    //----- source color
+    cSrc0 = state->rgbTransferR[cSrcPtr[0]];
+    cSrc1 = state->rgbTransferG[cSrcPtr[1]];
+    cSrc2 = state->rgbTransferB[cSrcPtr[2]];
 
     //----- source alpha
     aSrc = shape;
 
-    //----- result alpha and non-isolated group element correction
-    aResult = aSrc + aDest - div255(aSrc * aDest);
-    alphaI = aResult;
+    //----- special case for aSrc = 255
+    if (aSrc == 255) {
+      aResult = 255;
+      cResult0 = cSrc0;
+      cResult1 = cSrc1;
+      cResult2 = cSrc2;
+    } else {
 
-    //----- result color
-    if (alphaI == 0) {
-      cResult0 = 0;
-      cResult1 = 0;
-      cResult2 = 0;
-    } else {
-      cResult0 = state->rgbTransferR[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
-      cResult1 = state->rgbTransferG[(Guchar)(((alphaI - aSrc) * cDest1 +
-					       aSrc * cSrcPtr[1]) / alphaI)];
-      cResult2 = state->rgbTransferB[(Guchar)(((alphaI - aSrc) * cDest2 +
-					       aSrc * cSrcPtr[2]) / alphaI)];
+      //----- read destination alpha
+      aDest = *destAlphaPtr;
+
+      //----- special case for aDest = 0
+      if (aDest == 0) {
+	aResult = aSrc;
+	cResult0 = cSrc0;
+	cResult1 = cSrc1;
+	cResult2 = cSrc2;
+      } else {
+
+	//----- read destination pixel
+	cDest0 = destColorPtr[0];
+	cDest1 = destColorPtr[1];
+	cDest2 = destColorPtr[2];
+
+	//----- result alpha and non-isolated group element correction
+	aResult = aSrc + aDest - div255(aSrc * aDest);
+	alphaI = aResult;
+
+	//----- result color
+	cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+	cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+	cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
+      }
     }
 
     //----- write destination pixel
@@ -1252,6 +1278,7 @@
 void Splash::pipeRunShapeBGR8(SplashPipe *pipe, int x0, int x1, int y,
 			      Guchar *shapePtr, SplashColorPtr cSrcPtr) {
   Guchar shape, aSrc, aDest, alphaI, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
   Guchar cDest0, cDest1, cDest2;
   Guchar cResult0, cResult1, cResult2;
   SplashColorPtr destColorPtr;
@@ -1294,31 +1321,47 @@
     }
     lastX = x;
 
-    //----- read destination pixel
-    cDest0 = destColorPtr[2];
-    cDest1 = destColorPtr[1];
-    cDest2 = destColorPtr[0];
-    aDest = *destAlphaPtr;
+    //----- source color
+    cSrc0 = state->rgbTransferR[cSrcPtr[0]];
+    cSrc1 = state->rgbTransferG[cSrcPtr[1]];
+    cSrc2 = state->rgbTransferB[cSrcPtr[2]];
 
     //----- source alpha
     aSrc = shape;
 
-    //----- result alpha and non-isolated group element correction
-    aResult = aSrc + aDest - div255(aSrc * aDest);
-    alphaI = aResult;
+    //----- special case for aSrc = 255
+    if (aSrc == 255) {
+      aResult = 255;
+      cResult0 = cSrc0;
+      cResult1 = cSrc1;
+      cResult2 = cSrc2;
+    } else {
 
-    //----- result color
-    if (alphaI == 0) {
-      cResult0 = 0;
-      cResult1 = 0;
-      cResult2 = 0;
-    } else {
-      cResult0 = state->rgbTransferR[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
-      cResult1 = state->rgbTransferG[(Guchar)(((alphaI - aSrc) * cDest1 +
-					       aSrc * cSrcPtr[1]) / alphaI)];
-      cResult2 = state->rgbTransferB[(Guchar)(((alphaI - aSrc) * cDest2 +
-					       aSrc * cSrcPtr[2]) / alphaI)];
+      //----- read destination alpha
+      aDest = *destAlphaPtr;
+
+      //----- special case for aDest = 0
+      if (aDest == 0) {
+	aResult = aSrc;
+	cResult0 = cSrc0;
+	cResult1 = cSrc1;
+	cResult2 = cSrc2;
+      } else {
+
+	//----- read destination pixel
+	cDest0 = destColorPtr[2];
+	cDest1 = destColorPtr[1];
+	cDest2 = destColorPtr[0];
+
+	//----- result alpha and non-isolated group element correction
+	aResult = aSrc + aDest - div255(aSrc * aDest);
+	alphaI = aResult;
+
+	//----- result color
+	cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+	cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+	cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
+      }
     }
 
     //----- write destination pixel
@@ -1394,22 +1437,22 @@
 
     //----- overprint
     if (state->overprintMask & 1) {
-      cSrc0 = cSrcPtr[0];
+      cSrc0 = state->cmykTransferC[cSrcPtr[0]];
     } else {
       cSrc0 = div255(aDest * cDest0);
     }
     if (state->overprintMask & 2) {
-      cSrc1 = cSrcPtr[1];
+      cSrc1 = state->cmykTransferM[cSrcPtr[1]];
     } else {
       cSrc1 = div255(aDest * cDest1);
     }
     if (state->overprintMask & 4) {
-      cSrc2 = cSrcPtr[2];
+      cSrc2 = state->cmykTransferY[cSrcPtr[2]];
     } else {
       cSrc2 = div255(aDest * cDest2);
     }
     if (state->overprintMask & 8) {
-      cSrc3 = cSrcPtr[3];
+      cSrc3 = state->cmykTransferK[cSrcPtr[3]];
     } else {
       cSrc3 = div255(aDest * cDest3);
     }
@@ -1417,25 +1460,34 @@
     //----- source alpha
     aSrc = shape;
 
-    //----- result alpha and non-isolated group element correction
-    aResult = aSrc + aDest - div255(aSrc * aDest);
-    alphaI = aResult;
+    //----- special case for aSrc = 255
+    if (aSrc == 255) {
+      aResult = 255;
+      cResult0 = cSrc0;
+      cResult1 = cSrc1;
+      cResult2 = cSrc2;
+      cResult3 = cSrc3;
+    } else {
 
-    //----- result color
-    if (alphaI == 0) {
-      cResult0 = 0;
-      cResult1 = 0;
-      cResult2 = 0;
-      cResult3 = 0;
-    } else {
-      cResult0 = state->cmykTransferC[(Guchar)(((alphaI - aSrc) * cDest0 +
-						aSrc * cSrc0) / alphaI)];
-      cResult1 = state->cmykTransferM[(Guchar)(((alphaI - aSrc) * cDest1 +
-						aSrc * cSrc1) / alphaI)];
-      cResult2 = state->cmykTransferY[(Guchar)(((alphaI - aSrc) * cDest2 +
-						aSrc * cSrc2) / alphaI)];
-      cResult3 = state->cmykTransferK[(Guchar)(((alphaI - aSrc) * cDest3 +
-						aSrc * cSrc3) / alphaI)];
+      //----- special case for aDest = 0
+      if (aDest == 0) {
+	aResult = aSrc;
+	cResult0 = cSrc0;
+	cResult1 = cSrc1;
+	cResult2 = cSrc2;
+	cResult3 = cSrc3;
+      } else {
+
+	//----- result alpha and non-isolated group element correction
+	aResult = aSrc + aDest - div255(aSrc * aDest);
+	alphaI = aResult;
+
+	//----- result color
+	cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+	cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+	cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
+	cResult3 = (Guchar)(((alphaI - aSrc) * cDest3 + aSrc * cSrc3) / alphaI);
+      }
     }
 
     //----- write destination pixel
@@ -1462,9 +1514,10 @@
 // bitmap->mode == splashModeMono1 && !bitmap->alpha
 void Splash::pipeRunAAMono1(SplashPipe *pipe, int x0, int x1, int y,
 			    Guchar *shapePtr, SplashColorPtr cSrcPtr) {
-  Guchar shape, aSrc, cDest0, cResult0;
+  Guchar shape, aSrc, cSrc0, cDest0, cResult0;
   SplashColorPtr destColorPtr;
   Guchar destColorMask;
+  SplashScreenCursor screenCursor;
   int cSrcStride, x, lastX;
 
   if (cSrcPtr) {
@@ -1490,6 +1543,8 @@
   destColorPtr = &bitmap->data[y * bitmap->rowSize + (x0 >> 3)];
   destColorMask = 0x80 >> (x0 & 7);
 
+  screenCursor = state->screen->getTestCursor(y);
+
   for (x = x0; x <= x1; ++x) {
 
     //----- shape
@@ -1506,16 +1561,18 @@
     //----- read destination pixel
     cDest0 = (*destColorPtr & destColorMask) ? 0xff : 0x00;
 
+    //----- source color
+    cSrc0 = state->grayTransfer[cSrcPtr[0]];
+
     //----- source alpha
     aSrc = div255(pipe->aInput * shape);
 
     //----- result color
     // note: aDest = alphaI = aResult = 0xff
-    cResult0 = state->grayTransfer[(Guchar)div255((0xff - aSrc) * cDest0 +
-						  aSrc * cSrcPtr[0])];
+    cResult0 = (Guchar)div255((0xff - aSrc) * cDest0 + aSrc * cSrc0);
 
     //----- write destination pixel
-    if (state->screen->test(x, y, cResult0)) {
+    if (state->screen->testWithCursor(screenCursor, x, cResult0)) {
       *destColorPtr |= destColorMask;
     } else {
       *destColorPtr &= ~destColorMask;
@@ -1537,7 +1594,7 @@
 // bitmap->mode == splashModeMono8 && bitmap->alpha
 void Splash::pipeRunAAMono8(SplashPipe *pipe, int x0, int x1, int y,
 			    Guchar *shapePtr, SplashColorPtr cSrcPtr) {
-  Guchar shape, aSrc, aDest, alphaI, aResult, cDest0, cResult0;
+  Guchar shape, aSrc, aDest, alphaI, aResult, cSrc0, cDest0, cResult0;
   SplashColorPtr destColorPtr;
   Guchar *destAlphaPtr;
   int cSrcStride, x, lastX;
@@ -1582,6 +1639,9 @@
     cDest0 = *destColorPtr;
     aDest = *destAlphaPtr;
 
+    //----- source color
+    cSrc0 = state->grayTransfer[cSrcPtr[0]];
+
     //----- source alpha
     aSrc = div255(pipe->aInput * shape);
 
@@ -1593,8 +1653,7 @@
     if (alphaI == 0) {
       cResult0 = 0;
     } else {
-      cResult0 = state->grayTransfer[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
+      cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
     }
 
     //----- write destination pixel
@@ -1616,6 +1675,7 @@
 void Splash::pipeRunAARGB8(SplashPipe *pipe, int x0, int x1, int y,
 			   Guchar *shapePtr, SplashColorPtr cSrcPtr) {
   Guchar shape, aSrc, aDest, alphaI, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
   Guchar cDest0, cDest1, cDest2;
   Guchar cResult0, cResult1, cResult2;
   SplashColorPtr destColorPtr;
@@ -1664,6 +1724,11 @@
     cDest2 = destColorPtr[2];
     aDest = *destAlphaPtr;
 
+    //----- source color
+    cSrc0 = state->rgbTransferR[cSrcPtr[0]];
+    cSrc1 = state->rgbTransferG[cSrcPtr[1]];
+    cSrc2 = state->rgbTransferB[cSrcPtr[2]];
+
     //----- source alpha
     aSrc = div255(pipe->aInput * shape);
 
@@ -1677,12 +1742,9 @@
       cResult1 = 0;
       cResult2 = 0;
     } else {
-      cResult0 = state->rgbTransferR[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
-      cResult1 = state->rgbTransferG[(Guchar)(((alphaI - aSrc) * cDest1 +
-					       aSrc * cSrcPtr[1]) / alphaI)];
-      cResult2 = state->rgbTransferB[(Guchar)(((alphaI - aSrc) * cDest2 +
-					       aSrc * cSrcPtr[2]) / alphaI)];
+      cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+      cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+      cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
     }
 
     //----- write destination pixel
@@ -1707,6 +1769,7 @@
 void Splash::pipeRunAABGR8(SplashPipe *pipe, int x0, int x1, int y,
 			   Guchar *shapePtr, SplashColorPtr cSrcPtr) {
   Guchar shape, aSrc, aDest, alphaI, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
   Guchar cDest0, cDest1, cDest2;
   Guchar cResult0, cResult1, cResult2;
   SplashColorPtr destColorPtr;
@@ -1755,6 +1818,11 @@
     cDest2 = destColorPtr[0];
     aDest = *destAlphaPtr;
 
+    //----- source color
+    cSrc0 = state->rgbTransferR[cSrcPtr[0]];
+    cSrc1 = state->rgbTransferG[cSrcPtr[1]];
+    cSrc2 = state->rgbTransferB[cSrcPtr[2]];
+
     //----- source alpha
     aSrc = div255(pipe->aInput * shape);
 
@@ -1768,12 +1836,9 @@
       cResult1 = 0;
       cResult2 = 0;
     } else {
-      cResult0 = state->rgbTransferR[(Guchar)(((alphaI - aSrc) * cDest0 +
-					       aSrc * cSrcPtr[0]) / alphaI)];
-      cResult1 = state->rgbTransferG[(Guchar)(((alphaI - aSrc) * cDest1 +
-					       aSrc * cSrcPtr[1]) / alphaI)];
-      cResult2 = state->rgbTransferB[(Guchar)(((alphaI - aSrc) * cDest2 +
-					       aSrc * cSrcPtr[2]) / alphaI)];
+      cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+      cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+      cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
     }
 
     //----- write destination pixel
@@ -1851,22 +1916,22 @@
 
     //----- overprint
     if (state->overprintMask & 1) {
-      cSrc0 = cSrcPtr[0];
+      cSrc0 = state->cmykTransferC[cSrcPtr[0]];
     } else {
       cSrc0 = div255(aDest * cDest0);
     }
     if (state->overprintMask & 2) {
-      cSrc1 = cSrcPtr[1];
+      cSrc1 = state->cmykTransferM[cSrcPtr[1]];
     } else {
       cSrc1 = div255(aDest * cDest1);
     }
     if (state->overprintMask & 4) {
-      cSrc2 = cSrcPtr[2];
+      cSrc2 = state->cmykTransferY[cSrcPtr[2]];
     } else {
       cSrc2 = div255(aDest * cDest2);
     }
     if (state->overprintMask & 8) {
-      cSrc3 = cSrcPtr[3];
+      cSrc3 = state->cmykTransferK[cSrcPtr[3]];
     } else {
       cSrc3 = div255(aDest * cDest3);
     }
@@ -1885,14 +1950,10 @@
       cResult2 = 0;
       cResult3 = 0;
     } else {
-      cResult0 = state->cmykTransferC[(Guchar)(((alphaI - aSrc) * cDest0 +
-						aSrc * cSrc0) / alphaI)];
-      cResult1 = state->cmykTransferM[(Guchar)(((alphaI - aSrc) * cDest1 +
-						aSrc * cSrc1) / alphaI)];
-      cResult2 = state->cmykTransferY[(Guchar)(((alphaI - aSrc) * cDest2 +
-						aSrc * cSrc2) / alphaI)];
-      cResult3 = state->cmykTransferK[(Guchar)(((alphaI - aSrc) * cDest3 +
-						aSrc * cSrc3) / alphaI)];
+      cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+      cResult1 = (Guchar)(((alphaI - aSrc) * cDest1 + aSrc * cSrc1) / alphaI);
+      cResult2 = (Guchar)(((alphaI - aSrc) * cDest2 + aSrc * cSrc2) / alphaI);
+      cResult3 = (Guchar)(((alphaI - aSrc) * cDest3 + aSrc * cSrc3) / alphaI);
     }
 
     //----- write destination pixel
@@ -1931,8 +1992,6 @@
 
 Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
 	       SplashScreenParams *screenParams) {
-  int i;
-
   bitmap = bitmapA;
   bitmapComps = splashColorModeNComps[bitmap->mode];
   vectorAntialias = vectorAntialiasA;
@@ -1940,13 +1999,12 @@
   state = new SplashState(bitmap->width, bitmap->height, vectorAntialias,
 			  screenParams);
   scanBuf = (Guchar *)gmalloc(bitmap->width);
-  if (vectorAntialias) {
-    for (i = 0; i <= 255; ++i) {
-      aaGamma[i] = (Guchar)splashRound(
-			       splashPow((SplashCoord)i / (SplashCoord)255,
-					 splashAAGamma) * 255);
-    }
+  if (bitmap->mode == splashModeMono1) {
+    scanBuf2 = (Guchar *)gmalloc(bitmap->width);
+  } else {
+    scanBuf2 = NULL;
   }
+  groupBackBitmap = NULL;
   minLineWidth = 0;
   clearModRegion();
   debugMode = gFalse;
@@ -1954,8 +2012,6 @@
 
 Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
 	       SplashScreen *screenA) {
-  int i;
-
   bitmap = bitmapA;
   bitmapComps = splashColorModeNComps[bitmap->mode];
   vectorAntialias = vectorAntialiasA;
@@ -1963,13 +2019,12 @@
   state = new SplashState(bitmap->width, bitmap->height, vectorAntialias,
 			  screenA);
   scanBuf = (Guchar *)gmalloc(bitmap->width);
-  if (vectorAntialias) {
-    for (i = 0; i <= 255; ++i) {
-      aaGamma[i] = (Guchar)splashRound(
-			       splashPow((SplashCoord)i / (SplashCoord)255,
-					 splashAAGamma) * 255);
-    }
+  if (bitmap->mode == splashModeMono1) {
+    scanBuf2 = (Guchar *)gmalloc(bitmap->width);
+  } else {
+    scanBuf2 = NULL;
   }
+  groupBackBitmap = NULL;
   minLineWidth = 0;
   clearModRegion();
   debugMode = gFalse;
@@ -1981,6 +2036,7 @@
   }
   delete state;
   gfree(scanBuf);
+  gfree(scanBuf2);
 }
 
 //------------------------------------------------------------------------
@@ -2047,7 +2103,7 @@
   return state->lineDashPhase;
 }
 
-GBool Splash::getStrokeAdjust() {
+SplashStrokeAdjustMode Splash::getStrokeAdjust() {
   return state->strokeAdjust;
 }
 
@@ -2128,7 +2184,7 @@
   state->setLineDash(lineDash, lineDashLength, lineDashPhase);
 }
 
-void Splash::setStrokeAdjust(GBool strokeAdjust) {
+void Splash::setStrokeAdjust(SplashStrokeAdjustMode strokeAdjust) {
   state->strokeAdjust = strokeAdjust;
 }
 
@@ -2169,6 +2225,10 @@
   state->overprintMask = overprintMask;
 }
 
+void Splash::setEnablePathSimplification(GBool en) {
+  state->enablePathSimplification = en;
+}
+
 //------------------------------------------------------------------------
 // state save/restore
 //------------------------------------------------------------------------
@@ -2300,7 +2360,8 @@
 
 SplashError Splash::stroke(SplashPath *path) {
   SplashPath *path2, *dPath;
-  SplashCoord t0, t1, t2, t3, w, w2;
+  SplashCoord t0, t1, t2, t3, w, w2, lineDashMax, lineDashTotal;
+  int lineCap, lineJoin, i;
 
   if (debugMode) {
     printf("stroke [dash:%d] [width:%.2f]:\n",
@@ -2312,15 +2373,6 @@
     return splashErrEmptyPath;
   }
   path2 = flattenPath(path, state->matrix, state->flatness);
-  if (state->lineDashLength > 0) {
-    dPath = makeDashedPath(path2);
-    delete path2;
-    path2 = dPath;
-    if (path2->length == 0) {
-      delete path2;
-      return splashErrEmptyPath;
-    }
-  }
 
   // Compute an approximation of the transformed line width.
   // Given a CTM of [m0 m1],
@@ -2341,10 +2393,62 @@
     w = (t1 < t2) ? t1 : t2;
   }
   w2 = w * state->lineWidth;
+
+  // construct the dashed path
+  if (state->lineDashLength > 0) {
+
+    // check the maximum transformed dash element length (using the
+    // same approximation as for line width) -- if it's less than 0.1
+    // pixel, don't apply the dash pattern; this avoids a huge
+    // performance/memory hit with PDF files that use absurd dash
+    // patterns like [0.0007 0.0003]
+    lineDashTotal = 0;
+    lineDashMax = 0;
+    for (i = 0; i < state->lineDashLength; ++i) {
+      lineDashTotal += state->lineDash[i];
+      if (state->lineDash[i] > lineDashMax) {
+	lineDashMax = state->lineDash[i];
+      }
+    }
+    // Acrobat simply draws nothing if the dash array is [0]
+    if (lineDashTotal == 0) {
+      delete path2;
+      return splashOk;
+    }
+    if (w * lineDashMax > 0.1) {
+
+      dPath = makeDashedPath(path2);
+      delete path2;
+      path2 = dPath;
+      if (path2->length == 0) {
+	delete path2;
+	return splashErrEmptyPath;
+      }
+    }
+  }
+
+  // round caps on narrow lines look bad, and can't be
+  // stroke-adjusted, so use projecting caps instead (but we can't do
+  // this if there are zero-length dashes or segments, because those
+  // turn into round dots)
+  lineCap = state->lineCap;
+  lineJoin = state->lineJoin;
+  if (state->strokeAdjust == splashStrokeAdjustCAD &&
+      w2 < 3.5) {
+    if (lineCap == splashLineCapRound &&
+	!state->lineDashContainsZeroLengthDashes() &&
+	!path->containsZeroLengthSubpaths()) {
+      lineCap = splashLineCapProjecting;
+    }
+    if (lineJoin == splashLineJoinRound) {
+      lineJoin = splashLineJoinBevel;
+    }
+  }
+
   // if there is a min line width set, and the transformed line width
   // is smaller, use the min line width
   if (w > 0 && w2 < minLineWidth) {
-    strokeWide(path2, minLineWidth / w);
+    strokeWide(path2, minLineWidth / w, splashLineCapButt, splashLineJoinBevel);
   } else if (bitmap->mode == splashModeMono1) {
     // in monochrome mode, use 0-width lines for any transformed line
     // width <= 1 -- lines less than 1 pixel wide look too fat without
@@ -2352,7 +2456,7 @@
     if (w2 < 1.001) {
       strokeNarrow(path2);
     } else {
-      strokeWide(path2, state->lineWidth);
+      strokeWide(path2, state->lineWidth, lineCap, lineJoin);
     }
   } else {
     // in gray and color modes, only use 0-width lines if the line
@@ -2360,7 +2464,7 @@
     if (state->lineWidth == 0) {
       strokeNarrow(path2);
     } else {
-      strokeWide(path2, state->lineWidth);
+      strokeWide(path2, state->lineWidth, lineCap, lineJoin);
     }
   }
 
@@ -2380,7 +2484,9 @@
 
   nClipRes[0] = nClipRes[1] = nClipRes[2] = 0;
 
-  xPath = new SplashXPath(path, state->matrix, state->flatness, gFalse);
+  xPath = new SplashXPath(path, state->matrix, state->flatness, gFalse,
+			  state->enablePathSimplification,
+			  state->strokeAdjust);
 
   pipeInit(&pipe, state->strokePattern,
 	   (Guchar)splashRound(state->strokeAlpha * 255),
@@ -2497,10 +2603,11 @@
   (this->*pipe->run)(pipe, x0, x1, y, scanBuf + x0, NULL);
 }
 
-void Splash::strokeWide(SplashPath *path, SplashCoord w) {
+void Splash::strokeWide(SplashPath *path, SplashCoord w,
+			int lineCap, int lineJoin) {
   SplashPath *path2;
 
-  path2 = makeStrokePath(path, w, gFalse);
+  path2 = makeStrokePath(path, w, lineCap, lineJoin, gFalse);
   fillWithPattern(path2, gFalse, state->strokePattern, state->strokeAlpha);
   delete path2;
 }
@@ -2636,8 +2743,8 @@
   SplashCoord lineDashTotal;
   SplashCoord lineDashStartPhase, lineDashDist, segLen;
   SplashCoord x0, y0, x1, y1, xa, ya;
-  GBool lineDashStartOn, lineDashOn, newPath;
-  int lineDashStartIdx, lineDashIdx;
+  GBool lineDashStartOn, lineDashEndOn, lineDashOn, newPath;
+  int lineDashStartIdx, lineDashIdx, subpathStart, nDashes;
   int i, j, k;
 
   lineDashTotal = 0;
@@ -2649,6 +2756,13 @@
     return new SplashPath();
   }
   lineDashStartPhase = state->lineDashPhase;
+  if (lineDashStartPhase > lineDashTotal * 2) {
+    i = splashFloor(lineDashStartPhase / (lineDashTotal * 2));
+    lineDashStartPhase -= lineDashTotal * i * 2;
+  } else if (lineDashStartPhase < 0) {
+    i = splashCeil(-lineDashStartPhase / (lineDashTotal * 2));
+    lineDashStartPhase += lineDashTotal * i * 2;
+  }
   i = splashFloor(lineDashStartPhase / lineDashTotal);
   lineDashStartPhase -= (SplashCoord)i * lineDashTotal;
   lineDashStartOn = gTrue;
@@ -2657,7 +2771,9 @@
     while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) {
       lineDashStartOn = !lineDashStartOn;
       lineDashStartPhase -= state->lineDash[lineDashStartIdx];
-      ++lineDashStartIdx;
+      if (++lineDashStartIdx == state->lineDashLength) {
+	lineDashStartIdx = 0;
+      }
     }
   }
 
@@ -2674,8 +2790,11 @@
 
     // initialize the dash parameters
     lineDashOn = lineDashStartOn;
+    lineDashEndOn = lineDashStartOn;
     lineDashIdx = lineDashStartIdx;
     lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase;
+    subpathStart = dPath->length;
+    nDashes = 0;
 
     // process each segment of the subpath
     newPath = gTrue;
@@ -2691,12 +2810,32 @@
       // process the segment
       while (segLen > 0) {
 
-	if (lineDashDist >= segLen) {
+	// Special case for zero-length dash segments: draw a very
+	// short -- but not zero-length -- segment.  This ensures that
+	// we get the correct behavior with butt and projecting line
+	// caps.  The PS/PDF specs imply that zero-length segments are
+	// not drawn unless the line cap is round, but Acrobat and
+	// Ghostscript both draw very short segments (for butt caps)
+	// and squares (for projecting caps).
+	if (lineDashDist == 0) {
 	  if (lineDashOn) {
 	    if (newPath) {
 	      dPath->moveTo(x0, y0);
 	      newPath = gFalse;
+	      ++nDashes;
 	    }
+	    xa = x0 + ((SplashCoord)0.001 / segLen) * (x1 - x0);
+	    ya = y0 + ((SplashCoord)0.001 / segLen) * (y1 - y0);
+	    dPath->lineTo(xa, ya);
+	  }
+
+	} else if (lineDashDist >= segLen) {
+	  if (lineDashOn) {
+	    if (newPath) {
+	      dPath->moveTo(x0, y0);
+	      newPath = gFalse;
+	      ++nDashes;
+	    }
 	    dPath->lineTo(x1, y1);
 	  }
 	  lineDashDist -= segLen;
@@ -2709,6 +2848,7 @@
 	    if (newPath) {
 	      dPath->moveTo(x0, y0);
 	      newPath = gFalse;
+	      ++nDashes;
 	    }
 	    dPath->lineTo(xa, ya);
 	  }
@@ -2718,6 +2858,8 @@
 	  lineDashDist = 0;
 	}
 
+	lineDashEndOn = lineDashOn;
+
 	// get the next entry in the dash array
 	if (lineDashDist <= 0) {
 	  lineDashOn = !lineDashOn;
@@ -2729,6 +2871,31 @@
 	}
       }
     }
+
+    // in a closed subpath, where the dash pattern is "on" at both the
+    // start and end of the subpath, we need to merge the start and
+    // end to get a proper line join
+    if ((path->flags[j] & splashPathClosed) &&
+	lineDashStartOn &&
+	lineDashEndOn) {
+      if (nDashes == 1) {
+	dPath->close();
+      } else if (nDashes > 1) {
+	k = subpathStart;
+	do {
+	  ++k;
+	  dPath->lineTo(dPath->pts[k].x, dPath->pts[k].y);
+	} while (!(dPath->flags[k] & splashPathLast));
+	++k;
+	memmove(&dPath->pts[subpathStart], &dPath->pts[k],
+		(dPath->length - k) * sizeof(SplashPathPoint));
+	memmove(&dPath->flags[subpathStart], &dPath->flags[k],
+		(dPath->length - k) * sizeof(Guchar));
+	dPath->length -= k - subpathStart;
+	dPath->curSubpath -= k - subpathStart;
+      }
+    }
+
     i = j + 1;
   }
 
@@ -2750,7 +2917,7 @@
   SplashPath *path2;
   SplashXPath *xPath;
   SplashXPathScanner *scanner;
-  int xMin, yMin, xMax, yMax, x, y, t;
+  int xMin, yMin, xMax, xMin2, xMax2, yMax, y, t;
   SplashClipResult clipRes;
 
   if (path->length == 0) {
@@ -2763,7 +2930,9 @@
 
   path2 = tweakFillPath(path);
 
-  xPath = new SplashXPath(path2, state->matrix, state->flatness, gTrue);
+  xPath = new SplashXPath(path2, state->matrix, state->flatness, gTrue,
+			  state->enablePathSimplification,
+			  state->strokeAdjust);
   if (path2 != path) {
     delete path2;
   }
@@ -2806,23 +2975,25 @@
     // draw the spans
     if (vectorAntialias && !inShading) {
       for (y = yMin; y <= yMax; ++y) {
-	scanner->getSpan(scanBuf, y, xMin, xMax);
-	if (clipRes != splashClipAllInside) {
-	  state->clip->clipSpan(scanBuf, y, xMin, xMax, state->strokeAdjust);
+	scanner->getSpan(scanBuf, y, xMin, xMax, &xMin2, &xMax2);
+	if (xMin2 <= xMax2) {
+	  if (clipRes != splashClipAllInside) {
+	    state->clip->clipSpan(scanBuf, y, xMin2, xMax2,
+				  state->strokeAdjust);
+	  }
+	  (this->*pipe.run)(&pipe, xMin2, xMax2, y, scanBuf + xMin2, NULL);
 	}
-	for (x = xMin; x <= xMax; ++x) {
-	  scanBuf[x] = aaGamma[scanBuf[x]];
-	}
-	(this->*pipe.run)(&pipe, xMin, xMax, y, scanBuf + xMin, NULL);
       }
     } else {
       for (y = yMin; y <= yMax; ++y) {
-	scanner->getSpanBinary(scanBuf, y, xMin, xMax);
-	if (clipRes != splashClipAllInside) {
-	  state->clip->clipSpanBinary(scanBuf, y, xMin, xMax,
-				      state->strokeAdjust);
+	scanner->getSpanBinary(scanBuf, y, xMin, xMax, &xMin2, &xMax2);
+	if (xMin2 <= xMax2) {
+	  if (clipRes != splashClipAllInside) {
+	    state->clip->clipSpanBinary(scanBuf, y, xMin2, xMax2,
+					state->strokeAdjust);
+	  }
+	  (this->*pipe.run)(&pipe, xMin2, xMax2, y, scanBuf + xMin2, NULL);
 	}
-	(this->*pipe.run)(&pipe, xMin, xMax, y, scanBuf + xMin, NULL);
       }
     }
   }
@@ -2849,7 +3020,7 @@
   SplashCoord xx0, yy0, xx1, yy1, dx, dy, d, wx, wy, w;
   int n;
 
-  if (!state->strokeAdjust || path->hints) {
+  if (state->strokeAdjust == splashStrokeAdjustOff || path->hints) {
     return path;
   }
 
@@ -2887,7 +3058,7 @@
 	 splashAbs(path->pts[1].y - path->pts[2].y) < 0.001)))) {
     wx = state->matrix[0] + state->matrix[2];
     wy = state->matrix[1] + state->matrix[3];
-    w = sqrt(wx*wx + wy*wy);
+    w = splashSqrt(wx*wx + wy*wy);
     if (w < 0.001) {
       w = 0;
     } else {
@@ -2905,7 +3076,7 @@
     }
     dx = xx1 - xx0;
     dy = yy1 - yy0;
-    d = sqrt(dx * dx + dy * dy);
+    d = splashSqrt(dx * dx + dy * dy);
     if (d < 0.001) {
       d = 0;
     } else {
@@ -2995,6 +3166,10 @@
   } else if (y > yMax2) {
     yMax2 = y;
   }
+  // sanity-check the coordinates - xMinI/yMinI/xMaxI/yMaxI are
+  // 32-bit integers, so coords need to be < 2^31
+  SplashXPath::clampCoords(&xMin2, &yMin2);
+  SplashXPath::clampCoords(&xMax2, &yMax2);
   xMinI = splashFloor(xMin2);
   yMinI = splashFloor(yMin2);
   xMaxI = splashFloor(xMax2);
@@ -3005,77 +3180,6 @@
          splashClipAllOutside;
 }
 
-SplashError Splash::xorFill(SplashPath *path, GBool eo) {
-  SplashPipe pipe;
-  SplashXPath *xPath;
-  SplashXPathScanner *scanner;
-  int xMin, yMin, xMax, yMax, y, t;
-  SplashClipResult clipRes;
-  SplashBlendFunc origBlendFunc;
-
-  if (path->length == 0) {
-    return splashErrEmptyPath;
-  }
-  if (pathAllOutside(path)) {
-    opClipRes = splashClipAllOutside;
-    return splashOk;
-  }
-  xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue);
-  xMin = xPath->getXMin();
-  yMin = xPath->getYMin();
-  xMax = xPath->getXMax();
-  yMax = xPath->getYMax();
-  if (xMin > xMax || yMin > yMax) {
-    delete xPath;
-    return splashOk;
-  }
-  scanner = new SplashXPathScanner(xPath, eo, yMin, yMax);
-
-  // check clipping
-  if ((clipRes = state->clip->testRect(xMin, yMin, xMax, yMax,
-				       state->strokeAdjust))
-      != splashClipAllOutside) {
-
-    if ((t = state->clip->getXMinI(state->strokeAdjust)) > xMin) {
-      xMin = t;
-    }
-    if ((t = state->clip->getXMaxI(state->strokeAdjust)) < xMax) {
-      xMax = t;
-    }
-    if ((t = state->clip->getYMinI(state->strokeAdjust)) > yMin) {
-      yMin = t;
-    }
-    if ((t = state->clip->getYMaxI(state->strokeAdjust)) < yMax) {
-      yMax = t;
-    }
-    if (xMin > xMax || yMin > yMax) {
-      delete scanner;
-      delete xPath;
-      return splashOk;
-    }
-
-    origBlendFunc = state->blendFunc;
-    state->blendFunc = &blendXor;
-    pipeInit(&pipe, state->fillPattern, 255, gTrue, gFalse);
-
-    // draw the spans
-    for (y = yMin; y <= yMax; ++y) {
-      scanner->getSpanBinary(scanBuf, y, xMin, xMax);
-      if (clipRes != splashClipAllInside) {
-	state->clip->clipSpanBinary(scanBuf, y, xMin, xMax,
-				    state->strokeAdjust);
-      }
-      (this->*pipe.run)(&pipe, xMin, xMax, y, scanBuf + xMin, NULL);
-    }
-    state->blendFunc = origBlendFunc;
-  }
-  opClipRes = clipRes;
-
-  delete scanner;
-  delete xPath;
-  return splashOk;
-}
-
 SplashError Splash::fillChar(SplashCoord x, SplashCoord y,
 			     int c, SplashFont *font) {
   SplashGlyphBitmap glyph;
@@ -3208,14 +3312,14 @@
 
 void Splash::getImageBounds(SplashCoord xyMin, SplashCoord xyMax,
 			    int *xyMinI, int *xyMaxI) {
-  if (state->strokeAdjust) {
-    splashStrokeAdjust(xyMin, xyMax, xyMinI, xyMaxI);
-  } else {
+  if (state->strokeAdjust == splashStrokeAdjustOff) {
     *xyMinI = splashFloor(xyMin);
     *xyMaxI = splashFloor(xyMax);
     if (*xyMaxI <= *xyMinI) {
       *xyMaxI = *xyMinI + 1;
     }
+  } else {
+    splashStrokeAdjust(xyMin, xyMax, xyMinI, xyMaxI, state->strokeAdjust);
   }
 }
 
@@ -3254,8 +3358,14 @@
   // stream-mode upscaling -- this is slower, so we only use it if the
   // upscaled mask is large (in which case clipping should remove many
   // pixels)
-  if (wSize > 2 * w && hSize > 2 * h && wSize * hSize > 1000000) {
+#if USE_FIXEDPOINT
+  if ((wSize > 2 * w && hSize > 2 * h && (int)wSize > 1000000 / (int)hSize) ||
+      (wSize >     w && hSize >     h && (int)wSize > 10000000 / (int)hSize)) {
+#else
+  if ((wSize > 2 * w && hSize > 2 * h && wSize * hSize > 1000000) ||
+      (wSize >     w && hSize >     h && wSize * hSize > 10000000)) {
     upscaleMask(src, srcData, w, h, mat, glyphMode, interpolate);
+#endif
 
   // scaling only
   } else if (mat[0] > 0 && minorAxisZero && mat[3] > 0) {
@@ -3462,10 +3572,12 @@
 	  if (y1 >= srcHeight) {
 	    y1 = srcHeight - 1;
 	  }
-	  pix0 = ((SplashCoord)1 - sx) * unscaledImage[y0 * srcWidth + x0]
-	         + sx * unscaledImage[y0 * srcWidth + x1];
-	  pix1 = ((SplashCoord)1 - sx) * unscaledImage[y1 * srcWidth + x0]
-	         + sx * unscaledImage[y1 * srcWidth + x1];
+	  pix0 = ((SplashCoord)1 - sx)
+	           * (SplashCoord)unscaledImage[y0 * srcWidth + x0]
+	         + sx * (SplashCoord)unscaledImage[y0 * srcWidth + x1];
+	  pix1 = ((SplashCoord)1 - sx)
+	           * (SplashCoord)unscaledImage[y1 * srcWidth + x0]
+	         + sx * (SplashCoord)unscaledImage[y1 * srcWidth + x1];
 	  scanBuf[x] = (Guchar)splashRound(((SplashCoord)1 - sy) * pix0
 					   + sy * pix1);
 	} else {
@@ -4041,10 +4153,10 @@
 			   int scaledWidth, int scaledHeight,
 			   SplashBitmap *dest) {
   Guchar *lineBuf;
-  Guint pix;
-  Guchar *destPtr0, *destPtr;
-  int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx;
-  int i, j;
+  Guchar pix;
+  Guchar *srcPtr, *destPtr;
+  int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep;
+  int i;
 
   // Bresenham parameters for y scale
   yp = scaledHeight / srcHeight;
@@ -4060,7 +4172,7 @@
   // init y scale Bresenham
   yt = 0;
 
-  destPtr0 = dest->data;
+  destPtr = dest->data;
   for (y = 0; y < srcHeight; ++y) {
 
     // y scale Bresenham
@@ -4077,7 +4189,8 @@
     // init x scale Bresenham
     xt = 0;
 
-    xx = 0;
+    // generate one row
+    srcPtr = lineBuf;
     for (x = 0; x < srcWidth; ++x) {
 
       // x scale Bresenham
@@ -4089,20 +4202,20 @@
       }
 
       // compute the final pixel
-      pix = lineBuf[x] ? 255 : 0;
+      pix = *srcPtr ? 255 : 0;
+      ++srcPtr;
 
-      // store the pixel
-      for (i = 0; i < yStep; ++i) {
-	for (j = 0; j < xStep; ++j) {
-	  destPtr = destPtr0 + i * scaledWidth + xx + j;
-	  *destPtr++ = (Guchar)pix;
-	}
+      // duplicate the pixel horizontally
+      for (i = 0; i < xStep; ++i) {
+	*destPtr++ = pix;
       }
+    }
 
-      xx += xStep;
+    // duplicate the row vertically
+    for (i = 1 ; i < yStep; ++i) {
+      memcpy(destPtr, destPtr - scaledWidth, scaledWidth);
+      destPtr += scaledWidth;
     }
-
-    destPtr0 += yStep * scaledWidth;
   }
 
   gfree(lineBuf);
@@ -4149,11 +4262,11 @@
       xSrc1 = srcWidth - 1;
     }
     lineBuf0[x] = (Guchar)(int)
-                  ((xs * lineBuf0[xSrc0] +
-		    ((SplashCoord)1 - xs) * lineBuf0[xSrc1]) * 255);
+          ((xs * (int)lineBuf0[xSrc0] +
+	    ((SplashCoord)1 - xs) * (int)lineBuf0[xSrc1]) * 255);
     lineBuf1[x] = (Guchar)(int)
-                  ((xs * lineBuf1[xSrc0] +
-		    ((SplashCoord)1 - xs) * lineBuf1[xSrc1]) * 255);
+          ((xs * (int)lineBuf1[xSrc0] +
+	    ((SplashCoord)1 - xs) * (int)lineBuf1[xSrc1]) * 255);
   }
 
   destPtr = dest->data;
@@ -4193,8 +4306,8 @@
 	  xSrc1 = srcWidth - 1;
 	}
 	lineBuf1[x] = (Guchar)(int)
-	              ((xs * lineBuf1[xSrc0] +
-			((SplashCoord)1 - xs) * lineBuf1[xSrc1]) * 255);
+	              ((xs * (int)lineBuf1[xSrc0] +
+			((SplashCoord)1 - xs) * (int)lineBuf1[xSrc1]) * 255);
       }
 
       ++yBuf;
@@ -4203,8 +4316,8 @@
     // do the vertical interpolation
     for (x = 0; x < scaledWidth; ++x) {
 
-      pix = (Guchar)(int)(ys * lineBuf0[x] +
-			  ((SplashCoord)1 - ys) * lineBuf1[x]);
+      pix = (Guchar)(int)(ys * (int)lineBuf0[x] +
+			  ((SplashCoord)1 - ys) * (int)lineBuf1[x]);
 
       // store the pixel
       *destPtr++ = pix;
@@ -4329,7 +4442,13 @@
   // stream-mode upscaling -- this is slower, so we only use it if the
   // upscaled image is large (in which case clipping should remove
   // many pixels)
-  if (wSize > 2 * w && hSize > 2 * h && wSize * hSize > 1000000) {
+#if USE_FIXEDPOINT
+  if ((wSize > 2 * w && hSize > 2 * h && (int)wSize > 1000000 / (int)hSize) ||
+      (wSize >     w && hSize >     h && (int)wSize > 10000000 / (int)hSize)) {
+#else
+  if ((wSize > 2 * w && hSize > 2 * h && wSize * hSize > 1000000) ||
+      (wSize >     w && hSize >     h && wSize * hSize > 10000000)) {
+#endif
     upscaleImage(src, srcData, srcMode, nComps, srcAlpha,
 		 w, h, mat, interpolate);
 
@@ -4367,7 +4486,7 @@
     }
 
   // scaling plus horizontal flip
-  } else if (mat[0] > 0 && minorAxisZero && mat[3] > 0) {
+  } else if (mat[0] < 0 && minorAxisZero && mat[3] > 0) {
     getImageBounds(mat[0] + mat[4], mat[4], &x0, &x1);
     getImageBounds(mat[5], mat[3] + mat[5], &y0, &y1);
     clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1,
@@ -4384,7 +4503,7 @@
     }
     
   // scaling plus horizontal and vertical flips
-  } else if (mat[0] > 0 && minorAxisZero && mat[3] < 0) {
+  } else if (mat[0] < 0 && minorAxisZero && mat[3] < 0) {
     getImageBounds(mat[0] + mat[4], mat[4], &x0, &x1);
     getImageBounds(mat[3] + mat[5], mat[5], &y0, &y1);
     clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1,
@@ -4557,16 +4676,18 @@
 	  q10 = &unscaledImage[(y1 * srcWidth + x0) * nComps];
 	  q11 = &unscaledImage[(y1 * srcWidth + x1) * nComps];
 	  for (i = 0; i < nComps; ++i) {
-	    pix0 = ((SplashCoord)1 - sx) * *q00++ + sx * *q01++;
-	    pix1 = ((SplashCoord)1 - sx) * *q10++ + sx * *q11++;
+	    pix0 = ((SplashCoord)1 - sx) * (int)*q00++ + sx * (int)*q01++;
+	    pix1 = ((SplashCoord)1 - sx) * (int)*q10++ + sx * (int)*q11++;
 	    *p++ = (Guchar)splashRound(((SplashCoord)1 - sy) * pix0
 				       + sy * pix1);
 	  }
 	  if (srcAlpha) {
-	    pix0 = ((SplashCoord)1 - sx) * unscaledAlpha[y0 * srcWidth + x0]
-	           + sx * unscaledAlpha[y0 * srcWidth + x1];
-	    pix1 = ((SplashCoord)1 - sx) * unscaledAlpha[y1 * srcWidth + x0]
-	           + sx * unscaledAlpha[y1 * srcWidth + x1];
+	    pix0 = ((SplashCoord)1 - sx)
+	             * (SplashCoord)unscaledAlpha[y0 * srcWidth + x0]
+	           + sx * (SplashCoord)unscaledAlpha[y0 * srcWidth + x1];
+	    pix1 = ((SplashCoord)1 - sx)
+	             * (SplashCoord)unscaledAlpha[y1 * srcWidth + x0]
+	           + sx * (SplashCoord)unscaledAlpha[y1 * srcWidth + x1];
 	    scanBuf[x] = (Guchar)splashRound(((SplashCoord)1 - sy) * pix0
 					     + sy * pix1);
 	  } else {
@@ -5139,6 +5260,12 @@
     alphaPixBuf = NULL;
   }
 
+  // make gcc happy
+  pix[0] = pix[1] = pix[2] = 0;
+#if SPLASH_CMYK
+  pix[3] = 0;
+#endif
+
   // init y scale Bresenham
   yt = 0;
 
@@ -5266,6 +5393,12 @@
     alphaLineBuf = NULL;
   }
 
+  // make gcc happy
+  pix[0] = pix[1] = pix[2] = 0;
+#if SPLASH_CMYK
+  pix[3] = 0;
+#endif
+
   // init y scale Bresenham
   yt = 0;
 
@@ -5380,11 +5513,15 @@
 			    int scaledWidth, int scaledHeight,
 			    SplashBitmap *dest) {
   Guchar *lineBuf, *alphaLineBuf;
-  Guint pix[splashMaxColorComps];
+  Guchar pix0, pix1, pix2;
+#if SPLASH_CMYK
+  Guchar pix3;
+#endif
   Guint alpha;
-  Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr;
-  int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx;
-  int i, j;
+  Guchar *srcPtr, *srcAlphaPtr;
+  Guchar *destPtr, *destAlphaPtr;
+  int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep;
+  int i;
 
   // Bresenham parameters for y scale
   yp = scaledHeight / srcHeight;
@@ -5405,8 +5542,8 @@
   // init y scale Bresenham
   yt = 0;
 
-  destPtr0 = dest->data;
-  destAlphaPtr0 = dest->alpha;
+  destPtr = dest->data;
+  destAlphaPtr = dest->alpha;
   for (y = 0; y < srcHeight; ++y) {
 
     // y scale Bresenham
@@ -5423,7 +5560,9 @@
     // init x scale Bresenham
     xt = 0;
 
-    xx = 0;
+    // generate one row
+    srcPtr = lineBuf;
+    srcAlphaPtr = alphaLineBuf;
     for (x = 0; x < srcWidth; ++x) {
 
       // x scale Bresenham
@@ -5434,41 +5573,35 @@
 	xStep = xp;
       }
 
-      // compute the final pixel
-      for (i = 0; i < nComps; ++i) {
-	pix[i] = lineBuf[x * nComps + i];
-      }
-
-      // store the pixel
+      // duplicate the pixel horizontally
       switch (srcMode) {
       case splashModeMono8:
-	for (i = 0; i < yStep; ++i) {
-	  for (j = 0; j < xStep; ++j) {
-	    destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps;
-	    *destPtr++ = (Guchar)pix[0];
-	  }
+	pix0 = *srcPtr++;
+	for (i = 0; i < xStep; ++i) {
+	  *destPtr++ = pix0;
 	}
 	break;
       case splashModeRGB8:
-	for (i = 0; i < yStep; ++i) {
-	  for (j = 0; j < xStep; ++j) {
-	    destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps;
-	    *destPtr++ = (Guchar)pix[0];
-	    *destPtr++ = (Guchar)pix[1];
-	    *destPtr++ = (Guchar)pix[2];
-	  }
+	pix0 = *srcPtr++;
+	pix1 = *srcPtr++;
+	pix2 = *srcPtr++;
+	for (i = 0; i < xStep; ++i) {
+	  *destPtr++ = pix0;
+	  *destPtr++ = pix1;
+	  *destPtr++ = pix2;
 	}
 	break;
 #if SPLASH_CMYK
       case splashModeCMYK8:
-	for (i = 0; i < yStep; ++i) {
-	  for (j = 0; j < xStep; ++j) {
-	    destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps;
-	    *destPtr++ = (Guchar)pix[0];
-	    *destPtr++ = (Guchar)pix[1];
-	    *destPtr++ = (Guchar)pix[2];
-	    *destPtr++ = (Guchar)pix[3];
-	  }
+	pix0 = *srcPtr++;
+	pix1 = *srcPtr++;
+	pix2 = *srcPtr++;
+	pix3 = *srcPtr++;
+	for (i = 0; i < xStep; ++i) {
+	  *destPtr++ = pix0;
+	  *destPtr++ = pix1;
+	  *destPtr++ = pix2;
+	  *destPtr++ = pix3;
 	}
 	break;
 #endif
@@ -5478,23 +5611,26 @@
 	break;
       }
 
-      // process alpha
+      // duplicate the alpha value horizontally
       if (srcAlpha) {
-	alpha = alphaLineBuf[x];
-	for (i = 0; i < yStep; ++i) {
-	  for (j = 0; j < xStep; ++j) {
-	    destAlphaPtr = destAlphaPtr0 + i * scaledWidth + xx + j;
-	    *destAlphaPtr = (Guchar)alpha;
-	  }
+	alpha = *srcAlphaPtr++;
+	for (i = 0; i < xStep; ++i) {
+	  *destAlphaPtr++ = alpha;
 	}
       }
+    }
 
-      xx += xStep;
+    // duplicate the row vertically
+    for (i = 1; i < yStep; ++i) {
+      memcpy(destPtr, destPtr - scaledWidth * nComps,
+	     scaledWidth * nComps);
+      destPtr += scaledWidth * nComps;
     }
-
-    destPtr0 += yStep * scaledWidth * nComps;
     if (srcAlpha) {
-      destAlphaPtr0 += yStep * scaledWidth;
+      for (i = 1; i < yStep; ++i) {
+	memcpy(destAlphaPtr, destAlphaPtr - scaledWidth, scaledWidth);
+	destAlphaPtr += scaledWidth;
+      }
     }
   }
 
@@ -5555,22 +5691,28 @@
     }
     for (i = 0; i < nComps; ++i) {
       lineBuf0[x*nComps+i] = (Guchar)(int)
-	                     (xs * lineBuf0[xSrc0*nComps+i] +
-			      ((SplashCoord)1 - xs) * lineBuf0[xSrc1*nComps+i]);
+	    (xs * (int)lineBuf0[xSrc0*nComps+i] +
+	     ((SplashCoord)1 - xs) * (int)lineBuf0[xSrc1*nComps+i]);
       lineBuf1[x*nComps+i] = (Guchar)(int)
-	                     (xs * lineBuf1[xSrc0*nComps+i] +
-			      ((SplashCoord)1 - xs) * lineBuf1[xSrc1*nComps+i]);
+	    (xs * (int)lineBuf1[xSrc0*nComps+i] +
+	     ((SplashCoord)1 - xs) * (int)lineBuf1[xSrc1*nComps+i]);
     }
     if (srcAlpha) {
       alphaLineBuf0[x] = (Guchar)(int)
-	                 (xs * alphaLineBuf0[xSrc0] +
-			  ((SplashCoord)1 - xs) * alphaLineBuf0[xSrc1]);
+	    (xs * (int)alphaLineBuf0[xSrc0] +
+	     ((SplashCoord)1 - xs) * (int)alphaLineBuf0[xSrc1]);
       alphaLineBuf1[x] = (Guchar)(int)
-	                 (xs * alphaLineBuf1[xSrc0] +
-			  ((SplashCoord)1 - xs) * alphaLineBuf1[xSrc1]);
+	    (xs * (int)alphaLineBuf1[xSrc0] +
+	     ((SplashCoord)1 - xs) * (int)alphaLineBuf1[xSrc1]);
     }
   }
 
+  // make gcc happy
+  pix[0] = pix[1] = pix[2] = 0;
+#if SPLASH_CMYK
+  pix[3] = 0;
+#endif
+
   destPtr = dest->data;
   destAlphaPtr = dest->alpha;
   for (y = 0; y < scaledHeight; ++y) {
@@ -5612,14 +5754,14 @@
 	  xSrc1 = srcWidth - 1;
 	}
 	for (i = 0; i < nComps; ++i) {
-	  lineBuf1[x*nComps+i] =
-	        (Guchar)(int)(xs * lineBuf1[xSrc0*nComps+i] +
-			      ((SplashCoord)1 - xs) * lineBuf1[xSrc1*nComps+i]);
+	  lineBuf1[x*nComps+i] = (Guchar)(int)
+	        (xs * (int)lineBuf1[xSrc0*nComps+i] +
+		 ((SplashCoord)1 - xs) * (int)lineBuf1[xSrc1*nComps+i]);
 	}
 	if (srcAlpha) {
-	  alphaLineBuf1[x] =
-	        (Guchar)(int)(xs * alphaLineBuf1[xSrc0] +
-			      ((SplashCoord)1 - xs) * alphaLineBuf1[xSrc1]);
+	  alphaLineBuf1[x] = (Guchar)(int)
+	        (xs * (int)alphaLineBuf1[xSrc0] +
+		 ((SplashCoord)1 - xs) * (int)alphaLineBuf1[xSrc1]);
 	}
       }
 
@@ -5630,8 +5772,9 @@
     for (x = 0; x < scaledWidth; ++x) {
 
       for (i = 0; i < nComps; ++i) {
-	pix[i] = (Guchar)(int)(ys * lineBuf0[x*nComps+i] +
-			       ((SplashCoord)1 - ys) * lineBuf1[x*nComps+i]);
+	pix[i] = (Guchar)(int)
+	         (ys * (int)lineBuf0[x*nComps+i] +
+		  ((SplashCoord)1 - ys) * (int)lineBuf1[x*nComps+i]);
       }
 
       // store the pixel
@@ -5661,8 +5804,8 @@
       // process alpha
       if (srcAlpha) {
 	*destAlphaPtr++ = (Guchar)(int)
-	                  (ys * alphaLineBuf0[x] +
-			   ((SplashCoord)1 - ys) * alphaLineBuf1[x]);
+	                  (ys * (int)alphaLineBuf0[x] +
+			   ((SplashCoord)1 - ys) * (int)alphaLineBuf1[x]);
       }
     }
   }
@@ -5878,9 +6021,13 @@
 			      int xDest, int yDest, int w, int h,
 			      GBool noClip, GBool nonIsolated) {
   SplashPipe pipe;
-  int x0, x1, y0, y1, y, t;
+  Guchar *mono1Ptr, *lineBuf, *linePtr;
+  Guchar mono1Mask, b;
+  int x0, x1, x, y0, y1, y, t;
 
-  if (src->mode != bitmap->mode) {
+  if (!(src->mode == bitmap->mode ||
+	(src->mode == splashModeMono8 && bitmap->mode == splashModeMono1) ||
+	(src->mode == splashModeRGB8 && bitmap->mode == splashModeBGR8))) {
     return splashErrModeMismatch;
   }
 
@@ -5887,76 +6034,277 @@
   pipeInit(&pipe, NULL,
 	   (Guchar)splashRound(state->fillAlpha * 255),
 	   !noClip || src->alpha != NULL, nonIsolated);
-  if (noClip) {
-    if (src->alpha) {
-      for (y = 0; y < h; ++y) {
-	// this uses shape instead of alpha, which isn't technically
-	// correct, but works out the same
-	(this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
-			  src->getAlphaPtr() +
-			    (ySrc + y) * src->getWidth() + xSrc,
-			  src->getDataPtr() + (ySrc + y) * src->getRowSize() +
-			    xSrc * bitmapComps);
+  if (src->mode == splashModeMono1) {
+    // in mono1 mode, pipeRun expects the source to be in mono8
+    // format, so we need to extract the source color values into
+    // scanBuf, expanding them from mono1 to mono8
+    if (noClip) {
+      if (src->alpha) {
+	for (y = 0; y < h; ++y) {
+	  mono1Ptr = src->getDataPtr()
+	             + (ySrc + y) * src->rowSize + (xSrc >> 3);
+	  mono1Mask = 0x80 >> (xSrc & 7);
+	  for (x = 0; x < w; ++x) {
+	    scanBuf[x] = (*mono1Ptr & mono1Mask) ? 0xff : 0x00;
+	    mono1Ptr += mono1Mask & 1;
+	    mono1Mask = (mono1Mask << 7) | (mono1Mask >> 1);
+	  }
+	  // this uses shape instead of alpha, which isn't technically
+	  // correct, but works out the same
+	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
+			    src->getAlphaPtr() +
+			      (ySrc + y) * src->getWidth() + xSrc,
+			    scanBuf);
+	}
+      } else {
+	for (y = 0; y < h; ++y) {
+	  mono1Ptr = src->getDataPtr()
+	             + (ySrc + y) * src->rowSize + (xSrc >> 3);
+	  mono1Mask = 0x80 >> (xSrc & 7);
+	  for (x = 0; x < w; ++x) {
+	    scanBuf[x] = (*mono1Ptr & mono1Mask) ? 0xff : 0x00;
+	    mono1Ptr += mono1Mask & 1;
+	    mono1Mask = (mono1Mask << 7) | (mono1Mask >> 1);
+	  }
+	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
+			    NULL,
+			    scanBuf);
+	}
       }
     } else {
-      for (y = 0; y < h; ++y) {
-	(this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
-			  NULL,
-			  src->getDataPtr() + (ySrc + y) * src->getRowSize() +
-			    xSrc * bitmapComps);
+      x0 = xDest;
+      if ((t = state->clip->getXMinI(state->strokeAdjust)) > x0) {
+	x0 = t;
       }
+      x1 = xDest + w;
+      if ((t = state->clip->getXMaxI(state->strokeAdjust) + 1) < x1) {
+	x1 = t;
+      }
+      y0 = yDest;
+      if ((t = state->clip->getYMinI(state->strokeAdjust)) > y0) {
+	y0 = t;
+      }
+      y1 = yDest + h;
+      if ((t = state->clip->getYMaxI(state->strokeAdjust) + 1) < y1) {
+	y1 = t;
+      }
+      if (x0 < x1 && y0 < y1) {
+	if (src->alpha) {
+	  for (y = y0; y < y1; ++y) {
+	    mono1Ptr = src->getDataPtr()
+	               + (ySrc + y - yDest) * src->rowSize
+	               + ((xSrc + x0 - xDest) >> 3);
+	    mono1Mask = 0x80 >> ((xSrc + x0 - xDest) & 7);
+	    for (x = x0; x < x1; ++x) {
+	      scanBuf[x] = (*mono1Ptr & mono1Mask) ? 0xff : 0x00;
+	      mono1Ptr += mono1Mask & 1;
+	      mono1Mask = (mono1Mask << 7) | (mono1Mask >> 1);
+	    }
+	    memcpy(scanBuf2 + x0,
+		   src->getAlphaPtr() + (ySrc + y - yDest) * src->getWidth() + 
+		     (xSrc + x0 - xDest),
+		   x1 - x0);
+	    if (!state->clip->clipSpanBinary(scanBuf2, y, x0, x1 - 1,
+					     state->strokeAdjust)) {
+	      continue;
+	    }
+	    // this uses shape instead of alpha, which isn't technically
+	    // correct, but works out the same
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, y,
+			      scanBuf2 + x0,
+			      scanBuf + x0);
+	  }
+	} else {
+	  for (y = y0; y < y1; ++y) {
+	    mono1Ptr = src->getDataPtr()
+	               + (ySrc + y - yDest) * src->rowSize
+	               + ((xSrc + x0 - xDest) >> 3);
+	    mono1Mask = 0x80 >> ((xSrc + x0 - xDest) & 7);
+	    for (x = x0; x < x1; ++x) {
+	      scanBuf[x] = (*mono1Ptr & mono1Mask) ? 0xff : 0x00;
+	      mono1Ptr += mono1Mask & 1;
+	      mono1Mask = (mono1Mask << 7) | (mono1Mask >> 1);
+	    }
+	    memset(scanBuf2 + x0, 0xff, x1 - x0);
+	    if (!state->clip->clipSpanBinary(scanBuf2, y, x0, x1 - 1,
+					     state->strokeAdjust)) {
+	      continue;
+	    }
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, y,
+			      scanBuf2 + x0,
+			      scanBuf + x0);
+	  }
+	}
+      }
     }
-  } else {
-    x0 = xDest;
-    if ((t = state->clip->getXMinI(state->strokeAdjust)) > x0) {
-      x0 = t;
-    }
-    x1 = xDest + w;
-    if ((t = state->clip->getXMaxI(state->strokeAdjust) + 1) < x1) {
-      x1 = t;
-    }
-    y0 = yDest;
-    if ((t = state->clip->getYMinI(state->strokeAdjust)) > y0) {
-      y0 = t;
-    }
-    y1 = yDest + h;
-    if ((t = state->clip->getYMaxI(state->strokeAdjust) + 1) < y1) {
-      y1 = t;
-    }
-    if (x0 < x1 && y0 < y1) {
+
+  } else if (src->mode == splashModeBGR8) {
+    // in BGR8 mode, pipeRun expects the source to be in RGB8 format,
+    // so we need to swap bytes
+    lineBuf = (Guchar *)gmallocn(w, 3);
+    if (noClip) {
       if (src->alpha) {
-	for (y = y0; y < y1; ++y) {
-	  memcpy(scanBuf + x0,
-		 src->getAlphaPtr() + (ySrc + y - yDest) * src->getWidth() + 
-		   (xSrc + x0 - xDest),
-		 x1 - x0);
-	  if (!state->clip->clipSpanBinary(scanBuf, y, x0, x1 - 1,
-					   state->strokeAdjust)) {
-	    continue;
+	for (y = 0; y < h; ++y) {
+	  memcpy(lineBuf,
+		 src->getDataPtr() + (ySrc + y) * src->rowSize + xSrc * 3,
+		 w * 3);
+	  for (x = 0, linePtr = lineBuf; x < w; ++x, linePtr += 3) {
+	    b = linePtr[0];
+	    linePtr[0] = linePtr[2];
+	    linePtr[2] = b;
 	  }
 	  // this uses shape instead of alpha, which isn't technically
 	  // correct, but works out the same
-	  (this->*pipe.run)(&pipe, x0, x1 - 1, y,
-			    scanBuf + x0,
-			    src->getDataPtr() +
-			      (ySrc + y - yDest) * src->getRowSize() +
-			      (xSrc + x0 - xDest) * bitmapComps);
+	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
+			    src->getAlphaPtr() +
+			      (ySrc + y) * src->getWidth() + xSrc,
+			    lineBuf);
 	}
       } else {
-	for (y = y0; y < y1; ++y) {
-	  memset(scanBuf + x0, 0xff, x1 - x0);
-	  if (!state->clip->clipSpanBinary(scanBuf, y, x0, x1 - 1,
-					   state->strokeAdjust)) {
-	    continue;
+	for (y = 0; y < h; ++y) {
+	  memcpy(lineBuf,
+		 src->getDataPtr() + (ySrc + y) * src->rowSize + xSrc * 3,
+		 w * 3);
+	  for (x = 0, linePtr = lineBuf; x < w; ++x, linePtr += 3) {
+	    b = linePtr[0];
+	    linePtr[0] = linePtr[2];
+	    linePtr[2] = b;
 	  }
 	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
-			    scanBuf + x0,
-			    src->getDataPtr() +
-			      (ySrc + y - yDest) * src->getRowSize() +
-			      (xSrc - xDest) * bitmapComps);
+			    NULL, lineBuf);
 	}
       }
+    } else {
+      x0 = xDest;
+      if ((t = state->clip->getXMinI(state->strokeAdjust)) > x0) {
+	x0 = t;
+      }
+      x1 = xDest + w;
+      if ((t = state->clip->getXMaxI(state->strokeAdjust) + 1) < x1) {
+	x1 = t;
+      }
+      y0 = yDest;
+      if ((t = state->clip->getYMinI(state->strokeAdjust)) > y0) {
+	y0 = t;
+      }
+      y1 = yDest + h;
+      if ((t = state->clip->getYMaxI(state->strokeAdjust) + 1) < y1) {
+	y1 = t;
+      }
+      if (x0 < x1 && y0 < y1) {
+	if (src->alpha) {
+	  for (y = y0; y < y1; ++y) {
+	    memcpy(scanBuf + x0,
+		   src->getAlphaPtr() + (ySrc + y - yDest) * src->getWidth() + 
+		     (xSrc + x0 - xDest),
+		   x1 - x0);
+	    state->clip->clipSpan(scanBuf, y, x0, x1 - 1, state->strokeAdjust);
+	    memcpy(lineBuf,
+		   src->getDataPtr() +
+		     (ySrc + y - yDest) * src->rowSize +
+		     (xSrc + x0 - xDest) * 3,
+		   (x1 - x0) * 3);
+	    for (x = 0, linePtr = lineBuf; x < x1 - x0; ++x, linePtr += 3) {
+	      b = linePtr[0];
+	      linePtr[0] = linePtr[2];
+	      linePtr[2] = b;
+	    }
+	    // this uses shape instead of alpha, which isn't technically
+	    // correct, but works out the same
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, y,
+			      scanBuf + x0, lineBuf);
+	  }
+	} else {
+	  for (y = y0; y < y1; ++y) {
+	    memset(scanBuf + x0, 0xff, x1 - x0);
+	    state->clip->clipSpan(scanBuf, y, x0, x1 - 1, state->strokeAdjust);
+	    memcpy(lineBuf,
+		   src->getDataPtr() +
+		     (ySrc + y - yDest) * src->rowSize +
+		     (xSrc + x0 - xDest) * 3,
+		   (x1 - x0) * 3);
+	    for (x = 0, linePtr = lineBuf; x < x1 - x0; ++x, linePtr += 3) {
+	      b = linePtr[0];
+	      linePtr[0] = linePtr[2];
+	      linePtr[2] = b;
+	    }
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, yDest + y,
+			      scanBuf + x0,
+			      src->getDataPtr() +
+			        (ySrc + y - yDest) * src->rowSize +
+			        (xSrc + x0 - xDest) * bitmapComps);
+	  }
+	}
+      }
     }
+    gfree(lineBuf);
+
+  } else { // src->mode not mono1 or BGR8
+    if (noClip) {
+      if (src->alpha) {
+	for (y = 0; y < h; ++y) {
+	  // this uses shape instead of alpha, which isn't technically
+	  // correct, but works out the same
+	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
+			    src->getAlphaPtr() +
+			      (ySrc + y) * src->getWidth() + xSrc,
+			    src->getDataPtr() + (ySrc + y) * src->rowSize +
+			      xSrc * bitmapComps);
+	}
+      } else {
+	for (y = 0; y < h; ++y) {
+	  (this->*pipe.run)(&pipe, xDest, xDest + w - 1, yDest + y,
+			    NULL,
+			    src->getDataPtr() + (ySrc + y) * src->rowSize +
+			      xSrc * bitmapComps);
+	}
+      }
+    } else {
+      x0 = xDest;
+      if ((t = state->clip->getXMinI(state->strokeAdjust)) > x0) {
+	x0 = t;
+      }
+      x1 = xDest + w;
+      if ((t = state->clip->getXMaxI(state->strokeAdjust) + 1) < x1) {
+	x1 = t;
+      }
+      y0 = yDest;
+      if ((t = state->clip->getYMinI(state->strokeAdjust)) > y0) {
+	y0 = t;
+      }
+      y1 = yDest + h;
+      if ((t = state->clip->getYMaxI(state->strokeAdjust) + 1) < y1) {
+	y1 = t;
+      }
+      if (x0 < x1 && y0 < y1) {
+	if (src->alpha) {
+	  for (y = y0; y < y1; ++y) {
+	    memcpy(scanBuf + x0,
+		   src->getAlphaPtr() + (ySrc + y - yDest) * src->getWidth() + 
+		     (xSrc + x0 - xDest),
+		   x1 - x0);
+	    state->clip->clipSpan(scanBuf, y, x0, x1 - 1, state->strokeAdjust);
+	    // this uses shape instead of alpha, which isn't technically
+	    // correct, but works out the same
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, y,
+			      scanBuf + x0,
+			      src->getDataPtr() +
+			        (ySrc + y - yDest) * src->rowSize +
+			        (xSrc + x0 - xDest) * bitmapComps);
+	  }
+	} else {
+	  for (y = y0; y < y1; ++y) {
+	    memset(scanBuf + x0, 0xff, x1 - x0);
+	    state->clip->clipSpan(scanBuf, y, x0, x1 - 1, state->strokeAdjust);
+	    (this->*pipe.run)(&pipe, x0, x1 - 1, yDest + y,
+			      scanBuf + x0,
+			      src->getDataPtr() +
+			        (ySrc + y - yDest) * src->rowSize +
+			        (xSrc + x0 - xDest) * bitmapComps);
+	  }
+	}
+      }
+    }
   }
 
   return splashOk;
@@ -5980,13 +6328,21 @@
       mask = 0x80;
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	c = (*p & mask) ? 0xff : 0x00;
-	c = div255(alpha1 * color0 + alpha * c);
-	if (c & 0x80) {
-	  *p |= mask;
-	} else {
-	  *p &= ~mask;
+	if (alpha == 0) {
+	  if (color0 & 0x80) {
+	    *p |= mask;
+	  } else {
+	    *p &= ~mask;
+	  }
+	} else if (alpha != 255) {
+	  alpha1 = 255 - alpha;
+	  c = (*p & mask) ? 0xff : 0x00;
+	  c = div255(alpha1 * color0 + alpha * c);
+	  if (c & 0x80) {
+	    *p |= mask;
+	  } else {
+	    *p &= ~mask;
+	  }
 	}
 	if (!(mask >>= 1)) {
 	  mask = 0x80;
@@ -6002,8 +6358,12 @@
       q = &bitmap->alpha[y * bitmap->width];
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	if (alpha == 0) {
+	  p[0] = color0;
+	} else if (alpha != 255) {
+	  alpha1 = 255 - alpha;
+	  p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	}
 	++p;
       }
     }
@@ -6018,10 +6378,16 @@
       q = &bitmap->alpha[y * bitmap->width];
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	p[0] = div255(alpha1 * color0 + alpha * p[0]);
-	p[1] = div255(alpha1 * color1 + alpha * p[1]);
-	p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	if (alpha == 0) {
+	  p[0] = color0;
+	  p[1] = color1;
+	  p[2] = color2;
+	} else if (alpha != 255) {
+	  alpha1 = 255 - alpha;
+	  p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	  p[1] = div255(alpha1 * color1 + alpha * p[1]);
+	  p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	}
 	p += 3;
       }
     }
@@ -6037,11 +6403,18 @@
       q = &bitmap->alpha[y * bitmap->width];
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	p[0] = div255(alpha1 * color0 + alpha * p[0]);
-	p[1] = div255(alpha1 * color1 + alpha * p[1]);
-	p[2] = div255(alpha1 * color2 + alpha * p[2]);
-	p[3] = div255(alpha1 * color3 + alpha * p[3]);
+	if (alpha == 0) {
+	  p[0] = color0;
+	  p[1] = color1;
+	  p[2] = color2;
+	  p[3] = color3;
+	} else if (alpha != 255) {
+	  alpha1 = 255 - alpha;
+	  p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	  p[1] = div255(alpha1 * color1 + alpha * p[1]);
+	  p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	  p[3] = div255(alpha1 * color3 + alpha * p[3]);
+	}
 	p += 4;
       }
     }
@@ -6120,11 +6493,95 @@
   return splashOk;
 }
 
+SplashError Splash::blitCorrectedAlpha(SplashBitmap *dest, int xSrc, int ySrc,
+				       int xDest, int yDest, int w, int h) {
+  SplashColorPtr p, q;
+  Guchar *alpha0Ptr;
+  Guchar alpha0, aSrc;
+  int x, y, mask, srcMask;
+
+  if (bitmap->mode != dest->mode ||
+      !bitmap->alpha ||
+      !dest->alpha ||
+      !groupBackBitmap) {
+    return splashErrModeMismatch;
+  }
+
+  switch (bitmap->mode) {
+  case splashModeMono1:
+    for (y = 0; y < h; ++y) {
+      p = &dest->data[(yDest + y) * dest->rowSize + (xDest >> 3)];
+      mask = 0x80 >> (xDest & 7);
+      q = &bitmap->data[(ySrc + y) * bitmap->rowSize + (xSrc >> 3)];
+      srcMask = 0x80 >> (xSrc & 7);
+      for (x = 0; x < w; ++x) {
+	if (*q & srcMask) {
+	  *p |= mask;
+	} else {
+	  *p &= ~mask;
+	}
+	if (!(mask >>= 1)) {
+	  mask = 0x80;
+	  ++p;
+	}
+	if (!(srcMask >>= 1)) {
+	  srcMask = 0x80;
+	  ++q;
+	}
+      }
+    }
+    break;
+  case splashModeMono8:
+    for (y = 0; y < h; ++y) {
+      p = &dest->data[(yDest + y) * dest->rowSize + xDest];
+      q = &bitmap->data[(ySrc + y) * bitmap->rowSize + xSrc];
+      memcpy(p, q, w);
+    }
+    break;
+  case splashModeRGB8:
+  case splashModeBGR8:
+    for (y = 0; y < h; ++y) {
+      p = &dest->data[(yDest + y) * dest->rowSize + 3 * xDest];
+      q = &bitmap->data[(ySrc + y) * bitmap->rowSize + 3 * xSrc];
+      memcpy(p, q, 3 * w);
+    }
+    break;
+#if SPLASH_CMYK
+  case splashModeCMYK8:
+    for (y = 0; y < h; ++y) {
+      p = &dest->data[(yDest + y) * dest->rowSize + 4 * xDest];
+      q = &bitmap->data[(ySrc + y) * bitmap->rowSize + 4 * xSrc];
+      memcpy(p, q, 4 * w);
+    }
+    break;
+#endif
+  }
+
+  for (y = 0; y < h; ++y) {
+    p = &dest->alpha[(yDest + y) * dest->width + xDest];
+    q = &bitmap->alpha[(ySrc + y) * bitmap->width + xSrc];
+    alpha0Ptr = &groupBackBitmap->alpha[(groupBackY + ySrc + y)
+					  * groupBackBitmap->width +
+					(groupBackX + xSrc)];
+    for (x = 0; x < w; ++x) {
+      alpha0 = *alpha0Ptr++;
+      aSrc = *q++;
+      *p++ = alpha0 + aSrc - div255(alpha0 * aSrc);
+    }
+  }
+
+  return splashOk;
+}
+
 SplashPath *Splash::makeStrokePath(SplashPath *path, SplashCoord w,
-				    GBool flatten) {
+				   int lineCap, int lineJoin,
+				   GBool flatten) {
   SplashPath *pathIn, *dashPath, *pathOut;
   SplashCoord d, dx, dy, wdx, wdy, dxNext, dyNext, wdxNext, wdyNext;
   SplashCoord crossprod, dotprod, miter, m;
+  SplashCoord angle, angleNext, dAngle, xc, yc;
+  SplashCoord dxJoin, dyJoin, dJoin, kappa;
+  SplashCoord cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
   GBool first, last, closed;
   int subpathStart0, subpathStart1, seg, i0, i1, j0, j1, k0, k1;
   int left0, left1, left2, right0, right1, right2, join0, join1, join2;
@@ -6184,7 +6641,7 @@
       j1 = j0;
     }
     if (pathIn->flags[i1] & splashPathLast) {
-      if (first && state->lineCap == splashLineCapRound) {
+      if (first && lineCap == splashLineCapRound) {
 	// special case: zero-length subpath with round line caps -->
 	// draw a circle
 	pathOut->moveTo(pathIn->pts[i0].x + (SplashCoord)0.5 * w,
@@ -6250,16 +6707,17 @@
     wdy = (SplashCoord)0.5 * w * dy;
 
     // draw the start cap
-    pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx);
     if (i0 == subpathStart0) {
-      firstPt = pathOut->length - 1;
+      firstPt = pathOut->length;
     }
     if (first && !closed) {
-      switch (state->lineCap) {
+      switch (lineCap) {
       case splashLineCapButt:
+	pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx);
 	pathOut->lineTo(pathIn->pts[i0].x + wdy, pathIn->pts[i0].y - wdx);
 	break;
       case splashLineCapRound:
+	pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx);
 	pathOut->curveTo(pathIn->pts[i0].x - wdy - bezierCircle * wdx,
 			 pathIn->pts[i0].y + wdx - bezierCircle * wdy,
 			 pathIn->pts[i0].x - wdx - bezierCircle * wdy,
@@ -6274,29 +6732,27 @@
 			 pathIn->pts[i0].y - wdx);
 	break;
       case splashLineCapProjecting:
-	pathOut->lineTo(pathIn->pts[i0].x - wdx - wdy,
+	pathOut->moveTo(pathIn->pts[i0].x - wdx - wdy,
 			pathIn->pts[i0].y + wdx - wdy);
 	pathOut->lineTo(pathIn->pts[i0].x - wdx + wdy,
 			pathIn->pts[i0].y - wdx - wdy);
-	pathOut->lineTo(pathIn->pts[i0].x + wdy,
-			pathIn->pts[i0].y - wdx);
 	break;
       }
     } else {
+      pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx);
       pathOut->lineTo(pathIn->pts[i0].x + wdy, pathIn->pts[i0].y - wdx);
     }
 
-    // draw the left side of the segment rectangle
+    // draw the left side of the segment rectangle and the end cap
     left2 = pathOut->length - 1;
-    pathOut->lineTo(pathIn->pts[j0].x + wdy, pathIn->pts[j0].y - wdx);
-
-    // draw the end cap
     if (last && !closed) {
-      switch (state->lineCap) {
+      switch (lineCap) {
       case splashLineCapButt:
+	pathOut->lineTo(pathIn->pts[j0].x + wdy, pathIn->pts[j0].y - wdx);
 	pathOut->lineTo(pathIn->pts[j0].x - wdy, pathIn->pts[j0].y + wdx);
 	break;
       case splashLineCapRound:
+	pathOut->lineTo(pathIn->pts[j0].x + wdy, pathIn->pts[j0].y - wdx);
 	pathOut->curveTo(pathIn->pts[j0].x + wdy + bezierCircle * wdx,
 			 pathIn->pts[j0].y - wdx + bezierCircle * wdy,
 			 pathIn->pts[j0].x + wdx + bezierCircle * wdy,
@@ -6315,11 +6771,10 @@
 			pathIn->pts[j0].y - wdx + wdy);
 	pathOut->lineTo(pathIn->pts[j0].x - wdy + wdx,
 			pathIn->pts[j0].y + wdx + wdy);
-	pathOut->lineTo(pathIn->pts[j0].x - wdy,
-			pathIn->pts[j0].y + wdx);
 	break;
       }
     } else {
+      pathOut->lineTo(pathIn->pts[j0].x + wdy, pathIn->pts[j0].y - wdx);
       pathOut->lineTo(pathIn->pts[j0].x - wdy, pathIn->pts[j0].y + wdx);
     }
 
@@ -6327,7 +6782,7 @@
     // (NB: if stroke adjustment is enabled, the closepath operation MUST
     // add a segment because this segment is used for a hint)
     right2 = pathOut->length - 1;
-    pathOut->close(state->strokeAdjust);
+    pathOut->close(state->strokeAdjust != splashStrokeAdjustOff);
 
     // draw the join
     join2 = pathOut->length;
@@ -6372,43 +6827,121 @@
       }
 
       // round join
-      if (state->lineJoin == splashLineJoinRound) {
-	pathOut->moveTo(pathIn->pts[j0].x + (SplashCoord)0.5 * w,
-			pathIn->pts[j0].y);
-	pathOut->curveTo(pathIn->pts[j0].x + (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y + bezierCircle2 * w,
-			 pathIn->pts[j0].x + bezierCircle2 * w,
-			 pathIn->pts[j0].y + (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].x,
-			 pathIn->pts[j0].y + (SplashCoord)0.5 * w);
-	pathOut->curveTo(pathIn->pts[j0].x - bezierCircle2 * w,
-			 pathIn->pts[j0].y + (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].x - (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y + bezierCircle2 * w,
-			 pathIn->pts[j0].x - (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y);
-	pathOut->curveTo(pathIn->pts[j0].x - (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y - bezierCircle2 * w,
-			 pathIn->pts[j0].x - bezierCircle2 * w,
-			 pathIn->pts[j0].y - (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].x,
-			 pathIn->pts[j0].y - (SplashCoord)0.5 * w);
-	pathOut->curveTo(pathIn->pts[j0].x + bezierCircle2 * w,
-			 pathIn->pts[j0].y - (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].x + (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y - bezierCircle2 * w,
-			 pathIn->pts[j0].x + (SplashCoord)0.5 * w,
-			 pathIn->pts[j0].y);
+      if (lineJoin == splashLineJoinRound) {
+	// join angle < 180
+	if (crossprod < 0) {
+	  angle = atan2((double)dx, (double)-dy);
+	  angleNext = atan2((double)dxNext, (double)-dyNext);
+	  if (angle < angleNext) {
+	    angle += 2 * M_PI;
+	  }
+	  dAngle = (angle  - angleNext) / M_PI;
+	  if (dAngle < 0.501) {
+	    // span angle is <= 90 degrees -> draw a single arc
+	    kappa = dAngle * bezierCircle * w;
+	    cx1 = pathIn->pts[j0].x - wdy + kappa * dx;
+	    cy1 = pathIn->pts[j0].y + wdx + kappa * dy;
+	    cx2 = pathIn->pts[j0].x - wdyNext - kappa * dxNext;
+	    cy2 = pathIn->pts[j0].y + wdxNext - kappa * dyNext;
+	    pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y);
+	    pathOut->lineTo(pathIn->pts[j0].x - wdyNext,
+			    pathIn->pts[j0].y + wdxNext);
+	    pathOut->curveTo(cx2, cy2, cx1, cy1,
+			     pathIn->pts[j0].x - wdy,
+			     pathIn->pts[j0].y + wdx);
+	  } else {
+	    // span angle is > 90 degrees -> split into two arcs
+	    dJoin = splashDist(-wdy, wdx, -wdyNext, wdxNext);
+	    if (dJoin > 0) {
+	      dxJoin = (-wdyNext + wdy) / dJoin;
+	      dyJoin = (wdxNext - wdx) / dJoin;
+	      xc = pathIn->pts[j0].x
+		   + (SplashCoord)0.5 * w
+		     * cos((double)((SplashCoord)0.5 * (angle + angleNext)));
+	      yc = pathIn->pts[j0].y
+		   + (SplashCoord)0.5 * w
+		     * sin((double)((SplashCoord)0.5 * (angle + angleNext)));
+	      kappa = dAngle * bezierCircle2 * w;
+	      cx1 = pathIn->pts[j0].x - wdy + kappa * dx;
+	      cy1 = pathIn->pts[j0].y + wdx + kappa * dy;
+	      cx2 = xc - kappa * dxJoin;
+	      cy2 = yc - kappa * dyJoin;
+	      cx3 = xc + kappa * dxJoin;
+	      cy3 = yc + kappa * dyJoin;
+	      cx4 = pathIn->pts[j0].x - wdyNext - kappa * dxNext;
+	      cy4 = pathIn->pts[j0].y + wdxNext - kappa * dyNext;
+	      pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y);
+	      pathOut->lineTo(pathIn->pts[j0].x - wdyNext,
+			      pathIn->pts[j0].y + wdxNext);
+	      pathOut->curveTo(cx4, cy4, cx3, cy3, xc, yc);
+	      pathOut->curveTo(cx2, cy2, cx1, cy1,
+			       pathIn->pts[j0].x - wdy,
+			       pathIn->pts[j0].y + wdx);
+	    }
+	  }
 
+	// join angle >= 180
+	} else {
+	  angle = atan2((double)-dx, (double)dy);
+	  angleNext = atan2((double)-dxNext, (double)dyNext);
+	  if (angleNext < angle) {
+	    angleNext += 2 * M_PI;
+	  }
+	  dAngle = (angleNext - angle) / M_PI;
+	  if (dAngle < 0.501) {
+	    // span angle is <= 90 degrees -> draw a single arc
+	    kappa = dAngle * bezierCircle * w;
+	      cx1 = pathIn->pts[j0].x + wdy + kappa * dx;
+	      cy1 = pathIn->pts[j0].y - wdx + kappa * dy;
+	      cx2 = pathIn->pts[j0].x + wdyNext - kappa * dxNext;
+	      cy2 = pathIn->pts[j0].y - wdxNext - kappa * dyNext;
+	      pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y);
+	      pathOut->lineTo(pathIn->pts[j0].x + wdy,
+			      pathIn->pts[j0].y - wdx);
+	      pathOut->curveTo(cx1, cy1, cx2, cy2,
+			       pathIn->pts[j0].x + wdyNext,
+			       pathIn->pts[j0].y - wdxNext);
+	  } else {
+	    // span angle is > 90 degrees -> split into two arcs
+	    dJoin = splashDist(wdy, -wdx, wdyNext, -wdxNext);
+	    if (dJoin > 0) {
+	      dxJoin = (wdyNext - wdy) / dJoin;
+	      dyJoin = (-wdxNext + wdx) / dJoin;
+	      xc = pathIn->pts[j0].x
+		   + (SplashCoord)0.5 * w
+		     * cos((double)((SplashCoord)0.5 * (angle + angleNext)));
+	      yc = pathIn->pts[j0].y
+		   + (SplashCoord)0.5 * w
+		     * sin((double)((SplashCoord)0.5 * (angle + angleNext)));
+	      kappa = dAngle * bezierCircle2 * w;
+	      cx1 = pathIn->pts[j0].x + wdy + kappa * dx;
+	      cy1 = pathIn->pts[j0].y - wdx + kappa * dy;
+	      cx2 = xc - kappa * dxJoin;
+	      cy2 = yc - kappa * dyJoin;
+	      cx3 = xc + kappa * dxJoin;
+	      cy3 = yc + kappa * dyJoin;
+	      cx4 = pathIn->pts[j0].x + wdyNext - kappa * dxNext;
+	      cy4 = pathIn->pts[j0].y - wdxNext - kappa * dyNext;
+	      pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y);
+	      pathOut->lineTo(pathIn->pts[j0].x + wdy,
+			      pathIn->pts[j0].y - wdx);
+	      pathOut->curveTo(cx1, cy1, cx2, cy2, xc, yc);
+	      pathOut->curveTo(cx3, cy3, cx4, cy4,
+			       pathIn->pts[j0].x + wdyNext,
+			       pathIn->pts[j0].y - wdxNext);
+	    }
+	  }
+	}
+
       } else {
 	pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y);
 
-	// angle < 180
+	// join angle < 180
 	if (crossprod < 0) {
 	  pathOut->lineTo(pathIn->pts[j0].x - wdyNext,
 			  pathIn->pts[j0].y + wdxNext);
 	  // miter join inside limit
-	  if (state->lineJoin == splashLineJoinMiter &&
+	  if (lineJoin == splashLineJoinMiter &&
 	      splashSqrt(miter) <= state->miterLimit) {
 	    pathOut->lineTo(pathIn->pts[j0].x - wdy + wdx * m,
 			    pathIn->pts[j0].y + wdx + wdy * m);
@@ -6420,12 +6953,12 @@
 			    pathIn->pts[j0].y + wdx);
 	  }
 
-	// angle >= 180
+	// join angle >= 180
 	} else {
 	  pathOut->lineTo(pathIn->pts[j0].x + wdy,
 			  pathIn->pts[j0].y - wdx);
 	  // miter join inside limit
-	  if (state->lineJoin == splashLineJoinMiter &&
+	  if (lineJoin == splashLineJoinMiter &&
 	      splashSqrt(miter) <= state->miterLimit) {
 	    pathOut->lineTo(pathIn->pts[j0].x + wdy + wdx * m,
 			    pathIn->pts[j0].y - wdx + wdy * m);
@@ -6443,36 +6976,106 @@
     }
 
     // add stroke adjustment hints
-    if (state->strokeAdjust) {
-      if (seg == 0 && !closed) {
-	if (state->lineCap == splashLineCapButt) {
+    if (state->strokeAdjust != splashStrokeAdjustOff) {
+
+      // subpath with one segment
+      if (seg == 0 && last) {
+	switch (lineCap) {
+	case splashLineCapButt:
 	  pathOut->addStrokeAdjustHint(firstPt, left2 + 1,
-				       firstPt, firstPt + 1);
-	  if (last) {
-	    pathOut->addStrokeAdjustHint(firstPt, left2 + 1,
-					 left2 + 1, left2 + 2);
+				       firstPt, pathOut->length - 1);
+	  break;
+	case splashLineCapProjecting:
+	  pathOut->addStrokeAdjustHint(firstPt, left2 + 1,
+				       firstPt, pathOut->length - 1, gTrue);
+	  break;
+	case splashLineCapRound:
+	  break;
+	}
+	pathOut->addStrokeAdjustHint(left2, right2,
+				     firstPt, pathOut->length - 1);
+      } else {
+
+	// start of subpath
+	if (seg == 1) {
+
+	  // start cap
+	  if (!closed) {
+	    switch (lineCap) {
+	    case splashLineCapButt:
+	      pathOut->addStrokeAdjustHint(firstPt, left1 + 1,
+					   firstPt, firstPt + 1);
+	      pathOut->addStrokeAdjustHint(firstPt, left1 + 1,
+					   right1 + 1, right1 + 1);
+	      break;
+	    case splashLineCapProjecting:
+	      pathOut->addStrokeAdjustHint(firstPt, left1 + 1,
+					   firstPt, firstPt + 1, gTrue);
+	      pathOut->addStrokeAdjustHint(firstPt, left1 + 1,
+					   right1 + 1, right1 + 1, gTrue);
+	      break;
+	    case splashLineCapRound:
+	      break;
+	    }
 	  }
-	} else if (state->lineCap == splashLineCapProjecting) {
-	  if (last) {
-	    pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 2,
-					 firstPt + 1, firstPt + 2);
-	    pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 2,
-					 left2 + 2, left2 + 3);
-	  } else {
-	    pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 1,
-					 firstPt + 1, firstPt + 2);
-	  }
+
+	  // first segment
+	  pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2);
+	  pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1);
 	}
-      }
-      if (seg >= 1) {
-	if (seg >= 2) {
+
+	// middle of subpath
+	if (seg > 1) {
 	  pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0);
 	  pathOut->addStrokeAdjustHint(left1, right1, join0, left2);
-	} else {
-	  pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2);
+	  pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1);
 	}
-	pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1);
+
+	// end of subpath
+	if (last) {
+
+	  if (closed) {
+	    // first segment
+	    pathOut->addStrokeAdjustHint(leftFirst, rightFirst,
+					 left2 + 1, right2);
+	    pathOut->addStrokeAdjustHint(leftFirst, rightFirst,
+					 join2, pathOut->length - 1);
+
+	    // last segment
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 left1 + 1, right1);
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 join1, pathOut->length - 1);
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 leftFirst - 1, leftFirst);
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 rightFirst + 1, rightFirst + 1);
+
+	  } else {
+
+	    // last segment
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 left1 + 1, right1);
+	    pathOut->addStrokeAdjustHint(left2, right2,
+					 join1, pathOut->length - 1);
+
+	    // end cap
+	    switch (lineCap) {
+	    case splashLineCapButt:
+	      pathOut->addStrokeAdjustHint(left2 - 1, left2 + 1,
+					   left2 + 1, left2 + 2);
+	      break;
+	    case splashLineCapProjecting:
+	      pathOut->addStrokeAdjustHint(left2 - 1, left2 + 1,
+					   left2 + 1, left2 + 2, gTrue);
+	      break;
+	    case splashLineCapRound:
+	      break;
+	    }
+	  }
+	}
       }
+
       left0 = left1;
       left1 = left2;
       right0 = right1;
@@ -6483,34 +7086,6 @@
 	leftFirst = left2;
 	rightFirst = right2;
       }
-      if (last) {
-	if (seg >= 2) {
-	  pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0);
-	  pathOut->addStrokeAdjustHint(left1, right1,
-				       join0, pathOut->length - 1);
-	} else {
-	  pathOut->addStrokeAdjustHint(left1, right1,
-				       firstPt, pathOut->length - 1);
-	}
-	if (closed) {
-	  pathOut->addStrokeAdjustHint(left1, right1, firstPt, leftFirst);
-	  pathOut->addStrokeAdjustHint(left1, right1,
-				       rightFirst + 1, rightFirst + 1);
-	  pathOut->addStrokeAdjustHint(leftFirst, rightFirst,
-				       left1 + 1, right1);
-	  pathOut->addStrokeAdjustHint(leftFirst, rightFirst,
-				       join1, pathOut->length - 1);
-	}
-	if (!closed && seg > 0) {
-	  if (state->lineCap == splashLineCapButt) {
-	    pathOut->addStrokeAdjustHint(left1 - 1, left1 + 1,
-					 left1 + 1, left1 + 2);
-	  } else if (state->lineCap == splashLineCapProjecting) {
-	    pathOut->addStrokeAdjustHint(left1 - 1, left1 + 2,
-					 left1 + 2, left1 + 3);
-	  }
-	}
-      }
     }
 
     i0 = j0;
@@ -6525,6 +7100,29 @@
   return pathOut;
 }
 
+SplashClipResult Splash::limitRectToClipRect(int *xMin, int *yMin,
+					     int *xMax, int *yMax) {
+  int t;
+
+  if ((t = state->clip->getXMinI(state->strokeAdjust)) > *xMin) {
+    *xMin = t;
+  }
+  if ((t = state->clip->getXMaxI(state->strokeAdjust) + 1) < *xMax) {
+    *xMax = t;
+  }
+  if ((t = state->clip->getYMinI(state->strokeAdjust)) > *yMin) {
+    *yMin = t;
+  }
+  if ((t = state->clip->getYMaxI(state->strokeAdjust) + 1) < *yMax) {
+    *yMax = t;
+  }
+  if (*xMin >= *xMax || *yMin >= *yMax) {
+    return splashClipAllOutside;
+  }
+  return state->clip->testRect(*xMin, *yMin, *xMax - 1, *yMax - 1,
+			       state->strokeAdjust);
+}
+
 void Splash::dumpPath(SplashPath *path) {
   int i;
 
@@ -6536,6 +7134,15 @@
 	   (path->flags[i] & splashPathClosed) ? " closed" : "",
 	   (path->flags[i] & splashPathCurve) ? " curve" : "");
   }
+  if (path->hintsLength == 0) {
+    printf("  no hints\n");
+  } else {
+    for (i = 0; i < path->hintsLength; ++i) {
+      printf("  hint %3d: ctrl0=%d ctrl1=%d pts=%d..%d\n",
+	     i, path->hints[i].ctrl0, path->hints[i].ctrl1,
+	     path->hints[i].firstPt, path->hints[i].lastPt);
+    }
+  }
 }
 
 void Splash::dumpXPath(SplashXPath *path) {

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/Splash.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -95,7 +95,7 @@
   SplashCoord *getLineDash();
   int getLineDashLength();
   SplashCoord getLineDashPhase();
-  GBool getStrokeAdjust();
+  SplashStrokeAdjustMode getStrokeAdjust();
   SplashClip *getClip();
   SplashBitmap *getSoftMask();
   GBool getInNonIsolatedGroup();
@@ -118,7 +118,7 @@
   // the <lineDash> array will be copied
   void setLineDash(SplashCoord *lineDash, int lineDashLength,
 		   SplashCoord lineDashPhase);
-  void setStrokeAdjust(GBool strokeAdjust);
+  void setStrokeAdjust(SplashStrokeAdjustMode strokeAdjust);
   // NB: uses transformed coordinates.
   void clipResetToRect(SplashCoord x0, SplashCoord y0,
 		       SplashCoord x1, SplashCoord y1);
@@ -133,6 +133,7 @@
 			      GBool nonIsolated, GBool knockout);
   void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray);
   void setOverprintMask(Guint overprintMask);
+  void setEnablePathSimplification(GBool en);
 
   //----- state save/restore
 
@@ -150,9 +151,6 @@
   // Fill a path using the current fill pattern.
   SplashError fill(SplashPath *path, GBool eo);
 
-  // Fill a path, XORing with the current fill pattern.
-  SplashError xorFill(SplashPath *path, GBool eo);
-
   // Draw a character, using the current fill pattern.
   SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font);
 
@@ -213,6 +211,12 @@
   SplashError blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
 			      int xDest, int yDest, int w, int h);
 
+  // Copy a rectangular region from the bitmap belonging to this
+  // Splash object to <dest>.  The alpha values are corrected for a
+  // non-isolated group.
+  SplashError blitCorrectedAlpha(SplashBitmap *dest, int xSrc, int ySrc,
+				 int xDest, int yDest, int w, int h);
+
   //----- misc
 
   // Construct a path for a stroke, given the path to be stroked and
@@ -220,8 +224,15 @@
   // the current state.  If <flatten> is true, this function will
   // first flatten the path and handle the linedash.
   SplashPath *makeStrokePath(SplashPath *path, SplashCoord w,
+			     int lineCap, int lineJoin,
 			     GBool flatten = gTrue);
 
+  // Reduce the size of a rectangle as much as possible by moving any
+  // edges that are completely outside the clip region.  Returns the
+  // clipping status of the resulting rectangle.
+  SplashClipResult limitRectToClipRect(int *xMin, int *yMin,
+				       int *xMax, int *yMax);
+
   // Return the associated bitmap.
   SplashBitmap *getBitmap() { return bitmap; }
 
@@ -296,7 +307,8 @@
   void updateModY(int y);
   void strokeNarrow(SplashPath *path);
   void drawStrokeSpan(SplashPipe *pipe, int x0, int x1, int y, GBool noClip);
-  void strokeWide(SplashPath *path, SplashCoord w);
+  void strokeWide(SplashPath *path, SplashCoord w,
+		  int lineCap, int lineJoin);
   SplashPath *flattenPath(SplashPath *path, SplashCoord *matrix,
 			  SplashCoord flatness);
   void flattenCurve(SplashCoord x0, SplashCoord y0,
@@ -407,10 +419,10 @@
   int bitmapComps;
   SplashState *state;
   Guchar *scanBuf;
+  Guchar *scanBuf2;
   SplashBitmap			// for transparency groups, this is the bitmap
     *groupBackBitmap;		//   containing the alpha0/color0 values
   int groupBackX, groupBackY;	// offset within groupBackBitmap
-  Guchar aaGamma[256];
   SplashCoord minLineWidth;
   int modXMin, modYMin, modXMax, modYMax;
   SplashClipResult opClipRes;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashBitmap.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashBitmap.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashBitmap.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <limits.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashErrorCodes.h"
 #include "SplashBitmap.h"
 
@@ -154,7 +155,18 @@
 
 #if SPLASH_CMYK
   case splashModeCMYK8:
-    // PNM doesn't support CMYK
+    fprintf(f, "P7\n");
+    fprintf(f, "WIDTH %d\n", width);
+    fprintf(f, "HEIGHT %d\n", height);
+    fprintf(f, "DEPTH 4\n");
+    fprintf(f, "MAXVAL 255\n");
+    fprintf(f, "TUPLTYPE CMYK\n");
+    fprintf(f, "ENDHDR\n");
+    row = data;
+    for (y = 0; y < height; ++y) {
+      fwrite(row, 1, 4 * width, f);
+      row += rowSize;
+    }
     break;
 #endif
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashErrorCodes.h"
 #include "SplashPath.h"
 #include "SplashXPath.h"
@@ -52,6 +53,8 @@
   eo = NULL;
   scanners = NULL;
   length = size = 0;
+  isSimple = gTrue;
+  prev = NULL;
   if ((w = hardXMax + 1) <= 0) {
     w = 1;
   }
@@ -59,7 +62,7 @@
 }
 
 SplashClip::SplashClip(SplashClip *clip) {
-  int w, i;
+  int w;
 
   hardXMin = clip->hardXMin;
   hardYMin = clip->hardYMin;
@@ -75,17 +78,12 @@
   yMaxI = clip->yMaxI;
   intBoundsValid = clip->intBoundsValid;
   intBoundsStrokeAdjust = clip->intBoundsStrokeAdjust;
-  length = clip->length;
-  size = clip->size;
-  paths = (SplashXPath **)gmallocn(size, sizeof(SplashXPath *));
-  eo = (Guchar *)gmallocn(size, sizeof(Guchar));
-  scanners = (SplashXPathScanner **)
-                 gmallocn(size, sizeof(SplashXPathScanner *));
-  for (i = 0; i < length; ++i) {
-    paths[i] = clip->paths[i]->copy();
-    eo[i] = clip->eo[i];
-    scanners[i] = new SplashXPathScanner(paths[i], eo[i], yMinI, yMaxI);
-  }
+  paths = NULL;
+  eo = NULL;
+  scanners = NULL;
+  length = size = 0;
+  isSimple = clip->isSimple;
+  prev = clip;
   if ((w = splashCeil(xMax)) <= 0) {
     w = 1;
   }
@@ -96,8 +94,8 @@
   int i;
 
   for (i = 0; i < length; ++i) {
+    delete scanners[i];
     delete paths[i];
-    delete scanners[i];
   }
   gfree(paths);
   gfree(eo);
@@ -136,6 +134,8 @@
   eo = NULL;
   scanners = NULL;
   length = size = 0;
+  isSimple = gTrue;
+  prev = NULL;
 
   if (x0 < x1) {
     xMin = x0;
@@ -202,11 +202,15 @@
 }
 
 SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix,
-				   SplashCoord flatness, GBool eoA) {
+				   SplashCoord flatness, GBool eoA,
+				   GBool enablePathSimplification,
+				   SplashStrokeAdjustMode strokeAdjust) {
   SplashXPath *xPath;
   SplashCoord t;
 
-  xPath = new SplashXPath(path, matrix, flatness, gTrue);
+  xPath = new SplashXPath(path, matrix, flatness, gTrue,
+			  enablePathSimplification,
+			  strokeAdjust);
 
   // check for an empty path
   if (xPath->length == 0) {
@@ -218,36 +222,11 @@
   }
 
   // check for a rectangle
-  if (xPath->length == 4 &&
-      xPath->segs[0].y0 == xPath->segs[0].y1 &&
-      xPath->segs[1].x0 == xPath->segs[1].x1 &&
-      xPath->segs[2].x0 == xPath->segs[2].x1 &&
-      xPath->segs[3].y0 == xPath->segs[3].y1) {
-    clipToRect(xPath->segs[1].x0, xPath->segs[0].y0,
-               xPath->segs[2].x0, xPath->segs[3].y0);
+  if (xPath->isRect) {
+    clipToRect(xPath->rectX0, xPath->rectY0, xPath->rectX1, xPath->rectY1);
     delete xPath;
     return splashOk;
   }
-  if (xPath->length == 4 &&
-      xPath->segs[0].x0 == xPath->segs[0].x1 &&
-      xPath->segs[1].y0 == xPath->segs[1].y1 &&
-      xPath->segs[2].x0 == xPath->segs[2].x1 &&
-      xPath->segs[3].y0 == xPath->segs[3].y1) {
-    clipToRect(xPath->segs[0].x0, xPath->segs[1].y0,
-               xPath->segs[2].x0, xPath->segs[3].y0);
-    delete xPath;
-    return splashOk;
-  }
-  if (xPath->length == 4 &&
-      xPath->segs[0].x0 == xPath->segs[0].x1 &&
-      xPath->segs[1].x0 == xPath->segs[1].x1 &&
-      xPath->segs[2].y0 == xPath->segs[2].y1 &&
-      xPath->segs[3].y0 == xPath->segs[3].y1) {
-    clipToRect(xPath->segs[0].x0, xPath->segs[2].y0,
-               xPath->segs[1].x0, xPath->segs[3].y0);
-    delete xPath;
-    return splashOk;
-  }
 
   grow(1);
   paths[length] = xPath;
@@ -268,6 +247,7 @@
   scanners[length] = new SplashXPathScanner(xPath, eoA, splashFloor(yMin),
 					    splashCeil(yMax) - 1);
   ++length;
+  isSimple = gFalse;
 
   return splashOk;
 }
@@ -274,7 +254,7 @@
 
 SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin,
 				      int rectXMax, int rectYMax,
-				      GBool strokeAdjust) {
+				      SplashStrokeAdjustMode strokeAdjust) {
   // In general, this function tests the rectangle:
   //     x = [rectXMin, rectXMax + 1)    (note: coords are ints)
   //     y = [rectYMin, rectYMax + 1)
@@ -282,7 +262,7 @@
   //     x = [xMin, xMax)                (note: coords are fp)
   //     y = [yMin, yMax)
 
-  if (strokeAdjust && length == 0) {
+  if (strokeAdjust != splashStrokeAdjustOff && isSimple) {
     // special case for stroke adjustment with a simple clipping
     // rectangle -- the clipping region is:
     //     x = [xMinI, xMaxI + 1)
@@ -313,7 +293,7 @@
 	(SplashCoord)rectYMin >= yMax) {
       return splashClipAllOutside;
     }
-    if (length == 0 &&
+    if (isSimple &&
 	(SplashCoord)rectXMin >= xMin &&
 	(SplashCoord)(rectXMax + 1) <= xMax &&
 	(SplashCoord)rectYMin >= yMin &&
@@ -325,9 +305,10 @@
 }
 
 void SplashClip::clipSpan(Guchar *line, int y, int x0, int x1,
-			  GBool strokeAdjust) {
+			  SplashStrokeAdjustMode strokeAdjust) {
+  SplashClip *clip;
   SplashCoord d;
-  int x0a, x1a, x, i;
+  int x0a, x1a, x0b, x1b, x, i;
 
   updateIntBounds(strokeAdjust);
 
@@ -360,7 +341,7 @@
   //--- clip to the floating point rectangle
   //    (if stroke adjustment is disabled)
 
-  if (!strokeAdjust) {
+  if (strokeAdjust == splashStrokeAdjustOff) {
 
     // clip left edge (xMin)
     if (x0a == xMinI) {
@@ -391,22 +372,31 @@
     }
   }
 
-  if (length == 0) {
+  if (isSimple) {
     return;
   }
 
   //--- clip to the paths
 
-  for (i = 0; i < length; ++i) {
-    scanners[i]->getSpan(buf, y, x0a, x1a);
-    for (x = x0a; x <= x1a; ++x) {
-      line[x] = mul255(line[x], buf[x]);
+  for (clip = this; clip; clip = clip->prev) {
+    for (i = 0; i < clip->length; ++i) {
+      clip->scanners[i]->getSpan(buf, y, x0a, x1a, &x0b, &x1b);
+      if (x0a < x0b) {
+	memset(line + x0a, 0, x0b - x0a);
+      }
+      for (x = x0b; x <= x1b; ++x) {
+	line[x] = mul255(line[x], buf[x]);
+      }
+      if (x1b < x1a) {
+	memset(line + x1b + 1, 0, x1a - x1b);
+      }
     }
   }
 }
 
 GBool SplashClip::clipSpanBinary(Guchar *line, int y, int x0, int x1,
-				 GBool strokeAdjust) {
+				 SplashStrokeAdjustMode strokeAdjust) {
+  SplashClip *clip;
   int x0a, x1a, x0b, x1b, x, i;
   Guchar any;
 
@@ -438,7 +428,7 @@
     return gFalse;
   }
 
-  if (length == 0) {
+  if (isSimple) {
     for (x = x0a; x <= x1a; ++x) {
       if (line[x]) {
 	return gTrue;
@@ -448,52 +438,63 @@
   }
 
   any = 0;
-  for (i = 0; i < length; ++i) {
-    scanners[i]->getSpanBinary(buf, y, x0a, x1a);
-    for (x0b = x0a; x0b <= x1a && !buf[x0b]; ++x0b) ;
-    if (x0a < x0b) {
-      memset(line + x0a, 0, x0b - x0a);
+  for (clip = this; clip; clip = clip->prev) {
+    for (i = 0; i < clip->length; ++i) {
+      clip->scanners[i]->getSpanBinary(buf, y, x0a, x1a, &x0b, &x1b);
+      if (x0a < x0b) {
+	memset(line + x0a, 0, x0b - x0a);
+      }
+      for (x = x0b; x <= x1b; ++x) {
+	line[x] &= buf[x];
+	any |= line[x];
+      }
+      if (x1b < x1a) {
+	memset(line + x1b + 1, 0, x1a - x1b);
+      }
     }
-    for (x1b = x1a; x1b >= x0b && !buf[x1b]; --x1b) ;
-    if (x1b < x1a) {
-      memset(line + x1b + 1, 0, x1a - x1b);
-    }
-    for (x = x0b; x <= x1b; ++x) {
-      line[x] &= buf[x];
-      any |= line[x];
-    }
   }
 
   return any != 0;
 }
 
-int SplashClip::getXMinI(GBool strokeAdjust) {
+int SplashClip::getXMinI(SplashStrokeAdjustMode strokeAdjust) {
   updateIntBounds(strokeAdjust);
   return xMinI;
 }
 
-int SplashClip::getXMaxI(GBool strokeAdjust) {
+int SplashClip::getXMaxI(SplashStrokeAdjustMode strokeAdjust) {
   updateIntBounds(strokeAdjust);
   return xMaxI;
 }
 
-int SplashClip::getYMinI(GBool strokeAdjust) {
+int SplashClip::getYMinI(SplashStrokeAdjustMode strokeAdjust) {
   updateIntBounds(strokeAdjust);
   return yMinI;
 }
 
-int SplashClip::getYMaxI(GBool strokeAdjust) {
+int SplashClip::getYMaxI(SplashStrokeAdjustMode strokeAdjust) {
   updateIntBounds(strokeAdjust);
   return yMaxI;
 }
 
-void SplashClip::updateIntBounds(GBool strokeAdjust) {
+int SplashClip::getNumPaths() {
+  SplashClip *clip;
+  int n;
+
+  n = 0;
+  for (clip = this; clip; clip = clip->prev) {
+    n += clip->length;
+  }
+  return n;
+}
+
+void SplashClip::updateIntBounds(SplashStrokeAdjustMode strokeAdjust) {
   if (intBoundsValid && strokeAdjust == intBoundsStrokeAdjust) {
     return;
   }
-  if (strokeAdjust && length == 0) {
-    splashStrokeAdjust(xMin, xMax, &xMinI, &xMaxI);
-    splashStrokeAdjust(yMin, yMax, &yMinI, &yMaxI);
+  if (strokeAdjust != splashStrokeAdjustOff && isSimple) {
+    splashStrokeAdjust(xMin, xMax, &xMinI, &xMaxI, strokeAdjust);
+    splashStrokeAdjust(yMin, yMax, &yMinI, &yMaxI, strokeAdjust);
   } else {
     xMinI = splashFloor(xMin);
     yMinI = splashFloor(yMin);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -57,7 +57,9 @@
 
   // Interesect the clip with <path>.
   SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
-			 SplashCoord flatness, GBool eoA);
+			 SplashCoord flatness, GBool eoA,
+			 GBool enablePathSimplification,
+			 SplashStrokeAdjustMode strokeAdjust);
 
   // Tests a rectangle against the clipping region.  Returns one of:
   //   - splashClipAllInside if the entire rectangle is inside the
@@ -70,18 +72,18 @@
   //     outside the clipping region
   SplashClipResult testRect(int rectXMin, int rectYMin,
 			    int rectXMax, int rectYMax,
-			    GBool strokeAdjust);
+			    SplashStrokeAdjustMode strokeAdjust);
 
   // Clip a scan line.  Modifies line[] by multiplying with clipping
   // shape values for one scan line: ([x0, x1], y).
   void clipSpan(Guchar *line, int y, int x0, int x1,
-		GBool strokeAdjust);
+		SplashStrokeAdjustMode strokeAdjust);
 
   // Like clipSpan(), but uses the values 0 and 255 only.
   // Returns true if there are any non-zero values in the result
   // (i.e., returns false if the entire line is clipped out).
   GBool clipSpanBinary(Guchar *line, int y, int x0, int x1,
-		       GBool strokeAdjust);
+		       SplashStrokeAdjustMode strokeAdjust);
 
   // Get the rectangle part of the clip region.
   SplashCoord getXMin() { return xMin; }
@@ -90,19 +92,19 @@
   SplashCoord getYMax() { return yMax; }
 
   // Get the rectangle part of the clip region, in integer coordinates.
-  int getXMinI(GBool strokeAdjust);
-  int getXMaxI(GBool strokeAdjust);
-  int getYMinI(GBool strokeAdjust);
-  int getYMaxI(GBool strokeAdjust);
+  int getXMinI(SplashStrokeAdjustMode strokeAdjust);
+  int getXMaxI(SplashStrokeAdjustMode strokeAdjust);
+  int getYMinI(SplashStrokeAdjustMode strokeAdjust);
+  int getYMaxI(SplashStrokeAdjustMode strokeAdjust);
 
   // Get the number of arbitrary paths used by the clip region.
-  int getNumPaths() { return length; }
+  int getNumPaths();
 
 private:
 
   SplashClip(SplashClip *clip);
   void grow(int nPaths);
-  void updateIntBounds(GBool strokeAdjust);
+  void updateIntBounds(SplashStrokeAdjustMode strokeAdjust);
 
   int hardXMin, hardYMin,	// coordinates cannot fall outside of
       hardXMax, hardYMax;	//   [hardXMin, hardXMax), [hardYMin, hardYMax)
@@ -120,6 +122,8 @@
   Guchar *eo;
   SplashXPathScanner **scanners;
   int length, size;
+  GBool isSimple;
+  SplashClip *prev;
   Guchar *buf;
 };
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,7 +8,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma implementation
@@ -19,6 +19,7 @@
 #include FT_SIZES_H
 #include FT_GLYPH_H
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashMath.h"
 #include "SplashGlyphBitmap.h"
 #include "SplashPath.h"
@@ -66,6 +67,10 @@
   // if the textMat values are too small, FreeType's fixed point
   // arithmetic doesn't work so well
   textScale = splashDist(0, 0, textMat[2], textMat[3]) / size;
+  // avoid problems with singular (or close-to-singular) matrices
+  if (textScale < 0.00001) {
+    textScale = 0.00001;
+  }
 
   div = face->bbox.xMax > 20000 ? 65536 : 1;
 
@@ -220,7 +225,7 @@
   SplashFTFontFile *ff;
   FT_Vector offset;
   FT_GlyphSlot slot;
-  FT_UInt gid;
+  int gid;
   FT_Int32 flags;
   int rowSize;
   Guchar *p, *q;
@@ -235,11 +240,11 @@
   slot = ff->face->glyph;
 
   if (ff->codeToGID && c < ff->codeToGIDLen) {
-    gid = (FT_UInt)ff->codeToGID[c];
+    gid = ff->codeToGID[c];
   } else {
-    gid = (FT_UInt)c;
+    gid = c;
   }
-  if (ff->trueType && gid < 0) {
+  if (ff->fontType == splashFontTrueType && gid < 0) {
     // skip the TrueType notdef glyph
     return gFalse;
   }
@@ -258,13 +263,19 @@
   flags = FT_LOAD_NO_BITMAP;
   if (ff->engine->flags & splashFTNoHinting) {
     flags |= FT_LOAD_NO_HINTING;
-  } else if (ff->useLightHinting) {
+  } else if (ff->fontType == splashFontType1) {
     flags |= FT_LOAD_TARGET_LIGHT;
   } else {
     flags |= FT_LOAD_NO_AUTOHINT;
   }
-  if (FT_Load_Glyph(ff->face, gid, flags)) {
-    return gFalse;
+  if (FT_Load_Glyph(ff->face, (FT_UInt)gid, flags)) {
+    // fonts with broken hinting instructions can cause errors here;
+    // try again with no hinting (this is probably only relevant for
+    // TrueType fonts)
+    flags = FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING;
+    if (FT_Load_Glyph(ff->face, (FT_UInt)gid, flags)) {
+      return gFalse;
+    }
   }
   if (FT_Render_Glyph(slot, aa ? FT_RENDER_MODE_NORMAL
 		               : FT_RENDER_MODE_MONO)) {
@@ -321,7 +332,7 @@
   SplashFTFontFile *ff;
   SplashFTFontPath path;
   FT_GlyphSlot slot;
-  FT_UInt gid;
+  int gid;
   FT_Glyph glyph;
 
   ff = (SplashFTFontFile *)fontFile;
@@ -331,14 +342,20 @@
   if (ff->codeToGID && c < ff->codeToGIDLen) {
     gid = ff->codeToGID[c];
   } else {
-    gid = (FT_UInt)c;
+    gid = c;
   }
-  if (ff->trueType && gid < 0) {
+  if (ff->fontType == splashFontTrueType && gid < 0) {
     // skip the TrueType notdef glyph
     return NULL;
   }
-  if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) {
-    return NULL;
+  if (FT_Load_Glyph(ff->face, (FT_UInt)gid, FT_LOAD_NO_BITMAP)) {
+    // fonts with broken hinting instructions can cause errors here;
+    // try again with no hinting (this is probably only relevant for
+    // TrueType fonts)
+    if (FT_Load_Glyph(ff->face, (FT_UInt)gid,
+		      FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING)) {
+      return NULL;
+    }
   }
   if (FT_Get_Glyph(slot, &glyph)) {
     return NULL;
@@ -429,4 +446,4 @@
   return 0;
 }
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFont.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -11,7 +11,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma interface
@@ -55,6 +55,6 @@
   SplashCoord textScale;
 };
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,7 +8,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma implementation
@@ -19,6 +19,7 @@
 #  include <unistd.h>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "gfile.h"
 #include "FoFiTrueType.h"
@@ -87,13 +88,13 @@
 						  GBool deleteFile,
 #endif
 						  const char **enc) {
-  return SplashFTFontFile::loadType1Font(this, idA,
+  return SplashFTFontFile::loadType1Font(this, idA, splashFontType1,
 #if LOAD_FONTS_FROM_MEM
 					 fontBuf,
 #else
 					 fileName, deleteFile,
 #endif
-					 enc, gTrue);
+					 enc);
 }
 
 SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA,
@@ -104,13 +105,13 @@
 						   GBool deleteFile,
 #endif
 						   const char **enc) {
-  return SplashFTFontFile::loadType1Font(this, idA,
+  return SplashFTFontFile::loadType1Font(this, idA, splashFontType1C,
 #if LOAD_FONTS_FROM_MEM
 					 fontBuf,
 #else
 					 fileName, deleteFile,
 #endif
-					 enc, gFalse);
+					 enc);
 }
 
 SplashFontFile *SplashFTFontEngine::loadOpenTypeT1CFont(SplashFontFileID *idA,
@@ -143,8 +144,8 @@
     fontBuf2 = new GString();
     ff->convertToType1(NULL, enc, gFalse, &gstringWrite, fontBuf2);
     delete ff;
-    ret = SplashFTFontFile::loadType1Font(this, idA, fontBuf2, enc,
-					  gFalse);
+    ret = SplashFTFontFile::loadType1Font(this, idA, splashFontType1,
+					  fontBuf2, enc);
     if (ret) {
       delete fontBuf;
     } else {
@@ -159,8 +160,9 @@
     ff->convertToType1(NULL, enc, gFalse, &fileWrite, tmpFile);
     delete ff;
     fclose(tmpFile);
-    ret = SplashFTFontFile::loadType1Font(this, idA, tmpFileName->getCString(),
-					  gTrue, enc, gFalse);
+    ret = SplashFTFontFile::loadType1Font(this, idA, splashFontType1,
+					  tmpFileName->getCString(),
+					  gTrue, enc);
     if (ret) {
       if (deleteFile) {
 	unlink(fileName);
@@ -172,13 +174,13 @@
 #endif
   } else {
     delete ff;
-    ret = SplashFTFontFile::loadType1Font(this, idA,
+    ret = SplashFTFontFile::loadType1Font(this, idA, splashFontOpenTypeT1C,
 #if LOAD_FONTS_FROM_MEM
 					  fontBuf,
 #else
 					  fileName, deleteFile,
 #endif
-					  enc, gFalse);
+					  enc);
   }
   return ret;
 }
@@ -185,12 +187,13 @@
 
 SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
-						GString *fontBuf
+						GString *fontBuf,
 #else
 						char *fileName,
-						GBool deleteFile
+						GBool deleteFile,
 #endif
-						) {
+						int *codeToGID,
+						int codeToGIDLen) {
   FoFiType1C *ff;
   int *cidToGIDMap;
   int nCIDs;
@@ -197,9 +200,12 @@
   SplashFontFile *ret;
 
   // check for a CFF font
-  if (useCIDs) {
+  if (codeToGID) {
     cidToGIDMap = NULL;
     nCIDs = 0;
+  } else if (useCIDs) {
+    cidToGIDMap = NULL;
+    nCIDs = 0;
 #if LOAD_FONTS_FROM_MEM
   } else if ((ff = FoFiType1C::make(fontBuf->getCString(),
 				    fontBuf->getLength()))) {
@@ -212,13 +218,14 @@
     cidToGIDMap = NULL;
     nCIDs = 0;
   }
-  ret = SplashFTFontFile::loadCIDFont(this, idA,
+  ret = SplashFTFontFile::loadCIDFont(this, idA, splashFontCID,
 #if LOAD_FONTS_FROM_MEM
 				      fontBuf,
 #else
 				      fileName, deleteFile,
 #endif
-				      cidToGIDMap, nCIDs);
+				      codeToGID ? codeToGID : cidToGIDMap,
+				      codeToGID ? codeToGIDLen : nCIDs);
   if (!ret) {
     gfree(cidToGIDMap);
   }
@@ -266,8 +273,8 @@
     if (!useCIDs) {
       cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
     }
-    ret = SplashFTFontFile::loadCIDFont(this, idA, fontBuf2,
-					cidToGIDMap, nCIDs);
+    ret = SplashFTFontFile::loadCIDFont(this, idA, splashFontOpenTypeCFF,
+					fontBuf2, cidToGIDMap, nCIDs);
     if (ret) {
       delete fontBuf;
     } else {
@@ -284,7 +291,7 @@
     if (!useCIDs) {
       cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
     }
-    ret = SplashFTFontFile::loadCIDFont(this, idA,
+    ret = SplashFTFontFile::loadCIDFont(this, idA, splashFontOpenTypeCFF,
 					tmpFileName->getCString(), gTrue,
 					cidToGIDMap, nCIDs);
     if (ret) {
@@ -300,7 +307,7 @@
     if (!codeToGID && !useCIDs && ff->isOpenTypeCFF()) {
       cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
     }
-    ret = SplashFTFontFile::loadCIDFont(this, idA,
+    ret = SplashFTFontFile::loadCIDFont(this, idA, splashFontOpenTypeCFF,
 #if LOAD_FONTS_FROM_MEM
 					fontBuf,
 #else
@@ -356,7 +363,7 @@
   fclose(tmpFile);
 #endif
   delete ff;
-  ret = SplashFTFontFile::loadTrueTypeFont(this, idA,
+  ret = SplashFTFontFile::loadTrueTypeFont(this, idA, splashFontTrueType,
 #if LOAD_FONTS_FROM_MEM
 					   fontBuf2,
 #else
@@ -382,4 +389,4 @@
   return ret;
 }
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontEngine.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -11,7 +11,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma interface
@@ -60,11 +60,11 @@
 				      const char **enc);
   SplashFontFile *loadCIDFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
-			      GString *fontBuf
+			      GString *fontBuf,
 #else
-			      char *fileName, GBool deleteFile
+			      char *fileName, GBool deleteFile,
 #endif
-			      );
+			      int *codeToGID, int codeToGIDLen);
   SplashFontFile *loadOpenTypeCFFFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
 				      GString *fontBuf,
@@ -94,6 +94,6 @@
   friend class SplashFTFont;
 };
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,7 +8,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma implementation
@@ -15,6 +15,7 @@
 #endif
 
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "SplashFTFontEngine.h"
 #include "SplashFTFont.h"
@@ -26,6 +27,7 @@
 
 SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA,
 						SplashFontFileID *idA,
+						SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 						GString *fontBufA,
 #else
@@ -32,8 +34,7 @@
 						char *fileNameA,
 						GBool deleteFileA,
 #endif
-						const char **encA,
-						GBool useLightHintingA) {
+						const char **encA) {
   FT_Face faceA;
   int *codeToGIDA;
   const char *name;
@@ -55,18 +56,18 @@
     }
   }
 
-  return new SplashFTFontFile(engineA, idA,
+  return new SplashFTFontFile(engineA, idA, fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 			      fontBufA,
 #else
 			      fileNameA, deleteFileA,
 #endif
-			      faceA, codeToGIDA, 256,
-			      gFalse, useLightHintingA);
+			      faceA, codeToGIDA, 256);
 }
 
 SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA,
 					      SplashFontFileID *idA,
+					      SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 					      GString *fontBufA,
 #else
@@ -86,18 +87,18 @@
     return NULL;
   }
 
-  return new SplashFTFontFile(engineA, idA,
+  return new SplashFTFontFile(engineA, idA, fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 			      fontBufA,
 #else
 			      fileNameA, deleteFileA,
 #endif
-			      faceA, codeToGIDA, codeToGIDLenA,
-			      gFalse, gFalse);
+			      faceA, codeToGIDA, codeToGIDLenA);
 }
 
 SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA,
 						   SplashFontFileID *idA,
+						   SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 						   GString *fontBufA,
 #else
@@ -118,18 +119,18 @@
     return NULL;
   }
 
-  return new SplashFTFontFile(engineA, idA,
+  return new SplashFTFontFile(engineA, idA, fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 			      fontBufA,
 #else
 			      fileNameA, deleteFileA,
 #endif
-			      faceA, codeToGIDA, codeToGIDLenA,
-			      gTrue, gFalse);
+			      faceA, codeToGIDA, codeToGIDLenA);
 }
 
 SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA,
 				   SplashFontFileID *idA,
+				   SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 				   GString *fontBufA,
 #else
@@ -136,12 +137,11 @@
 				   char *fileNameA, GBool deleteFileA,
 #endif
 				   FT_Face faceA,
-				   int *codeToGIDA, int codeToGIDLenA,
-				   GBool trueTypeA, GBool useLightHintingA):
+				   int *codeToGIDA, int codeToGIDLenA):
 #if LOAD_FONTS_FROM_MEM
-  SplashFontFile(idA, fontBufA)
+  SplashFontFile(idA, fontTypeA, fontBufA)
 #else
-  SplashFontFile(idA, fileNameA, deleteFileA)
+  SplashFontFile(idA, fontTypeA, fileNameA, deleteFileA)
 #endif
 {
   engine = engineA;
@@ -148,8 +148,6 @@
   face = faceA;
   codeToGID = codeToGIDA;
   codeToGIDLen = codeToGIDLenA;
-  trueType = trueTypeA;
-  useLightHinting = useLightHintingA;
 }
 
 SplashFTFontFile::~SplashFTFontFile() {
@@ -170,4 +168,4 @@
   return font;
 }
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFTFontFile.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -11,7 +11,7 @@
 
 #include <aconf.h>
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 
 #ifdef USE_GCC_PRAGMAS
 #pragma interface
@@ -33,15 +33,16 @@
 
   static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA,
 				       SplashFontFileID *idA,
+				       SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 				       GString *fontBufA,
 #else
 				       char *fileNameA, GBool deleteFileA,
 #endif
-				       const char **encA,
-				       GBool useLightHintingA);
+				       const char **encA);
   static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA,
 				     SplashFontFileID *idA,
+				     SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 				     GString *fontBufA,
 #else
@@ -50,6 +51,7 @@
 				     int *codeToGIDA, int codeToGIDLenA);
   static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA,
 					  SplashFontFileID *idA,
+					  SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 					  GString *fontBufA,
 #else
@@ -71,6 +73,7 @@
 
   SplashFTFontFile(SplashFTFontEngine *engineA,
 		   SplashFontFileID *idA,
+		   SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 		   GString *fontBufA,
 #else
@@ -77,19 +80,16 @@
 		   char *fileNameA, GBool deleteFileA,
 #endif
 		   FT_Face faceA,
-		   int *codeToGIDA, int codeToGIDLenA,
-		   GBool trueTypeA, GBool useLightHintingA);
+		   int *codeToGIDA, int codeToGIDLenA);
 
   SplashFTFontEngine *engine;
   FT_Face face;
   int *codeToGID;
   int codeToGIDLen;
-  GBool trueType;
-  GBool useLightHinting;
 
   friend class SplashFTFont;
 };
 
-#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#endif // HAVE_FREETYPE_H
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashMath.h"
 #include "SplashGlyphBitmap.h"
 #include "SplashFontFile.h"
@@ -66,6 +67,12 @@
   // deal with rounding errors
   glyphW = xMax - xMin + 3;
   glyphH = yMax - yMin + 3;
+  if (glyphW > 1000 || glyphH > 1000) {
+    // if the glyphs are too large, don't cache them -- setting the
+    // cache bitmap size to something tiny will cause getGlyph() to
+    // fall back to the uncached case
+    glyphW = glyphH = 1;
+  }
   if (aa) {
     glyphSize = glyphW * glyphH;
   } else {
@@ -76,7 +83,7 @@
   cacheAssoc = splashFontCacheAssoc;
   for (cacheSets = splashFontCacheMaxSets;
        cacheSets > 1 &&
-	 cacheSets * cacheAssoc * glyphSize > splashFontCacheSize;
+	 glyphSize > splashFontCacheSize / (cacheSets * cacheAssoc);
        cacheSets >>= 1) ;
   cache = (Guchar *)gmallocn(cacheSets * cacheAssoc, glyphSize);
   cacheTags = (SplashFontCacheTag *)gmallocn(cacheSets * cacheAssoc,

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFont.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -17,6 +17,7 @@
 
 #include "gtypes.h"
 #include "SplashTypes.h"
+#include "SplashMath.h"
 
 struct SplashGlyphBitmap;
 struct SplashFontCacheTag;
@@ -54,10 +55,14 @@
   GBool matches(SplashFontFile *fontFileA, SplashCoord *matA,
 		SplashCoord *textMatA) {
     return fontFileA == fontFile &&
-           matA[0] == mat[0] && matA[1] == mat[1] &&
-           matA[2] == mat[2] && matA[3] == mat[3] &&
-           textMatA[0] == textMat[0] && textMatA[1] == textMat[1] &&
-           textMatA[2] == textMat[2] && textMatA[3] == textMat[3];
+           splashAbs(matA[0] - mat[0]) < 0.0001 &&
+	   splashAbs(matA[1] - mat[1]) < 0.0001 &&
+           splashAbs(matA[2] - mat[2]) < 0.0001 &&
+           splashAbs(matA[3] - mat[3]) < 0.0001 &&
+           splashAbs(textMatA[0] - textMat[0]) < 0.0001 &&
+           splashAbs(textMatA[1] - textMat[1]) < 0.0001 &&
+           splashAbs(textMatA[2] - textMat[2]) < 0.0001 &&
+	   splashAbs(textMatA[3] - textMat[3]) < 0.0001;
   }
 
   // Get a glyph - this does a cache lookup first, and if not found,

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,6 +18,7 @@
 #  include <unistd.h>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "SplashMath.h"
 #include "SplashFTFontEngine.h"
@@ -37,7 +38,7 @@
 //------------------------------------------------------------------------
 
 SplashFontEngine::SplashFontEngine(
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 				   GBool enableFreeType,
 				   Guint freeTypeFlags,
 #endif
@@ -48,7 +49,7 @@
     fontCache[i] = NULL;
   }
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (enableFreeType) {
     ftEngine = SplashFTFontEngine::init(aa, freeTypeFlags);
   } else {
@@ -66,7 +67,7 @@
     }
   }
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (ftEngine) {
     delete ftEngine;
   }
@@ -99,7 +100,7 @@
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadType1Font(idA,
 #if LOAD_FONTS_FROM_MEM
@@ -135,7 +136,7 @@
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadType1CFont(idA,
 #if LOAD_FONTS_FROM_MEM
@@ -171,7 +172,7 @@
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadOpenTypeT1CFont(idA,
 #if LOAD_FONTS_FROM_MEM
@@ -198,24 +199,25 @@
 
 SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
-					      GString *fontBuf
+					      GString *fontBuf,
 #else
 					      char *fileName,
-					      GBool deleteFile
+					      GBool deleteFile,
 #endif
-					      ) {
+					      int *codeToGID,
+					      int codeToGIDLen) {
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadCIDFont(idA,
 #if LOAD_FONTS_FROM_MEM
-				     fontBuf
+				     fontBuf,
 #else
-				     fileName, deleteFile
+				     fileName, deleteFile,
 #endif
-				     );
+				     codeToGID, codeToGIDLen);
   }
 #endif
 
@@ -244,7 +246,7 @@
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadOpenTypeCFFFont(idA,
 #if LOAD_FONTS_FROM_MEM
@@ -283,7 +285,7 @@
   SplashFontFile *fontFile;
 
   fontFile = NULL;
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadTrueTypeFont(idA,
 #if LOAD_FONTS_FROM_MEM

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontEngine.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -29,7 +29,7 @@
 
 #define splashFontCacheSize 16
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 #define splashFTNoHinting (1 << 0)
 #endif
 
@@ -42,7 +42,7 @@
 
   // Create a font engine.
   SplashFontEngine(
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
 		   GBool enableFreeType,
 		   Guint freeTypeFlags,
 #endif
@@ -78,11 +78,11 @@
 				      const char **enc);
   SplashFontFile *loadCIDFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
-			      GString *fontBuf
+			      GString *fontBuf,
 #else
-			      char *fileName, GBool deleteFile
+			      char *fileName, GBool deleteFile,
 #endif
-			      );
+			      int *codeToGID, int codeToGIDLen);
   SplashFontFile *loadOpenTypeCFFFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
 				      GString *fontBuf,
@@ -115,7 +115,7 @@
 
   SplashFont *fontCache[splashFontCacheSize];
 
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
+#if HAVE_FREETYPE_H
   SplashFTFontEngine *ftEngine;
 #endif
 };

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,6 +16,7 @@
 #ifndef _WIN32
 #  include <unistd.h>
 #endif
+#include "gmempp.h"
 #include "GString.h"
 #include "SplashFontFile.h"
 #include "SplashFontFileID.h"
@@ -31,6 +32,7 @@
 //------------------------------------------------------------------------
 
 SplashFontFile::SplashFontFile(SplashFontFileID *idA,
+			       SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 			       GString *fontBufA
 #else
@@ -38,6 +40,7 @@
 #endif
 			       ) {
   id = idA;
+  fontType = fontTypeA;
 #if LOAD_FONTS_FROM_MEM
   fontBuf = fontBufA;
 #else
@@ -60,11 +63,22 @@
 }
 
 void SplashFontFile::incRefCnt() {
+#if MULTITHREADED
+  gAtomicIncrement(&refCnt);
+#else
   ++refCnt;
+#endif
 }
 
 void SplashFontFile::decRefCnt() {
-  if (!--refCnt) {
+  GBool done;
+
+#if MULTITHREADED
+  done = gAtomicDecrement(&refCnt) == 0;
+#else
+  done = --refCnt == 0;
+#endif
+  if (done) {
     delete this;
   }
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFile.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,6 +18,10 @@
 #include "gtypes.h"
 #include "SplashTypes.h"
 
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
+
 class GString;
 class SplashFontEngine;
 class SplashFont;
@@ -24,6 +28,20 @@
 class SplashFontFileID;
 
 //------------------------------------------------------------------------
+// SplashFontType
+//------------------------------------------------------------------------
+
+enum SplashFontType {
+  splashFontType1,		// GfxFontType.fontType1
+  splashFontType1C,		// GfxFontType.fontType1C
+  splashFontOpenTypeT1C,	// GfxFontType.fontType1COT
+  splashFontCID,		// GfxFontType.fontCIDType0/fontCIDType0C
+  splashFontOpenTypeCFF,	// GfxFontType.fontCIDType0COT
+  splashFontTrueType		// GfxFontType.fontTrueType/fontTrueTypeOT/
+				//             fontCIDType2/fontCIDType2OT
+};
+
+//------------------------------------------------------------------------
 // SplashFontFile
 //------------------------------------------------------------------------
 
@@ -49,6 +67,7 @@
 protected:
 
   SplashFontFile(SplashFontFileID *idA,
+		 SplashFontType fontTypeA,
 #if LOAD_FONTS_FROM_MEM
 		 GString *fontBufA
 #else
@@ -57,6 +76,7 @@
 		 );
 
   SplashFontFileID *id;
+  SplashFontType fontType;
 #if LOAD_FONTS_FROM_MEM
   GString *fontBuf;
 #else
@@ -63,7 +83,11 @@
   GString *fileName;
   GBool deleteFile;
 #endif
+#if MULTITHREADED
+  GAtomicCounter refCnt;
+#else
   int refCnt;
+#endif
 
   friend class SplashFontEngine;
 };

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFileID.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFileID.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashFontFileID.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "SplashFontFileID.h"
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashMath.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashMath.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashMath.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,9 +12,13 @@
 #include <aconf.h>
 
 #if USE_FIXEDPONT
-#include "FixedPoint.h"
+#  include "FixedPoint.h"
 #else
-#include <math.h>
+#  include <math.h>
+#  if (defined(__GNUC__) && defined(__SSE2__)) || \
+      (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64)))
+#    include <emmintrin.h>
+#  endif
 #endif
 #include "SplashTypes.h"
 
@@ -26,14 +30,40 @@
 #endif
 }
 
+// floor() and (int)() are implemented separately, which results
+// in changing the FPCW multiple times - so we optimize it with
+// some inline assembly or SSE intrinsics.
 static inline int splashFloor(SplashCoord x) {
 #if USE_FIXEDPOINT
+
+  //--- fixed point
+
   return FixedPoint::floor(x);
-#else
-#if __GNUC__ && __i386__
-  // floor() and (int)() are implemented separately, which results
-  // in changing the FPCW multiple times - so we optimize it with
-  // some inline assembly
+
+#elif (defined(__GNUC__) && defined(__SSE2__)) || \
+      (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64)))
+
+  //--- SSE2 intrinsics
+  // NB: 64-bit x86 guarantees availability of SSE2.
+
+  __m128d m1, m2;
+  __m128i m3;
+  int s, i;
+
+  m1 = _mm_set_sd(x);		// m1 = x
+  i = _mm_cvttsd_si32(m1);	// i = trunc(x)
+  m2 = _mm_cvtsi32_sd(m1, i);	// m2 = (double)trunc(x)
+  m1 = _mm_sub_sd(m1, m2);	// m1 = x - trunc(x)
+  m3 = _mm_castpd_si128(m1); 	// m3 = m1 (as 64-bit int)
+  m3 = _mm_srli_epi64(m3, 63);	// m3 = m3 >> 63
+  s = _mm_cvtsi128_si32(m3);	// s = m3 = sign bit of x - trunc(x)
+  return i - s;			// trunc(x) - sign bit
+
+#elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__)
+
+  //--- x87 inline assembly (gcc/clang)
+  // (this code fails on OSX for reasons I don't understand)
+
   Gushort oldCW, newCW, t;
   int result;
 
@@ -48,10 +78,11 @@
 		   : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t)
 		   : "t" (x));
   return result;
+
 #elif defined(_WIN32) && defined(_M_IX86)
-  // floor() and (int)() are implemented separately, which results
-  // in changing the FPCW multiple times - so we optimize it with
-  // some inline assembly
+
+  //--- x87 inline assembly (VC)
+
   Gushort oldCW, newCW;
   int result;
 
@@ -65,20 +96,50 @@
   __asm fistp DWORD PTR result
   __asm fldcw WORD PTR oldCW
   return result;
+
 #else
+
+  //--- all others
+
   return (int)floor(x);
+
 #endif
-#endif
 }
 
+// ceil() and (int)() are implemented separately, which results
+// in changing the FPCW multiple times - so we optimize it with
+// some inline assembly or SSE intrinsics.
 static inline int splashCeil(SplashCoord x) {
 #if USE_FIXEDPOINT
+
+  //--- fixed point
+
   return FixedPoint::ceil(x);
-#else
-#if __GNUC__ && __i386__
-  // ceil() and (int)() are implemented separately, which results
-  // in changing the FPCW multiple times - so we optimize it with
-  // some inline assembly
+
+#elif (defined(__GNUC__) && defined(__SSE2__)) || \
+      (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64)))
+
+  //--- SSE2 intrinsics
+  // NB: 64-bit x86 guarantees availability of SSE2.
+
+  __m128d m1, m2;
+  __m128i m3;
+  int s, i;
+
+  m1 = _mm_set_sd(x);		// m1 = x
+  i = _mm_cvttsd_si32(m1);	// i = trunc(x)
+  m2 = _mm_cvtsi32_sd(m1, i);	// m2 = (double)trunc(x)
+  m2 = _mm_sub_sd(m2, m1);	// m2 = trunc(x) - x
+  m3 = _mm_castpd_si128(m2); 	// m3 = m2 (as 64-bit int)
+  m3 = _mm_srli_epi64(m3, 63);	// m3 = m3 >> 63
+  s = _mm_cvtsi128_si32(m3);	// s = m3 = sign bit of x - trunc(x)
+  return i + s;			// trunc(x) + sign bit
+
+#elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__)
+
+  //--- x87 inline assembly (gcc/clang)
+  // (this code fails on OSX for reasons I don't understand)
+
   Gushort oldCW, newCW, t;
   int result;
 
@@ -93,7 +154,11 @@
 		   : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t)
 		   : "t" (x));
   return result;
+
 #elif defined(_WIN32) && defined(_M_IX86)
+
+  //--- x87 inline assembly (VC)
+
   // ceil() and (int)() are implemented separately, which results
   // in changing the FPCW multiple times - so we optimize it with
   // some inline assembly
@@ -110,57 +175,30 @@
   __asm fistp DWORD PTR result
   __asm fldcw WORD PTR oldCW
   return result;
+
 #else
+
+  //--- all others
+
   return (int)ceil(x);
+
 #endif
-#endif
 }
 
 static inline int splashRound(SplashCoord x) {
 #if USE_FIXEDPOINT
+
+  //--- fixed point
+
   return FixedPoint::round(x);
+
 #else
-#if __GNUC__ && __i386__
-  // this could use round-to-nearest mode and avoid the "+0.5",
-  // but that produces slightly different results (because i+0.5
-  // sometimes rounds up and sometimes down using the even rule)
-  Gushort oldCW, newCW, t;
-  int result;
 
-  x += 0.5;
-  __asm__ volatile("fnstcw %0\n"
-		   "movw   %0, %3\n"
-		   "andw   $0xf3ff, %3\n"
-		   "orw    $0x0400, %3\n"
-		   "movw   %3, %1\n"       // round down
-		   "fldcw  %1\n"
-		   "fistl %2\n"
-		   "fldcw  %0\n"
-		   : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t)
-		   : "t" (x));
-  return result;
-#elif defined(_WIN32) && defined(_M_IX86)
-  // this could use round-to-nearest mode and avoid the "+0.5",
-  // but that produces slightly different results (because i+0.5
-  // sometimes rounds up and sometimes down using the even rule)
-  Gushort oldCW, newCW;
-  int result;
+  //--- all others
 
-  x += 0.5;
-  __asm fld QWORD PTR x
-  __asm fnstcw WORD PTR oldCW
-  __asm mov ax, WORD PTR oldCW
-  __asm and ax, 0xf3ff
-  __asm or ax, 0x0400
-  __asm mov WORD PTR newCW, ax     // round down
-  __asm fldcw WORD PTR newCW
-  __asm fistp DWORD PTR result
-  __asm fldcw WORD PTR oldCW
-  return result;
-#else
-  return (int)floor(x + 0.5);
+  return splashFloor(x + 0.5);
+
 #endif
-#endif
 }
 
 static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) {
@@ -262,23 +300,53 @@
 //         but
 //               xMin  = 10.1   xMax  = 11.3   (width = 1.2)
 //           --> xMinI = 10     xMaxI = 12     (width = 2)
+//
+// 4. Use a hybrid approach, choosing between two of the above
+//    options, based on width.  E.g., use #2 if width <= 4, and use #1
+//    if width > 4.
+//
+// If w >= 0 and strokeAdjMode is splashStrokeAdjustCAD then a special
+// mode for projecting line caps is enabled, with w being the
+// transformed line width.
+
 static inline void splashStrokeAdjust(SplashCoord xMin, SplashCoord xMax,
-				      int *xMinI, int *xMaxI) {
+				      int *xMinI, int *xMaxI,
+				      SplashStrokeAdjustMode strokeAdjMode,
+				      SplashCoord w = -1) {
   int x0, x1;
 
-  // NB: enable exactly one of these.
+  // this will never be called with strokeAdjMode == splashStrokeAdjustOff
+  if (strokeAdjMode == splashStrokeAdjustCAD) {
+    x0 = splashRound(xMin);
+    if (w >= 0) {
+      x1 = splashRound(xMax - w) + splashRound(w);
+    } else {
+      x1 = x0 + splashRound(xMax - xMin);
+    }
+  } else {
+    // NB: enable exactly one of these.
 #if 1 // 1. Round both edge coordinates.
-  x0 = splashRound(xMin);
-  x1 = splashRound(xMax);
+    x0 = splashRound(xMin);
+    x1 = splashRound(xMax);
 #endif
 #if 0 // 2. Round the min coordinate; add the ceiling of the width.
-  x0 = splashRound(xMin);
-  x1 = x0 + splashCeil(xMax - xMin);
+    x0 = splashRound(xMin);
+    x1 = x0 + splashCeil(xMax - xMin);
 #endif
 #if 0 // 3. Use floor on the min coord and ceiling on the max coord.
-  x0 = splashFloor(xMin);
-  x1 = splashCeil(xMax);
+    x0 = splashFloor(xMin);
+    x1 = splashCeil(xMax);
 #endif
+#if 0 // 4. Hybrid.
+    SplashCoord w = xMax - xMin;
+    x0 = splashRound(xMin);
+    if (w > 4) {
+      x1 = splashRound(xMax);
+    } else {
+      x1 = x0 + splashRound(w);
+    }
+#endif
+  }
   if (x1 == x0) {
     ++x1;
   }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashErrorCodes.h"
 #include "SplashPath.h"
 
@@ -156,7 +157,8 @@
 }
 
 void SplashPath::addStrokeAdjustHint(int ctrl0, int ctrl1,
-				     int firstPt, int lastPt) {
+				     int firstPt, int lastPt,
+				     GBool projectingCap) {
   if (hintsLength == hintsSize) {
     hintsSize = hintsLength ? 2 * hintsLength : 8;
     hints = (SplashPathHint *)greallocn(hints, hintsSize,
@@ -166,6 +168,7 @@
   hints[hintsLength].ctrl1 = ctrl1;
   hints[hintsLength].firstPt = firstPt;
   hints[hintsLength].lastPt = lastPt;
+  hints[hintsLength].projectingCap = projectingCap;
   ++hintsLength;
 }
 
@@ -186,3 +189,25 @@
   *y = pts[length - 1].y;
   return gTrue;
 }
+
+GBool SplashPath::containsZeroLengthSubpaths() {
+  GBool zeroLength;
+  int i;
+
+  zeroLength = gTrue;  // make gcc happy
+  for (i = 0; i < length; ++i) {
+    if (flags[i] & splashPathFirst) {
+      zeroLength = gTrue;
+    } else {
+      if (pts[i].x != pts[i-1].x || pts[i].y != pts[i-1].y) {
+	zeroLength = gFalse;
+      }
+      if (flags[i] & splashPathLast) {
+	if (zeroLength) {
+	  return gTrue;
+	}
+      }
+    }
+  }
+  return gFalse;
+}

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPath.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -49,6 +49,7 @@
 struct SplashPathHint {
   int ctrl0, ctrl1;
   int firstPt, lastPt;
+  GBool projectingCap;
 };
 
 //------------------------------------------------------------------------
@@ -89,7 +90,10 @@
   // Add a stroke adjustment hint.  The controlling segments are
   // <ctrl0> and <ctrl1> (where segments are identified by their first
   // point), and the points to be adjusted are <firstPt> .. <lastPt>.
-  void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt);
+  // <projectingCap> is true if the points are part of a projecting
+  // line cap.
+  void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt,
+			   GBool projectingCap = gFalse);
 
   // Add (<dx>, <dy>) to every point on this path.
   void offset(SplashCoord dx, SplashCoord dy);
@@ -102,6 +106,10 @@
   // Get the current point.
   GBool getCurPt(SplashCoord *x, SplashCoord *y);
 
+  // Returns true if the path contains one or more zero length
+  // subpaths.
+  GBool containsZeroLengthSubpaths();
+
 private:
 
   SplashPath(SplashPath *path);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPattern.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPattern.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashPattern.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "SplashMath.h"
 #include "SplashScreen.h"
 #include "SplashPattern.h"

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,6 +18,7 @@
 #include <algorithm>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashMath.h"
 #include "SplashScreen.h"
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashScreen.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -21,6 +21,8 @@
 // SplashScreen
 //------------------------------------------------------------------------
 
+typedef Guchar *SplashScreenCursor;
+
 class SplashScreen {
 public:
 
@@ -39,6 +41,20 @@
     return value < mat[(yy << log2Size) + xx] ? 0 : 1;
   }
 
+  // To do a series of tests with the same y value, call
+  // getTestCursor(y), and then call testWithCursor(cursor, x, value)
+  // for each x.
+  SplashScreenCursor getTestCursor(int y) {
+    int yy;
+    yy = y & sizeM1;
+    return &mat[yy << log2Size];
+  }
+
+  int testWithCursor(SplashScreenCursor cursor, int x, Guchar value) {
+    int xx = x & sizeM1;
+    return value >= cursor[xx];
+  }
+
   // Returns true if value is above the white threshold or below the
   // black threshold, i.e., if the corresponding halftone will be
   // solid white or black.

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashPattern.h"
 #include "SplashScreen.h"
 #include "SplashClip.h"
@@ -55,7 +56,7 @@
   lineDash = NULL;
   lineDashLength = 0;
   lineDashPhase = 0;
-  strokeAdjust = gFalse;
+  strokeAdjust = splashStrokeAdjustOff;
   clip = new SplashClip(0, 0, width, height);
   clipIsShared = gFalse;
   softMask = NULL;
@@ -67,12 +68,15 @@
     rgbTransferG[i] = (Guchar)i;
     rgbTransferB[i] = (Guchar)i;
     grayTransfer[i] = (Guchar)i;
+#if SPLASH_CMYK
     cmykTransferC[i] = (Guchar)i;
     cmykTransferM[i] = (Guchar)i;
     cmykTransferY[i] = (Guchar)i;
     cmykTransferK[i] = (Guchar)i;
+#endif
   }
   overprintMask = 0xffffffff;
+  enablePathSimplification = gFalse;
   next = NULL;
 }
 
@@ -99,7 +103,7 @@
   lineDash = NULL;
   lineDashLength = 0;
   lineDashPhase = 0;
-  strokeAdjust = gFalse;
+  strokeAdjust = splashStrokeAdjustOff;
   clip = new SplashClip(0, 0, width, height);
   clipIsShared = gFalse;
   softMask = NULL;
@@ -111,12 +115,15 @@
     rgbTransferG[i] = (Guchar)i;
     rgbTransferB[i] = (Guchar)i;
     grayTransfer[i] = (Guchar)i;
+#if SPLASH_CMYK
     cmykTransferC[i] = (Guchar)i;
     cmykTransferM[i] = (Guchar)i;
     cmykTransferY[i] = (Guchar)i;
     cmykTransferK[i] = (Guchar)i;
+#endif
   }
   overprintMask = 0xffffffff;
+  enablePathSimplification = gFalse;
   next = NULL;
 }
 
@@ -153,11 +160,14 @@
   memcpy(rgbTransferG, state->rgbTransferG, 256);
   memcpy(rgbTransferB, state->rgbTransferB, 256);
   memcpy(grayTransfer, state->grayTransfer, 256);
+#if SPLASH_CMYK
   memcpy(cmykTransferC, state->cmykTransferC, 256);
   memcpy(cmykTransferM, state->cmykTransferM, 256);
   memcpy(cmykTransferY, state->cmykTransferY, 256);
   memcpy(cmykTransferK, state->cmykTransferK, 256);
+#endif
   overprintMask = state->overprintMask;
+  enablePathSimplification = state->enablePathSimplification;
   next = NULL;
 }
 
@@ -202,6 +212,32 @@
   lineDashPhase = lineDashPhaseA;
 }
 
+GBool SplashState::lineDashContainsZeroLengthDashes() {
+  int i;
+
+  if (lineDashLength == 0) {
+    return gFalse;
+  }
+
+  // if the line dash array has an odd number of elements, we need to
+  // check all of the elements; if the length is even, we only need to
+  // check even-number elements
+  if (lineDashLength & 1) {
+    for (i = 0; i < lineDashLength; ++i) {
+      if (lineDash[i] == 0) {
+	return gTrue;
+      }
+    }
+  } else {
+    for (i = 0; i < lineDashLength; i += 2) {
+      if (lineDash[i] == 0) {
+	return gTrue;
+      }
+    }
+  }
+  return gFalse;
+}
+
 void SplashState::clipResetToRect(SplashCoord x0, SplashCoord y0,
 				  SplashCoord x1, SplashCoord y1) {
   if (clipIsShared) {
@@ -225,7 +261,8 @@
     clip = clip->copy();
     clipIsShared = gFalse;
   }
-  return clip->clipToPath(path, matrix, flatness, eo);
+  return clip->clipToPath(path, matrix, flatness, eo,
+			  enablePathSimplification, strokeAdjust);
 }
 
 void SplashState::setSoftMask(SplashBitmap *softMaskA) {
@@ -238,12 +275,15 @@
 
 void SplashState::setTransfer(Guchar *red, Guchar *green, Guchar *blue,
 			      Guchar *gray) {
+#if SPLASH_CMYK
   int i;
+#endif
 
   memcpy(rgbTransferR, red, 256);
   memcpy(rgbTransferG, green, 256);
   memcpy(rgbTransferB, blue, 256);
   memcpy(grayTransfer, gray, 256);
+#if SPLASH_CMYK
   for (i = 0; i < 256; ++i) {
     cmykTransferC[i] = 255 - rgbTransferR[255 - i];
     cmykTransferM[i] = 255 - rgbTransferG[255 - i];
@@ -250,4 +290,5 @@
     cmykTransferY[i] = 255 - rgbTransferB[255 - i];
     cmykTransferK[i] = 255 - grayTransfer[255 - i];
   }
+#endif
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashState.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -70,6 +70,10 @@
   void setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
 		   SplashCoord lineDashPhaseA);
 
+  // Returns true if the current line dash pattern contains one or
+  // more zero-length "on" sections (dashes).
+  GBool lineDashContainsZeroLengthDashes();
+
   void clipResetToRect(SplashCoord x0, SplashCoord y0,
 		       SplashCoord x1, SplashCoord y1);
   SplashError clipToRect(SplashCoord x0, SplashCoord y0,
@@ -101,7 +105,7 @@
   SplashCoord *lineDash;
   int lineDashLength;
   SplashCoord lineDashPhase;
-  GBool strokeAdjust;
+  SplashStrokeAdjustMode strokeAdjust;
   SplashClip *clip;
   GBool clipIsShared;
   SplashBitmap *softMask;
@@ -112,11 +116,14 @@
          rgbTransferG[256],
          rgbTransferB[256];
   Guchar grayTransfer[256];
+#if SPLASH_CMYK
   Guchar cmykTransferC[256],
          cmykTransferM[256],
          cmykTransferY[256],
          cmykTransferK[256];
+#endif
   Guint overprintMask;
+  GBool enablePathSimplification;
 
   SplashState *next;		// used by Splash class
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashTypes.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashTypes.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashTypes.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -107,6 +107,16 @@
 				SplashColorPtr blend, SplashColorMode cm);
 
 //------------------------------------------------------------------------
+// stroke adjustment mode
+//------------------------------------------------------------------------
+
+enum SplashStrokeAdjustMode {
+  splashStrokeAdjustOff,
+  splashStrokeAdjustNormal,
+  splashStrokeAdjustCAD
+};
+
+//------------------------------------------------------------------------
 // screen parameters
 //------------------------------------------------------------------------
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,6 +18,7 @@
 #include <algorithm>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "SplashMath.h"
 #include "SplashPath.h"
 #include "SplashXPath.h"
@@ -24,6 +25,11 @@
 
 //------------------------------------------------------------------------
 
+#define minCosSquaredJoinAngle 0.75
+#define maxPointToLineDistanceSquared 0.04
+
+//------------------------------------------------------------------------
+
 struct SplashXPathPoint {
   SplashCoord x, y;
 };
@@ -54,29 +60,58 @@
 // SplashXPath
 //------------------------------------------------------------------------
 
+// SplashXPath segment coords are clipped to +/-maxCoord to avoid
+// problems.  The xMin/yMin/xMax/yMax fields are 32-bit integers, so
+// coords need to be < 2^31 / aa{Horiz,Vert}.
+#define maxCoord 100000000.0
+
+void SplashXPath::clampCoords(SplashCoord *x, SplashCoord *y) {
+#if !USE_FIXEDPOINT
+  if (*x > maxCoord) {
+    *x = maxCoord;
+  } else if (*x < -maxCoord) {
+    *x = -maxCoord;
+  }
+  if (*y > maxCoord) {
+    *y = maxCoord;
+  } else if (*y < -maxCoord) {
+    *y = -maxCoord;
+  }
+#endif
+}
+
 SplashXPath::SplashXPath(SplashPath *path, SplashCoord *matrix,
-			 SplashCoord flatness, GBool closeSubpaths) {
+			 SplashCoord flatness, GBool closeSubpaths,
+			 GBool simplify,
+			 SplashStrokeAdjustMode strokeAdjMode) {
   SplashXPathPoint *pts;
-  SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xsp, ysp;
-  SplashCoord xMinFP, xMaxFP, yMinFP, yMaxFP;
-  int curSubpath, i;
+  SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xsp, ysp, t;
+  int curSubpath, firstSegInSubpath, i;
+  GBool adjusted;
 
-  // transform the points
+  //--- transform the points
   pts = (SplashXPathPoint *)gmallocn(path->length, sizeof(SplashXPathPoint));
   for (i = 0; i < path->length; ++i) {
     transform(matrix, path->pts[i].x, path->pts[i].y, &pts[i].x, &pts[i].y);
+    clampCoords(&pts[i].x, &pts[i].y);
   }
 
-  // do stroke adjustment
+  //--- do stroke adjustment
   if (path->hints) {
-    strokeAdjust(pts, path->hints, path->hintsLength);
+    adjusted = strokeAdjust(pts, path->hints, path->hintsLength,
+			    strokeAdjMode);
+  } else {
+    adjusted = gFalse;
   }
 
+  //--- construct the segments
+
   segs = NULL;
   length = size = 0;
 
   x0 = y0 = xsp = ysp = 0; // make gcc happy
   curSubpath = 0;
+  firstSegInSubpath = 0;
   i = 0;
   while (i < path->length) {
 
@@ -123,12 +158,17 @@
 	++i;
       }
 
-      // close a subpath
-      if (closeSubpaths &&
-	  (path->flags[i-1] & splashPathLast) &&
-	  (pts[i-1].x != pts[curSubpath].x ||
-	   pts[i-1].y != pts[curSubpath].y)) {
-	addSegment(x0, y0, xsp, ysp);
+      // end a subpath
+      if (path->flags[i-1] & splashPathLast) {
+	if (closeSubpaths &&
+	    (pts[i-1].x != pts[curSubpath].x ||
+	     pts[i-1].y != pts[curSubpath].y)) {
+	  addSegment(x0, y0, xsp, ysp);
+	}
+	if (simplify && !adjusted) {
+	  mergeSegments(firstSegInSubpath);
+	}
+	firstSegInSubpath = length;
       }
     }
   }
@@ -135,55 +175,69 @@
 
   gfree(pts);
 
+  finishSegments();
+
+  //--- check for a rectangle
+  isRect = gFalse;
+  rectX0 = rectY0 = rectX1 = rectY1 = 0;
+  if (length == 4) {
 #if HAVE_STD_SORT
-  std::sort(segs, segs + length, SplashXPathSeg::cmpY);
+    std::sort(segs, segs + length, SplashXPathSeg::cmpY);
 #else
-  qsort(segs, length, sizeof(SplashXPathSeg), &SplashXPathSeg::cmpY);
+    qsort(segs, length, sizeof(SplashXPathSeg), &SplashXPathSeg::cmpY);
 #endif
-
-  if (length == 0) {
-    xMin = yMin = xMax = yMax = 0;
-  } else {
-    if (segs[0].x0 < segs[0].x1) {
-      xMinFP = segs[0].x0;
-      xMaxFP = segs[0].x1;
-    } else {
-      xMinFP = segs[0].x1;
-      xMaxFP = segs[0].x0;
+    if (segs[0].y0 == segs[0].y1 &&
+	segs[1].x0 == segs[1].x1 &&
+	segs[2].x0 == segs[2].x1 &&
+	segs[3].y0 == segs[3].y1) {
+      isRect = gTrue;
+      rectX0 = segs[1].x0;
+      rectX1 = segs[2].x0;
+      rectY0 = segs[0].y0;
+      rectY1 = segs[3].y0;
+    } else if (segs[0].x0 == segs[0].x1 &&
+	       segs[1].y0 == segs[1].y1 &&
+	       segs[2].x0 == segs[2].x1 &&
+	       segs[3].y0 == segs[3].y1) {
+      isRect = gTrue;
+      rectX0 = segs[0].x0;
+      rectX1 = segs[2].x0;
+      rectY0 = segs[1].y0;
+      rectY1 = segs[3].y0;
+    } else if (segs[0].x0 == segs[0].x1 &&
+	       segs[1].x0 == segs[1].x1 &&
+	       segs[2].y0 == segs[2].y1 &&
+	       segs[3].y0 == segs[3].y1) {
+      isRect = gTrue;
+      rectX0 = segs[0].x0;
+      rectX1 = segs[1].x0;
+      rectY0 = segs[2].y0;
+      rectY1 = segs[3].y0;
     }
-    yMinFP = segs[0].y0;
-    yMaxFP = segs[0].y1;
-    for (i = 1; i < length; ++i) {
-      if (segs[i].x0 < xMinFP) {
-	xMinFP = segs[i].x0;
-      } else if (segs[i].x0 > xMaxFP) {
-	xMaxFP = segs[i].x0;
+    if (isRect) {
+      if (rectX0 > rectX1) {
+	t = rectX0;  rectX0 = rectX1;  rectX1 = t;
       }
-      if (segs[i].x1 < xMinFP) {
-	xMinFP = segs[i].x1;
-      } else if (segs[i].x1 > xMaxFP) {
-	xMaxFP = segs[i].x1;
+      if (rectY0 > rectY1) {
+	t = rectY0;  rectY0 = rectY1;  rectY1 = t;
       }
-      if (segs[i].y1 > yMaxFP) {
-	yMaxFP = segs[i].y1;
-      }
     }
-    xMin = splashFloor(xMinFP);
-    yMin = splashFloor(yMinFP);
-    xMax = splashFloor(xMaxFP);
-    yMax = splashFloor(yMaxFP);
   }
 }
 
-void SplashXPath::strokeAdjust(SplashXPathPoint *pts,
-			       SplashPathHint *hints, int nHints) {
+GBool SplashXPath::strokeAdjust(SplashXPathPoint *pts,
+				SplashPathHint *hints, int nHints,
+				SplashStrokeAdjustMode strokeAdjMode) {
   SplashXPathAdjust *adjusts, *adjust;
   SplashPathHint *hint;
   SplashCoord x0, y0, x1, y1, x2, y2, x3, y3;
-  SplashCoord adj0, adj1, d;
+  SplashCoord adj0, adj1, w, d;
   int xi0, xi1;
   int i, j;
+  GBool adjusted;
 
+  adjusted = gFalse;
+
   // set up the stroke adjustment hints
   adjusts = (SplashXPathAdjust *)gmallocn(nHints, sizeof(SplashXPathAdjust));
   for (i = 0; i < nHints; ++i) {
@@ -192,14 +246,21 @@
     x1 = pts[hint->ctrl0 + 1].x;    y1 = pts[hint->ctrl0 + 1].y;
     x2 = pts[hint->ctrl1    ].x;    y2 = pts[hint->ctrl1    ].y;
     x3 = pts[hint->ctrl1 + 1].x;    y3 = pts[hint->ctrl1 + 1].y;
+    w = -1;
     if (x0 == x1 && x2 == x3) {
       adjusts[i].vert = gTrue;
       adj0 = x0;
       adj1 = x2;
+      if (hint->projectingCap) {
+	w = splashAbs(y1 - y0);
+      }
     } else if (y0 == y1 && y2 == y3) {
       adjusts[i].vert = gFalse;
       adj0 = y0;
       adj1 = y2;
+      if (hint->projectingCap) {
+	w = splashAbs(x1 - x0);
+      }
     } else {
       goto done;
     }
@@ -220,7 +281,7 @@
     adjusts[i].xmb = (SplashCoord)0.5 * (adj0 + adj1) + d;
     adjusts[i].x1a = adj1 - d;
     adjusts[i].x1b = adj1 + d;
-    splashStrokeAdjust(adj0, adj1, &xi0, &xi1);
+    splashStrokeAdjust(adj0, adj1, &xi0, &xi1, strokeAdjMode, w);
     adjusts[i].x0 = (SplashCoord)xi0;
     // the "minus epsilon" thing here is needed when vector
     // antialiasing is turned off -- otherwise stroke adjusted lines
@@ -255,9 +316,11 @@
       }
     }
   }
+  adjusted = gTrue;
 
  done:
   gfree(adjusts);
+  return adjusted;
 }
 
 SplashXPath::SplashXPath(SplashXPath *xPath) {
@@ -380,38 +443,202 @@
 void SplashXPath::addSegment(SplashCoord x0, SplashCoord y0,
 			     SplashCoord x1, SplashCoord y1) {
   grow(1);
-  if (y0 <= y1) {
-    segs[length].x0 = x0;
-    segs[length].y0 = y0;
-    segs[length].x1 = x1;
-    segs[length].y1 = y1;
-    segs[length].count = 1;
-  } else {
-    segs[length].x0 = x1;
-    segs[length].y0 = y1;
-    segs[length].x1 = x0;
-    segs[length].y1 = y0;
-    segs[length].count = -1;
+  segs[length].x0 = x0;
+  segs[length].y0 = y0;
+  segs[length].x1 = x1;
+  segs[length].y1 = y1;
+  ++length;
+}
+
+// Returns true if the angle between (x0,y0)-(x1,y1) and
+// (x1,y1)-(x2,y2) is close to 180 degrees.
+static GBool joinAngleIsFlat(SplashCoord x0, SplashCoord y0,
+			     SplashCoord x1, SplashCoord y1,
+			     SplashCoord x2, SplashCoord y2) {
+  SplashCoord dx1, dy1, dx2, dy2, d, len1, len2;
+
+  dx1 = x1 - x0;
+  dy1 = y1 - y0;
+  dx2 = x2 - x1;
+  dy2 = y2 - y1;
+  d = dx1 * dx2 + dy1 * dy2;
+  len1 = dx1 * dx1 + dy1 * dy1;
+  len2 = dx2 * dx2 + dy2 * dy2;
+  return d > 0 && d * d > len1 * len2 * minCosSquaredJoinAngle;
+}
+
+// Returns true if (x1,y1) is sufficiently close to the segment
+// (x0,y0)-(x2,y2), looking at the perpendicular point-to-line
+// distance.
+static GBool pointCloseToSegment(SplashCoord x0, SplashCoord y0,
+				 SplashCoord x1, SplashCoord y1,
+				 SplashCoord x2, SplashCoord y2) {
+  SplashCoord t1, t2, dx, dy;
+
+  // compute the perpendicular distance from the point to the segment,
+  // i.e., the projection of (x0,y0)-(x1,y1) onto a unit normal to the
+  // segment (this actually computes the square of the distance)
+  dx = x2 - x0;
+  dy = y2 - y0;
+  t1 = dx*dx + dy*dy;
+  if (t1 < 0.0001) {
+    // degenerate case: (x0,y0) and (x2,y2) are (nearly) identical --
+    // just compute the distance to (x1,y1)
+    dx = x0 - x1;
+    dy = y0 - y1;
+    t2 = dx*dx + dy*dy;
+    return t2 < maxPointToLineDistanceSquared;
   }
+  t2 = x1 * dy - dx * y1 - x0 * y2 + x2 * y0;
+  // actual distance = t2 / sqrt(t1)
+  return t2 * t2 < t1 * maxPointToLineDistanceSquared;
+}
+
+// Attempt to simplify the path by merging sequences of consecutive
+// segments in [first] .. [length]-1.
+void SplashXPath::mergeSegments(int first) {
+  GBool horiz, vert;
+  int in, out, prev, i, j;
+
+  in = out = first;
+  while (in < length) {
+
+    // skip zero-length segments
+    if (segs[in].x0 == segs[in].x1 && segs[in].y0 == segs[in].y1) {
+      ++in;
+      continue;
+    }
+
+    horiz = segs[in].y0 == segs[in].y1;
+    vert = segs[in].x0 == segs[in].x1;
+
+    // check for a sequence of mergeable segments: in .. i
+    prev = in;
+    for (i = in + 1; i < length; ++i) {
+
+      // skip zero-length segments
+      if (segs[i].x0 == segs[i].x1 && segs[i].y0 == segs[i].y1) {
+	continue;
+      }
+
+      // check for a horizontal or vertical segment
+      if ((horiz && segs[in].y0 != segs[in].y1) ||
+	  (vert && segs[in].x0 != segs[in].x1)) {
+	break;
+      }
+
+      // check the angle between segs i-1 and i
+      // (actually, we compare seg i to the previous non-zero-length
+      // segment, which may not be i-1)
+      if (!joinAngleIsFlat(segs[prev].x0, segs[prev].y0,
+			   segs[i].x0, segs[i].y0,
+			   segs[i].x1, segs[i].y1)) {
+	break;
+      }
+
+      // check the distances from the ends of segs in .. i-1 to the
+      // proposed new segment
+      for (j = in; j < i; ++j) {
+	if (!pointCloseToSegment(segs[in].x0, segs[in].y0,
+				 segs[j].x1, segs[j].y1,
+				 segs[i].x1, segs[i].y1)) {
+	  break;
+	}
+      }
+      if (j < i) {
+	break;
+      }
+
+      prev = i;
+    }
+
+    // we can merge segs: in .. i-1
+    // (this may be the single segment: in)
+    segs[out].x0 = segs[in].x0;
+    segs[out].y0 = segs[in].y0;
+    segs[out].x1 = segs[i-1].x1;
+    segs[out].y1 = segs[i-1].y1;
+    in = i;
+    ++out;
+  }
+
+  length = out;
+}
+
+void SplashXPath::finishSegments() {
+  SplashXPathSeg *seg;
+  SplashCoord xMinFP, xMaxFP, yMinFP, yMaxFP, t;
+  int i;
+
+  xMinFP = yMinFP = xMaxFP = yMaxFP = 0;
+
+  for (i = 0; i < length; ++i) {
+    seg = &segs[i];
+
+    //--- compute the slopes
+    if (seg->y0 <= seg->y1) {
+      seg->count = 1;
+    } else {
+      t = seg->x0;  seg->x0 = seg->x1;  seg->x1 = t;
+      t = seg->y0;  seg->y0 = seg->y1;  seg->y1 = t;
+      seg->count = -1;
+    }
 #if USE_FIXEDPOINT
-  if (y0 == y1 || x0 == x1 ||
-      !FixedPoint::divCheck(x1 - x0, y1 - y0, &segs[length].dxdy) ||
-      !FixedPoint::divCheck(y1 - y0, x1 - x0, &segs[length].dydx)) {
-    segs[length].dxdy = 0;
-    segs[length].dydx = 0;
-  }
+    if (seg->y0 == seg->y1 || seg->x0 == seg->x1 ||
+	!FixedPoint::divCheck(seg->x1 - seg->x0, seg->y1 - seg->y0,
+			      &seg->dxdy) ||
+	!FixedPoint::divCheck(seg->y1 - seg->y0, seg->x1 - seg->x0,
+			      &seg->dydx)) {
+      seg->dxdy = 0;
+      seg->dydx = 0;
+    }
 #else
-  if (y0 == y1 || x0 == x1) {
-    segs[length].dxdy = 0;
-    segs[length].dydx = 0;
-  } else {
-    segs[length].dxdy = (x1 - x0) / (y1 - y0);
-    if (segs[length].dxdy == 0) {
-      segs[length].dydx = 0;
+    if (seg->y0 == seg->y1 || seg->x0 == seg->x1) {
+      seg->dxdy = 0;
+      seg->dydx = 0;
     } else {
-      segs[length].dydx = 1 / segs[length].dxdy;
+      seg->dxdy = (seg->x1 - seg->x0) / (seg->y1 - seg->y0);
+      if (seg->dxdy == 0) {
+	seg->dydx = 0;
+      } else {
+	seg->dydx = 1 / seg->dxdy;
+      }
     }
+#endif
+
+    //--- update bbox
+    if (i == 0) {
+      if (seg->x0 <= seg->x1) {
+	xMinFP = seg->x0;
+	xMaxFP = seg->x1;
+      } else {
+	xMinFP = seg->x1;
+	xMaxFP = seg->x0;
+      }
+      yMinFP = seg->y0;
+      yMaxFP = seg->y1;
+    } else {
+      if (seg->x0 < xMinFP) {
+	xMinFP = seg->x0;
+      } else if (seg->x0 > xMaxFP) {
+	xMaxFP = seg->x0;
+      }
+      if (seg->x1 < xMinFP) {
+	xMinFP = seg->x1;
+      } else if (seg->x1 > xMaxFP) {
+	xMaxFP = seg->x1;
+      }
+      if (seg->y0 < yMinFP) {
+	yMinFP = seg->y0;
+      }
+      if (seg->y1 > yMaxFP) {
+	yMaxFP = seg->y1;
+      }
+    }
   }
-#endif
-  ++length;
+
+  xMin = splashFloor(xMinFP);
+  yMin = splashFloor(yMinFP);
+  xMax = splashFloor(xMaxFP);
+  yMax = splashFloor(yMaxFP);
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPath.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -37,36 +37,48 @@
   int count;			// EO/NZWN counter increment
 
   //----- used by SplashXPathScanner
-  SplashCoord xCur0, xCur1;	// current x values
+  int iy;
+  SplashCoord sx0, sx1, mx;
+  SplashXPathSeg *prev, *next;
 
 #if HAVE_STD_SORT
+
+  static bool cmpMX(const SplashXPathSeg &s0,
+		    const SplashXPathSeg &s1) {
+    if (s0.iy != s1.iy) {
+      return s0.iy < s1.iy;
+    }
+    return s0.mx < s1.mx;
+  }
+
   static bool cmpY(const SplashXPathSeg &seg0,
 		   const SplashXPathSeg &seg1) {
     return seg0.y0 < seg1.y0;
   }
+
 #else
-  static int cmpY(const void *seg0, const void *seg1) {
+
+  static int cmpMX(const void *p0, const void *p1) {
+    SplashXPathSeg *s0 = (SplashXPathSeg *)p0;
+    SplashXPathSeg *s1 = (SplashXPathSeg *)p1;
     SplashCoord cmp;
 
-    cmp = ((SplashXPathSeg *)seg0)->y0
-          - ((SplashXPathSeg *)seg1)->y0;
-    return (cmp > 0) ? 1 : (cmp < 0) ? -1 : 0;
+    if (s0->iy != s1->iy) {
+      return s0->iy - s1->iy;
+    }
+    cmp = s0->mx - s1->mx;
+    return (cmp < 0) ? -1 : (cmp > 0) ? 1 : 0;
   }
-#endif
 
-  static int cmpX(SplashXPathSeg *seg0, SplashXPathSeg *seg1) {
+  static int cmpY(const void *seg0, const void *seg1) {
     SplashCoord cmp;
 
-    if ((cmp = seg0->xCur0 - seg1->xCur0) == 0) {
-      cmp = seg0->dxdy - seg1->dxdy;
-    }
+    cmp = ((SplashXPathSeg *)seg0)->y0
+          - ((SplashXPathSeg *)seg1)->y0;
     return (cmp > 0) ? 1 : (cmp < 0) ? -1 : 0;
   }
 
-  static int cmpXi(const void *p0, const void *p1) {
-    return cmpX(*(SplashXPathSeg **)p0, *(SplashXPathSeg **)p1);
-  }
-
+#endif
 };
 
 //------------------------------------------------------------------------
@@ -81,7 +93,8 @@
   // space, via <matrix>.  If <closeSubpaths> is true, closes all open
   // subpaths.
   SplashXPath(SplashPath *path, SplashCoord *matrix,
-	      SplashCoord flatness, GBool closeSubpaths);
+	      SplashCoord flatness, GBool closeSubpaths,
+	      GBool simplify, SplashStrokeAdjustMode strokeAdjMode);
 
   // Copy an expanded path.
   SplashXPath *copy() { return new SplashXPath(this); }
@@ -95,11 +108,13 @@
 
 private:
 
+  static void clampCoords(SplashCoord *x, SplashCoord *y);
   SplashXPath(SplashXPath *xPath);
   void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi,
 		 SplashCoord *xo, SplashCoord *yo);
-  void strokeAdjust(SplashXPathPoint *pts,
-		    SplashPathHint *hints, int nHints);
+  GBool strokeAdjust(SplashXPathPoint *pts,
+		     SplashPathHint *hints, int nHints,
+		     SplashStrokeAdjustMode strokeAdjMode);
   void grow(int nSegs);
   void addCurve(SplashCoord x0, SplashCoord y0,
 		SplashCoord x1, SplashCoord y1,
@@ -107,8 +122,10 @@
 		SplashCoord x3, SplashCoord y3,
 		SplashCoord flatness,
 		GBool first, GBool last, GBool end0, GBool end1);
+  void mergeSegments(int first);
   void addSegment(SplashCoord x0, SplashCoord y0,
 		  SplashCoord x1, SplashCoord y1);
+  void finishSegments();
 
   SplashXPathSeg *segs;
   int length, size;		// length and size of segs array
@@ -115,6 +132,9 @@
   int xMin, xMax;
   int yMin, yMax;
 
+  GBool isRect;
+  SplashCoord rectX0, rectY0, rectX1, rectY1;
+
   friend class SplashXPathScanner;
   friend class SplashClip;
   friend class Splash;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,6 +18,7 @@
 #include <algorithm>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "GList.h"
 #include "SplashMath.h"
 #include "SplashXPath.h"
@@ -25,543 +26,595 @@
 
 //------------------------------------------------------------------------
 
-#define minVertStep 0.05
+#if ANTIALIAS_256
 
+#define aaVert  15
+#define aaHoriz 17
+
+#else
+
+#define aaVert  4
+#define aaHoriz 4
+
+static Guchar map16to255[17] = {
+  0,
+  16,
+  32,
+  48,
+  64,
+  80,
+  96,
+  112,
+  128,
+  143,
+  159,
+  175,
+  191,
+  207,
+  223,
+  239,
+  255
+};
+
+#endif
+
 //------------------------------------------------------------------------
 
-SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, GBool eoA,
+SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, GBool eo,
 				       int yMinA, int yMaxA) {
   xPath = xPathA;
-  eo = eoA;
+  eoMask = eo ? 1 : 0xffffffff;
   yMin = yMinA;
   yMax = yMaxA;
+  if (xPath->isRect) {
+    rectX0I = splashFloor(xPath->rectX0);
+    rectY0I = splashFloor(xPath->rectY0);
+    rectX1I = splashFloor(xPath->rectX1);
+    rectY1I = splashFloor(xPath->rectY1);
+  }
 
-  activeSegs = new GList();
-  nextSeg = 0;
-  yNext = xPath->yMin;
+  pre = &preSeg;
+  post = &postSeg;
+  pre->mx = xPath->xMin - 1;
+  post->mx = xPath->xMax + 1;
+
+  resetDone = gFalse;
+  resetAA = gFalse;
 }
 
 SplashXPathScanner::~SplashXPathScanner() {
-  delete activeSegs;
 }
 
-void SplashXPathScanner::getSpan(Guchar *line, int y, int x0, int x1) {
-  SplashXPathSeg *seg, *seg0;
-  SplashCoord y0, y1, y1p;
-  GBool intersect, last;
-  int eoMask, state0, state1, count, i;
+void SplashXPathScanner::insertSegmentBefore(SplashXPathSeg *s,
+					     SplashXPathSeg *sNext) {
+  SplashXPathSeg *sPrev;
 
-  //--- clear the scan line buffer
-  memset(line + x0, 0, x1 - x0 + 1);
+  sPrev = sNext->prev;
+  sPrev->next = s;
+  s->prev = sPrev;
+  s->next = sNext;
+  sNext->prev = s;
+}
 
-  //--- reset the path
-  if (yNext != y) {
-    delete activeSegs;
-    activeSegs = new GList();
-    nextSeg = 0;
-    while (nextSeg < xPath->length) {
-      seg = &xPath->segs[nextSeg];
-      if (seg->y0 >= y) {
-	break;
+void SplashXPathScanner::removeSegment(SplashXPathSeg *s) {
+  SplashXPathSeg *sPrev, *sNext;
+
+  sPrev = s->prev;
+  sNext = s->next;
+  sPrev->next = sNext;
+  sNext->prev = sPrev;
+  s->prev = s->next = NULL;
+}
+
+void SplashXPathScanner::moveSegmentAfter(SplashXPathSeg *s,
+					  SplashXPathSeg *sPrev) {
+  SplashXPathSeg *sNext;
+
+  s->prev->next = s->next;
+  s->next->prev = s->prev;
+
+  sNext = sPrev->next;
+  sPrev->next = s;
+  s->prev = sPrev;
+  s->next = sNext;
+  sNext->prev = s;
+}
+
+void SplashXPathScanner::reset(GBool aa, GBool aaChanged) {
+  SplashXPathSeg *seg;
+  SplashCoord y;
+  int i;
+
+  //--- initialize segment parameters
+  for (i = 0; i < xPath->length; ++i) {
+    seg = &xPath->segs[i];
+    if (aa) {
+      if (aaChanged) {
+	seg->iy = splashFloor(seg->y0 * aaVert);
       }
-      if (seg->y0 != seg->y1 && seg->y1 > y) {
-	if (seg->y0 == y) {
-	  seg->xCur0 = seg->x0;
-	} else {
-	  seg->xCur0 = seg->x0 + ((SplashCoord)y - seg->y0) * seg->dxdy;
-	}
-	activeSegs->append(seg);
+      y = (SplashCoord)(seg->iy + 1) / (SplashCoord)aaVert;
+    } else {
+      if (aaChanged) {
+	seg->iy = splashFloor(seg->y0);
       }
-      ++nextSeg;
+      y = (SplashCoord)(seg->iy + 1);
     }
-    activeSegs->sort(&SplashXPathSeg::cmpXi);
+    seg->sx0 = seg->x0;
+    if (seg->y1 <= y) {
+      seg->sx1 = seg->x1;
+    } else {
+      seg->sx1 = seg->x0 + (y - seg->y0) * seg->dxdy;
+    }
+    seg->mx = (seg->sx0 <= seg->sx1) ? seg->sx0 : seg->sx1;
+    seg->prev = seg->next = NULL;
   }
 
-  //--- process the scan line
-  y0 = y;
-  while (y0 < y + 1) {
+  //--- sort the inactive segments by iy, mx
+  if (aaChanged) {
+#if HAVE_STD_SORT
+    std::sort(xPath->segs, xPath->segs + xPath->length, &SplashXPathSeg::cmpMX);
+#else
+    qsort(xPath->segs, xPath->length, sizeof(SplashXPathSeg),
+	  &SplashXPathSeg::cmpMX);
+#endif
+  }
 
-    //--- delete finished segs
-    i = 0;
-    while (i < activeSegs->getLength()) {
-      seg = (SplashXPathSeg *)activeSegs->get(i);
-      if (seg->y1 <= y0) {
-	activeSegs->del(i);
-      } else {
-	++i;
-      }
-    }
+  //--- initialize the active list
+  pre->prev = NULL;
+  pre->next = post;
+  post->prev = pre;
+  post->next = NULL;
 
-    //--- check for bottom of path
-    if (!activeSegs->getLength() && nextSeg >= xPath->length) {
-      break;
+  //--- initialize the scan state
+  nextSeg = 0;
+  if (xPath->length) {
+    yBottomI = xPath->segs[0].iy;
+    if (aa) {
+      yBottomI -= yBottomI % aaVert;
     }
+  } else {
+    yBottomI = 0;
+  }
+  yTopI = yBottomI - 1;
+  if (aa) {
+    yTop = (SplashCoord)yTopI / (SplashCoord)aaVert;
+    yBottom = (SplashCoord)yBottomI / (SplashCoord)aaVert;
+  } else {
+    yTop = (SplashCoord)yTopI;
+    yBottom = (SplashCoord)yBottomI;
+  }
 
-    //--- sort activeSegs
-    sortActiveSegs();
+  resetDone = gTrue;
+  resetAA = aa;
+}
 
-    //--- add waiting segs
-    while (nextSeg < xPath->length) {
-      seg = &xPath->segs[nextSeg];
-      if (seg->y0 > y0) {
-	break;
+void SplashXPathScanner::skip(int newYBottomI, GBool aa) {
+  SplashXPathSeg *s0, *s1,*s2;
+  int iy;
+
+  yTopI = newYBottomI - 1;
+  yBottomI = newYBottomI;
+  if (aa) {
+    yTop = (SplashCoord)yTopI / (SplashCoord)aaVert;
+    yBottom = (SplashCoord)yBottomI / (SplashCoord)aaVert;
+  } else {
+    yTop = (SplashCoord)yTopI;
+    yBottom = (SplashCoord)yBottomI;
+  }
+
+  //--- remove finished segments; update sx0, sx1, mx for active segments
+  s0 = pre->next;
+  while (s0 != post) {
+    s1 = s0->next;
+
+    // check for a finished segment
+    if (s0->y1 < yTop) {
+      removeSegment(s0);
+
+    // compute sx0, sx1, mx
+    } else {
+      if (s0->y0 >= yTop) {
+	s0->sx0 = s0->x0;
+      } else {
+	s0->sx0 = s0->x0 + (yTop - s0->y0) * s0->dxdy;
       }
-      if (seg->y0 != seg->y1) {
-	seg->xCur0 = seg->x0;
-	insertActiveSeg(seg);
+      if (s0->y1 <= yBottom) {
+	s0->sx1 = s0->x1;
+      } else {
+	s0->sx1 = s0->x0 + (yBottom - s0->y0) * s0->dxdy;
       }
-      ++nextSeg;
+      s0->mx = (s0->sx0 <= s0->sx1) ? s0->sx0 : s0->sx1;
     }
 
-    //--- get the next "interesting" y value
-    y1 = y + 1;
-    if (nextSeg < xPath->length && xPath->segs[nextSeg].y0 < y1) {
-      y1 = xPath->segs[nextSeg].y0;
-    }
-    for (i = 0; i < activeSegs->getLength(); ++i) {
-      seg = (SplashXPathSeg *)activeSegs->get(i);
-      if (seg->y1 < y1) {
-	y1 = seg->y1;
-      }
-    }
+    s0 = s1;
+  }
 
-    //--- compute xCur1 values, check for intersections
-    seg0 = NULL;
-    intersect = gFalse;
-    for (i = 0; i < activeSegs->getLength(); ++i) {
-      seg = (SplashXPathSeg *)activeSegs->get(i);
-      if (seg->y1 == y1) {
-	seg->xCur1 = seg->x1;
+  //--- check for intersections
+  s0 = pre->next;
+  if (s0 != post) {
+    s1 = s0->next;
+    while (s1 != post) {
+      if (s1->mx < s0->mx) {
+	for (s2 = s0->prev; s1->mx < s2->mx; s2 = s2->prev) ;
+	moveSegmentAfter(s1, s2);
       } else {
-	seg->xCur1 = seg->x0 + (y1 - seg->y0) * seg->dxdy;
+	s0 = s1;
       }
-      if (seg0 && seg0->xCur1 > seg->xCur1) {
-	intersect = gTrue;
-      }
-      seg0 = seg;
+      s1 = s0->next;
     }
+  }
 
-    //--- draw rectangles
-    if (intersect) {
-      for (; y0 < y1; y0 += minVertStep) {
-	if ((y1p = y0 + minVertStep) >= y1) {
-	  y1p = y1;
-	  last = gTrue;
-	} else {
-	  last = gFalse;
-	}
-	state0 = state1 = count = 0;
-	seg0 = NULL;
-	eoMask = eo ? 1 : 0xffffffff;
-	for (i = 0; i < activeSegs->getLength(); ++i) {
-	  seg = (SplashXPathSeg *)activeSegs->get(i);
-	  if (last && seg->y1 == y1) {
-	    seg->xCur1 = seg->x1;
-	  } else {
-	    seg->xCur1 = seg->x0 + (y1p - seg->y0) * seg->dxdy;
-	  }
-	  count += seg->count;
-	  state1 = count & eoMask;
-	  if (!state0 && state1) {
-	    seg0 = seg;
-	  } else if (state0 && !state1) {
-	    drawRectangle(line, x0, x1, y0, y1p, seg0->xCur0, seg->xCur0);
-	  }
-	  state0 = state1;
-	}
-	for (i = 0; i < activeSegs->getLength(); ++i) {
-	  seg = (SplashXPathSeg *)activeSegs->get(i);
-	  seg->xCur0 = seg->xCur1;
-	}
-	sortActiveSegs();
+  //--- insert new segments with a merge sort
+  // - this has to be done one (sub)scanline at a time, because the
+  //   inactive list is bin-sorted by (sub)scanline
+  while (nextSeg < xPath->length && xPath->segs[nextSeg].iy <= yTopI) {
+    // the first inactive segment determines the next scanline to process
+    iy = xPath->segs[nextSeg].iy;
+    s0 = pre->next;
+    do {
+      s1 = &xPath->segs[nextSeg];
+      ++nextSeg;
+      if (s1->y1 < yTop) {
+	continue;
       }
-
-    //--- draw trapezoids
-    } else {
-      state0 = state1 = count = 0;
-      seg0 = NULL;
-      eoMask = eo ? 1 : 0xffffffff;
-      for (i = 0; i < activeSegs->getLength(); ++i) {
-	seg = (SplashXPathSeg *)activeSegs->get(i);
-	count += seg->count;
-	state1 = count & eoMask;
-	if (!state0 && state1) {
-	  seg0 = seg;
-	} else if (state0 && !state1) {
-	  drawTrapezoid(line, x0, x1, y0, y1,
-			seg0->xCur0, seg0->xCur1, seg0->dydx,
-			seg->xCur0, seg->xCur1, seg->dydx);
-	}
-	state0 = state1;
+      if (s1->y0 >= yTop) {
+	s1->sx0 = s1->x0;
+      } else {
+	s1->sx0 = s1->x0 + (yTop - s1->y0) * s1->dxdy;
       }
-      for (i = 0; i < activeSegs->getLength(); ++i) {
-	seg = (SplashXPathSeg *)activeSegs->get(i);
-	seg->xCur0 = seg->xCur1;
+      if (s1->y1 <= yBottom) {
+	s1->sx1 = s1->x1;
+      } else {
+	s1->sx1 = s1->x0 + (yBottom - s1->y0) * s1->dxdy;
       }
-    }
+      s1->mx = (s1->sx0 <= s1->sx1) ? s1->sx0 : s1->sx1;
+      insertSegmentBefore(s1, s0);
+    } while (nextSeg < xPath->length && xPath->segs[nextSeg].iy <= iy);
+  }
+}
 
-    //--- next slice
-    y0 = y1;
+void SplashXPathScanner::advance(GBool aa) {
+  SplashXPathSeg *s, *sNext, *s1;
+
+  yTopI = yBottomI;
+  yTop = yBottom;
+  yBottomI = yTopI + 1;
+  if (aa) {
+    yBottom = (SplashCoord)yBottomI / (SplashCoord)aaVert;
+  } else {
+    yBottom = (SplashCoord)yBottomI;
   }
 
-  yNext = y + 1;
-}
+  s = pre->next;
+  while (s != post) {
+    sNext = s->next;
 
-void SplashXPathScanner::getSpanBinary(Guchar *line, int y, int x0, int x1) {
-  SplashXPathSeg *seg;
-  int xx0, xx1, xx;
-  int eoMask, state0, state1, count, i;
+    // check for a finished segment
+    if (s->y1 < yTop) {
+      removeSegment(s);
 
-  //--- clear the scan line buffer
-  memset(line + x0, 0, x1 - x0 + 1);
+    } else {
 
-  //--- reset the path
-  if (yNext != y) {
-    delete activeSegs;
-    activeSegs = new GList();
-    nextSeg = 0;
-    while (nextSeg < xPath->length) {
-      seg = &xPath->segs[nextSeg];
-      if (seg->y0 >= y) {
-	break;
+      // compute sx0, sx1, mx
+      s->sx0 = s->sx1;
+      if (s->y1 <= yBottom) {
+	s->sx1 = s->x1;
+      } else {
+	s->sx1 = s->x0 + (yBottom - s->y0) * s->dxdy;
       }
-      if (seg->y1 > y) {
-	if (seg->y0 == y) {
-	  seg->xCur0 = seg->x0;
-	} else {
-	  seg->xCur0 = seg->x0 + ((SplashCoord)y - seg->y0) * seg->dxdy;
-	}
-	activeSegs->append(seg);
+      s->mx = (s->sx0 <= s->sx1) ? s->sx0 : s->sx1;
+
+      // check for intersection
+      if (s->mx < s->prev->mx) {
+	for (s1 = s->prev->prev; s->mx < s1->mx; s1 = s1->prev) ;
+	moveSegmentAfter(s, s1);
       }
-      ++nextSeg;
     }
-    activeSegs->sort(&SplashXPathSeg::cmpXi);
+
+    s = sNext;
   }
 
-  //--- delete finished segs
-  i = 0;
-  while (i < activeSegs->getLength()) {
-    seg = (SplashXPathSeg *)activeSegs->get(i);
-    if (seg->y1 <= y) {
-      activeSegs->del(i);
-    } else {
-      ++i;
+  // insert new segments
+  s = pre->next;
+  while (nextSeg < xPath->length && xPath->segs[nextSeg].iy <= yTopI) {
+    s1 = &xPath->segs[nextSeg];
+    ++nextSeg;
+    while (s1->mx > s->mx) {
+      s = s->next;
     }
+    insertSegmentBefore(s1, s);
   }
+}
 
-  //--- sort activeSegs
-  sortActiveSegs();
+void SplashXPathScanner::generatePixels(int x0, int x1, Guchar *line,
+					int *xMin, int *xMax) {
+  SplashXPathSeg *s;
+  int fillCount, x, xEnd, ix0, ix1, t;
 
-  //--- add waiting segs
-  while (nextSeg < xPath->length) {
-    seg = &xPath->segs[nextSeg];
-    if (seg->y0 >= y + 1) {
-      break;
+  fillCount = 0;
+  x = x0 * aaHoriz;
+  xEnd = (x1 + 1) * aaHoriz;
+  for (s = pre->next; s != post && x < xEnd; s = s->next) {
+    ix0 = splashFloor(s->sx0 * aaHoriz);
+    ix1 = splashFloor(s->sx1 * aaHoriz);
+    if (ix0 > ix1) {
+      t = ix0;  ix0 = ix1;  ix1 = t;
     }
-    seg->xCur0 = seg->x0;
-    insertActiveSeg(seg);
-    ++nextSeg;
-  }
-
-  //--- compute xCur1 values
-  for (i = 0; i < activeSegs->getLength(); ++i) {
-    seg = (SplashXPathSeg *)activeSegs->get(i);
-    if (seg->y1 <= y + 1) {
-      seg->xCur1 = seg->x1;
-    } else {
-      seg->xCur1 = seg->x0 + ((SplashCoord)(y + 1) - seg->y0) * seg->dxdy;
+    if (!(fillCount & eoMask)) {
+      if (ix0 > x) {
+	x = ix0;
+      }
     }
+    if (ix1 >= xEnd) {
+      ix1 = xEnd - 1;
+    }
+    if (x / aaHoriz < *xMin) {
+      *xMin = x / aaHoriz;
+    }
+    if (ix1 / aaHoriz > *xMax) {
+      *xMax = ix1 / aaHoriz;
+    }
+    for (; x <= ix1; ++x) {
+      ++line[x / aaHoriz];
+    }
+    if (s->y0 <= yTop && s->y1 > yTop) {
+      fillCount += s->count;
+    }
   }
+}
 
-  //--- draw spans
-  state0 = state1 = count = 0;
-  eoMask = eo ? 1 : 0xffffffff;
-  xx0 = xx1 = 0; // make gcc happy
-  for (i = 0; i < activeSegs->getLength(); ++i) {
-    seg = (SplashXPathSeg *)activeSegs->get(i);
-    if (seg->y0 <= y && seg->y0 < seg->y1) {
-      count += seg->count;
-      state1 = count & eoMask;
+void SplashXPathScanner::generatePixelsBinary(int x0, int x1, Guchar *line,
+					      int *xMin, int *xMax) {
+  SplashXPathSeg *s;
+  int fillCount, x, xEnd, ix0, ix1, t;
+
+  fillCount = 0;
+  x = x0;
+  xEnd = x1 + 1;
+  for (s = pre->next; s != post && x < xEnd; s = s->next) {
+    ix0 = splashFloor(s->sx0);
+    ix1 = splashFloor(s->sx1);
+    if (ix0 > ix1) {
+      t = ix0;  ix0 = ix1;  ix1 = t;
     }
-    if (state0) {
-      xx = splashCeil(seg->xCur0) - 1;
-      if (xx > xx1) {
-	xx1 = xx;
+    if (!(fillCount & eoMask)) {
+      if (ix0 > x) {
+	x = ix0;
       }
-      xx = splashFloor(seg->xCur1);
-      if (xx < xx0) {
-	xx0 = xx;
-      }
-      xx = splashCeil(seg->xCur1) - 1;
-      if (xx > xx1) {
-	xx1 = xx;
-      }
-    } else {
-      if (seg->xCur0 < seg->xCur1) {
-	xx0 = splashFloor(seg->xCur0);
-	xx1 = splashCeil(seg->xCur1) - 1;
-      } else {
-	xx0 = splashFloor(seg->xCur1);
-	xx1 = splashCeil(seg->xCur0) - 1;
-      }
     }
-    if (!state1) {
-      if (xx0 < x0) {
-	xx0 = x0;
-      }
-      if (xx1 > x1) {
-	xx1 = x1;
-      }
-      for (xx = xx0; xx <= xx1; ++xx) {
-	line[xx] = 0xff;
-      }
+    if (ix1 >= xEnd) {
+      ix1 = xEnd - 1;
     }
-    state0 = state1;
+    if (x < *xMin) {
+      *xMin = x;
+    }
+    if (ix1 > *xMax) {
+      *xMax = ix1;
+    }
+    for (; x <= ix1; ++x) {
+      line[x] = 255;
+    }
+    if (s->y0 <= yTop && s->y1 > yTop) {
+      fillCount += s->count;
+    }
   }
-
-  //--- update xCur0 values
-  for (i = 0; i < activeSegs->getLength(); ++i) {
-    seg = (SplashXPathSeg *)activeSegs->get(i);
-    seg->xCur0 = seg->xCur1;
-  }
-
-  yNext = y + 1;
 }
 
-inline void SplashXPathScanner::addArea(Guchar *line, int x, SplashCoord a) {
-  int a2, t;
+void SplashXPathScanner::drawRectangleSpan(Guchar *line, int y,
+					   int x0, int x1,
+					   int *xMin, int *xMax) {
+  SplashCoord edge;
+  Guchar pix;
+  int xe, x;
 
-  a2 = splashRound(a * 255);
-  if (a2 <= 0) {
+  if (rectX0I > x1 || rectX1I < x0) {
     return;
   }
-  t = line[x] + a2;
-  if (t > 255) {
-    t = 255;
-  }
-  line[x] = t;
-}
 
-// Draw a trapezoid with edges:
-//   top:    (xa0, y0) - (xb0, y0)
-//   left:   (xa0, y0) - (xa1, y1)
-//   right:  (xb0, y0) - (xb1, y1)
-//   bottom: (xa1, y1) - (xb1, y1)
-void SplashXPathScanner::drawTrapezoid(Guchar *line, int xMin, int xMax,
-				       SplashCoord y0, SplashCoord y1,
-				       SplashCoord xa0, SplashCoord xa1,
-				       SplashCoord dydxa,
-				       SplashCoord xb0, SplashCoord xb1,
-				       SplashCoord dydxb) {
-  SplashCoord a, dy;
-  int x0, x1, x2, x3, x;
+  *xMin = x0 <= rectX0I ? rectX0I : x0;
+  *xMax = rectX1I <= x1 ? rectX1I : x1;
 
-  // check for a rectangle
-  if (dydxa == 0 && dydxb == 0 && xa0 >= xMin && xb0 <= xMax) {
-    x0 = splashFloor(xa0);
-    x3 = splashFloor(xb0);
-    dy = y1 - y0;
-    if (x0 == x3) {
-      addArea(line, x0, (xb0 - xa0) * dy);
+  //--- upper edge
+  if (y == rectY0I) {
+
+    // handle a rectangle less than one pixel high
+    if (rectY0I == rectY1I) {
+      edge = xPath->rectY1 - xPath->rectY0;
     } else {
-      addArea(line, x0, ((SplashCoord)1 - (xa0 - x0)) * dy);
-      for (x = x0 + 1; x <= x3 - 1; ++x) {
-	addArea(line, x, y1 - y0);
+      edge = (SplashCoord)1 - (xPath->rectY0 - rectY0I);
+    }
+
+    // upper left corner
+    if (x0 <= rectX0I) {
+      pix = (Guchar)splashCeil(edge
+			       * ((SplashCoord)1 - (xPath->rectX0 - rectX0I))
+			       * 255);
+      if (pix < 16) {
+	pix = 16;
       }
-      addArea(line, x3, (xb0 - x3) * (y1 - y0));
+      line[rectX0I] = pix;
+      x = rectX0I + 1;
+    } else {
+      x = x0;
     }
-    return;
-  }
 
-  if (dydxa > 0) {
-    x0 = splashFloor(xa0);
-    x1 = splashFloor(xa1);
-  } else {
-    x0 = splashFloor(xa1);
-    x1 = splashFloor(xa0);
-  }
-  if (x0 < xMin) {
-    x0 = xMin;
-  }
-  if (dydxb > 0) {
-    x2 = splashFloor(xb0);
-    x3 = splashFloor(xb1);
-  } else {
-    x2 = splashFloor(xb1);
-    x3 = splashFloor(xb0);
-  }
-  if (x3 > xMax) {
-    x3 = xMax;
-  }
-  for (x = x0; x <= x3; ++x) {
-    a = y1 - y0;
-    if (x <= x1) {
-      a -= areaLeft(x, xa0, y0, xa1, y1, dydxa);
+    // upper right corner
+    if (rectX1I <= x1) {
+      pix = (Guchar)splashCeil(edge * (xPath->rectX1 - rectX1I) * 255);
+      if (pix < 16) {
+	pix = 16;
+      }
+      line[rectX1I] = pix;
+      xe = rectX1I - 1;
+    } else {
+      xe = x1;
     }
-    if (x >= x2) {
-      a -= areaRight(x, xb0, y0, xb1, y1, dydxb);
+
+    // upper edge
+    pix = (Guchar)splashCeil(edge * 255);
+    if (pix < 16) {
+      pix = 16;
     }
-    addArea(line, x, a);
-  }
-}
+    for (; x <= xe; ++x) {
+      line[x] = pix;
+    }
 
-// Compute area within a pixel slice ((xp,y0)-(xp+1,y1)) to the left
-// of a trapezoid edge ((x0,y0)-(x1,y1)).
-SplashCoord SplashXPathScanner::areaLeft(int xp,
-					 SplashCoord x0, SplashCoord y0,
-					 SplashCoord x1, SplashCoord y1,
-					 SplashCoord dydx) {
-  SplashCoord a, ya, yb;
+  //--- lower edge
+  } else if (y == rectY1I) {
+    edge = xPath->rectY1 - rectY1I;
 
-  if (dydx >= 0) {
-    if (x0 >= xp) {
-      if (x1 <= xp + 1) {
-	a = ((x0 + x1) * 0.5 - xp) * (y1 - y0);
-      } else {
-	yb = y0 + ((SplashCoord)(xp + 1) - x0) * dydx;
-	a = (y1 - y0) - ((SplashCoord)(xp + 1) - x0) * (yb - y0) * 0.5;
+    // lower left corner
+    if (x0 <= rectX0I) {
+      pix = (Guchar)splashCeil(edge
+			       * ((SplashCoord)1 - (xPath->rectX0 - rectX0I))
+			       * 255);
+      if (pix < 16) {
+	pix = 16;
       }
+      line[rectX0I] = pix;
+      x = rectX0I + 1;
     } else {
-      if (x1 <= xp + 1) {
-	ya = y0 + ((SplashCoord)xp - x0) * dydx;
-	a = (x1 - xp) * (y1 - ya) * 0.5;
-      } else {
-	// ya = y1 - (x1 - xp - 0.5) * dydx;
-	// a = y1 - ya;
-	a = (x1 - xp - 0.5) * dydx;
-      }
+      x = x0;
     }
-  } else {
-    if (x0 <= xp + 1) {
-      if (x1 >= xp) {
-	a = ((x0 + x1) * 0.5 - xp) * (y1 - y0);
-      } else {
-	ya = y0 + ((SplashCoord)xp - x0) * dydx;
-	a = (x0 - xp) * (ya - y0) * 0.5;
+
+    // lower right corner
+    if (rectX1I <= x1) {
+      pix = (Guchar)splashCeil(edge * (xPath->rectX1 - rectX1I) * 255);
+      if (pix < 16) {
+	pix = 16;
       }
+      line[rectX1I] = pix;
+      xe = rectX1I - 1;
     } else {
-      if (x1 >= xp) {
-	yb = y0 + ((SplashCoord)(xp + 1) - x0) * dydx;
-	a = (y1 - y0) - ((SplashCoord)(xp + 1) - x1) * (y1 - yb) * 0.5;
-      } else {
-	// ya = y0 + (xp - x0 + 0.5) * dydx;
-	// a = ya - y0;
-	a = ((SplashCoord)xp - x0 + 0.5) * dydx;
-      }
+      xe = x1;
     }
-  }
-  return a;
-}
 
-// Compute area within a pixel slice ((xp,y0)-(xp+1,y1)) to the left
-// of a trapezoid edge ((x0,y0)-(x1,y1)).
-SplashCoord SplashXPathScanner::areaRight(int xp,
-					  SplashCoord x0, SplashCoord y0,
-					  SplashCoord x1, SplashCoord y1,
-					  SplashCoord dydx) {
-  SplashCoord a, ya, yb;
+    // lower edge
+    pix = (Guchar)splashCeil(edge * 255);
+    if (pix < 16) {
+      pix = 16;
+    }
+    for (; x <= xe; ++x) {
+      line[x] = pix;
+    }
 
-  if (dydx >= 0) {
-    if (x0 >= xp) {
-      if (x1 <= xp + 1) {
-	a = ((SplashCoord)(xp + 1) - (x0 + x1) * 0.5) * (y1 - y0);
-      } else {
-	yb = y0 + ((SplashCoord)(xp + 1) - x0) * dydx;
-	a = ((SplashCoord)(xp + 1) - x0) * (yb - y0) * 0.5;
+  //--- between the upper and lower edges
+  } else if (y > rectY0I && y < rectY1I) {
+
+    // left edge
+    if (x0 <= rectX0I) {
+      pix = (Guchar)splashCeil(((SplashCoord)1 - (xPath->rectX0 - rectX0I))
+			       * 255);
+      if (pix < 16) {
+	pix = 16;
       }
+      line[rectX0I] = pix;
+      x = rectX0I + 1;
     } else {
-      if (x1 <= xp + 1) {
-	ya = y0 + ((SplashCoord)xp - x0) * dydx;
-	a = (y1 - y0) - (x1 - xp) * (y1 - ya) * 0.5;
-      } else {
-	// ya = y0 + (xp - x0 + 0.5) * dydx;
-	// a = ya - y0;
-	a = ((SplashCoord)xp + 0.5 - x0) * dydx;
-      }
+      x = x0;
     }
-  } else {
-    if (x0 <= xp + 1) {
-      if (x1 >= xp) {
-	a = ((SplashCoord)(xp + 1) - (x0 + x1) * 0.5) * (y1 - y0);
-      } else {
-	ya = y0 + ((SplashCoord)xp - x0) * dydx;
-	a = (y1 - y0) - (x0 - xp) * (ya - y0) * 0.5;
+
+    // right edge
+    if (rectX1I <= x1) {
+      pix = (Guchar)splashCeil((xPath->rectX1 - rectX1I) * 255);
+      if (pix < 16) {
+	pix = 16;
       }
+      line[rectX1I] = pix;
+      xe = rectX1I - 1;
     } else {
-      if (x1 >= xp) {
-	yb = y0 + ((SplashCoord)(xp + 1) - x0) * dydx;
-	a = ((SplashCoord)(xp + 1) - x1) * (y1 - yb) * 0.5;
-      } else {
-	// ya = y1 - (x1 - xp - 0.5) * dydx;
-	// a = y1 - ya;
-	a = (x1 - xp - 0.5) * dydx;
-      }
+      xe = x1;
     }
+
+    // middle
+    for (; x <= xe; ++x) {
+      line[x] = 255;
+    }
   }
-  return a;
 }
 
-void SplashXPathScanner::drawRectangle(Guchar *line, int xMin, int xMax,
-				       SplashCoord y0, SplashCoord y1,
-				       SplashCoord x0, SplashCoord x1) {
-  SplashCoord dy, a;
-  int xx0, xx1, x;
+void SplashXPathScanner::drawRectangleSpanBinary(Guchar *line, int y,
+						 int x0, int x1,
+						 int *xMin, int *xMax) {
+  int xe, x;
 
-  xx0 = splashFloor(x0);
-  if (xx0 < xMin) {
-    xx0 = xMin;
-  }
-  xx1 = splashFloor(x1);
-  if (xx1 > xMax) {
-    xx1 = xMax;
-  }
-  dy = y1 - y0;
-  for (x = xx0; x <= xx1; ++x) {
-    a = dy;
-    if ((SplashCoord)x < x0) {
-      a -= (x0 - x) * dy;
+  if (y >= rectY0I && y <= rectY1I) {
+    if (x0 <= rectX0I) {
+      x = rectX0I;
+    } else {
+      x = x0;
     }
-    if ((SplashCoord)(x + 1) > x1) {
-      a -= ((SplashCoord)(x + 1) - x1) * dy;
+    *xMin = x;
+    if (rectX1I <= x1) {
+      xe = rectX1I;
+    } else {
+      xe = x1;
     }
-    addArea(line, x, a);
+    *xMax = xe;
+    for (; x <= xe; ++x) {
+      line[x] = 255;
+    }
   }
 }
 
-void SplashXPathScanner::sortActiveSegs() {
-  SplashXPathSeg *seg0, *seg1;
-  int i, j, k;
+void SplashXPathScanner::getSpan(Guchar *line, int y, int x0, int x1,
+				 int *xMin, int *xMax) {
+  int iy, x, k;
 
-  if (activeSegs->getLength() < 2) {
+  iy = y * aaVert;
+  if (!resetDone || !resetAA) {
+    reset(gTrue, gTrue);
+  } else if (yBottomI > iy) {
+    reset(gTrue, gFalse);
+  }
+  memset(line + x0, 0, x1 - x0 + 1);
+
+  *xMin = x1 + 1;
+  *xMax = x0 - 1;
+
+  if (xPath->isRect) {
+    drawRectangleSpan(line, y, x0, x1, xMin, xMax);
     return;
   }
-  seg0 = (SplashXPathSeg *)activeSegs->get(0);
-  for (i = 1; i < activeSegs->getLength(); ++i) {
-    seg1 = (SplashXPathSeg *)activeSegs->get(i);
-    if (SplashXPathSeg::cmpX(seg0, seg1) > 0) {
-      for (j = i - 1; j > 0; --j) {
-	if (SplashXPathSeg::cmpX((SplashXPathSeg *)activeSegs->get(j - 1),
-				 seg1) <= 0) {
-	  break;
-	}
-      }
-      for (k = i; k > j; --k) {
-	activeSegs->put(k, activeSegs->get(k-1));
-      }
-      activeSegs->put(j, seg1);
-    } else {
-      seg0 = seg1;
-    }
+
+  if (yBottomI < iy) {
+    skip(iy, gTrue);
   }
+  for (k = 0; k < aaVert; ++k, ++iy) {
+    advance(gTrue);
+    generatePixels(x0, x1, line, xMin, xMax);
+  }
+
+#if !ANTIALIAS_256
+  for (x = *xMin; x <= *xMax; ++x) {
+    line[x] = map16to255[line[x]];
+  }
+#endif
 }
 
-void SplashXPathScanner::insertActiveSeg(SplashXPathSeg *seg) {
-  int i;
+void SplashXPathScanner::getSpanBinary(Guchar *line, int y, int x0, int x1,
+				       int *xMin, int *xMax) {
+  int iy;
 
-  for (i = 0; i < activeSegs->getLength(); ++i) {
-    if (SplashXPathSeg::cmpX(seg, (SplashXPathSeg *)activeSegs->get(i)) < 0) {
-      break;
-    }
+  iy = y;
+  if (!resetDone || resetAA) {
+    reset(gFalse, gTrue);
+  } else if (yBottomI > iy) {
+    reset(gFalse, gFalse);
   }
-  activeSegs->insert(i, seg);
+  memset(line + x0, 0, x1 - x0 + 1);
+
+  *xMin = x1 + 1;
+  *xMax = x0 - 1;
+
+  if (xPath->isRect) {
+    drawRectangleSpanBinary(line, y, x0, x1, xMin, xMax);
+    return;
+  }
+
+  if (yBottomI < iy) {
+    skip(iy, gFalse);
+  }
+  advance(gFalse);
+  generatePixelsBinary(x0, x1, line, xMin, xMax);
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/splash/SplashXPathScanner.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,11 +16,17 @@
 #endif
 
 #include "SplashTypes.h"
+#include "SplashXPath.h"
 
 class GList;
-class SplashXPath;
 
 //------------------------------------------------------------------------
+
+// Set this to 0 for antialiasing with 16 levels of gray.
+// Set it to 1 for (much slower) antialiasing with 256 levels of gray.
+#define ANTIALIAS_256 0
+
+//------------------------------------------------------------------------
 // SplashXPathScanner
 //------------------------------------------------------------------------
 
@@ -28,7 +34,7 @@
 public:
 
   // Create a new SplashXPathScanner object.  <xPathA> must be sorted.
-  SplashXPathScanner(SplashXPath *xPathA, GBool eoA,
+  SplashXPathScanner(SplashXPath *xPathA, GBool eo,
 		     int yMinA, int yMaxA);
 
   ~SplashXPathScanner();
@@ -35,41 +41,44 @@
 
   // Compute shape values for a scan line.  Fills in line[] with shape
   // values for one scan line: ([x0, x1], y).  The values are in [0,
-  // 255].
-  void getSpan(Guchar *line, int y, int x0, int x1);
+  // 255].  Also returns the min/max x positions with non-zero shape
+  // values.
+  void getSpan(Guchar *line, int y, int x0, int x1, int *xMin, int *xMax);
 
   // Like getSpan(), but uses the values 0 and 255 only.  Writes 255
   // for all pixels which include non-zero area inside the path.
-  void getSpanBinary(Guchar *line, int y, int x0, int x1);
+  void getSpanBinary(Guchar *line, int y, int x0, int x1,
+		     int *xMin, int *xMax);
 
 private:
 
-  inline void addArea(Guchar *line, int x, SplashCoord a);
-  void drawTrapezoid(Guchar *line, int xMin, int xMax,
-		     SplashCoord y0, SplashCoord y1,
-		     SplashCoord xa0, SplashCoord xa1, SplashCoord dydxa,
-		     SplashCoord xb0, SplashCoord xb1, SplashCoord dydxb);
-  SplashCoord areaLeft(int xp,
-		       SplashCoord x0, SplashCoord y0,
-		       SplashCoord x1, SplashCoord y1,
-		       SplashCoord dydx);
-  SplashCoord areaRight(int xp,
-			SplashCoord x0, SplashCoord y0,
-			SplashCoord x1, SplashCoord y1,
-			SplashCoord dydx);
-  void drawRectangle(Guchar *line, int xMin, int xMax,
-		     SplashCoord y0, SplashCoord y1,
-		     SplashCoord x0, SplashCoord x1);
-  void sortActiveSegs();
-  void insertActiveSeg(SplashXPathSeg *seg);
+  void insertSegmentBefore(SplashXPathSeg *s, SplashXPathSeg *sNext);
+  void removeSegment(SplashXPathSeg *s);
+  void moveSegmentAfter(SplashXPathSeg *s, SplashXPathSeg *sPrev);
+  void reset(GBool aa, GBool aaChanged);
+  void skip(int newYBottomI, GBool aa);
+  void advance(GBool aa);
+  void generatePixels(int x0, int x1, Guchar *line, int *xMin, int *xMax);
+  void generatePixelsBinary(int x0, int x1, Guchar *line,
+			    int *xMin, int *xMax);
+  void drawRectangleSpan(Guchar *line, int y, int x0, int x1,
+			 int *xMin, int *xMax);
+  void drawRectangleSpanBinary(Guchar *line, int y, int x0, int x1,
+			       int *xMin, int *xMax);
 
   SplashXPath *xPath;
-  GBool eo;
+  int eoMask;
   int yMin, yMax;
+  int rectX0I, rectY0I, rectX1I, rectY1I;
 
-  GList *activeSegs;		// [SplashXPathSeg]
+  SplashXPathSeg preSeg, postSeg;
+  SplashXPathSeg *pre, *post;
+
+  GBool resetDone;
+  GBool resetAA;
   int nextSeg;
-  int yNext;
+  int yTopI, yBottomI;
+  SplashCoord yTop, yBottom;
 };
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "Error.h"
@@ -79,33 +80,105 @@
 //------------------------------------------------------------------------
 
 AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) {
+  Object acroFormObj2;
   AcroForm *acroForm;
-  Object fieldsObj, obj1, obj2;
-  int i;
+  AcroFormField *field;
+  Object fieldsObj, annotsObj, annotRef, annotObj, obj1, obj2;
+  int pageNum, i, j;
 
-  acroForm = new AcroForm(docA, acroFormObjA);
+  // this is the normal case: acroFormObj is a dictionary, as expected
+  if (acroFormObjA->isDict()) {
+    acroForm = new AcroForm(docA, acroFormObjA);
 
-  if (acroFormObjA->dictLookup("NeedAppearances", &obj1)->isBool()) {
-    acroForm->needAppearances = obj1.getBool();
-  }
-  obj1.free();
+    if (acroFormObjA->dictLookup("NeedAppearances", &obj1)->isBool()) {
+      acroForm->needAppearances = obj1.getBool();
+    }
+    obj1.free();
 
-  acroForm->buildAnnotPageList(catalog);
+    acroForm->buildAnnotPageList(catalog);
 
-  if (!acroFormObjA->dictLookup("Fields", &obj1)->isArray()) {
-    if (!obj1.isNull()) {
-      error(errSyntaxError, -1, "AcroForm Fields entry is wrong type");
+    if (!acroFormObjA->dictLookup("Fields", &obj1)->isArray()) {
+      if (!obj1.isNull()) {
+	error(errSyntaxError, -1, "AcroForm Fields entry is wrong type");
+      }
+      obj1.free();
+      delete acroForm;
+      return NULL;
     }
+    for (i = 0; i < obj1.arrayGetLength(); ++i) {
+      obj1.arrayGetNF(i, &obj2);
+      acroForm->scanField(&obj2);
+      obj2.free();
+    }
     obj1.free();
-    delete acroForm;
-    return NULL;
+
+    // scan the annotations, looking for Widget-type annots that are
+    // not attached to the AcroForm object
+    for (pageNum = 1; pageNum <= catalog->getNumPages(); ++pageNum) {
+      if (catalog->getPage(pageNum)->getAnnots(&annotsObj)->isArray()) {
+	for (i = 0; i < annotsObj.arrayGetLength(); ++i) {
+	  if (annotsObj.arrayGetNF(i, &annotRef)->isRef()) {
+	    for (j = 0; j < acroForm->fields->getLength(); ++j) {
+	      field = (AcroFormField *)acroForm->fields->get(j);
+	      if (field->fieldRef.isRef()) {
+		if (field->fieldRef.getRefNum() == annotRef.getRefNum() &&
+		    field->fieldRef.getRefGen() == annotRef.getRefGen()) {
+		  break;
+		}
+	      }
+	    }
+	    if (j == acroForm->fields->getLength()) {
+	      annotRef.fetch(acroForm->doc->getXRef(), &annotObj);
+	      if (annotObj.isDict()) {
+		if (annotObj.dictLookup("Subtype", &obj1)->isName("Widget")) {
+		  acroForm->scanField(&annotRef);
+		}
+		obj1.free();
+	      }
+	      annotObj.free();
+	    }
+	  }
+	  annotRef.free();
+	}
+      }
+      annotsObj.free();
+    }
+
+  // if acroFormObjA is a null object, but there are Widget-type
+  // annots, we still create an AcroForm
+  } else {
+    // create an empty dict for acroFormObj
+    acroFormObj2.initDict(docA->getXRef());
+    acroForm = new AcroForm(docA, &acroFormObj2);
+    acroFormObj2.free();
+
+    acroForm->buildAnnotPageList(catalog);
+
+    // scan the annotations, looking for any Widget-type annots
+    for (pageNum = 1; pageNum <= catalog->getNumPages(); ++pageNum) {
+      if (catalog->getPage(pageNum)->getAnnots(&annotsObj)->isArray()) {
+	for (i = 0; i < annotsObj.arrayGetLength(); ++i) {
+	  if (annotsObj.arrayGetNF(i, &annotRef)->isRef()) {
+	    annotRef.fetch(acroForm->doc->getXRef(), &annotObj);
+	    if (annotObj.isDict()) {
+	      if (annotObj.dictLookup("Subtype", &obj1)->isName("Widget")) {
+		acroForm->scanField(&annotRef);
+	      }
+	      obj1.free();
+	    }
+	    annotObj.free();
+	  }
+	  annotRef.free();
+	}
+      }
+      annotsObj.free();
+    }
+
+    if (acroForm->fields->getLength() == 0) {
+      delete acroForm;
+      acroForm = NULL;
+    }
   }
-  for (i = 0; i < obj1.arrayGetLength(); ++i) {
-    obj1.arrayGetNF(i, &obj2);
-    acroForm->scanField(&obj2);
-    obj2.free();
-  }
-  obj1.free();
 
   return acroForm;
 }
@@ -235,7 +308,7 @@
   GString *typeStr;
   TextString *nameA;
   Guint flagsA;
-  GBool haveFlags;
+  GBool haveFlags, typeFromParentA;
   Object fieldObjA, parentObj, parentObj2, obj1, obj2;
   AcroFormFieldType typeA;
   AcroFormField *field;
@@ -253,8 +326,10 @@
 
   if (fieldObjA.dictLookup("FT", &obj1)->isName()) {
     typeStr = new GString(obj1.getName());
+    typeFromParentA = gFalse;
   } else {
     typeStr = NULL;
+    typeFromParentA = gTrue;
   }
   obj1.free();
 
@@ -304,7 +379,19 @@
   if (!typeStr) {
     error(errSyntaxError, -1, "Missing type in AcroForm field");
     goto err1;
-  } else if (!typeStr->cmp("Btn")) {
+  }
+
+  //----- check for a radio button
+
+  // this is a kludge: if we see a Btn-type field with kids, and the
+  // Ff entry is missing, assume the kids are radio buttons
+  if (typeFromParentA && !typeStr->cmp("Btn") && !haveFlags) {
+    flagsA = acroFormFlagRadio;
+  }
+
+  //----- determine field type
+
+  if (!typeStr->cmp("Btn")) {
     if (flagsA & acroFormFlagPushbutton) {
       typeA = acroFormFieldPushbutton;
     } else if (flagsA & acroFormFlagRadio) {
@@ -335,7 +422,7 @@
   delete typeStr;
 
   field = new AcroFormField(acroFormA, fieldRefA, &fieldObjA,
-			    typeA, nameA, flagsA);
+			    typeA, nameA, flagsA, typeFromParentA);
   fieldObjA.free();
   return field;
 
@@ -349,7 +436,7 @@
 AcroFormField::AcroFormField(AcroForm *acroFormA,
 			     Object *fieldRefA, Object *fieldObjA,
 			     AcroFormFieldType typeA, TextString *nameA,
-			     Guint flagsA) {
+			     Guint flagsA, GBool typeFromParentA) {
   acroForm = acroFormA;
   fieldRefA->copy(&fieldRef);
   fieldObjA->copy(&fieldObj);
@@ -356,6 +443,7 @@
   type = typeA;
   name = nameA;
   flags = flagsA;
+  typeFromParent = typeFromParentA;
 }
 
 AcroFormField::~AcroFormField() {
@@ -364,6 +452,24 @@
   delete name;
 }
 
+int AcroFormField::getPageNum() {
+  Object kidsObj, annotRef;
+  int pageNum;
+
+  pageNum = 0;
+  if (fieldObj.dictLookup("Kids", &kidsObj)->isArray()) {
+    if (kidsObj.arrayGetLength() > 0) {
+      kidsObj.arrayGetNF(0, &annotRef);
+      pageNum = acroForm->lookupAnnotPage(&annotRef);
+      annotRef.free();
+    }
+  } else {
+    pageNum = acroForm->lookupAnnotPage(&fieldRef);
+  }
+  kidsObj.free();
+  return pageNum;
+}
+
 const char *AcroFormField::getType() {
   switch (type) {
   case acroFormFieldPushbutton:    return "PushButton";
@@ -392,12 +498,16 @@
 }
 
 Unicode *AcroFormField::getValue(int *length) {
-  Object obj1;
+  Object obj1, obj2;
   Unicode *u;
   char *s;
   TextString *ts;
+  GString *gs;
   int n, i;
 
+  u = NULL;
+  *length = 0;
+
   fieldLookup("V", &obj1);
   if (obj1.isName()) {
     s = obj1.getName();
@@ -407,7 +517,6 @@
       u[i] = s[i] & 0xff;
     }
     *length = n;
-    return u;
   } else if (obj1.isString()) {
     ts = new TextString(obj1.getString());
     n = ts->getLength();
@@ -415,10 +524,198 @@
     memcpy(u, ts->getUnicode(), n * sizeof(Unicode));
     *length = n;
     delete ts;
-    return u;
+  } else if (obj1.isDict()) {
+    obj1.dictLookup("Contents", &obj2);
+    if (obj2.isString()) {
+      gs = obj2.getString();
+      n = gs->getLength();
+      u = (Unicode *)gmallocn(n, sizeof(Unicode));
+      for (i = 0; i < n; ++i) {
+	u[i] = gs->getChar(i) & 0xff;
+      }
+      *length = n;
+    }
+    obj2.free();
+  }
+  obj1.free();
+
+  return u;
+}
+
+void AcroFormField::getBBox(double *llx, double *lly,
+			    double *urx, double *ury) {
+  Object annotObj, rectObj, numObj;
+  double t;
+
+  *llx = *lly = *urx = *ury = 0;
+
+  if (getAnnotObj(&annotObj)->isDict()) {
+    annotObj.dictLookup("Rect", &rectObj);
+    if (rectObj.isArray() && rectObj.arrayGetLength() == 4) {
+      rectObj.arrayGet(0, &numObj);
+      if (numObj.isNum()) {
+	*llx = numObj.getNum();
+      }
+      numObj.free();
+      rectObj.arrayGet(1, &numObj);
+      if (numObj.isNum()) {
+	*lly = numObj.getNum();
+      }
+      numObj.free();
+      rectObj.arrayGet(2, &numObj);
+      if (numObj.isNum()) {
+	*urx = numObj.getNum();
+      }
+      numObj.free();
+      rectObj.arrayGet(3, &numObj);
+      if (numObj.isNum()) {
+	*ury = numObj.getNum();
+      }
+      numObj.free();
+    }
+    rectObj.free();
+  }
+  annotObj.free();
+
+  if (*llx > *urx) {
+    t = *llx;  *llx = *urx;  *urx = t;
+  }
+  if (*lly > *ury) {
+    t = *lly;  *lly = *ury;  *ury = t;
+  }
+}
+
+void AcroFormField::getFont(Ref *fontID, double *fontSize) {
+  Object daObj;
+  GList *daToks;
+  char *fontTag;
+  double tfSize, m2, m3;
+  int tfPos, tmPos, i;
+
+  fontID->num = fontID->gen = -1;
+  *fontSize = 0;
+
+  if (fieldLookup("DA", &daObj)->isString()) {
+
+    // parse the default appearance string
+    daToks = tokenize(daObj.getString());
+    tfPos = tmPos = -1;
+    for (i = 2; i < daToks->getLength(); ++i) {
+      if (!((GString *)daToks->get(i))->cmp("Tf")) {
+	tfPos = i - 2;
+      } else if (i >= 6 && !((GString *)daToks->get(i))->cmp("Tm")) {
+	tmPos = i - 6;
+      }
+    }
+
+    // handle the Tf operator
+    if (tfPos >= 0) {
+      fontTag = ((GString *)daToks->get(tfPos))->getCString();
+      if (*fontTag == '/') {
+	++fontTag;
+      }
+      *fontID = findFontName(fontTag);
+      tfSize = atof(((GString *)daToks->get(tfPos + 1))->getCString());
+    } else {
+      tfSize = 1;
+    }
+
+    // handle the Tm operator
+    if (tmPos >= 0) {
+      // transformed font size = sqrt(m[2]^2 + m[3]^2) * size
+      m2 = atof(((GString *)daToks->get(tfPos + 2))->getCString());
+      m3 = atof(((GString *)daToks->get(tfPos + 3))->getCString());
+      tfSize *= sqrt(m2*m2 + m3*m3);
+    }
+    *fontSize = tfSize;
+
+    deleteGList(daToks, GString);
+  }
+
+  daObj.free();
+}
+
+Ref AcroFormField::findFontName(char *fontTag) {
+  Object drObj, fontDictObj, fontObj, baseFontObj;
+  Ref fontID;
+  GBool found;
+
+  fontID.num = fontID.gen = -1;
+  found = gFalse;
+
+  if (fieldObj.dictLookup("DR", &drObj)->isDict()) {
+    if (drObj.dictLookup("Font", &fontDictObj)->isDict()) {
+      if (fontDictObj.dictLookupNF(fontTag, &fontObj)->isRef()) {
+	fontID = fontObj.getRef();
+	found = gTrue;
+      }
+      fontObj.free();
+    }
+    fontDictObj.free();
+  }
+  drObj.free();
+  if (found) {
+    return fontID;
+  }
+
+  if (acroForm->acroFormObj.dictLookup("DR", &drObj)->isDict()) {
+    if (drObj.dictLookup("Font", &fontDictObj)->isDict()) {
+      if (fontDictObj.dictLookupNF(fontTag, &fontObj)->isRef()) {
+	fontID = fontObj.getRef();
+      }
+      fontObj.free();
+    }
+    fontDictObj.free();
+  }
+  drObj.free();
+  return fontID;
+}
+
+void AcroFormField::getColor(double *red, double *green, double *blue) {
+  Object daObj;
+  GList *daToks;
+  int i;
+
+  *red = *green = *blue = 0;
+
+  if (fieldLookup("DA", &daObj)->isString()) {
+
+    // parse the default appearance string
+    daToks = tokenize(daObj.getString());
+    for (i = 1; i < daToks->getLength(); ++i) {
+
+      // handle the g operator
+      if (!((GString *)daToks->get(i))->cmp("g")) {
+	*red = *green = *blue =
+	    atof(((GString *)daToks->get(i - 1))->getCString());
+	break;
+
+      // handle the rg operator
+      } else if (i >= 3 && !((GString *)daToks->get(i))->cmp("rg")) {
+	*red = atof(((GString *)daToks->get(i - 3))->getCString());
+	*green = atof(((GString *)daToks->get(i - 2))->getCString());
+	*blue = atof(((GString *)daToks->get(i - 1))->getCString());
+	break;
+      }
+    }
+
+    deleteGList(daToks, GString);
+  }
+
+  daObj.free();
+}
+
+int AcroFormField::getMaxLen() {
+  Object obj;
+  int len;
+
+  if (fieldLookup("MaxLen", &obj)->isInt()) {
+    len = obj.getInt();
   } else {
-    return NULL;
+    len = -1;
   }
+  obj.free();
+  return len;
 }
 
 void AcroFormField::draw(int pageNum, Gfx *gfx, GBool printing) {
@@ -445,7 +742,7 @@
   Object obj1, obj2;
   double xMin, yMin, xMax, yMax, t;
   int annotFlags;
-  GBool oc;
+  GBool oc, render;
 
   if (!annotObj->isDict()) {
     return;
@@ -518,7 +815,16 @@
 
   //----- draw it
 
+  render = gFalse;
   if (acroForm->needAppearances) {
+    render = gTrue;
+  } else {
+    if (!annotObj->dictLookup("AP", &obj1)->isDict()) {
+      render = gTrue;
+    }
+    obj1.free();
+  }
+  if (render) {
     drawNewAppearance(gfx, annotObj->getDict(),
 		      xMin, yMin, xMax, yMax);
   } else {
@@ -562,11 +868,13 @@
   }
 }
 
-// Regenerate the appearnce for this field, and draw it.
+// Regenerate the appearance for this field, and draw it.
 void AcroFormField::drawNewAppearance(Gfx *gfx, Dict *annot,
 				      double xMin, double yMin,
 				      double xMax, double yMax) {
+  GString *appearBuf;
   Object appearance, mkObj, ftObj, appearDict, drObj, apObj, asObj;
+  Object resources, fontResources, defaultFont, gfxStateDict;
   Object obj1, obj2, obj3;
   Dict *mkDict;
   MemStream *appearStream;
@@ -595,7 +903,7 @@
   if (mkDict) {
     if (mkDict->lookup("BG", &obj1)->isArray() &&
 	obj1.arrayGetLength() > 0) {
-      setColor(obj1.getArray(), gTrue, 0);
+      setColor(obj1.getArray(), gTrue, 0, appearBuf);
       appearBuf->appendf("0 0 {0:.4f} {1:.4f} re f\n",
 			 xMax - xMin, yMax - yMin);
     }
@@ -678,6 +986,7 @@
     if (borderWidth > 0) {
       mkDict->lookup("BC", &obj1);
       if (!(obj1.isArray() && obj1.arrayGetLength() > 0)) {
+	obj1.free();
 	mkDict->lookup("BG", &obj1);
       }
       if (obj1.isArray() && obj1.arrayGetLength() > 0) {
@@ -700,20 +1009,26 @@
 	  case annotBorderSolid:
 	  case annotBorderUnderlined:
 	    appearBuf->appendf("{0:.4f} w\n", borderWidth);
-	    setColor(obj1.getArray(), gFalse, 0);
-	    drawCircle(0.5 * dx, 0.5 * dy, r - 0.5 * borderWidth, "s");
+	    setColor(obj1.getArray(), gFalse, 0, appearBuf);
+	    drawCircle(0.5 * dx, 0.5 * dy, r - 0.5 * borderWidth, "s",
+		       appearBuf);
 	    break;
 	  case annotBorderBeveled:
 	  case annotBorderInset:
 	    appearBuf->appendf("{0:.4f} w\n", 0.5 * borderWidth);
-	    setColor(obj1.getArray(), gFalse, 0);
-	    drawCircle(0.5 * dx, 0.5 * dy, r - 0.25 * borderWidth, "s");
+	    setColor(obj1.getArray(), gFalse, 0, appearBuf);
+	    drawCircle(0.5 * dx, 0.5 * dy, r - 0.25 * borderWidth, "s",
+		       appearBuf);
 	    setColor(obj1.getArray(), gFalse,
-		     borderType == annotBorderBeveled ? 1 : -1);
-	    drawCircleTopLeft(0.5 * dx, 0.5 * dy, r - 0.75 * borderWidth);
+		     borderType == annotBorderBeveled ? 1 : -1,
+		     appearBuf);
+	    drawCircleTopLeft(0.5 * dx, 0.5 * dy, r - 0.75 * borderWidth,
+			      appearBuf);
 	    setColor(obj1.getArray(), gFalse,
-		     borderType == annotBorderBeveled ? -1 : 1);
-	    drawCircleBottomRight(0.5 * dx, 0.5 * dy, r - 0.75 * borderWidth);
+		     borderType == annotBorderBeveled ? -1 : 1,
+		     appearBuf);
+	    drawCircleBottomRight(0.5 * dx, 0.5 * dy, r - 0.75 * borderWidth,
+				  appearBuf);
 	    break;
 	  }
 
@@ -728,7 +1043,7 @@
 	    // fall through to the solid case
 	  case annotBorderSolid:
 	    appearBuf->appendf("{0:.4f} w\n", borderWidth);
-	    setColor(obj1.getArray(), gFalse, 0);
+	    setColor(obj1.getArray(), gFalse, 0, appearBuf);
 	    appearBuf->appendf("{0:.4f} {0:.4f} {1:.4f} {2:.4f} re s\n",
 			       0.5 * borderWidth,
 			       dx - borderWidth, dy - borderWidth);
@@ -736,7 +1051,8 @@
 	  case annotBorderBeveled:
 	  case annotBorderInset:
 	    setColor(obj1.getArray(), gTrue,
-		     borderType == annotBorderBeveled ? 1 : -1);
+		     borderType == annotBorderBeveled ? 1 : -1,
+		     appearBuf);
 	    appearBuf->append("0 0 m\n");
 	    appearBuf->appendf("0 {0:.4f} l\n", dy);
 	    appearBuf->appendf("{0:.4f} {1:.4f} l\n", dx, dy);
@@ -747,7 +1063,8 @@
 	    appearBuf->appendf("{0:.4f} {0:.4f} l\n", borderWidth);
 	    appearBuf->append("f\n");
 	    setColor(obj1.getArray(), gTrue,
-		     borderType == annotBorderBeveled ? -1 : 1);
+		     borderType == annotBorderBeveled ? -1 : 1,
+		     appearBuf);
 	    appearBuf->append("0 0 m\n");
 	    appearBuf->appendf("{0:.4f} 0 l\n", dx);
 	    appearBuf->appendf("{0:.4f} {1:.4f} l\n", dx, dy);
@@ -760,7 +1077,7 @@
 	    break;
 	  case annotBorderUnderlined:
 	    appearBuf->appendf("{0:.4f} w\n", borderWidth);
-	    setColor(obj1.getArray(), gFalse, 0);
+	    setColor(obj1.getArray(), gFalse, 0, appearBuf);
 	    appearBuf->appendf("0 0 m {0:.4f} 0 l s\n", dx);
 	    break;
 	  }
@@ -777,7 +1094,7 @@
   gfree(borderDash);
 
   // get the resource dictionary
-  fieldLookup("DR", &drObj);
+  buildDefaultResourceDict(&drObj);
 
   // build the font dictionary
   if (drObj.isDict() && drObj.dictLookup("Font", &obj1)->isDict()) {
@@ -839,7 +1156,8 @@
 	    ->isName(appearanceState->getCString())) {
 	if (caption) {
 	  drawText(caption, da, fontDict, gFalse, 0, acroFormQuadCenter,
-		   gFalse, gTrue, rot, xMin, yMin, xMax, yMax, borderWidth);
+		   gFalse, gTrue, rot, xMin, yMin, xMax, yMax, borderWidth,
+		   appearBuf);
 	} else {
 	  if (mkDict) {
 	    if (mkDict->lookup("BC", &obj2)->isArray() &&
@@ -846,8 +1164,9 @@
 		obj2.arrayGetLength() > 0) {
 	      dx = xMax - xMin;
 	      dy = yMax - yMin;
-	      setColor(obj2.getArray(), gTrue, 0);
-	      drawCircle(0.5 * dx, 0.5 * dy, 0.2 * (dx < dy ? dx : dy), "f");
+	      setColor(obj2.getArray(), gTrue, 0, appearBuf);
+	      drawCircle(0.5 * dx, 0.5 * dy, 0.2 * (dx < dy ? dx : dy), "f",
+			 appearBuf);
 	    }
 	    obj2.free();
 	  }
@@ -858,17 +1177,21 @@
     } else if (flags & acroFormFlagPushbutton) {
       if (caption) {
 	drawText(caption, da, fontDict, gFalse, 0, acroFormQuadCenter,
-		 gFalse, gFalse, rot, xMin, yMin, xMax, yMax, borderWidth);
+		 gFalse, gFalse, rot, xMin, yMin, xMax, yMax, borderWidth,
+		 appearBuf);
       }
     // checkbox
     } else {
       fieldLookup("V", &obj1);
-      if (obj1.isName() && !obj1.isName("Off")) {
+      if (obj1.isName() && !(obj1.isName("Off") ||
+			     obj1.isName("No") ||
+			     obj1.isName(""))) {
 	if (!caption) {
 	  caption = new GString("3"); // ZapfDingbats checkmark
 	}
 	drawText(caption, da, fontDict, gFalse, 0, acroFormQuadCenter,
-		 gFalse, gTrue, rot, xMin, yMin, xMax, yMax, borderWidth);
+		 gFalse, gTrue, rot, xMin, yMin, xMax, yMax, borderWidth,
+		 appearBuf);
       }
       obj1.free();
     }
@@ -897,7 +1220,8 @@
       }
       drawText(obj1.getString(), da, fontDict,
 	       flags & acroFormFlagMultiline, comb, quadding,
-	       gTrue, gFalse, rot, xMin, yMin, xMax, yMax, borderWidth);
+	       gTrue, gFalse, rot, xMin, yMin, xMax, yMax, borderWidth,
+	       appearBuf);
     }
     obj1.free();
   } else if (ftObj.isName("Ch")) {
@@ -913,7 +1237,7 @@
       if (fieldLookup("V", &obj1)->isString()) {
 	drawText(obj1.getString(), da, fontDict,
 		 gFalse, 0, quadding, gTrue, gFalse, rot,
-		 xMin, yMin, xMax, yMax, borderWidth);
+		 xMin, yMin, xMax, yMax, borderWidth, appearBuf);
 	//~ Acrobat draws a popup icon on the right side
       }
       obj1.free();
@@ -969,7 +1293,7 @@
 	obj2.free();
 	// draw the text
 	drawListBox(text, selection, nOptions, topIdx, da, fontDict, quadding,
-		    xMin, yMin, xMax, yMax, borderWidth);
+		    xMin, yMin, xMax, yMax, borderWidth, appearBuf);
 	for (i = 0; i < nOptions; ++i) {
 	  delete text[i];
 	}
@@ -979,7 +1303,22 @@
       obj1.free();
     }
   } else if (ftObj.isName("Sig")) {
-    //~unimp
+    //~ check to see if background is already drawn
+    gfxStateDict.initDict(acroForm->doc->getXRef());
+    obj1.initReal(0.5);
+    gfxStateDict.dictAdd(copyString("ca"), &obj1);
+    appearBuf->append("/GS1 gs\n");
+    appearBuf->appendf("0.7 0.7 1 rg 0 0 {0:.2f} {1:.2f} re f\n",
+		       xMax - xMin, yMax - yMin);
+    caption = new GString("SIGN HERE");
+    if (da) {
+      delete da;
+    }
+    da = new GString("/Helv 10 Tf 1 0 0 rg");
+    drawText(caption, da, fontDict,
+	     gFalse, 0, acroFormQuadLeft, gFalse, gFalse, rot,
+	     xMin, yMin, xMax, yMax, borderWidth, appearBuf);
+    delete caption;
   } else {
     error(errSyntaxError, -1, "Unknown field type");
   }
@@ -1001,11 +1340,34 @@
   obj1.arrayAdd(obj2.initReal(yMax - yMin));
   appearDict.dictAdd(copyString("BBox"), &obj1);
 
-  // set the resource dictionary
+  // set the resource dictionary; add a default font
   if (drObj.isDict()) {
-    appearDict.dictAdd(copyString("Resources"), drObj.copy(&obj1));
+    drObj.copy(&resources);
+  } else {
+    resources.initDict(acroForm->doc->getXRef());
   }
   drObj.free();
+  fontResources.initDict(acroForm->doc->getXRef());
+  if (resources.dictLookup("Font", &obj1)->isDict()) {
+    for (i = 0; i < obj1.dictGetLength(); ++i) {
+      obj1.dictGetValNF(i, &obj2);
+      fontResources.dictAdd(copyString(obj1.dictGetKey(i)), &obj2);
+    }
+  }
+  obj1.free();
+  defaultFont.initDict(acroForm->doc->getXRef());
+  defaultFont.dictAdd(copyString("Type"), obj1.initName("Font"));
+  defaultFont.dictAdd(copyString("Subtype"), obj1.initName("Type1"));
+  defaultFont.dictAdd(copyString("BaseFont"), obj1.initName("Helvetica"));
+  defaultFont.dictAdd(copyString("Encoding"), obj1.initName("WinAnsiEncoding"));
+  fontResources.dictAdd(copyString("xpdf_default_font"), &defaultFont);
+  resources.dictAdd(copyString("Font"), &fontResources);
+  if (gfxStateDict.isDict()) {
+    obj1.initDict(acroForm->doc->getXRef());
+    obj1.dictAdd(copyString("GS1"), &gfxStateDict);
+    resources.dictAdd(copyString("ExtGState"), &obj1);
+  }
+  appearDict.dictAdd(copyString("Resources"), &resources);
 
   // build the appearance stream
   appearStream = new MemStream(appearBuf->getCString(), 0,
@@ -1029,7 +1391,8 @@
 // have 1, 3, or 4 elements).  If <adjust> is +1, color is brightened;
 // if <adjust> is -1, color is darkened; otherwise color is not
 // modified.
-void AcroFormField::setColor(Array *a, GBool fill, int adjust) {
+void AcroFormField::setColor(Array *a, GBool fill, int adjust,
+			     GString *appearBuf) {
   Object obj1;
   double color[4];
   int nComps, i;
@@ -1078,7 +1441,7 @@
 			     GBool multiline, int comb, int quadding,
 			     GBool txField, GBool forceZapfDingbats, int rot,
 			     double xMin, double yMin, double xMax, double yMax,
-			     double border) {
+			     double border, GString *appearBuf) {
   GString *text2;
   GList *daToks;
   GString *tok;
@@ -1111,20 +1474,7 @@
   // parse the default appearance string
   tfPos = tmPos = -1;
   if (da) {
-    daToks = new GList();
-    i = 0;
-    while (i < da->getLength()) {
-      while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) {
-	++i;
-      }
-      if (i < da->getLength()) {
-	for (j = i + 1;
-	     j < da->getLength() && !Lexer::isSpace(da->getChar(j));
-	     ++j) ;
-	daToks->append(new GString(da, i, j - i));
-	i = j;
-      }
-    }
+    daToks = tokenize(da);
     for (i = 2; i < daToks->getLength(); ++i) {
       if (i >= 2 && !((GString *)daToks->get(i))->cmp("Tf")) {
 	tfPos = i - 2;
@@ -1156,6 +1506,8 @@
     if (tok->getLength() >= 1 && tok->getChar(0) == '/') {
       if (!fontDict || !(font = fontDict->lookup(tok->getCString() + 1))) {
 	error(errSyntaxError, -1, "Unknown font in field's DA string");
+	tok->clear();
+	tok->append("/xpdf_default_font");
       }
     } else {
       error(errSyntaxError, -1,
@@ -1477,7 +1829,8 @@
 				int nOptions, int topIdx,
 				GString *da, GfxFontDict *fontDict,
 				GBool quadding, double xMin, double yMin,
-				double xMax, double yMax, double border) {
+				double xMax, double yMax, double border,
+				GString *appearBuf) {
   GList *daToks;
   GString *tok;
   GfxFont *font;
@@ -1491,20 +1844,7 @@
   // parse the default appearance string
   tfPos = tmPos = -1;
   if (da) {
-    daToks = new GList();
-    i = 0;
-    while (i < da->getLength()) {
-      while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) {
-	++i;
-      }
-      if (i < da->getLength()) {
-	for (j = i + 1;
-	     j < da->getLength() && !Lexer::isSpace(da->getChar(j));
-	     ++j) ;
-	daToks->append(new GString(da, i, j - i));
-	i = j;
-      }
-    }
+    daToks = tokenize(da);
     for (i = 2; i < daToks->getLength(); ++i) {
       if (i >= 2 && !((GString *)daToks->get(i))->cmp("Tf")) {
 	tfPos = i - 2;
@@ -1524,6 +1864,8 @@
     if (tok->getLength() >= 1 && tok->getChar(0) == '/') {
       if (!fontDict || !(font = fontDict->lookup(tok->getCString() + 1))) {
 	error(errSyntaxError, -1, "Unknown font in field's DA string");
+	tok->clear();
+	tok->append("/xpdf_default_font");
       }
     } else {
       error(errSyntaxError, -1,
@@ -1735,7 +2077,7 @@
 // Draw an (approximate) circle of radius <r> centered at (<cx>, <cy>).
 // <cmd> is used to draw the circle ("f", "s", or "b").
 void AcroFormField::drawCircle(double cx, double cy, double r,
-			       const char *cmd) {
+			       const char *cmd, GString *appearBuf) {
   appearBuf->appendf("{0:.4f} {1:.4f} m\n",
 		     cx + r, cy);
   appearBuf->appendf("{0:.4f} {1:.4f} {2:.4f} {3:.4f} {4:.4f} {5:.4f} c\n",
@@ -1759,7 +2101,8 @@
 
 // Draw the top-left half of an (approximate) circle of radius <r>
 // centered at (<cx>, <cy>).
-void AcroFormField::drawCircleTopLeft(double cx, double cy, double r) {
+void AcroFormField::drawCircleTopLeft(double cx, double cy, double r,
+				      GString *appearBuf) {
   double r2;
 
   r2 = r / sqrt(2.0);
@@ -1784,7 +2127,8 @@
 
 // Draw the bottom-right half of an (approximate) circle of radius <r>
 // centered at (<cx>, <cy>).
-void AcroFormField::drawCircleBottomRight(double cx, double cy, double r) {
+void AcroFormField::drawCircleBottomRight(double cx, double cy, double r,
+					  GString *appearBuf) {
   double r2;
 
   r2 = r / sqrt(2.0);
@@ -1807,6 +2151,27 @@
   appearBuf->append("S\n");
 }
 
+GList *AcroFormField::tokenize(GString *s) {
+  GList *toks;
+  int i, j;
+
+  toks = new GList();
+  i = 0;
+  while (i < s->getLength()) {
+    while (i < s->getLength() && Lexer::isSpace(s->getChar(i))) {
+      ++i;
+    }
+    if (i < s->getLength()) {
+      for (j = i + 1;
+	   j < s->getLength() && !Lexer::isSpace(s->getChar(j));
+	   ++j) ;
+      toks->append(new GString(s, i, j - i));
+      i = j;
+    }
+  }
+  return toks;
+}
+
 Object *AcroFormField::getResources(Object *res) {
   Object kidsObj, annotObj, obj1;
   int i;
@@ -1841,6 +2206,35 @@
   return res;
 }
 
+Object *AcroFormField::getFieldRef(Object *ref) {
+  return fieldRef.copy(ref);
+}
+
+Object *AcroFormField::getValueObj(Object *val) {
+  return fieldLookup("V", val);
+}
+
+Object *AcroFormField::getParentRef(Object *parent) {
+  return fieldObj.dictLookupNF("Parent", parent);
+}
+
+// Get the first annotation object associated with this field.
+Object *AcroFormField::getAnnotObj(Object *annotObj) {
+  Object kidsObj;
+
+  if (fieldObj.dictLookup("Kids", &kidsObj)->isArray()) {
+    if (kidsObj.arrayGetLength() > 0) {
+      kidsObj.arrayGet(0, annotObj);
+    } else {
+      annotObj->initNull();
+    }
+  } else {
+    fieldObj.copy(annotObj);
+  }
+  kidsObj.free();
+  return annotObj;
+}
+
 Object *AcroFormField::getAnnotResources(Dict *annot, Object *res) {
   Object apObj, asObj, appearance, obj1;
 
@@ -1873,6 +2267,60 @@
   return res;
 }
 
+// Merge the field and AcroForm DR objects.
+void AcroFormField::buildDefaultResourceDict(Object *dr) {
+  Object formDR, fieldDR, resDict, newResDict, resObj;
+  char *resType, *resName;
+  int i, j;
+
+  // NB: we need to deep-copy the dictionaries here, because multiple
+  // threads can be sharing these objects.
+
+  dr->initDict(acroForm->doc->getXRef());
+
+  acroForm->acroFormObj.dictLookup("DR", &formDR);
+  if (formDR.isDict()) {
+    for (i = 0; i < formDR.dictGetLength(); ++i) {
+      resType = formDR.dictGetKey(i);
+      formDR.dictGetVal(i, &resDict);
+      if (resDict.isDict()) {
+	newResDict.initDict(acroForm->doc->getXRef());
+	dr->dictAdd(copyString(resType), &newResDict);
+	for (j = 0; j < resDict.dictGetLength(); ++j) {
+	  resName = resDict.dictGetKey(j);
+	  resDict.dictGetValNF(j, &resObj);
+	  newResDict.dictAdd(copyString(resName), &resObj);
+	}
+      }
+      resDict.free();
+    }
+  }
+  formDR.free();
+
+  fieldObj.dictLookup("DR", &fieldDR);
+  if (fieldDR.isDict()) {
+    for (i = 0; i < fieldDR.dictGetLength(); ++i) {
+      resType = fieldDR.dictGetKey(i);
+      fieldDR.dictGetVal(i, &resDict);
+      if (resDict.isDict()) {
+	dr->dictLookup(resType, &newResDict);
+	if (!newResDict.isDict()) {
+	  newResDict.free();
+	  newResDict.initDict(acroForm->doc->getXRef());
+	}
+	dr->dictAdd(copyString(resType), &newResDict);
+	for (j = 0; j < resDict.dictGetLength(); ++j) {
+	  resName = resDict.dictGetKey(j);
+	  resDict.dictGetValNF(j, &resObj);
+	  newResDict.dictAdd(copyString(resName), &resObj);
+	}
+      }
+      resDict.free();
+    }
+  }
+  fieldDR.free();
+}
+
 // Look up an inheritable field dictionary entry.
 Object *AcroFormField::fieldLookup(const char *key, Object *obj) {
   return fieldLookup(fieldObj.getDict(), key, obj);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -73,17 +73,29 @@
 
   virtual ~AcroFormField();
 
+  virtual int getPageNum();
   virtual const char *getType();
   virtual Unicode *getName(int *length);
   virtual Unicode *getValue(int *length);
+  virtual void getBBox(double *llx, double *lly, double *urx, double *ury);
+  virtual void getFont(Ref *fontID, double *fontSize);
+  virtual void getColor(double *red, double *green, double *blue);
+  int getMaxLen();
 
   virtual Object *getResources(Object *res);
 
+  AcroFormFieldType getAcroFormFieldType() { return type; }
+  Object *getFieldRef(Object *ref);
+  Object *getValueObj(Object *val);
+  Object *getParentRef(Object *parent);
+  GBool getTypeFromParent() { return typeFromParent; }
+
 private:
 
   AcroFormField(AcroForm *acroFormA, Object *fieldRefA, Object *fieldObjA,
 		AcroFormFieldType typeA, TextString *nameA,
-		Guint flagsA);
+		Guint flagsA, GBool typeFromParentA);
+  Ref findFontName(char *fontTag);
   void draw(int pageNum, Gfx *gfx, GBool printing);
   void drawAnnot(int pageNum, Gfx *gfx, GBool printing,
 		 Object *annotRef, Object *annotObj);
@@ -93,24 +105,31 @@
   void drawNewAppearance(Gfx *gfx, Dict *annot,
 			 double xMin, double yMin,
 			 double xMax, double yMax);
-  void setColor(Array *a, GBool fill, int adjust);
+  void setColor(Array *a, GBool fill, int adjust, GString *appearBuf);
   void drawText(GString *text, GString *da, GfxFontDict *fontDict,
 		GBool multiline, int comb, int quadding,
 		GBool txField, GBool forceZapfDingbats, int rot,
 		double xMin, double yMin, double xMax, double yMax,
-		double border);
+		double border, GString *appearBuf);
   void drawListBox(GString **text, GBool *selection,
 		   int nOptions, int topIdx,
 		   GString *da, GfxFontDict *fontDict,
 		   GBool quadding, double xMin, double yMin,
-		   double xMax, double yMax, double border);
+		   double xMax, double yMax, double border,
+		   GString *appearBuf);
   void getNextLine(GString *text, int start,
 		   GfxFont *font, double fontSize, double wMax,
 		   int *end, double *width, int *next);
-  void drawCircle(double cx, double cy, double r, const char *cmd);
-  void drawCircleTopLeft(double cx, double cy, double r);
-  void drawCircleBottomRight(double cx, double cy, double r);
+  void drawCircle(double cx, double cy, double r, const char *cmd,
+		  GString *appearBuf);
+  void drawCircleTopLeft(double cx, double cy, double r,
+			 GString *appearBuf);
+  void drawCircleBottomRight(double cx, double cy, double r,
+			     GString *appearBuf);
+  GList *tokenize(GString *s);
+  Object *getAnnotObj(Object *annotObj);
   Object *getAnnotResources(Dict *annot, Object *res);
+  void buildDefaultResourceDict(Object *dr);
   Object *fieldLookup(const char *key, Object *obj);
   Object *fieldLookup(Dict *dict, const char *key, Object *obj);
 
@@ -120,7 +139,7 @@
   AcroFormFieldType type;
   TextString *name;
   Guint flags;
-  GString *appearBuf;
+  GBool typeFromParent;
 
   friend class AcroForm;
 };

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GList.h"
 #include "Error.h"
 #include "Object.h"
@@ -25,6 +26,8 @@
 #include "PDFDoc.h"
 #include "OptionalContent.h"
 #include "Form.h"
+#include "BuiltinFontTables.h"
+#include "FontEncodingTables.h"
 #include "Annot.h"
 
 // the MSVC math.h doesn't define this
@@ -310,6 +313,8 @@
 	generatePolyLineAppearance();
       } else if (!type->cmp("Polygon")) {
 	generatePolygonAppearance();
+      } else if (!type->cmp("FreeText")) {
+	generateFreeTextAppearance();
       }
     }
   }
@@ -690,6 +695,107 @@
   annotObj.free();
 }
 
+//~ this doesn't handle rich text
+//~ this doesn't handle the callout
+//~ this doesn't handle the RD field
+void Annot::generateFreeTextAppearance() {
+  Object annotObj, gfxStateDict, appearDict, obj1, obj2;
+  Object resources, gsResources, fontResources, defaultFont;
+  GString *text, *da;
+  double lineWidth;
+  int quadding, rot;
+  MemStream *appearStream;
+
+  if (!getObject(&annotObj)->isDict()) {
+    annotObj.free();
+    return;
+  }
+
+  appearBuf = new GString();
+
+  //----- check for transparency
+  if (annotObj.dictLookup("CA", &obj1)->isNum()) {
+    gfxStateDict.initDict(doc->getXRef());
+    gfxStateDict.dictAdd(copyString("ca"), obj1.copy(&obj2));
+    appearBuf->append("/GS1 gs\n");
+  }
+  obj1.free();
+
+  //----- draw the text
+  if (annotObj.dictLookup("Contents", &obj1)->isString()) {
+    text = obj1.getString()->copy();
+  } else {
+    text = new GString();
+  }
+  obj1.free();
+  if (annotObj.dictLookup("Q", &obj1)->isInt()) {
+    quadding = obj1.getInt();
+  } else {
+    quadding = 0;
+  }
+  obj1.free();
+  if (annotObj.dictLookup("DA", &obj1)->isString()) {
+    da = obj1.getString()->copy();
+  } else {
+    da = new GString();
+  }
+  obj1.free();
+  // the "Rotate" field is not defined in the PDF spec, but Acrobat
+  // looks at it
+  if (annotObj.dictLookup("Rotate", &obj1)->isInt()) {
+    rot = obj1.getInt();
+  } else {
+    rot = 0;
+  }
+  obj1.free();
+  drawText(text, da, quadding, 0, rot);
+  delete text;
+  delete da;
+
+  //----- draw the border
+  if (borderStyle->getWidth() != 0) {
+    setLineStyle(borderStyle, &lineWidth);
+    appearBuf->appendf("{0:.4f} {1:.4f} {2:.4f} {3:.4f} re s\n",
+		       0.5 * lineWidth, 0.5 * lineWidth,
+		       xMax - xMin - lineWidth, yMax - yMin - lineWidth);
+  }
+
+  //----- build the appearance stream dictionary
+  appearDict.initDict(doc->getXRef());
+  appearDict.dictAdd(copyString("Length"),
+		     obj1.initInt(appearBuf->getLength()));
+  appearDict.dictAdd(copyString("Subtype"), obj1.initName("Form"));
+  obj1.initArray(doc->getXRef());
+  obj1.arrayAdd(obj2.initReal(0));
+  obj1.arrayAdd(obj2.initReal(0));
+  obj1.arrayAdd(obj2.initReal(xMax - xMin));
+  obj1.arrayAdd(obj2.initReal(yMax - yMin));
+  appearDict.dictAdd(copyString("BBox"), &obj1);
+  resources.initDict(doc->getXRef());
+  defaultFont.initDict(doc->getXRef());
+  defaultFont.dictAdd(copyString("Type"), obj1.initName("Font"));
+  defaultFont.dictAdd(copyString("Subtype"), obj1.initName("Type1"));
+  defaultFont.dictAdd(copyString("BaseFont"), obj1.initName("Helvetica"));
+  defaultFont.dictAdd(copyString("Encoding"), obj1.initName("WinAnsiEncoding"));
+  fontResources.initDict(doc->getXRef());
+  fontResources.dictAdd(copyString("xpdf_default_font"), &defaultFont);
+  resources.dictAdd(copyString("Font"), &fontResources);
+  if (gfxStateDict.isDict()) {
+    gsResources.initDict(doc->getXRef());
+    gsResources.dictAdd(copyString("GS1"), &gfxStateDict);
+    resources.dictAdd(copyString("ExtGState"), &gsResources);
+  }
+  appearDict.dictAdd(copyString("Resources"), &resources);
+
+  //----- build the appearance stream
+  appearStream = new MemStream(appearBuf->getCString(), 0,
+			       appearBuf->getLength(), &appearDict);
+  appearance.free();
+  appearance.initStream(appearStream);
+
+  annotObj.free();
+}
+
 void Annot::setLineStyle(AnnotBorderStyle *bs, double *lineWidth) {
   double *dash;
   double w;
@@ -1018,6 +1124,190 @@
   appearBuf->append("S\n");
 }
 
+void Annot::drawText(GString *text, GString *da, int quadding, double margin,
+		     int rot) {
+  GString *text2, *tok;
+  GList *daToks;
+  const char *charName;
+  double dx, dy, fontSize, fontSize2, x, y, w;
+  Gushort charWidth;
+  int tfPos, tmPos, i, j, c;
+
+  // check for a Unicode string
+  //~ this currently drops all non-Latin1 characters
+  if (text->getLength() >= 2 &&
+      text->getChar(0) == '\xfe' && text->getChar(1) == '\xff') {
+    text2 = new GString();
+    for (i = 2; i+1 < text->getLength(); i += 2) {
+      c = ((text->getChar(i) & 0xff) << 8) + (text->getChar(i+1) & 0xff);
+      if (c <= 0xff) {
+	text2->append((char)c);
+      } else {
+	text2->append('?');
+      }
+    }
+  } else {
+    text2 = text;
+  }
+
+  // parse the default appearance string
+  tfPos = tmPos = -1;
+  if (da) {
+    daToks = new GList();
+    i = 0;
+    while (i < da->getLength()) {
+      while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) {
+	++i;
+      }
+      if (i < da->getLength()) {
+	for (j = i + 1;
+	     j < da->getLength() && !Lexer::isSpace(da->getChar(j));
+	     ++j) ;
+	daToks->append(new GString(da, i, j - i));
+	i = j;
+      }
+    }
+    for (i = 2; i < daToks->getLength(); ++i) {
+      if (i >= 2 && !((GString *)daToks->get(i))->cmp("Tf")) {
+	tfPos = i - 2;
+      } else if (i >= 6 && !((GString *)daToks->get(i))->cmp("Tm")) {
+	tmPos = i - 6;
+      }
+    }
+  } else {
+    daToks = NULL;
+  }
+
+  // get the font and font size
+  fontSize = 0;
+  if (tfPos >= 0) {
+    //~ where do we look up the font?
+    tok = (GString *)daToks->get(tfPos);
+    tok->clear();
+    tok->append("/xpdf_default_font");
+    tok = (GString *)daToks->get(tfPos + 1);
+    fontSize = atof(tok->getCString());
+  } else {
+    error(errSyntaxError, -1,
+	  "Missing 'Tf' operator in annotation's DA string");
+    daToks->append(new GString("/xpdf_default_font"));
+    daToks->append(new GString("10"));
+    daToks->append(new GString("Tf"));
+  }
+
+  // setup
+  appearBuf->append("q\n");
+  if (rot == 90) {
+    appearBuf->appendf("0 1 -1 0 {0:.4f} 0 cm\n", xMax - xMin);
+    dx = yMax - yMin;
+    dy = xMax - xMin;
+  } else if (rot == 180) {
+    appearBuf->appendf("-1 0 0 -1 {0:.4f} {1:.4f} cm\n",
+		       xMax - xMin, yMax - yMin);
+    dx = xMax - yMax;
+    dy = yMax - yMin;
+  } else if (rot == 270) {
+    appearBuf->appendf("0 -1 1 0 0 {0:.4f} cm\n", yMax - yMin);
+    dx = yMax - yMin;
+    dy = xMax - xMin;
+  } else { // assume rot == 0
+    dx = xMax - xMin;
+    dy = yMax - yMin;
+  }
+  appearBuf->append("BT\n");
+
+  // compute string width
+  //~ this assumes we're substituting Helvetica/WinAnsiEncoding for everything
+  w = 0;
+  for (i = 0; i < text2->getLength(); ++i) {
+    charName = winAnsiEncoding[text->getChar(i) & 0xff];
+    if (charName && builtinFonts[4].widths->getWidth(charName, &charWidth)) {
+      w += charWidth;
+    } else {
+      w += 0.5;
+    }
+  }
+
+  // compute font autosize
+  if (fontSize == 0) {
+    fontSize = dy - 2 * margin;
+    fontSize2 = (dx - 2 * margin) / w;
+    if (fontSize2 < fontSize) {
+      fontSize = fontSize2;
+    }
+    fontSize = floor(fontSize);
+    if (tfPos >= 0) {
+      tok = (GString *)daToks->get(tfPos + 1);
+      tok->clear();
+      tok->appendf("{0:.4f}", fontSize);
+    }
+  }
+
+  // compute text start position
+  w *= fontSize;
+  switch (quadding) {
+  case 0:
+  default:
+    x = margin + 2;
+    break;
+  case 1:
+    x = (dx - w) / 2;
+    break;
+  case 2:
+    x = dx - margin - 2 - w;
+    break;
+  }
+  y = 0.5 * dy - 0.4 * fontSize;
+
+  // set the font matrix
+  if (tmPos >= 0) {
+    tok = (GString *)daToks->get(tmPos + 4);
+    tok->clear();
+    tok->appendf("{0:.4f}", x);
+    tok = (GString *)daToks->get(tmPos + 5);
+    tok->clear();
+    tok->appendf("{0:.4f}", y);
+  }
+  
+  // write the DA string
+  if (daToks) {
+    for (i = 0; i < daToks->getLength(); ++i) {
+      appearBuf->append((GString *)daToks->get(i))->append(' ');
+    }
+  }
+
+  // write the font matrix (if not part of the DA string)
+  if (tmPos < 0) {
+    appearBuf->appendf("1 0 0 1 {0:.4f} {1:.4f} Tm\n", x, y);
+  }
+
+  // write the text string
+  appearBuf->append('(');
+  for (i = 0; i < text2->getLength(); ++i) {
+    c = text2->getChar(i) & 0xff;
+    if (c == '(' || c == ')' || c == '\\') {
+      appearBuf->append('\\');
+      appearBuf->append(c);
+    } else if (c < 0x20 || c >= 0x80) {
+      appearBuf->appendf("\\{0:03o}", c);
+    } else {
+      appearBuf->append(c);
+    }
+  }
+  appearBuf->append(") Tj\n");
+
+  // cleanup
+  appearBuf->append("ET\n");
+  appearBuf->append("Q\n");
+
+  if (daToks) {
+    deleteGList(daToks, GString);
+  }
+  if (text2 != text) {
+    delete text2;
+  }
+}
+
 void Annot::draw(Gfx *gfx, GBool printing) {
   GBool oc, isLink;
 
@@ -1111,6 +1401,28 @@
   gfree(annots);
 }
 
+Annot *Annots::find(double x, double y) {
+  int i;
+
+  for (i = nAnnots - 1; i >= 0; --i) {
+    if (annots[i]->inRect(x, y)) {
+      return annots[i];
+    }
+  }
+  return NULL;
+}
+
+int Annots::findIdx(double x, double y) {
+  int i;
+
+  for (i = nAnnots - 1; i >= 0; --i) {
+    if (annots[i]->inRect(x, y)) {
+      return i;
+    }
+  }
+  return -1;
+}
+
 void Annots::generateAnnotAppearances() {
   int i;
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Annot.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -93,6 +93,10 @@
   double getYMax() { return yMax; }
   Object *getObject(Object *obj);
 
+  // Check if point is inside the annotation rectangle.
+  GBool inRect(double x, double y)
+    { return xMin <= x && x <= xMax && yMin <= y && y <= yMax; }
+
   // Get appearance object.
   Object *getAppearance(Object *obj) { return appearance.fetch(xref, obj); }
 
@@ -108,6 +112,7 @@
   void generateLineAppearance();
   void generatePolyLineAppearance();
   void generatePolygonAppearance();
+  void generateFreeTextAppearance();
   void setLineStyle(AnnotBorderStyle *bs, double *lineWidth);
   void setStrokeColor(double *color, int nComps);
   GBool setFillColor(Object *colorObj);
@@ -121,6 +126,8 @@
   void drawCircle(double cx, double cy, double r, const char *cmd);
   void drawCircleTopLeft(double cx, double cy, double r);
   void drawCircleBottomRight(double cx, double cy, double r);
+  void drawText(GString *text, GString *da, int quadding, double margin,
+		int rot);
 
   PDFDoc *doc;
   XRef *xref;			// the xref table for this PDF file
@@ -154,6 +161,11 @@
   int getNumAnnots() { return nAnnots; }
   Annot *getAnnot(int i) { return annots[i]; }
 
+  // If point <x>,<y> is in an annotation, return the associated
+  // annotation; else return NULL.
+  Annot *find(double x, double y);
+  int findIdx(double x, double y);
+
   // Generate an appearance stream for any non-form-field annotation
   // that is missing it.
   void generateAnnotAppearances();
@@ -162,6 +174,7 @@
 
   void scanFieldAppearances(Dict *node, Ref *ref, Dict *parent,
 			    Dict *acroForm);
+
   Annot *findAnnot(Ref *ref);
 
   PDFDoc *doc;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "Object.h"
 #include "Array.h"
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Array.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,9 @@
 #pragma interface
 #endif
 
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
 #include "Object.h"
 
 class XRef;
@@ -33,8 +36,13 @@
   ~Array();
 
   // Reference counting.
+#if MULTITHREADED
+  int incRef() { return gAtomicIncrement(&ref); }
+  int decRef() { return gAtomicDecrement(&ref); }
+#else
   int incRef() { return ++ref; }
   int decRef() { return --ref; }
+#endif
 
   // Get number of elements.
   int getLength() { return length; }
@@ -52,7 +60,11 @@
   Object *elems;		// array of elements
   int size;			// size of <elems> array
   int length;			// number of elements in array
+#if MULTITHREADED
+  GAtomicCounter ref;		// reference count
+#else
   int ref;			// reference count
+#endif
 };
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "FontEncodingTables.h"
 #include "BuiltinFont.h"
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFontTables.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFontTables.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/BuiltinFontTables.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,6 +8,7 @@
 
 #include <aconf.h>
 #include <stdlib.h>
+#include "gmempp.h"
 #include "FontEncodingTables.h"
 #include "BuiltinFontTables.h"
 

Added: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,228 @@
+#========================================================================
+#
+# xpdf/cmake-xpdf.txt
+#
+# CMake script for the Xpdf tools.
+#
+# Copyright 2015 Glyph & Cog, LLC
+#
+#========================================================================
+
+include_directories("${PROJECT_SOURCE_DIR}")
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/goo")
+include_directories("${PROJECT_SOURCE_DIR}/fofi")
+include_directories("${PROJECT_SOURCE_DIR}/splash")
+if (PNG_FOUND)
+  include_directories("${PNG_INCLUDE_DIRS}")
+  add_definitions("${PNG_DEFINITIONS}")
+endif ()
+if (HAVE_LCMS)
+  include_directories("${LCMS_INCLUDE_DIR}")
+  set(COLOR_MANAGER_SOURCE "ColorManager.cc")
+else ()
+  set(COLOR_MANAGER_SOURCE "")
+endif ()
+
+add_library(xpdf_objs OBJECT
+  AcroForm.cc
+  Annot.cc
+  Array.cc
+  BuiltinFont.cc
+  BuiltinFontTables.cc
+  Catalog.cc
+  CharCodeToUnicode.cc
+  CMap.cc
+  ${COLOR_MANAGER_SOURCE}
+  Decrypt.cc
+  Dict.cc
+  Error.cc
+  FontEncodingTables.cc
+  Form.cc
+  Function.cc
+  Gfx.cc
+  GfxFont.cc
+  GfxState.cc
+  GlobalParams.cc
+  JArithmeticDecoder.cc
+  JBIG2Stream.cc
+  JPXStream.cc
+  Lexer.cc
+  Link.cc
+  NameToCharCode.cc
+  Object.cc
+  OptionalContent.cc
+  Outline.cc
+  OutputDev.cc
+  Page.cc
+  Parser.cc
+  PDFDoc.cc
+  PDFDocEncoding.cc
+  PSTokenizer.cc
+  SecurityHandler.cc
+  Stream.cc
+  TextString.cc
+  UnicodeMap.cc
+  UnicodeTypeTable.cc
+  UTF8.cc
+  XFAForm.cc
+  XRef.cc
+  Zoox.cc
+)
+
+#--- object files needed by XpdfWidget
+
+if ((QT4_FOUND OR Qt5Widgets_FOUND)
+    AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
+
+  if (HIGHLIGHTED_REGIONS)
+    set(HIGHLIGHT_SRC "HighlightFile.cc")
+  else ()
+    set(HIGHLIGHT_SRC "")
+  endif ()
+
+  add_library(xpdf_widget_objs OBJECT
+    DisplayState.cc
+    PDFCore.cc
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    TileCache.cc
+    TileCompositor.cc
+    TileMap.cc
+    ${HIGHLIGHT_SRC}
+  )
+endif ()
+
+#--- pdftops
+
+if (HAVE_SPLASH)
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    SplashOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+else ()
+  add_executable(pdftops
+    $<TARGET_OBJECTS:xpdf_objs>
+    PreScanOutputDev.cc
+    PSOutputDev.cc
+    pdftops.cc
+  )
+  target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY})
+endif ()
+install(TARGETS pdftops RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
+
+#--- pdftotext
+
+add_executable(pdftotext
+  $<TARGET_OBJECTS:xpdf_objs>
+  TextOutputDev.cc
+  pdftotext.cc
+)
+target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdftotext RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
+
+#--- pdftohtml
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftohtml
+    $<TARGET_OBJECTS:xpdf_objs>
+    HTMLGen.cc
+    SplashOutputDev.cc
+    TextOutputDev.cc
+    pdftohtml.cc
+  )
+  target_link_libraries(pdftohtml goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftohtml RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfinfo
+
+add_executable(pdfinfo
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfinfo.cc
+)
+target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfinfo RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
+
+#--- pdffonts
+
+add_executable(pdffonts
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdffonts.cc
+)
+target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdffonts RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
+
+#--- pdfdetach
+
+add_executable(pdfdetach
+  $<TARGET_OBJECTS:xpdf_objs>
+  pdfdetach.cc
+)
+target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfdetach RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
+
+#--- pdftoppm
+
+if (HAVE_SPLASH)
+  add_executable(pdftoppm
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftoppm.cc
+  )
+  target_link_libraries(pdftoppm goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY})
+  install(TARGETS pdftoppm RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
+endif ()
+
+#--- pdftopng
+
+if (HAVE_SPLASH AND PNG_FOUND)
+  add_executable(pdftopng
+    $<TARGET_OBJECTS:xpdf_objs>
+    SplashOutputDev.cc
+    pdftopng.cc
+  )
+  target_link_libraries(pdftopng goo fofi splash
+                        ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
+                        ${DTYPE_LIBRARY}
+                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+  install(TARGETS pdftopng RUNTIME DESTINATION bin)
+  install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
+endif ()
+
+#--- pdfimages
+
+add_executable(pdfimages
+  $<TARGET_OBJECTS:xpdf_objs>
+  ImageOutputDev.cc
+  pdfimages.cc
+)
+target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY})
+install(TARGETS pdfimages RUNTIME DESTINATION bin)
+install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
+
+#--- xpdfrc man page
+
+install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "gfile.h"
 #include "GString.h"
 #include "Error.h"
@@ -200,9 +201,6 @@
     vector[i].cid = 0;
   }
   refCnt = 1;
-#if MULTITHREADED
-  gInitMutex(&mutex);
-#endif
 }
 
 CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) {
@@ -212,9 +210,6 @@
   wMode = wModeA;
   vector = NULL;
   refCnt = 1;
-#if MULTITHREADED
-  gInitMutex(&mutex);
-#endif
 }
 
 void CMap::useCMap(CMapCache *cache, char *useName) {
@@ -324,9 +319,6 @@
   if (vector) {
     freeCMapVector(vector);
   }
-#if MULTITHREADED
-  gDestroyMutex(&mutex);
-#endif
 }
 
 void CMap::freeCMapVector(CMapVectorEntry *vec) {
@@ -342,11 +334,9 @@
 
 void CMap::incRefCnt() {
 #if MULTITHREADED
-  gLockMutex(&mutex);
-#endif
+  gAtomicIncrement(&refCnt);
+#else
   ++refCnt;
-#if MULTITHREADED
-  gUnlockMutex(&mutex);
 #endif
 }
 
@@ -354,11 +344,9 @@
   GBool done;
 
 #if MULTITHREADED
-  gLockMutex(&mutex);
-#endif
+  done = gAtomicDecrement(&refCnt) == 0;
+#else
   done = --refCnt == 0;
-#if MULTITHREADED
-  gUnlockMutex(&mutex);
 #endif
   if (done) {
     delete this;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CMap.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -84,9 +84,10 @@
   int wMode;			// writing mode (0=horizontal, 1=vertical)
   CMapVectorEntry *vector;	// vector for first byte (NULL for
 				//   identity CMap)
+#if MULTITHREADED
+  GAtomicCounter refCnt;
+#else
   int refCnt;
-#if MULTITHREADED
-  GMutex mutex;
 #endif
 };
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <limits.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "gfile.h"
 #include "GList.h"
 #include "Object.h"
@@ -105,6 +106,9 @@
   baseURI = NULL;
   form = NULL;
   embeddedFiles = NULL;
+#if MULTITHREADED
+  gInitMutex(&pageMutex);
+#endif
 
   xref->getCatalog(&catDict);
   if (!catDict.isDict()) {
@@ -164,10 +168,17 @@
   // get the AcroForm dictionary
   catDict.dictLookup("AcroForm", &acroForm);
 
-  if (!acroForm.isNull()) {
-    form = Form::load(doc, this, &acroForm);
-  }
+  // get the NeedsRendering flag
+  // NB: Form::load() uses this value
+  needsRendering = catDict.dictLookup("NeedsRendering", &obj)->isBool() &&
+                   obj.getBool();
+  obj.free();
 
+  // create the Form
+  // (if acroForm is a null object, this will still create an AcroForm
+  // if there are unattached Widget-type annots)
+  form = Form::load(doc, this, &acroForm);
+
   // get the OCProperties dictionary
   catDict.dictLookup("OCProperties", &ocProperties);
 
@@ -199,6 +210,9 @@
     gfree(pages);
     gfree(pageRefs);
   }
+#if MULTITHREADED
+  gDestroyMutex(&pageMutex);
+#endif
   dests.free();
   nameTree.free();
   if (baseURI) {
@@ -218,24 +232,48 @@
 }
 
 Page *Catalog::getPage(int i) {
+  Page *page;
+
+#if MULTITHREADED
+  gLockMutex(&pageMutex);
+#endif
   if (!pages[i-1]) {
     loadPage(i);
   }
-  return pages[i-1];
+  page = pages[i-1];
+#if MULTITHREADED
+  gUnlockMutex(&pageMutex);
+#endif
+  return page;
 }
 
 Ref *Catalog::getPageRef(int i) {
+  Ref *pageRef;
+
+#if MULTITHREADED
+  gLockMutex(&pageMutex);
+#endif
   if (!pages[i-1]) {
     loadPage(i);
   }
-  return &pageRefs[i-1];
+  pageRef = &pageRefs[i-1];
+#if MULTITHREADED
+  gUnlockMutex(&pageMutex);
+#endif
+  return pageRef;
 }
 
 void Catalog::doneWithPage(int i) {
+#if MULTITHREADED
+  gLockMutex(&pageMutex);
+#endif
   if (pages[i-1]) {
     delete pages[i-1];
     pages[i-1] = NULL;
   }
+#if MULTITHREADED
+  gUnlockMutex(&pageMutex);
+#endif
 }
 
 GString *Catalog::readMetadata() {
@@ -266,13 +304,23 @@
 int Catalog::findPage(int num, int gen) {
   int i;
 
+#if MULTITHREADED
+  gLockMutex(&pageMutex);
+#endif
   for (i = 0; i < numPages; ++i) {
     if (!pages[i]) {
       loadPage(i+1);
     }
-    if (pageRefs[i].num == num && pageRefs[i].gen == gen)
+    if (pageRefs[i].num == num && pageRefs[i].gen == gen) {
+#if MULTITHREADED
+      gUnlockMutex(&pageMutex);
+#endif
       return i + 1;
+    }
   }
+#if MULTITHREADED
+  gUnlockMutex(&pageMutex);
+#endif
   return 0;
 }
 
@@ -284,19 +332,22 @@
   // try named destination dictionary then name tree
   found = gFalse;
   if (dests.isDict()) {
-    if (!dests.dictLookup(name->getCString(), &obj1)->isNull())
+    if (!dests.dictLookup(name->getCString(), &obj1)->isNull()) {
       found = gTrue;
-    else
+    } else {
       obj1.free();
+    }
   }
   if (!found && nameTree.isDict()) {
-    if (!findDestInTree(&nameTree, name, &obj1)->isNull())
+    if (!findDestInTree(&nameTree, name, &obj1)->isNull()) {
       found = gTrue;
-    else
+    } else {
       obj1.free();
+    }
   }
-  if (!found)
+  if (!found) {
     return NULL;
+  }
 
   // construct LinkDest
   dest = NULL;
@@ -303,10 +354,11 @@
   if (obj1.isArray()) {
     dest = new LinkDest(obj1.getArray());
   } else if (obj1.isDict()) {
-    if (obj1.dictLookup("D", &obj2)->isArray())
+    if (obj1.dictLookup("D", &obj2)->isArray()) {
       dest = new LinkDest(obj2.getArray());
-    else
+    } else {
       error(errSyntaxWarning, -1, "Bad named destination value");
+    }
     obj2.free();
   } else {
     error(errSyntaxWarning, -1, "Bad named destination value");
@@ -343,8 +395,9 @@
       name1.free();
     }
     names.free();
-    if (!found)
+    if (!found) {
       obj->initNull();
+    }
     return obj;
   }
   names.free();
@@ -374,8 +427,9 @@
   kids.free();
 
   // name was outside of ranges of all kids
-  if (!done)
+  if (!done) {
     obj->initNull();
+  }
 
   return obj;
 }
@@ -569,6 +623,46 @@
   }
 }
 
+Object *Catalog::getDestOutputProfile(Object *destOutProf) {
+  Object catDict, intents, intent, subtype;
+  int i;
+
+  if (!xref->getCatalog(&catDict)->isDict()) {
+    goto err1;
+  }
+  if (!catDict.dictLookup("OutputIntents", &intents)->isArray()) {
+    goto err2;
+  }
+  for (i = 0; i < intents.arrayGetLength(); ++i) {
+    intents.arrayGet(i, &intent);
+    if (!intent.isDict()) {
+      intent.free();
+      continue;
+    }
+    if (!intent.dictLookup("S", &subtype)->isName("GTS_PDFX")) {
+      subtype.free();
+      intent.free();
+      continue;
+    }
+    subtype.free();
+    if (!intent.dictLookup("DestOutputProfile", destOutProf)->isStream()) {
+      destOutProf->free();
+      intent.free();
+      goto err2;
+    }
+    intent.free();
+    intents.free();
+    catDict.free();
+    return destOutProf;
+  }
+
+ err2:
+  intents.free();
+ err1:
+  catDict.free();
+  return NULL;
+}
+
 void Catalog::readEmbeddedFileList(Dict *catDict) {
   Object obj1, obj2;
   char *touchedObjs;
@@ -733,3 +827,193 @@
   }
   return strObj;
 }
+
+TextString *Catalog::getPageLabel(int pageNum) {
+  Object catDict, node, pageLabelObj, start, prefix, style;
+  GString *label, *s;
+  TextString *ts;
+  int firstPageIndex, pageRangeNum;
+
+  if (!xref->getCatalog(&catDict)->isDict()) {
+    catDict.free();
+    return NULL;
+  }
+
+  label = NULL;
+  catDict.dictLookup("PageLabels", &node);
+  if (findPageLabel(&node, pageNum - 1, &pageLabelObj, &firstPageIndex)) {
+    if (pageLabelObj.isDict()) {
+      if (pageLabelObj.dictLookup("P", &prefix)->isString()) {
+	label = prefix.getString()->copy();
+      } else {
+	label = new GString();
+      }
+      prefix.free();
+
+      pageRangeNum = pageNum - firstPageIndex;
+      if (pageLabelObj.dictLookup("St", &start)->isInt()) {
+	pageRangeNum += start.getInt() - 1;
+      }
+      start.free();
+
+      if (pageLabelObj.dictLookup("S", &style)->isName()) {
+	if (style.isName("D")) {
+	  label->appendf("{0:d}", pageRangeNum);
+	} else if (style.isName("R")) {
+	  s = makeRomanNumeral(pageRangeNum, gTrue);
+	  label->append(s);
+	  delete s;
+	} else if (style.isName("r"))  {
+	  s = makeRomanNumeral(pageRangeNum, gFalse);
+	  label->append(s);
+	  delete s;
+	} else if (style.isName("A"))  {
+	  s = makeLetterLabel(pageRangeNum, gTrue);
+	  label->append(s);
+	  delete s;
+	} else if (style.isName("a"))  {
+	  s = makeLetterLabel(pageRangeNum, gFalse);
+	  label->append(s);
+	  delete s;
+	}
+      }
+      style.free();
+    }
+    pageLabelObj.free();
+  }
+  node.free();
+  catDict.free();
+
+  ts = new TextString(label);
+  delete label;
+  return ts;
+}
+
+GBool Catalog::findPageLabel(Object *node, int pageIndex,
+			     Object *pageLabelObj, int *firstPageIndex) {
+  Object limits, limit, nums, num, kids, kid;
+  int i;
+
+  if (!node->isDict()) {
+    return gFalse;
+  }
+
+  // we only check the lower limit because page labels are organized
+  // into ranges based on their first page number -- the Nums and Kids
+  // arrays are searched backward for the same reason
+  if (node->dictLookup("Limits", &limits)->isArray() &&
+      limits.arrayGetLength() == 2)  {
+    if (limits.arrayGet(0, &limit)->isInt()) {
+      if (pageIndex < limit.getInt()) {
+	limit.free();
+	limits.free();
+	return gFalse;
+      }
+    }
+    limit.free();
+  }
+  limits.free();
+
+  if (node->dictLookup("Nums", &nums)->isArray()) {
+    for (i = nums.arrayGetLength() / 2 - 1; i >= 0; --i) {
+      if (nums.arrayGet(2*i, &num)->isInt()) {
+	if (num.getInt() <= pageIndex) {
+	  nums.arrayGet(2*i + 1, pageLabelObj);
+	  *firstPageIndex = num.getInt();
+	  num.free();
+	  nums.free();
+	  return gTrue;
+	}
+      } else {
+	error(errSyntaxError, -1, "Invalid key in page label number tree");
+	num.free();
+	nums.free();
+	return gFalse;
+      }
+      num.free();
+    }
+  }
+  nums.free();
+
+  if (node->dictLookup("Kids", &kids)->isArray()) {
+    for (i = kids.arrayGetLength() - 1; i >= 0; --i) {
+      if (kids.arrayGet(i, &kid)->isDict()) {
+	if (findPageLabel(&kid, pageIndex, pageLabelObj, firstPageIndex)) {
+	  kid.free();
+	  kids.free();
+	  return gTrue;
+	}
+      }
+      kid.free();
+    }
+  }
+  kids.free();
+
+  return gFalse;
+}
+
+GString *Catalog::makeRomanNumeral(int num, GBool uppercase) {
+  GString *s;
+
+  s = new GString();
+  while (num >= 1000) {
+    s->append(uppercase ? 'M' : 'm');
+    num -= 1000;
+  }
+  if (num >= 900) {
+    s->append(uppercase ? "CM" : "cm");
+    num -= 900;
+  } else if (num >= 500) {
+    s->append(uppercase ? 'D' : 'd');
+    num -= 500;
+  } else if (num >= 400) {
+    s->append(uppercase ? "CD" : "cd");
+    num -= 400;
+  }
+  while (num >= 100) {
+    s->append(uppercase ? 'C' : 'c');
+    num -= 100;
+  }
+  if (num >= 90) {
+    s->append(uppercase ? "XC" : "xc");
+    num -= 90;
+  } else if (num >= 50) {
+    s->append(uppercase ? 'L' : 'l');
+    num -= 50;
+  } else if (num >= 40) {
+    s->append(uppercase ? "XL" : "xl");
+    num -= 40;
+  }
+  while (num >= 10) {
+    s->append(uppercase ? 'X' : 'x');
+    num -= 10;
+  }
+  if (num >= 9) {
+    s->append(uppercase ? "IX" : "ix");
+    num -= 9;
+  } else if (num >= 5) {
+    s->append(uppercase ? 'V' : 'v');
+    num -= 5;
+  } else if (num >= 4) {
+    s->append(uppercase ? "IV" : "iv");
+    num -= 4;
+  }
+  while (num >= 1) {
+    s->append(uppercase ? 'I' : 'i');
+    num -= 1;
+  }
+  return s;
+}
+
+GString *Catalog::makeLetterLabel(int num, GBool uppercase) {
+  GString *s;
+  int m, n, i;
+
+  m = (num - 1) / 26 + 1;
+  n = (num - 1) % 26;
+  s = new GString();
+  for (i = 0; i < m; ++i) {
+    s->append((char)((uppercase ? 'A' : 'a') + n));
+  }
+  return s;
+}

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Catalog.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,9 @@
 #pragma interface
 #endif
 
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
 #include "CharTypes.h"
 
 class GList;
@@ -27,6 +30,7 @@
 class LinkDest;
 class PageTreeNode;
 class Form;
+class TextString;
 
 //------------------------------------------------------------------------
 // Catalog
@@ -85,8 +89,13 @@
 
   Form *getForm() { return form; }
 
+  GBool getNeedsRendering() { return needsRendering; }
+
   Object *getOCProperties() { return &ocProperties; }
 
+  // Return the DestOutputProfile stream, or NULL if there isn't one.
+  Object *getDestOutputProfile(Object *destOutProf);
+
   // Get the list of embedded files.
   int getNumEmbeddedFiles();
   Unicode *getEmbeddedFileName(int idx);
@@ -94,6 +103,10 @@
   Object *getEmbeddedFileStreamRef(int idx);
   Object *getEmbeddedFileStreamObj(int idx, Object *strObj);
 
+  // Get the page label for page number [pageNum].  Returns NULL if
+  // the PDF file doesn't have page labels.
+  TextString *getPageLabel(int pageNum);
+
 private:
 
   PDFDoc *doc;
@@ -101,8 +114,10 @@
   PageTreeNode *pageTree;	// the page tree
   Page **pages;			// array of pages
   Ref *pageRefs;		// object ID for each page
+#if MULTITHREADED
+  GMutex pageMutex;
+#endif
   int numPages;			// number of pages
-  int pagesSize;		// size of pages array
   Object dests;			// named destination dictionary
   Object nameTree;		// name tree
   GString *baseURI;		// base URI for URI-type links
@@ -110,6 +125,7 @@
   Object structTreeRoot;	// structure tree root dictionary
   Object outline;		// outline dictionary
   Object acroForm;		// AcroForm dictionary
+  GBool needsRendering;		// NeedsRendering flag
   Form *form;			// parsed form
   Object ocProperties;		// OCProperties dictionary
   GList *embeddedFiles;		// embedded file list [EmbeddedFile]
@@ -125,6 +141,10 @@
   void readFileAttachmentAnnots(Object *pageNodeRef,
 				char *touchedObjs);
   void readEmbeddedFile(Object *fileSpec, Object *name1);
+  GBool findPageLabel(Object *node, int pageIndex,
+		      Object *pageLabelObj, int *firstPageIndex);
+  GString *makeRomanNumeral(int num, GBool uppercase);
+  GString *makeLetterLabel(int num, GBool uppercase);
 };
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "gfile.h"
 #include "GString.h"
 #include "Error.h"
@@ -34,18 +35,17 @@
 
 //------------------------------------------------------------------------
 
-static int getCharFromString(void *data) {
-  char *p;
-  int c;
+struct GStringIndex {
+  GString *s;
+  int i;
+};
 
-  p = *(char **)data;
-  if (*p) {
-    c = *p++;
-    *(char **)data = p;
-  } else {
-    c = EOF;
+static int getCharFromGString(void *data) {
+  GStringIndex *idx = (GStringIndex *)data;
+  if (idx->i >= idx->s->getLength()) {
+    return EOF;
   }
-  return c;
+  return idx->s->getChar(idx->i++) & 0xff;
 }
 
 static int getCharFromFile(void *data) {
@@ -234,23 +234,28 @@
 
 CharCodeToUnicode *CharCodeToUnicode::parseCMap(GString *buf, int nBits) {
   CharCodeToUnicode *ctu;
-  char *p;
+  GStringIndex idx;
 
   ctu = new CharCodeToUnicode(NULL);
-  p = buf->getCString();
-  ctu->parseCMap1(&getCharFromString, &p, nBits);
+  idx.s = buf;
+  idx.i = 0;
+  if (!ctu->parseCMap1(&getCharFromGString, &idx, nBits)) {
+    delete ctu;
+    return NULL;
+  }
   return ctu;
 }
 
 void CharCodeToUnicode::mergeCMap(GString *buf, int nBits) {
-  char *p;
+  GStringIndex idx;
 
-  p = buf->getCString();
-  parseCMap1(&getCharFromString, &p, nBits);
+  idx.s = buf;
+  idx.i = 0;
+  parseCMap1(&getCharFromGString, &idx, nBits);
 }
 
-void CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
-				   int nBits) {
+GBool CharCodeToUnicode::parseCMap1(int (*getCharFunc)(void *), void *data,
+				    int nBits) {
   PSTokenizer *pst;
   char tok1[256], tok2[256], tok3[256];
   int n1, n2, n3;
@@ -258,7 +263,9 @@
   CharCode maxCode, code1, code2;
   GString *name;
   FILE *f;
+  GBool ok;
 
+  ok = gFalse;
   maxCode = (nBits == 8) ? 0xff : (nBits == 16) ? 0xffff : 0xffffffff;
   pst = new PSTokenizer(getCharFunc, data);
   pst->getToken(tok1, sizeof(tok1), &n1);
@@ -267,7 +274,9 @@
       if (tok1[0] == '/') {
 	name = new GString(tok1 + 1);
 	if ((f = globalParams->findToUnicodeFile(name))) {
-	  parseCMap1(&getCharFromFile, f, nBits);
+	  if (parseCMap1(&getCharFromFile, f, nBits)) {
+	    ok = gTrue;
+	  }
 	  fclose(f);
 	} else {
 	  error(errSyntaxError, -1,
@@ -305,6 +314,7 @@
 		"Invalid entry in bfchar block in ToUnicode CMap");
 	}
 	addMapping(code1, tok2 + 1, n2 - 2, 0);
+	ok = gTrue;
       }
       pst->getToken(tok1, sizeof(tok1), &n1);
     } else if (!strcmp(tok2, "beginbfrange")) {
@@ -350,6 +360,7 @@
 	      if (code1 + i <= code2) {
 		tok1[n1 - 1] = '\0';
 		addMapping(code1 + i, tok1 + 1, n1 - 2, 0);
+		ok = gTrue;
 	      }
 	    } else {
 	      error(errSyntaxWarning, -1,
@@ -361,8 +372,8 @@
 	  tok3[n3 - 1] = '\0';
 	  for (i = 0; code1 <= code2; ++code1, ++i) {
 	    addMapping(code1, tok3 + 1, n3 - 2, i);
+	    ok = gTrue;
 	  }
-
 	} else {
 	  error(errSyntaxWarning, -1,
 		"Illegal entry in bfrange block in ToUnicode CMap");
@@ -369,11 +380,91 @@
 	}
       }
       pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "begincidchar")) {
+      // the begincidchar operator is not allowed in ToUnicode CMaps,
+      // but some buggy PDF generators incorrectly use
+      // code-to-CID-type CMaps here
+      error(errSyntaxWarning, -1,
+	    "Invalid 'begincidchar' operator in ToUnicode CMap");
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+	if (!strcmp(tok1, "endcidchar")) {
+	  break;
+	}
+	if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+	    !strcmp(tok2, "endcidchar")) {
+	  error(errSyntaxWarning, -1,
+		"Illegal entry in cidchar block in ToUnicode CMap");
+	  break;
+	}
+	if (!(tok1[0] == '<' && tok1[n1 - 1] == '>')) {
+	  error(errSyntaxWarning, -1,
+		"Illegal entry in cidchar block in ToUnicode CMap");
+	  continue;
+	}
+	tok1[n1 - 1] = '\0';
+	if (!parseHex(tok1 + 1, n1 - 2, &code1)) {
+	  error(errSyntaxWarning, -1,
+		"Illegal entry in cidchar block in ToUnicode CMap");
+	  continue;
+	}
+	if (code1 > maxCode) {
+	  error(errSyntaxWarning, -1,
+		"Invalid entry in cidchar block in ToUnicode CMap");
+	}
+	addMappingInt(code1, atoi(tok2));
+	ok = gTrue;
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
+    } else if (!strcmp(tok2, "begincidrange")) {
+      // the begincidrange operator is not allowed in ToUnicode CMaps,
+      // but some buggy PDF generators incorrectly use
+      // code-to-CID-type CMaps here
+      error(errSyntaxWarning, -1,
+	    "Invalid 'begincidrange' operator in ToUnicode CMap");
+      while (pst->getToken(tok1, sizeof(tok1), &n1)) {
+	if (!strcmp(tok1, "endcidrange")) {
+	  break;
+	}
+	if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
+	    !strcmp(tok2, "endcidrange") ||
+	    !pst->getToken(tok3, sizeof(tok3), &n3) ||
+	    !strcmp(tok3, "endcidrange")) {
+	  error(errSyntaxWarning, -1,
+		"Illegal entry in cidrange block in ToUnicode CMap");
+	  break;
+	}
+	if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
+	      tok2[0] == '<' && tok2[n2 - 1] == '>')) {
+	  error(errSyntaxWarning,
+		-1, "Illegal entry in cidrange block in ToUnicode CMap");
+	  continue;
+	}
+	tok1[n1 - 1] = tok2[n2 - 1] = '\0';
+	if (!parseHex(tok1 + 1, n1 - 2, &code1) ||
+	    !parseHex(tok2 + 1, n2 - 2, &code2)) {
+	  error(errSyntaxWarning, -1,
+		"Illegal entry in cidrange block in ToUnicode CMap");
+	  continue;
+	}
+	if (code1 > maxCode || code2 > maxCode) {
+	  error(errSyntaxWarning, -1,
+		"Invalid entry in cidrange block in ToUnicode CMap");
+	  if (code2 > maxCode) {
+	    code2 = maxCode;
+	  }
+	}
+	for (i = atoi(tok3); code1 <= code2; ++code1, ++i) {
+	  addMappingInt(code1, i);
+	  ok = gTrue;
+	}
+      }
+      pst->getToken(tok1, sizeof(tok1), &n1);
     } else {
       strcpy(tok1, tok2);
     }
   }
   delete pst;
+  return ok;
 }
 
 void CharCodeToUnicode::addMapping(CharCode code, char *uStr, int n,
@@ -426,6 +517,28 @@
   }
 }
 
+void CharCodeToUnicode::addMappingInt(CharCode code, Unicode u) {
+  CharCode oldLen, i;
+
+  if (code > 0xffffff) {
+    // This is an arbitrary limit to avoid integer overflow issues.
+    // (I've seen CMaps with mappings for <ffffffff>.)
+    return;
+  }
+  if (code >= mapLen) {
+    oldLen = mapLen;
+    mapLen = mapLen ? 2 * mapLen : 256;
+    if (code >= mapLen) {
+      mapLen = (code + 256) & ~255;
+    }
+    map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode));
+    for (i = oldLen; i < mapLen; ++i) {
+      map[i] = 0;
+    }
+  }
+  map[code] = u;
+}
+
 CharCodeToUnicode::CharCodeToUnicode() {
   tag = NULL;
   map = NULL;
@@ -433,9 +546,6 @@
   sMap = NULL;
   sMapLen = sMapSize = 0;
   refCnt = 1;
-#if MULTITHREADED
-  gInitMutex(&mutex);
-#endif
 }
 
 CharCodeToUnicode::CharCodeToUnicode(GString *tagA) {
@@ -450,9 +560,6 @@
   sMap = NULL;
   sMapLen = sMapSize = 0;
   refCnt = 1;
-#if MULTITHREADED
-  gInitMutex(&mutex);
-#endif
 }
 
 CharCodeToUnicode::CharCodeToUnicode(GString *tagA, Unicode *mapA,
@@ -471,9 +578,6 @@
   sMapLen = sMapLenA;
   sMapSize = sMapSizeA;
   refCnt = 1;
-#if MULTITHREADED
-  gInitMutex(&mutex);
-#endif
 }
 
 CharCodeToUnicode::~CharCodeToUnicode() {
@@ -482,18 +586,13 @@
   }
   gfree(map);
   gfree(sMap);
-#if MULTITHREADED
-  gDestroyMutex(&mutex);
-#endif
 }
 
 void CharCodeToUnicode::incRefCnt() {
 #if MULTITHREADED
-  gLockMutex(&mutex);
-#endif
+  gAtomicIncrement(&refCnt);
+#else
   ++refCnt;
-#if MULTITHREADED
-  gUnlockMutex(&mutex);
 #endif
 }
 
@@ -501,11 +600,9 @@
   GBool done;
 
 #if MULTITHREADED
-  gLockMutex(&mutex);
-#endif
+  done = gAtomicDecrement(&refCnt) == 0;
+#else
   done = --refCnt == 0;
-#if MULTITHREADED
-  gUnlockMutex(&mutex);
 #endif
   if (done) {
     delete this;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CharCodeToUnicode.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -78,8 +78,9 @@
 
 private:
 
-  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
+  GBool parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
   void addMapping(CharCode code, char *uStr, int n, int offset);
+  void addMappingInt(CharCode code, Unicode u);
   CharCodeToUnicode();
   CharCodeToUnicode(GString *tagA);
   CharCodeToUnicode(GString *tagA, Unicode *mapA,
@@ -92,9 +93,10 @@
   CharCode mapLen;
   CharCodeToUnicodeString *sMap;
   int sMapLen, sMapSize;
+#if MULTITHREADED
+  GAtomicCounter refCnt;
+#else
   int refCnt;
-#if MULTITHREADED
-  GMutex mutex;
 #endif
 };
 

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,61 +0,0 @@
-//========================================================================
-//
-// CoreOutputDev.cc
-//
-// Copyright 2004 Glyph & Cog, LLC
-//
-//========================================================================
-
-#include <aconf.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include "Object.h"
-#include "TextOutputDev.h"
-#include "CoreOutputDev.h"
-
-//------------------------------------------------------------------------
-// CoreOutputDev
-//------------------------------------------------------------------------
-
-CoreOutputDev::CoreOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
-			     GBool reverseVideoA, SplashColorPtr paperColorA,
-			     GBool incrementalUpdateA,
-			     CoreOutRedrawCbk redrawCbkA,
-			     void *redrawCbkDataA):
-  SplashOutputDev(colorModeA, bitmapRowPadA, reverseVideoA, paperColorA)
-{
-  incrementalUpdate = incrementalUpdateA;
-  redrawCbk = redrawCbkA;
-  redrawCbkData = redrawCbkDataA;
-}
-
-CoreOutputDev::~CoreOutputDev() {
-}
-
-void CoreOutputDev::endPage() {
-  SplashOutputDev::endPage();
-  if (!incrementalUpdate) {
-    (*redrawCbk)(redrawCbkData, 0, 0, getBitmapWidth(), getBitmapHeight(),
-		 gTrue);
-  }
-}
-
-void CoreOutputDev::dump() {
-  int x0, y0, x1, y1;
-
-  if (incrementalUpdate) {
-    getModRegion(&x0, &y0, &x1, &y1);
-    clearModRegion();
-    if (x1 >= x0 && y1 >= y0) {
-      (*redrawCbk)(redrawCbkData, x0, y0, x1, y1, gFalse);
-    }
-  }
-}
-
-void CoreOutputDev::clear() {
-  startDoc(NULL);
-  startPage(0, NULL);
-}

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/CoreOutputDev.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,61 +0,0 @@
-//========================================================================
-//
-// CoreOutputDev.h
-//
-// Copyright 2004 Glyph & Cog, LLC
-//
-//========================================================================
-
-#ifndef COREOUTPUTDEV_H
-#define COREOUTPUTDEV_H
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#include "SplashTypes.h"
-#include "SplashOutputDev.h"
-
-class TextPage;
-
-//------------------------------------------------------------------------
-
-typedef void (*CoreOutRedrawCbk)(void *data, int x0, int y0, int x1, int y1,
-				 GBool composited);
-
-//------------------------------------------------------------------------
-// CoreOutputDev
-//------------------------------------------------------------------------
-
-class CoreOutputDev: public SplashOutputDev {
-public:
-
-  CoreOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
-		GBool reverseVideoA, SplashColorPtr paperColorA,
-		GBool incrementalUpdateA,
-		CoreOutRedrawCbk redrawCbkA,
-		void *redrawCbkDataA);
-
-  virtual ~CoreOutputDev();
-
-  //----- initialization and control
-
-  // End a page.
-  virtual void endPage();
-
-  // Dump page contents to display.
-  virtual void dump();
-
-  //----- special access
-
-  // Clear out the document (used when displaying an empty window).
-  void clear();
-
-private:
-
-  GBool incrementalUpdate;      // incrementally update the display?
-  CoreOutRedrawCbk redrawCbk;
-  void *redrawCbkData;
-};
-
-#endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "Decrypt.h"
 
 static void aes256KeyExpansion(DecryptAES256State *s,
@@ -328,14 +329,18 @@
 // DecryptStream
 //------------------------------------------------------------------------
 
-DecryptStream::DecryptStream(Stream *strA, Guchar *fileKey,
-			     CryptAlgorithm algoA, int keyLength,
-			     int objNum, int objGen):
+DecryptStream::DecryptStream(Stream *strA, Guchar *fileKeyA,
+			     CryptAlgorithm algoA, int keyLengthA,
+			     int objNumA, int objGenA):
   FilterStream(strA)
 {
   int i;
 
+  memcpy(fileKey, fileKeyA, keyLengthA);
   algo = algoA;
+  keyLength = keyLengthA;
+  objNum = objNumA;
+  objGen = objGenA;
 
   // construct object key
   for (i = 0; i < keyLength; ++i) {
@@ -378,6 +383,11 @@
   delete str;
 }
 
+Stream *DecryptStream::copy() {
+  return new DecryptStream(str->copy(), fileKey, algo, keyLength,
+			   objNum, objGen);
+}
+
 void DecryptStream::reset() {
   str->reset();
   switch (algo) {
@@ -1349,46 +1359,46 @@
 typedef unsigned long long SHA512Uint64;
 
 static SHA512Uint64 sha512K[80] = {
-  0x428a2f98d728ae22LL, 0x7137449123ef65cdLL,
-  0xb5c0fbcfec4d3b2fLL, 0xe9b5dba58189dbbcLL,
-  0x3956c25bf348b538LL, 0x59f111f1b605d019LL,
-  0x923f82a4af194f9bLL, 0xab1c5ed5da6d8118LL,
-  0xd807aa98a3030242LL, 0x12835b0145706fbeLL,
-  0x243185be4ee4b28cLL, 0x550c7dc3d5ffb4e2LL,
-  0x72be5d74f27b896fLL, 0x80deb1fe3b1696b1LL,
-  0x9bdc06a725c71235LL, 0xc19bf174cf692694LL,
-  0xe49b69c19ef14ad2LL, 0xefbe4786384f25e3LL,
-  0x0fc19dc68b8cd5b5LL, 0x240ca1cc77ac9c65LL,
-  0x2de92c6f592b0275LL, 0x4a7484aa6ea6e483LL,
-  0x5cb0a9dcbd41fbd4LL, 0x76f988da831153b5LL,
-  0x983e5152ee66dfabLL, 0xa831c66d2db43210LL,
-  0xb00327c898fb213fLL, 0xbf597fc7beef0ee4LL,
-  0xc6e00bf33da88fc2LL, 0xd5a79147930aa725LL,
-  0x06ca6351e003826fLL, 0x142929670a0e6e70LL,
-  0x27b70a8546d22ffcLL, 0x2e1b21385c26c926LL,
-  0x4d2c6dfc5ac42aedLL, 0x53380d139d95b3dfLL,
-  0x650a73548baf63deLL, 0x766a0abb3c77b2a8LL,
-  0x81c2c92e47edaee6LL, 0x92722c851482353bLL,
-  0xa2bfe8a14cf10364LL, 0xa81a664bbc423001LL,
-  0xc24b8b70d0f89791LL, 0xc76c51a30654be30LL,
-  0xd192e819d6ef5218LL, 0xd69906245565a910LL,
-  0xf40e35855771202aLL, 0x106aa07032bbd1b8LL,
-  0x19a4c116b8d2d0c8LL, 0x1e376c085141ab53LL,
-  0x2748774cdf8eeb99LL, 0x34b0bcb5e19b48a8LL,
-  0x391c0cb3c5c95a63LL, 0x4ed8aa4ae3418acbLL,
-  0x5b9cca4f7763e373LL, 0x682e6ff3d6b2b8a3LL,
-  0x748f82ee5defb2fcLL, 0x78a5636f43172f60LL,
-  0x84c87814a1f0ab72LL, 0x8cc702081a6439ecLL,
-  0x90befffa23631e28LL, 0xa4506cebde82bde9LL,
-  0xbef9a3f7b2c67915LL, 0xc67178f2e372532bLL,
-  0xca273eceea26619cLL, 0xd186b8c721c0c207LL,
-  0xeada7dd6cde0eb1eLL, 0xf57d4f7fee6ed178LL,
-  0x06f067aa72176fbaLL, 0x0a637dc5a2c898a6LL,
-  0x113f9804bef90daeLL, 0x1b710b35131c471bLL,
-  0x28db77f523047d84LL, 0x32caab7b40c72493LL,
-  0x3c9ebe0a15c9bebcLL, 0x431d67c49c100d4cLL,
-  0x4cc5d4becb3e42b6LL, 0x597f299cfc657e2aLL,
-  0x5fcb6fab3ad6faecLL, 0x6c44198c4a475817LL
+  0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
+  0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
+  0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
+  0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
+  0xd807aa98a3030242ULL, 0x12835b0145706fbeULL,
+  0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
+  0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL,
+  0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
+  0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
+  0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
+  0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL,
+  0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
+  0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL,
+  0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
+  0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
+  0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
+  0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL,
+  0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
+  0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL,
+  0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
+  0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
+  0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
+  0xd192e819d6ef5218ULL, 0xd69906245565a910ULL,
+  0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
+  0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL,
+  0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
+  0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
+  0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
+  0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL,
+  0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
+  0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL,
+  0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
+  0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
+  0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
+  0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL,
+  0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
+  0x28db77f523047d84ULL, 0x32caab7b40c72493ULL,
+  0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
+  0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
+  0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
 };
 
 static inline SHA512Uint64 rotr64(SHA512Uint64 x, Guint n) {

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Decrypt.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -80,10 +80,11 @@
 class DecryptStream: public FilterStream {
 public:
 
-  DecryptStream(Stream *strA, Guchar *fileKey,
-		CryptAlgorithm algoA, int keyLength,
-		int objNum, int objGen);
+  DecryptStream(Stream *strA, Guchar *fileKeyA,
+		CryptAlgorithm algoA, int keyLengthA,
+		int objNumA, int objGenA);
   virtual ~DecryptStream();
+  virtual Stream *copy();
   virtual StreamKind getKind() { return strWeird; }
   virtual void reset();
   virtual int getChar();
@@ -93,7 +94,10 @@
 
 private:
 
+  Guchar fileKey[32];
   CryptAlgorithm algo;
+  int keyLength;
+  int objNum, objGen;
   int objKeyLength;
   Guchar objKey[32];
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stddef.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "Object.h"
 #include "XRef.h"
 #include "Dict.h"

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Dict.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,9 @@
 #pragma interface
 #endif
 
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
 #include "Object.h"
 
 struct DictEntry;
@@ -33,8 +36,13 @@
   ~Dict();
 
   // Reference counting.
+#if MULTITHREADED
+  int incRef() { return gAtomicIncrement(&ref); }
+  int decRef() { return gAtomicDecrement(&ref); }
+#else
   int incRef() { return ++ref; }
   int decRef() { return --ref; }
+#endif
 
   // Get number of entries.
   int getLength() { return length; }
@@ -67,7 +75,11 @@
   DictEntry **hashTab;		// hash table pointers
   int size;			// size of <entries> array
   int length;			// number of entries in dictionary
+#if MULTITHREADED
+  GAtomicCounter ref;		// reference count
+#else
   int ref;			// reference count
+#endif
 
   DictEntry *find(const char *key);
   void expand();

Added: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.cc	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,223 @@
+//========================================================================
+//
+// DisplayState.cc
+//
+// Copyright 2014 Glyph & Cog, LLC
+//
+//========================================================================
+
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
+#pragma implementation
+#endif
+
+#include <stdlib.h>
+#include "gmempp.h"
+#include "GString.h"
+#include "GList.h"
+#include "TileMap.h"
+#include "TileCache.h"
+#include "TileCompositor.h"
+#include "DisplayState.h"
+
+
+//------------------------------------------------------------------------
+// DisplayState
+//------------------------------------------------------------------------
+
+DisplayState::DisplayState(int maxTileWidthA, int maxTileHeightA,
+			   int tileCacheSizeA, int nWorkerThreadsA,
+			   SplashColorMode colorModeA, int bitmapRowPadA) {
+  int i;
+
+  maxTileWidth = maxTileWidthA;
+  maxTileHeight = maxTileHeightA;
+  tileCacheSize = tileCacheSizeA;
+  nWorkerThreads = nWorkerThreadsA;
+  colorMode = colorModeA;
+  bitmapRowPad = bitmapRowPadA;
+
+  tileMap = NULL;
+  tileCache = NULL;
+  tileCompositor = NULL;
+
+  for (i = 0; i < splashColorModeNComps[colorMode]; ++i) {
+    paperColor[i] = 0xff;
+    matteColor[i] = 0x80;
+  }
+  if (colorMode == splashModeRGB8 || colorMode == splashModeBGR8) {
+    selectColor[0] = 0x80;
+    selectColor[1] = 0x80;
+    selectColor[2] = 0xff;
+  } else {
+    for (i = 0; i < splashColorModeNComps[colorMode]; ++i) {
+      selectColor[i] = 0xa0;
+    }
+  }
+  reverseVideo = gFalse;
+
+  doc = NULL;
+
+  winW = winH = 100;
+  displayMode = displayContinuous;
+  zoom = 100;
+  rotate = 0;
+  scrollPage = 0;
+  scrollX = scrollY = 0;
+
+  selectRects = NULL;
+
+
+}
+
+DisplayState::~DisplayState() {
+  if (selectRects) {
+    deleteGList(selectRects, SelectRect);
+  }
+}
+
+void DisplayState::setPaperColor(SplashColorPtr paperColorA) {
+  splashColorCopy(paperColor, paperColorA);
+  tileCache->paperColorChanged();
+  tileCompositor->paperColorChanged();
+}
+
+void DisplayState::setMatteColor(SplashColorPtr matteColorA) {
+  splashColorCopy(matteColor, matteColorA);
+  tileCompositor->matteColorChanged();
+}
+
+void DisplayState::setSelectColor(SplashColorPtr selectColorA) {
+  splashColorCopy(selectColor, selectColorA);
+  tileCompositor->selectColorChanged();
+}
+
+void DisplayState::setReverseVideo(GBool reverseVideoA) {
+  if (reverseVideo != reverseVideoA) {
+    reverseVideo = reverseVideoA;
+    tileCache->reverseVideoChanged();
+    tileCompositor->reverseVideoChanged();
+  }
+}
+
+void DisplayState::setDoc(PDFDoc *docA) {
+  doc = docA;
+  tileMap->docChanged();
+  tileCache->docChanged();
+  tileCompositor->docChanged();
+}
+
+void DisplayState::setWindowSize(int winWA, int winHA) {
+  if (winW != winWA || winH != winHA) {
+    winW = winWA;
+    winH = winHA;
+    tileMap->windowSizeChanged();
+    tileCompositor->windowSizeChanged();
+  }
+}
+
+void DisplayState::setDisplayMode(DisplayMode displayModeA) {
+  if (displayMode != displayModeA) {
+    displayMode = displayModeA;
+    tileMap->displayModeChanged();
+    tileCompositor->displayModeChanged();
+  }
+}
+
+void DisplayState::setZoom(double zoomA) {
+  if (zoom != zoomA) {
+    zoom = zoomA;
+    tileMap->zoomChanged();
+    tileCompositor->zoomChanged();
+  }
+}
+
+void DisplayState::setRotate(int rotateA) {
+  if (rotate != rotateA) {
+    rotate = rotateA;
+    tileMap->rotateChanged();
+    tileCompositor->rotateChanged();
+  }
+}
+
+void DisplayState::setScrollPosition(int scrollPageA,
+				     int scrollXA, int scrollYA) {
+  if (scrollPage != scrollPageA ||
+      scrollX != scrollXA ||
+      scrollY != scrollYA) {
+    scrollPage = scrollPageA;
+    scrollX = scrollXA;
+    scrollY = scrollYA;
+    tileMap->scrollPositionChanged();
+    tileCompositor->scrollPositionChanged();
+  }
+}
+
+void DisplayState::setSelection(int selectPage,
+				double selectX0, double selectY0,
+				double selectX1, double selectY1) {
+  GList *rects;
+  SelectRect *rect;
+
+  rect = new SelectRect(selectPage, selectX0, selectY0, selectX1, selectY1);
+  rects = new GList();
+  rects->append(rect);
+  setSelection(rects);
+}
+
+void DisplayState::setSelection(GList *selectRectsA) {
+  SelectRect *rect, *rectA;
+  int i;
+
+  if (!selectRects && !selectRectsA) {
+    return;
+  }
+  if (selectRects && selectRectsA &&
+      selectRects->getLength() == selectRectsA->getLength()) {
+    for (i = 0; i < selectRects->getLength(); ++i) {
+      rect = (SelectRect *)selectRects->get(i);
+      rectA = (SelectRect *)selectRectsA->get(i);
+      if (*rect != *rectA) {
+	break;
+      }
+    }
+    if (i == selectRects->getLength()) {
+      deleteGList(selectRectsA, SelectRect);
+      return;
+    }
+  }
+  if (selectRects) {
+    deleteGList(selectRects, SelectRect);
+  }
+  selectRects = selectRectsA;
+  tileCompositor->selectionChanged();
+}
+
+void DisplayState::clearSelection() {
+  setSelection(NULL);
+}
+
+int DisplayState::getNumSelectRects() {
+  if (!selectRects) {
+    return 0;
+  }
+  return selectRects->getLength();
+}
+
+SelectRect *DisplayState::getSelectRect(int idx) {
+  return (SelectRect *)selectRects->get(idx);
+}
+
+void DisplayState::optionalContentChanged() {
+  tileCache->optionalContentChanged();
+  tileCompositor->optionalContentChanged();
+}
+
+
+
+void DisplayState::forceRedraw() {
+  tileMap->forceRedraw();
+  tileCache->forceRedraw();
+  tileCompositor->forceRedraw();
+}

Added: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h	                        (rev 0)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -0,0 +1,173 @@
+//========================================================================
+//
+// DisplayState.h
+//
+// Copyright 2014 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef DISPLAYSTATE_H
+#define DISPLAYSTATE_H
+
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
+#pragma interface
+#endif
+
+#include "gtypes.h"
+#include "SplashTypes.h"
+
+class GString;
+class GList;
+class PDFDoc;
+class TileMap;
+class TileCache;
+class TileCompositor;
+
+//------------------------------------------------------------------------
+// zoom level
+//------------------------------------------------------------------------
+
+// positive zoom levels are percentage of 72 dpi
+// (e.g., 50 means 36dpi, 100 means 72dpi, 150 means 108 dpi)
+
+#define zoomPage   -1
+#define zoomWidth  -2
+#define zoomHeight -3
+
+//------------------------------------------------------------------------
+// display mode
+//------------------------------------------------------------------------
+
+enum DisplayMode {
+  displaySingle,
+  displayContinuous,
+  displaySideBySideSingle,
+  displaySideBySideContinuous,
+  displayHorizontalContinuous
+};
+
+//------------------------------------------------------------------------
+// SelectRect
+//------------------------------------------------------------------------
+
+class SelectRect {
+public:
+
+  SelectRect(int pageA, double x0A, double y0A, double x1A, double y1A):
+    page(pageA), x0(x0A), y0(y0A), x1(x1A), y1(y1A) {}
+  int operator==(SelectRect r)
+    { return page == r.page && x0 == r.x0 && y0 == r.y0 &&
+                               x1 == r.x1 && y1 == r.y1; }
+  int operator!=(SelectRect r)
+    { return page != r.page || x0 != r.x0 || y0 != r.y0 ||
+                               x1 != r.x1 || y1 != r.y1; }
+
+  int page;
+  double x0, y0, x1, y1;	// user coords
+};
+
+
+//------------------------------------------------------------------------
+// DisplayState
+//------------------------------------------------------------------------
+
+class DisplayState {
+public:
+
+  DisplayState(int maxTileWidthA, int maxTileHeightA,
+	       int tileCacheSizeA, int nWorkerThreadsA,
+	       SplashColorMode colorModeA, int bitmapRowPadA);
+  ~DisplayState();
+
+  void setTileMap(TileMap *tileMapA)
+    { tileMap = tileMapA; }
+  void setTileCache(TileCache *tileCacheA)
+    { tileCache = tileCacheA; }
+  void setTileCompositor(TileCompositor *tileCompositorA)
+    { tileCompositor = tileCompositorA; }
+
+  void setPaperColor(SplashColorPtr paperColorA);
+  void setMatteColor(SplashColorPtr matteColorA);
+  void setSelectColor(SplashColorPtr selectColorA);
+  void setReverseVideo(GBool reverseVideoA);
+  void setDoc(PDFDoc *docA);
+  void setWindowSize(int winWA, int winHA);
+  void setDisplayMode(DisplayMode displayModeA);
+  void setZoom(double zoomA);
+  void setRotate(int rotateA);
+  void setScrollPosition(int scrollPageA, int scrollXA, int scrollYA);
+  void setSelection(int selectPage, double selectX0, double selectY0,
+		    double selectX1, double selectY1);
+  void setSelection(GList *selectRectsA);
+  void clearSelection();
+  void forceRedraw();
+
+  int getMaxTileWidth() { return maxTileWidth; }
+  int getMaxTileHeight() { return maxTileHeight; }
+  int getTileCacheSize() { return tileCacheSize; }
+  int getNWorkerThreads() { return nWorkerThreads; }
+  SplashColorMode getColorMode() { return colorMode; }
+  int getBitmapRowPad() { return bitmapRowPad; }
+  SplashColorPtr getPaperColor() { return paperColor; }
+  SplashColorPtr getMatteColor() { return matteColor; }
+  SplashColorPtr getSelectColor() { return selectColor; }
+  GBool getReverseVideo() { return reverseVideo; }
+  PDFDoc *getDoc() { return doc; }
+  int getWinW() { return winW; }
+  int getWinH() { return winH; }
+  DisplayMode getDisplayMode() { return displayMode; }
+  GBool displayModeIsContinuous()
+    { return displayMode == displayContinuous ||
+	     displayMode == displaySideBySideContinuous ||
+	     displayMode == displayHorizontalContinuous; }
+  GBool displayModeIsSideBySide()
+    { return displayMode == displaySideBySideSingle ||
+	     displayMode == displaySideBySideContinuous; }
+  double getZoom() { return zoom; }
+  int getRotate() { return rotate; }
+  int getScrollPage() { return scrollPage; }
+  int getScrollX() { return scrollX; }
+  int getScrollY() { return scrollY; }
+  GBool hasSelection() { return selectRects != NULL; }
+  GList *getSelectRects() { return selectRects; }
+  int getNumSelectRects();
+  SelectRect *getSelectRect(int idx);
+  void optionalContentChanged();
+
+private:
+
+  int maxTileWidth, maxTileHeight;
+  int tileCacheSize;
+  int nWorkerThreads;
+
+  SplashColorMode colorMode;
+  int bitmapRowPad;
+
+  TileMap *tileMap;
+  TileCache *tileCache;
+  TileCompositor *tileCompositor;
+
+  SplashColor paperColor;
+  SplashColor matteColor;
+  SplashColor selectColor;
+  GBool reverseVideo;
+
+  PDFDoc *doc;
+
+  int winW, winH;		// window (draw area) size
+  DisplayMode displayMode;
+  double zoom;			// zoom level (see zoom* defines, above)
+  int rotate;			// rotation (0, 90, 180, or 270)
+  int scrollPage;		// scroll page - only used in
+				//   non-continuous modes
+  int scrollX, scrollY;
+
+  GList *selectRects;		// selection rectangles [SelectRect]
+				//   (NULL if there is no selection)
+
+
+};
+
+#endif


Property changes on: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,11 +15,12 @@
 #include <stdio.h>
 #include <stddef.h>
 #include <stdarg.h>
+#include "gmempp.h"
 #include "GString.h"
 #include "GlobalParams.h"
 #include "Error.h"
 
-static const char *errorCategoryNames[] = {
+const char *errorCategoryNames[] = {
   "Syntax Warning",
   "Syntax Error",
   "Config Error",
@@ -41,6 +42,10 @@
   errorCbkData = data;
 }
 
+void *getErrorCallbackData() {
+  return errorCbkData;
+}
+
 void CDECL error(ErrorCategory category, GFileOffset pos,
 		 const char *msg, ...) {
   va_list args;
@@ -71,6 +76,7 @@
   if (errorCbk) {
     (*errorCbk)(errorCbkData, category, (int)pos, sanitized->getCString());
   } else {
+    fflush(stdout);
     if (pos >= 0) {
       fprintf(stderr, "%s (%d): %s\n",
 	      errorCategoryNames[category], (int)pos, sanitized->getCString());

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Error.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -34,10 +34,14 @@
   errInternal		// internal error - malfunction within the Xpdf code
 };
 
+extern const char *errorCategoryNames[];
+
 extern void setErrorCallback(void (*cbk)(void *data, ErrorCategory category,
 					 int pos, char *msg),
 			     void *data);
 
+extern void *getErrorCallbackData();
+
 extern void CDECL error(ErrorCategory category, GFileOffset pos,
 			const char *msg, ...);
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/FontEncodingTables.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/FontEncodingTables.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/FontEncodingTables.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -8,6 +8,7 @@
 
 #include <aconf.h>
 #include <stdlib.h>
+#include "gmempp.h"
 #include "FontEncodingTables.h"
 
 const char *macRomanEncoding[256] = {

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "GlobalParams.h"
 #include "Error.h"
 #include "Object.h"
@@ -26,27 +27,24 @@
 
 Form *Form::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObj) {
   Form *form;
-  Object xfaObj, catDict, needsRenderingObj;
+  Object xfaObj;
 
-  if (!acroFormObj->isDict()) {
-    error(errSyntaxError, -1, "AcroForm object is wrong type");
-    return NULL;
+  if (acroFormObj->isDict()) {
+    //~ temporary: create an XFAForm only for XFAF, not for dynamic XFA
+    acroFormObj->dictLookup("XFA", &xfaObj);
+    if (globalParams->getEnableXFA() &&
+	!xfaObj.isNull() &&
+	!catalog->getNeedsRendering()) {
+      form = XFAForm::load(docA, catalog, acroFormObj, &xfaObj);
+      xfaObj.free();
+      return form;
+    }
+    xfaObj.free();
   }
-  //~ temporary: create an XFAForm only for XFAF, not for dynamic XFA
-  acroFormObj->dictLookup("XFA", &xfaObj);
-  docA->getXRef()->getCatalog(&catDict);
-  catDict.dictLookup("NeedsRendering", &needsRenderingObj);
-  catDict.free();
-  if (globalParams->getEnableXFA() &&
-      !xfaObj.isNull() &&
-      !(needsRenderingObj.isBool() && needsRenderingObj.getBool())) {
-    form = XFAForm::load(docA, acroFormObj, &xfaObj);
-  } else {
-    form = AcroForm::load(docA, catalog, acroFormObj);
-  }
-  xfaObj.free();
-  needsRenderingObj.free();
-  return form;
+
+  // if acroFormObj is a null object, this will still create an
+  // AcroForm if there are unattached Widget-type annots
+  return AcroForm::load(docA, catalog, acroFormObj);
 }
 
 Form::Form(PDFDoc *docA) {
@@ -56,6 +54,40 @@
 Form::~Form() {
 }
 
+FormField *Form::findField(int pg, double x, double y) {
+  FormField *field;
+  double llx, lly, urx, ury;
+  int i;
+
+  for (i = 0; i < getNumFields(); ++i) {
+    field = getField(i);
+    if (field->getPageNum() == pg) {
+      field->getBBox(&llx, &lly, &urx, &ury);
+      if (llx <= x && x <= urx && lly <= y && y <= ury) {
+	return field;
+      }
+    }
+  }
+  return NULL;
+}
+
+int Form::findFieldIdx(int pg, double x, double y) {
+  FormField *field;
+  double llx, lly, urx, ury;
+  int i;
+
+  for (i = 0; i < getNumFields(); ++i) {
+    field = getField(i);
+    if (field->getPageNum() == pg) {
+      field->getBBox(&llx, &lly, &urx, &ury);
+      if (llx <= x && x <= urx && lly <= y && y <= ury) {
+	return i;
+      }
+    }
+  }
+  return -1;
+}
+
 //------------------------------------------------------------------------
 // FormField
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Form.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -36,6 +36,9 @@
   virtual int getNumFields() = 0;
   virtual FormField *getField(int idx) = 0;
 
+  FormField *findField(int pg, double x, double y);
+  int findFieldIdx(int pg, double x, double y);
+
 protected:
 
   Form(PDFDoc *docA);
@@ -51,10 +54,20 @@
   FormField();
   virtual ~FormField();
 
+  virtual int getPageNum() = 0;
   virtual const char *getType() = 0;
+
+  // Return the field name.  This never returns NULL.
   virtual Unicode *getName(int *length) = 0;
+
+  // Return the field value.  This returns NULL if the field does not
+  // have a value.
   virtual Unicode *getValue(int *length) = 0;
 
+  virtual void getBBox(double *llx, double *lly, double *urx, double *ury) = 0;
+  virtual void getFont(Ref *fontID, double *fontSize) = 0;
+  virtual void getColor(double *red, double *green, double *blue) = 0;
+
   // Return the resource dictionaries used to draw this field.  The
   // returned object must be either a dictionary or an array of
   // dictonaries.

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Function.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Function.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Function.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -17,6 +17,7 @@
 #include <ctype.h>
 #include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GList.h"
 #include "Object.h"
 #include "Dict.h"
@@ -407,7 +408,7 @@
 }
 
 SampledFunction::SampledFunction(SampledFunction *func) {
-  memcpy(this, func, sizeof(SampledFunction));
+  memcpy((void *)this, (void *)func, sizeof(SampledFunction));
   idxOffset = (int *)gmallocn(1 << m, sizeof(int));
   memcpy(idxOffset, func->idxOffset, (1 << m) * (int)sizeof(int));
   samples = (double *)gmallocn(nSamples, sizeof(double));
@@ -518,6 +519,12 @@
       goto err2;
     }
     n = obj1.arrayGetLength();
+    if (n > funcMaxOutputs) {
+      error(errSyntaxError, -1,
+	    "Functions with more than {0:d} outputs are unsupported",
+	    funcMaxOutputs);
+      goto err2;
+    }
     for (i = 0; i < n; ++i) {
       obj1.arrayGet(i, &obj2);
       if (!obj2.isNum()) {
@@ -584,7 +591,7 @@
 }
 
 ExponentialFunction::ExponentialFunction(ExponentialFunction *func) {
-  memcpy(this, func, sizeof(ExponentialFunction));
+  memcpy((void *)this, (void *)func, sizeof(ExponentialFunction));
 }
 
 void ExponentialFunction::transform(double *in, double *out) {
@@ -725,7 +732,7 @@
 StitchingFunction::StitchingFunction(StitchingFunction *func) {
   int i;
 
-  memcpy(this, func, sizeof(StitchingFunction));
+  memcpy((void *)this, (void *)func, sizeof(StitchingFunction));
   funcs = (Function **)gmallocn(k, sizeof(Function *));
   for (i = 0; i < k; ++i) {
     funcs[i] = func->funcs[i]->copy();
@@ -781,6 +788,8 @@
 
 // This is not an enum, because we can't foreward-declare the enum
 // type in Function.h
+//
+// NB: This must be kept in sync with psOpNames[] below.
 #define psOpAbs       0
 #define psOpAdd       1
 #define psOpAnd       2
@@ -821,15 +830,17 @@
 #define psOpTrue     37
 #define psOpTruncate 38
 #define psOpXor      39
+// the push/j/jz ops are used internally (and are not listed in psOpNames[])
 #define psOpPush     40
 #define psOpJ        41
 #define psOpJz       42
 
-#define nPSOps 43
+#define nPSOps (sizeof(psOpNames) / sizeof(const char *))
 
 // Note: 'if' and 'ifelse' are parsed separately.
 // The rest are listed here in alphabetical order.
-// The index in this table is equivalent to the psOpXXX defines.
+//
+// NB: This must be kept in sync with the psOpXXX defines above.
 static const char *psOpNames[] = {
   "abs",
   "add",
@@ -923,7 +934,7 @@
   //----- parse the function
   if (tokens->getLength() < 1 ||
       ((GString *)tokens->get(0))->cmp("{")) {
-    error(errSyntaxError, -1, "Expected '{' at start of PostScript function");
+    error(errSyntaxError, -1, "Expected '{{' at start of PostScript function");
     goto err2;
   }
   tokPtr = 1;
@@ -949,7 +960,7 @@
 }
 
 PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
-  memcpy(this, func, sizeof(PostScriptFunction));
+  memcpy((void *)this, (void *)func, sizeof(PostScriptFunction));
   codeString = func->codeString->copy();
   code = (PSCode *)gmallocn(codeSize, sizeof(PSCode));
   memcpy(code, func->code, codeSize * sizeof(PSCode));

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2,7 +2,7 @@
 //
 // Gfx.cc
 //
-// Copyright 1996-2013 Glyph & Cog, LLC
+// Copyright 1996-2016 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "GlobalParams.h"
@@ -54,8 +55,8 @@
 // Max delta allowed in any color component for a function shading fill.
 #define functionColorDelta (dblToCol(1 / 256.0))
 
-// Max number of splits along the t axis for an axial shading fill.
-#define axialMaxSplits 256
+// Number of splits along the t axis for an axial shading fill.
+#define axialSplits 256
 
 // Max delta allowed in any color component for an axial shading fill.
 #define axialColorDelta (dblToCol(1 / 256.0))
@@ -520,7 +521,6 @@
     baseMatrix[i] = state->getCTM()[i];
   }
   formDepth = 0;
-  textClipBBoxEmpty = gTrue;
   markedContentStack = new GList();
   ocState = gTrue;
   parser = NULL;
@@ -565,7 +565,6 @@
     baseMatrix[i] = state->getCTM()[i];
   }
   formDepth = 0;
-  textClipBBoxEmpty = gTrue;
   markedContentStack = new GList();
   ocState = gTrue;
   parser = NULL;
@@ -684,17 +683,28 @@
 void Gfx::go(GBool topLevel) {
   Object obj;
   Object args[maxArgs];
+  GBool aborted;
   int numArgs, i;
-  int lastAbortCheck, errCount;
+  int errCount;
 
   // scan a sequence of objects
-  updateLevel = 1; // make sure even empty pages trigger a call to dump()
-  lastAbortCheck = 0;
+  opCounter = 0;
+  aborted = gFalse;
   errCount = 0;
   numArgs = 0;
   parser->getObj(&obj);
   while (!obj.isEOF()) {
 
+    // check for an abort
+    ++opCounter;
+    if (abortCheckCbk && opCounter > 100) {
+      if ((*abortCheckCbk)(abortCheckCbkData)) {
+	aborted = gTrue;
+	break;
+      }
+      opCounter = 0;
+    }
+
     // got a command - execute it
     if (obj.isCmd()) {
       if (printCommands) {
@@ -714,22 +724,6 @@
 	args[i].free();
       numArgs = 0;
 
-      // periodically update display
-      if (++updateLevel >= 20000) {
-	out->dump();
-	updateLevel = 0;
-      }
-
-      // check for an abort
-      if (abortCheckCbk) {
-	if (updateLevel - lastAbortCheck > 10) {
-	  if ((*abortCheckCbk)(abortCheckCbkData)) {
-	    break;
-	  }
-	  lastAbortCheck = updateLevel;
-	}
-      }
-
       // check for too many errors
       if (errCount > contentStreamErrorLimit) {
 	error(errSyntaxError, -1,
@@ -760,24 +754,22 @@
 
   // args at end with no command
   if (numArgs > 0) {
-    error(errSyntaxError, getPos(), "Leftover args in content stream");
-    if (printCommands) {
-      printf("%d leftovers:", numArgs);
-      for (i = 0; i < numArgs; ++i) {
-	printf(" ");
-	args[i].print(stdout);
+    if (!aborted) {
+      error(errSyntaxError, getPos(), "Leftover args in content stream");
+      if (printCommands) {
+	printf("%d leftovers:", numArgs);
+	for (i = 0; i < numArgs; ++i) {
+	  printf(" ");
+	  args[i].print(stdout);
+	}
+	printf("\n");
+	fflush(stdout);
       }
-      printf("\n");
-      fflush(stdout);
     }
-    for (i = 0; i < numArgs; ++i)
+    for (i = 0; i < numArgs; ++i) {
       args[i].free();
+    }
   }
-
-  // update display
-  if (topLevel && updateLevel > 0) {
-    out->dump();
-  }
 }
 
 // Returns true if successful, false on error.
@@ -1006,6 +998,10 @@
     opSetFlat(&obj2, 1);
   }
   obj2.free();
+  if (obj1.dictLookup("RI", &obj2)->isName()) {
+    opSetRenderingIntent(&obj2, 1);
+  }
+  obj2.free();
 
   // font
   if (obj1.dictLookup("Font", &obj2)->isArray() &&
@@ -1270,8 +1266,26 @@
 }
 
 void Gfx::opSetRenderingIntent(Object args[], int numArgs) {
+  GfxRenderingIntent ri;
+
+  ri = parseRenderingIntent(args[0].getName());
+  state->setRenderingIntent(ri);
+  out->updateRenderingIntent(state);
 }
 
+GfxRenderingIntent Gfx::parseRenderingIntent(const char *name) {
+  if (!strcmp(name, "AbsoluteColorimetric")) {
+    return gfxRenderingIntentAbsoluteColorimetric;
+  }
+  if (!strcmp(name, "Saturation")) {
+    return gfxRenderingIntentSaturation;
+  }
+  if (!strcmp(name, "Perceptual")) {
+    return gfxRenderingIntentPerceptual;
+  }
+  return gfxRenderingIntentRelativeColorimetric;
+}
+
 //------------------------------------------------------------------------
 // color operators
 //------------------------------------------------------------------------
@@ -1887,6 +1901,7 @@
 			      GBool stroke, GBool eoFill, GBool text) {
   GfxPatternColorSpace *patCS;
   GfxColorSpace *cs;
+  GfxColor color;
   GfxState *savedState;
   double xMin, yMin, xMax, yMax, x, y, x1, y1, t;
   double cxMin, cyMin, cxMax, cyMax;
@@ -1895,7 +1910,7 @@
   double bbox[4], m[6], ictm[6], m1[6], imb[6];
   double det;
   double xstep, ystep;
-  int i;
+  int abortCheckCounter, i;
 
   // get color space
   patCS = (GfxPatternColorSpace *)(stroke ? state->getStrokeColorSpace()
@@ -1907,7 +1922,7 @@
   ptm = tPat->getMatrix();
   // iCTM = invert CTM
   det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
-  if (fabs(det) < 0.000001) {
+  if (fabs(det) <= 1e-10) {
     error(errSyntaxError, getPos(), "Singular matrix in tiling pattern fill");
     return;
   }
@@ -1935,7 +1950,7 @@
 
   // construct a (device space) -> (pattern space) transform matrix
   det = m1[0] * m1[3] - m1[1] * m1[2];
-  if (fabs(det) < 0.000001) {
+  if (fabs(det) <= 1e-10) {
     error(errSyntaxError, getPos(), "Singular matrix in tiling pattern fill");
     return;
   }
@@ -1966,12 +1981,20 @@
   } else {
     state->setFillColorSpace(GfxColorSpace::create(csDeviceGray));
     out->updateFillColorSpace(state);
+    state->getFillColorSpace()->getDefaultColor(&color);
+    state->setFillColor(&color);
+    out->updateFillColor(state);
     state->setStrokeColorSpace(GfxColorSpace::create(csDeviceGray));
     out->updateStrokeColorSpace(state);
+    state->getStrokeColorSpace()->getDefaultColor(&color);
+    state->setStrokeColor(&color);
+    out->updateStrokeColor(state);
   }
   if (!stroke) {
     state->setLineWidth(0);
     out->updateLineWidth(state);
+    state->setLineDash(NULL, 0, 0);
+    out->updateLineDash(state);
   }
 
   // clip to current path
@@ -2060,12 +2083,23 @@
     m1[4] = m[4];
     m1[5] = m[5];
     out->tilingPatternFill(state, this, tPat->getContentStreamRef(),
-			   tPat->getPaintType(), tPat->getResDict(),
+			   tPat->getPaintType(), tPat->getTilingType(),
+			   tPat->getResDict(),
 			   m1, bbox,
 			   xi0, yi0, xi1, yi1, xstep, ystep);
   } else {
+    abortCheckCounter = 0;
     for (yi = yi0; yi < yi1; ++yi) {
       for (xi = xi0; xi < xi1; ++xi) {
+	if (abortCheckCbk) {
+	  ++abortCheckCounter;
+	  if (abortCheckCounter > 100) {
+	    if ((*abortCheckCbk)(abortCheckCbkData)) {
+	      goto err;
+	    }
+	    abortCheckCounter = 0;
+	  }
+	}
 	x = xi * xstep;
 	y = yi * ystep;
 	m1[4] = x * m[0] + y * m[2] + m[4];
@@ -2115,7 +2149,7 @@
   ptm = sPat->getMatrix();
   // iCTM = invert CTM
   det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
-  if (fabs(det) < 0.000001) {
+  if (fabs(det) <= 1e-10) {
     error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill");
     return;
   }
@@ -2412,15 +2446,12 @@
   double x0, y0, x1, y1;
   double dx, dy, mul;
   GBool dxdyZero, horiz;
-  double tMin, tMax, t, tx, ty;
+  double tMin, tMax, tMinExt, tMaxExt, t, tx, ty;
   double sMin, sMax, tmp;
   double ux0, uy0, ux1, uy1, vx0, vy0, vx1, vy1;
   double t0, t1, tt;
-  double ta[axialMaxSplits + 1];
-  int next[axialMaxSplits + 1];
-  GfxColor color0, color1;
-  int nComps;
-  int i, j, k;
+  GfxColor colors[axialSplits];
+  int abortCheckCounter, nComps, i, j, k;
 
   if (out->useShadedFills() &&
       out->axialShadedFill(state, shading)) {
@@ -2435,37 +2466,44 @@
   shading->getCoords(&x0, &y0, &x1, &y1);
   dx = x1 - x0;
   dy = y1 - y0;
-  dxdyZero = fabs(dx) < 0.01 && fabs(dy) < 0.01;
+  dxdyZero = fabs(dx) < 0.0001 && fabs(dy) < 0.0001;
   horiz = fabs(dy) < fabs(dx);
   if (dxdyZero) {
+    tMinExt = tMaxExt = 0;
     tMin = tMax = 0;
   } else {
     mul = 1 / (dx * dx + dy * dy);
-    tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul;
+    tMinExt = tMaxExt = ((xMin - x0) * dx + (yMin - y0) * dy) * mul;
     t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul;
-    if (t < tMin) {
-      tMin = t;
-    } else if (t > tMax) {
-      tMax = t;
+    if (t < tMinExt) {
+      tMinExt = t;
+    } else if (t > tMaxExt) {
+      tMaxExt = t;
     }
     t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul;
-    if (t < tMin) {
-      tMin = t;
-    } else if (t > tMax) {
-      tMax = t;
+    if (t < tMinExt) {
+      tMinExt = t;
+    } else if (t > tMaxExt) {
+      tMaxExt = t;
     }
     t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul;
-    if (t < tMin) {
-      tMin = t;
-    } else if (t > tMax) {
-      tMax = t;
+    if (t < tMinExt) {
+      tMinExt = t;
+    } else if (t > tMaxExt) {
+      tMaxExt = t;
     }
-    if (tMin < 0 && !shading->getExtend0()) {
+    if ((tMin = tMinExt) < 0) {
       tMin = 0;
     }
-    if (tMax > 1 && !shading->getExtend1()) {
+    if (!shading->getExtend0()) {
+      tMinExt = tMin;
+    }
+    if ((tMax = tMaxExt) > 1) {
       tMax = 1;
     }
+    if (!shading->getExtend1()) {
+      tMaxExt = tMax;
+    }
   }
 
   // get the function domain
@@ -2499,22 +2537,6 @@
   // difference across a region is small enough, and then the region
   // is painted with a single color.
 
-  // set up
-  nComps = shading->getColorSpace()->getNComps();
-  ta[0] = tMin;
-  next[0] = axialMaxSplits;
-  ta[axialMaxSplits] = tMax;
-
-  // compute the color at t = tMin
-  if (tMin < 0) {
-    tt = t0;
-  } else if (tMin > 1) {
-    tt = t1;
-  } else {
-    tt = t0 + (t1 - t0) * tMin;
-  }
-  shading->getColor(tt, &color0);
-
   // compute the coordinates of the point on the t axis at t = tMin;
   // then compute the intersection of the perpendicular line with the
   // bounding box
@@ -2539,50 +2561,94 @@
   vx0 = tx - sMax * dy;
   vy0 = ty + sMax * dx;
 
-  i = 0;
-  while (i < axialMaxSplits) {
+  // fill the extension at t0
+  if (shading->getExtend0() && tMinExt < tMin) {
 
-    // bisect until color difference is small enough or we hit the
-    // bisection limit
-    j = next[i];
-    while (j > i + 1) {
-      if (ta[j] < 0) {
-	tt = t0;
-      } else if (ta[j] > 1) {
-	tt = t1;
+    // compute the color at t0
+    shading->getColor(t0, &colors[0]);
+
+    // compute the coordinates of the point on the t axis at t =
+    // tMinExt; then compute the intersection of the perpendicular
+    // line with the bounding box
+    tx = x0 + tMinExt * dx;
+    ty = y0 + tMinExt * dy;
+    if (dxdyZero) {
+      sMin = sMax = 0;
+    } else {
+      if (horiz) {
+	sMin = (yMin - ty) / dx;
+	sMax = (yMax - ty) / dx;
       } else {
-	tt = t0 + (t1 - t0) * ta[j];
+	sMin = (xMin - tx) / -dy;
+	sMax = (xMax - tx) / -dy;
       }
-      // require at least two splits (to avoid problems where the
-      // color doesn't change smoothly along the t axis)
-      if (j - i <= axialMaxSplits / 4) {
-	shading->getColor(tt, &color1);
-	for (k = 0; k < nComps; ++k) {
-	  if (abs(color1.c[k] - color0.c[k]) > axialColorDelta) {
-	    break;
-	  }
-	}
-	if (k == nComps) {
+      if (sMin > sMax) {
+	tmp = sMin; sMin = sMax; sMax = tmp;
+      }
+    }
+    ux1 = tx - sMin * dy;
+    uy1 = ty + sMin * dx;
+    vx1 = tx - sMax * dy;
+    vy1 = ty + sMax * dx;
+
+    // set the color
+    state->setFillColor(&colors[0]);
+    out->updateFillColor(state);
+
+    // fill the region
+    state->moveTo(ux1, uy1);
+    state->lineTo(vx1, vy1);
+    state->lineTo(vx0, vy0);
+    state->lineTo(ux0, uy0);
+    state->closePath();
+    out->fill(state);
+    state->clearPath();
+  }
+
+  // traverse the t axis, splitting [tMin, tMax] into axialSplits regions
+
+  // compute the color in the center of each region
+  for (i = 0; i < axialSplits; ++i) {
+    t = tMin + (tMax - tMin) * (i + 0.5) / axialSplits;
+    tt = t0 + (t1 - t0) * t;
+    shading->getColor(tt, &colors[i]);
+  }
+
+  // each iteration draws one or more regions, starting at i --
+  // if the colors are similar, it will combine regions i, i+1, ...
+  nComps = shading->getColorSpace()->getNComps();
+  abortCheckCounter = 0;
+  i = 0;
+  while (i < axialSplits) {
+
+    if (abortCheckCbk) {
+      ++abortCheckCounter;
+      if (abortCheckCounter > 100) {
+        if ((*abortCheckCbk)(abortCheckCbkData)) {
+          break;
+        }
+        abortCheckCounter = 0;
+      }
+    }
+
+    // check for similar colors
+    for (j = i + 1; j < axialSplits; ++j) {
+      for (k = 0; k < nComps; ++k) {
+	if (abs(colors[j].c[k] - colors[i].c[k]) > axialColorDelta) {
 	  break;
 	}
       }
-      k = (i + j) / 2;
-      ta[k] = 0.5 * (ta[i] + ta[j]);
-      next[i] = k;
-      next[k] = j;
-      j = k;
+      if (k < nComps) {
+	break;
+      }
     }
 
-    // use the average of the colors of the two sides of the region
-    for (k = 0; k < nComps; ++k) {
-      color0.c[k] = (color0.c[k] + color1.c[k]) / 2;
-    }
-
     // compute the coordinates of the point on the t axis; then
     // compute the intersection of the perpendicular line with the
     // bounding box
-    tx = x0 + ta[j] * dx;
-    ty = y0 + ta[j] * dy;
+    t = tMin + (tMax - tMin) * (double)j / axialSplits;
+    tx = x0 + t * dx;
+    ty = y0 + t * dy;
     if (dxdyZero) {
       sMin = sMax = 0;
     } else {
@@ -2603,7 +2669,7 @@
     vy1 = ty + sMax * dx;
 
     // set the color
-    state->setFillColor(&color0);
+    state->setFillColor(&colors[i]);
     out->updateFillColor(state);
 
     // fill the region
@@ -2620,11 +2686,62 @@
     uy0 = uy1;
     vx0 = vx1;
     vy0 = vy1;
-    color0 = color1;
-    i = next[i];
+
+    i = j;
   }
+
+  // fill the extension at t1
+  if (shading->getExtend1() && tMaxExt > tMax) {
+
+    // compute the color at t1
+    shading->getColor(t1, &colors[0]);
+
+    // compute the coordinates of the point on the t axis at t =
+    // tMaxExt; then compute the intersection of the perpendicular
+    // line with the bounding box
+    tx = x0 + tMaxExt * dx;
+    ty = y0 + tMaxExt * dy;
+    if (dxdyZero) {
+      sMin = sMax = 0;
+    } else {
+      if (horiz) {
+	sMin = (yMin - ty) / dx;
+	sMax = (yMax - ty) / dx;
+      } else {
+	sMin = (xMin - tx) / -dy;
+	sMax = (xMax - tx) / -dy;
+      }
+      if (sMin > sMax) {
+	tmp = sMin; sMin = sMax; sMax = tmp;
+      }
+    }
+    ux1 = tx - sMin * dy;
+    uy1 = ty + sMin * dx;
+    vx1 = tx - sMax * dy;
+    vy1 = ty + sMax * dx;
+
+    // set the color
+    state->setFillColor(&colors[0]);
+    out->updateFillColor(state);
+
+    // fill the region
+    state->moveTo(ux0, uy0);
+    state->lineTo(vx0, vy0);
+    state->lineTo(vx1, vy1);
+    state->lineTo(ux1, uy1);
+    state->closePath();
+    out->fill(state);
+    state->clearPath();
+  }
 }
 
+#if defined(__GNUC__) && !defined(__clang__)
+// this function makes a lot of sin()/cos() calls, which are slow
+// with glibc 2.16 and newer on x86; accuracy isn't terribly
+// important here, so tell gcc to use the fast version
+#pragma GCC optimize ("fast-math")
+#endif
+
 void Gfx::doRadialShFill(GfxRadialShading *shading) {
   double xMin, yMin, xMax, yMax;
   double x0, y0, r0, x1, y1, r1, t0, t1;
@@ -2637,9 +2754,9 @@
   GBool haveSLeft, haveSRight, haveSTop, haveSBottom, haveSZero;
   GBool haveSMin, haveSMax;
   GBool enclosed;
-  int ia, ib, k, n;
   double *ctm;
   double theta, alpha, angle, t;
+  int abortCheckCounter, ia, ib, k, n;
 
   if (out->useShadedFills() &&
       out->radialShadedFill(state, shading)) {
@@ -2826,8 +2943,19 @@
   }
 
   // fill the circles
+  abortCheckCounter = 0;
   while (ia < radialMaxSplits) {
 
+    if (abortCheckCbk) {
+      ++abortCheckCounter;
+      if (abortCheckCounter > 100) {
+	if ((*abortCheckCbk)(abortCheckCbkData)) {
+	  break;
+	}
+	abortCheckCounter = 0;
+      }
+    }
+
     // go as far along the t axis (toward t1) as we can, such that the
     // color difference is within the tolerance (radialColorDelta) --
     // this uses bisection (between the current value, t, and t1),
@@ -3004,14 +3132,28 @@
   }
 }
 
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC reset_options
+#endif
+
 void Gfx::doGouraudTriangleShFill(GfxGouraudTriangleShading *shading) {
   double x0, y0, x1, y1, x2, y2;
   double color0[gfxColorMaxComps];
   double color1[gfxColorMaxComps];
   double color2[gfxColorMaxComps];
-  int i;
+  int abortCheckCounter, i;
 
+  abortCheckCounter = 0;
   for (i = 0; i < shading->getNTriangles(); ++i) {
+    if (abortCheckCbk) {
+      ++abortCheckCounter;
+      if (abortCheckCounter > 25) {
+	if ((*abortCheckCbk)(abortCheckCbkData)) {
+	  break;
+	}
+	abortCheckCounter = 0;
+      }
+    }
     shading->getTriangle(i, &x0, &y0, color0,
 			 &x1, &y1, color1,
 			 &x2, &y2, color2);
@@ -3087,7 +3229,7 @@
 }
 
 void Gfx::doPatchMeshShFill(GfxPatchMeshShading *shading) {
-  int start, i;
+  int start, abortCheckCounter, i;
 
   if (shading->getNPatches() > 128) {
     start = 3;
@@ -3098,7 +3240,17 @@
   } else {
     start = 0;
   }
+  abortCheckCounter = 0;
   for (i = 0; i < shading->getNPatches(); ++i) {
+    if (abortCheckCbk) {
+      ++abortCheckCounter;
+      if (abortCheckCounter > 25) {
+	if ((*abortCheckCbk)(abortCheckCbkData)) {
+	  break;
+	}
+	abortCheckCounter = 0;
+      }
+    }
     fillPatch(shading->getPatch(i), shading, start);
   }
 }
@@ -3107,23 +3259,67 @@
   GfxPatch patch00, patch01, patch10, patch11;
   GfxColor c00, c01, c10, c11;
   double xx[4][8], yy[4][8];
-  double xxm, yym;
-  int nComps, i;
+  double x, y, xMin, yMin, xMax, yMax, xxm, yym;
+  int nComps, i, j;
+  GBool stop;
 
-  nComps = shading->getColorSpace()->getNComps();
   shading->getColor(patch->color[0][0], &c00);
-  shading->getColor(patch->color[0][1], &c01);
-  shading->getColor(patch->color[1][0], &c10);
-  shading->getColor(patch->color[1][1], &c11);
-  for (i = 0; i < nComps; ++i) {
-    if (abs(c00.c[i] - c01.c[i]) > patchColorDelta ||
-	abs(c01.c[i] - c11.c[i]) > patchColorDelta ||
-	abs(c11.c[i] - c10.c[i]) > patchColorDelta ||
-	abs(c10.c[i] - c00.c[i]) > patchColorDelta) {
-      break;
+  stop = gFalse;
+
+  // stop subdivision at max depth
+  if (depth == patchMaxDepth) {
+    stop = gTrue;
+  }
+
+  // stop subdivision if colors are close enough
+  if (!stop) {
+    nComps = shading->getColorSpace()->getNComps();
+    shading->getColor(patch->color[0][1], &c01);
+    shading->getColor(patch->color[1][0], &c10);
+    shading->getColor(patch->color[1][1], &c11);
+    for (i = 0; i < nComps; ++i) {
+      if (abs(c00.c[i] - c01.c[i]) > patchColorDelta ||
+	  abs(c01.c[i] - c11.c[i]) > patchColorDelta ||
+	  abs(c11.c[i] - c10.c[i]) > patchColorDelta ||
+	  abs(c10.c[i] - c00.c[i]) > patchColorDelta) {
+	break;
+      }
     }
+    if (i == nComps) {
+      stop = gTrue;
+    }
   }
-  if (i == nComps || depth == patchMaxDepth) {
+
+  // stop subdivision if patch is small enough
+  if (!stop) {
+    xMin = yMin = xMax = yMax = 0;
+    for (j = 0; j < 4; ++j) {
+      for (i = 0; i < 4; ++i) {
+	state->transformDelta(patch->x[i][j], patch->y[i][j], &x, &y);
+	if (i == 0 && j == 0) {
+	  xMin = xMax = x;
+	  yMin = yMax = y;
+	} else {
+	  if (x < xMin) {
+	    xMin = x;
+	  } else if (x > xMax) {
+	    xMax = x;
+	  }
+	  if (y < yMin) {
+	    yMin = y;
+	  } else if (y > yMax) {
+	    yMax = y;
+	  }
+	}
+      }
+    }
+    if (xMax - xMin < 1 && yMax - yMin < 1) {
+      stop = gTrue;
+    }
+  }
+
+  // draw the patch
+  if (stop) {
     state->setFillColor(&c00);
     out->updateFillColor(state);
     state->moveTo(patch->x[0][0], patch->y[0][0]);
@@ -3142,6 +3338,8 @@
     state->closePath();
     out->fill(state);
     state->clearPath();
+
+  // subdivide the patch
   } else {
     for (i = 0; i < 4; ++i) {
       xx[i][0] = patch->x[i][0];
@@ -3266,7 +3464,6 @@
   out->updateTextMat(state);
   out->updateTextPos(state);
   fontChanged = gTrue;
-  textClipBBoxEmpty = gTrue;
 }
 
 void Gfx::opEndText(Object args[], int numArgs) {
@@ -3724,7 +3921,7 @@
     out->restoreTextPos(state);
   }
 
-  updateLevel += 10 * s->getLength();
+  opCounter += 10 * s->getLength();
 }
 
 // NB: this is only called when ocState is false.
@@ -3741,6 +3938,7 @@
 void Gfx::opXObject(Object args[], int numArgs) {
   char *name;
   Object obj1, obj2, obj3, refObj;
+  GBool ocSaved, oc;
 #if OPI_SUPPORT
   Object opiDict;
 #endif
@@ -3757,6 +3955,15 @@
     obj1.free();
     return;
   }
+
+  // check for optional content key
+  ocSaved = ocState;
+  obj1.streamGetDict()->lookupNF("OC", &obj2);
+  if (doc->getOptionalContent()->evalOCObject(&obj2, &oc)) {
+    ocState &= oc;
+  }
+  obj2.free();
+
 #if USE_EXCEPTIONS
   try {
 #endif
@@ -3776,15 +3983,19 @@
     } else if (obj2.isName("Form")) {
       res->lookupXObjectNF(name, &refObj);
       if (out->useDrawForm() && refObj.isRef()) {
-	out->drawForm(refObj.getRef());
+	if (ocState) {
+	  out->drawForm(refObj.getRef());
+	}
       } else {
 	doForm(&refObj, &obj1);
       }
       refObj.free();
     } else if (obj2.isName("PS")) {
-      obj1.streamGetDict()->lookup("Level1", &obj3);
-      out->psXObject(obj1.getStream(),
-		     obj3.isStream() ? obj3.getStream() : (Stream *)NULL);
+      if (ocState) {
+	obj1.streamGetDict()->lookup("Level1", &obj3);
+	out->psXObject(obj1.getStream(),
+		       obj3.isStream() ? obj3.getStream() : (Stream *)NULL);
+      }
     } else if (obj2.isName()) {
       error(errSyntaxError, getPos(),
 	    "Unknown XObject subtype '{0:s}'", obj2.getName());
@@ -3806,6 +4017,8 @@
   }
 #endif
   obj1.free();
+
+  ocState = ocSaved;
 }
 
 void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
@@ -3813,20 +4026,26 @@
   int width, height;
   int bits, maskBits;
   StreamColorSpaceMode csMode;
-  GBool mask;
-  GBool invert;
+  GBool mask, invert;
   GfxColorSpace *colorSpace, *maskColorSpace;
   GfxImageColorMap *colorMap, *maskColorMap;
   Object maskObj, smaskObj;
-  GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
+  GBool haveColorKeyMask, haveExplicitMask, haveSoftMask, haveMatte;
   int maskColors[2*gfxColorMaxComps];
   int maskWidth, maskHeight;
   GBool maskInvert;
   Stream *maskStr;
+  double matte[gfxColorMaxComps];
   GBool interpolate;
+  GfxRenderingIntent riSaved;
   Object obj1, obj2;
   int i, n;
 
+  // check for optional content
+  if (!ocState && !inlineImg) {
+    return;
+  }
+
   // get info from the stream
   bits = 0;
   csMode = streamCSNone;
@@ -3835,6 +4054,9 @@
   // get stream dict
   dict = str->getDict();
 
+  // save the current rendering intent
+  riSaved = state->getRenderingIntent();
+
   // get size
   dict->lookup("Width", &obj1);
   if (obj1.isNull()) {
@@ -3948,6 +4170,12 @@
 
   } else {
 
+    // rendering intent
+    if (dict->lookup("Intent", &obj1)->isName()) {
+      opSetRenderingIntent(&obj1, 1);
+    }
+    obj1.free();
+
     // get color space and color map
     dict->lookup("ColorSpace", &obj1);
     if (obj1.isNull()) {
@@ -3992,7 +4220,7 @@
     }
 
     // get the mask
-    haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
+    haveColorKeyMask = haveExplicitMask = haveSoftMask = haveMatte = gFalse;
     maskStr = NULL; // make gcc happy
     maskWidth = maskHeight = 0; // make gcc happy
     maskInvert = gFalse; // make gcc happy
@@ -4002,6 +4230,9 @@
     if (smaskObj.isStream()) {
       // soft mask
       if (inlineImg) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err1;
       }
       maskStr = smaskObj.getStream();
@@ -4012,6 +4243,9 @@
 	maskDict->lookup("W", &obj1);
       }
       if (!obj1.isInt()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       maskWidth = obj1.getInt();
@@ -4022,6 +4256,9 @@
 	maskDict->lookup("H", &obj1);
       }
       if (!obj1.isInt()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       maskHeight = obj1.getInt();
@@ -4032,6 +4269,9 @@
 	maskDict->lookup("BPC", &obj1);
       }
       if (!obj1.isInt()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       maskBits = obj1.getInt();
@@ -4050,12 +4290,14 @@
 	  obj2.free();
 	}
       }
-      maskColorSpace = GfxColorSpace::parse(&obj1
-					    );
-      obj1.free();
-      if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+      if (!obj1.isName("DeviceGray")) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err1;
       }
+      maskColorSpace = new GfxDeviceGrayColorSpace();
+      obj1.free();
       maskDict->lookup("Decode", &obj1);
       if (obj1.isNull()) {
 	obj1.free();
@@ -4065,9 +4307,29 @@
       obj1.free();
       if (!maskColorMap->isOk()) {
 	delete maskColorMap;
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err1;
       }
-      //~ handle the Matte entry
+      if (maskDict->lookup("Matte", &obj1)->isArray()) {
+	if (obj1.arrayGetLength() == colorSpace->getNComps()) {
+	  for (i = 0; i < obj1.arrayGetLength(); ++i) {
+	    if (obj1.arrayGet(i, &obj2)->isNum()) {
+	      matte[i] = obj2.getNum();
+	    } else {
+	      error(errSyntaxError, getPos(),
+		    "Invalid Matte entry in soft mask");
+	      matte[i] = 0;
+	    }
+	    obj2.free();
+	  }
+	  haveMatte = gTrue;
+	} else {
+	  error(errSyntaxError, getPos(), "Invalid Matte entry in soft mask");
+	}
+      }
+      obj1.free();
       haveSoftMask = gTrue;
     } else if (maskObj.isArray()) {
       // color key mask
@@ -4104,6 +4366,9 @@
     } else if (maskObj.isStream()) {
       // explicit mask
       if (inlineImg) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err1;
       }
       maskStr = maskObj.getStream();
@@ -4114,6 +4379,9 @@
 	maskDict->lookup("W", &obj1);
       }
       if (!obj1.isInt()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       maskWidth = obj1.getInt();
@@ -4124,6 +4392,9 @@
 	maskDict->lookup("H", &obj1);
       }
       if (!obj1.isInt()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       maskHeight = obj1.getInt();
@@ -4134,6 +4405,9 @@
 	maskDict->lookup("IM", &obj1);
       }
       if (!obj1.isBool() || !obj1.getBool()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       obj1.free();
@@ -4148,6 +4422,9 @@
 	maskInvert = obj2.isNum() && obj2.getNum() == 1;
 	obj2.free();
       } else if (!obj1.isNull()) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
 	goto err2;
       }
       obj1.free();
@@ -4169,6 +4446,7 @@
       if (haveSoftMask) {
 	out->drawSoftMaskedImage(state, ref, str, width, height, colorMap,
 				 maskStr, maskWidth, maskHeight, maskColorMap,
+				 haveMatte ? matte : (double *)NULL,
 				 interpolate);
 	delete maskColorMap;
       } else if (haveExplicitMask) {
@@ -4187,10 +4465,16 @@
     smaskObj.free();
   }
 
+  // restore rendering intent
+  if (state->getRenderingIntent() != riSaved) {
+    state->setRenderingIntent(riSaved);
+    out->updateRenderingIntent(state);
+  }
+
   if ((i = width * height) > 1000) {
     i = 1000;
   }
-  updateLevel += i;
+  opCounter += i;
 
   return;
 
@@ -4198,6 +4482,12 @@
   obj1.free();
  err1:
   error(errSyntaxError, getPos(), "Bad image parameters");
+
+  // restore rendering intent
+  if (state->getRenderingIntent() != riSaved) {
+    state->setRenderingIntent(riSaved);
+    out->updateRenderingIntent(state);
+  }
 }
 
 void Gfx::doForm(Object *strRef, Object *str) {
@@ -4208,7 +4498,6 @@
   double m[6], bbox[4];
   Object resObj;
   Dict *resDict;
-  GBool oc, ocSaved;
   Object obj1, obj2, obj3;
   int i;
 
@@ -4217,6 +4506,11 @@
     return;
   }
 
+  // check for optional content
+  if (!ocState && !out->needCharCount()) {
+    return;
+  }
+
   // get stream dict
   dict = str->streamGetDict();
 
@@ -4227,25 +4521,11 @@
   }
   obj1.free();
 
-  // check for optional content key
-  ocSaved = ocState;
-  dict->lookupNF("OC", &obj1);
-  if (doc->getOptionalContent()->evalOCObject(&obj1, &oc) && !oc) {
-    obj1.free();
-    if (out->needCharCount()) {
-      ocState = gFalse;
-    } else {
-      return;
-    }
-  }
-  obj1.free();
-
   // get bounding box
   dict->lookup("BBox", &bboxObj);
   if (!bboxObj.isArray()) {
     bboxObj.free();
     error(errSyntaxError, getPos(), "Bad form bounding box");
-    ocState = ocSaved;
     return;
   }
   for (i = 0; i < 4; ++i) {
@@ -4308,8 +4588,6 @@
     delete blendingColorSpace;
   }
   resObj.free();
-
-  ocState = ocSaved;
 }
 
 void Gfx::drawForm(Object *strRef, Dict *resDict,
@@ -4328,7 +4606,7 @@
   pushResources(resDict);
 
   // save current graphics state
-  savedState = saveStateStack();
+  saveState();
 
   // kill any pre-existing path
   state->clearPath();
@@ -4376,9 +4654,15 @@
     baseMatrix[i] = state->getCTM()[i];
   }
 
+  // save the state stack -- this handles the case where the form
+  // contents have unbalanced q/Q operators
+  savedState = saveStateStack();
+
   // draw the form
   display(strRef, gFalse);
 
+  restoreStateStack(savedState);
+
   if (softMask || transpGroup) {
     out->endTransparencyGroup(state);
   }
@@ -4392,7 +4676,7 @@
   parser = oldParser;
 
   // restore graphics state
-  restoreStateStack(savedState);
+  restoreState();
 
   // pop resource stack
   popResources();
@@ -4410,6 +4694,15 @@
   contentStreamStack->append(oldGfx->contentStreamStack);
 }
 
+void Gfx::endOfPage() {
+  while (state->hasSaves()) {
+    restoreState();
+  }
+  while (markedContentStack->getLength() > 0) {
+    opEndMarkedContent(NULL, 0);
+  }
+}
+
 //------------------------------------------------------------------------
 // in-line image operators
 //------------------------------------------------------------------------
@@ -4416,6 +4709,7 @@
 
 void Gfx::opBeginImage(Object args[], int numArgs) {
   Stream *str;
+  GBool haveLength;
   int c1, c2, c3;
 
   // NB: this function is run even if ocState is false -- doImage() is
@@ -4422,29 +4716,47 @@
   // responsible for skipping over the inline image data
 
   // build dict/stream
-  str = buildImageStream();
+  str = buildImageStream(&haveLength);
 
   // display the image
   if (str) {
     doImage(NULL, str, gTrue);
   
-    // skip 'EI' tag
-    c1 = str->getUndecodedStream()->getChar();
-    c2 = str->getUndecodedStream()->getChar();
-    c3 = str->getUndecodedStream()->lookChar();
-    while (!(c1 == 'E' && c2 == 'I' && Lexer::isSpace(c3)) && c3 != EOF) {
-      c1 = c2;
+    // if we have the stream length, skip to end-of-stream and then
+    // skip 'EI' in the original stream
+    if (haveLength) {
+      while ((c1 = str->getChar()) != EOF) ;
+      delete str;
+      str = parser->getStream();
+      c1 = str->getChar();
+      c2 = str->getChar();
+      c3 = str->lookChar();
+      while (!(c1 == 'E' && c2 == 'I' && Lexer::isSpace(c3)) && c3 != EOF) {
+	c1 = c2;
+	c2 = str->getChar();
+	c3 = str->lookChar();
+      }
+
+    // else, look for the 'EI' tag and skip it
+    } else {
+      c1 = str->getUndecodedStream()->getChar();
       c2 = str->getUndecodedStream()->getChar();
       c3 = str->getUndecodedStream()->lookChar();
+      while (!(c1 == 'E' && c2 == 'I' && Lexer::isSpace(c3)) && c3 != EOF) {
+	c1 = c2;
+	c2 = str->getUndecodedStream()->getChar();
+	c3 = str->getUndecodedStream()->lookChar();
+      }
+      delete str;
     }
-    delete str;
   }
 }
 
-Stream *Gfx::buildImageStream() {
+Stream *Gfx::buildImageStream(GBool *haveLength) {
   Object dict;
-  Object obj;
+  Object obj, lengthObj;
   char *key;
+  int length;
   Stream *str;
 
   // build dictionary
@@ -4475,6 +4787,19 @@
   }
   obj.free();
 
+  // check for length field
+  length = 0;
+  *haveLength = gFalse;
+  if (!dict.dictLookup("Length", &lengthObj)->isInt()) {
+    lengthObj.free();
+    dict.dictLookup("L", &lengthObj);
+  }
+  if (lengthObj.isInt()) {
+    length = lengthObj.getInt();
+    *haveLength = gTrue;
+  }
+  lengthObj.free();
+
   // make stream
   if (!(str = parser->getStream())) {
     error(errSyntaxError, getPos(), "Invalid inline image data");
@@ -4481,7 +4806,7 @@
     dict.free();
     return NULL;
   }
-  str = new EmbedStream(str, &dict, gFalse, 0);
+  str = new EmbedStream(str, &dict, *haveLength, (GFileOffset)length);
   str = str->addFilters(&dict);
 
   return str;
@@ -4545,7 +4870,7 @@
   if (args[0].isName("OC") && numArgs == 2 && args[1].isName() &&
       res->lookupPropertiesNF(args[1].getName(), &obj)) {
     if (doc->getOptionalContent()->evalOCObject(&obj, &ocStateNew)) {
-      ocState = ocStateNew;
+      ocState &= ocStateNew;
     }
     obj.free();
     mcKind = gfxMCOptionalContent;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Gfx.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2,7 +2,7 @@
 //
 // Gfx.h
 //
-// Copyright 1996-2003 Glyph & Cog, LLC
+// Copyright 1996-2016 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -17,6 +17,7 @@
 
 #include "gtypes.h"
 #include "gfile.h"
+#include "GfxState.h"
 
 class GString;
 class GList;
@@ -30,19 +31,6 @@
 class OutputDev;
 class GfxFontDict;
 class GfxFont;
-class GfxPattern;
-class GfxTilingPattern;
-class GfxShadingPattern;
-class GfxShading;
-class GfxFunctionShading;
-class GfxAxialShading;
-class GfxRadialShading;
-class GfxGouraudTriangleShading;
-class GfxPatchMeshShading;
-struct GfxPatch;
-class GfxState;
-struct GfxColor;
-class GfxColorSpace;
 class Gfx;
 class PDFRectangle;
 class AnnotBorderStyle;
@@ -189,6 +177,9 @@
   // the new Gfx object.
   void takeContentStreamStack(Gfx *oldGfx);
 
+  // Clear the state stack and the marked content stack.
+  void endOfPage();
+
 private:
 
   PDFDoc *doc;
@@ -197,7 +188,8 @@
   GBool subPage;		// is this a sub-page object?
   GBool printCommands;		// print the drawing commands (for debugging)
   GfxResources *res;		// resource stack
-  int updateLevel;
+  int opCounter;		// operation counter (used to decide when
+				//   to check for an abort)
 
   GfxState *state;		// current graphics state
   GBool fontChanged;		// set if font or text matrix has changed
@@ -206,9 +198,6 @@
   double baseMatrix[6];		// default matrix for most recent
 				//   page/form/pattern
   int formDepth;
-  double textClipBBox[4];	// text clipping bounding box
-  GBool textClipBBoxEmpty;	// true if textClipBBox has not been
-				//   initialized yet
   GBool ocState;		// true if drawing is enabled, false if
 				//   disabled
   GList *markedContentStack;	// BMC/BDC/EMC stack [GfxMarkedContent]
@@ -246,6 +235,7 @@
 		  GBool isolated, GBool knockout,
 		  Function *transferFunc, GfxColor *backdropColor);
   void opSetRenderingIntent(Object args[], int numArgs);
+  GfxRenderingIntent parseRenderingIntent(const char *name);
 
   // color operators
   void opSetFillGray(Object args[], int numArgs);
@@ -345,7 +335,7 @@
 
   // in-line image operators
   void opBeginImage(Object args[], int numArgs);
-  Stream *buildImageStream();
+  Stream *buildImageStream(GBool *haveLength);
   void opImageData(Object args[], int numArgs);
   void opEndImage(Object args[], int numArgs);
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -18,10 +18,10 @@
 #include <ctype.h>
 #include <math.h>
 #include <limits.h>
-#if HAVE_STD_SORT
-#include <algorithm>
-#endif
 #include "gmem.h"
+#include "gmempp.h"
+#include "GList.h"
+#include "GHash.h"
 #include "Error.h"
 #include "Object.h"
 #include "Dict.h"
@@ -206,6 +206,7 @@
   type = typeA;
   embFontID = embFontIDA;
   embFontName = NULL;
+  hasToUnicode = gFalse;
 }
 
 GfxFont::~GfxFont() {
@@ -414,7 +415,7 @@
 
 void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) {
   Object obj1, obj2, obj3, obj4;
-  double t;
+  double t, t2;
   int i;
 
   // assume Times-Roman by default (for substitution purposes)
@@ -444,14 +445,34 @@
     }
     obj2.free();
 
-    // get Ascent and Descent
+    // get Ascent
+    // (CapHeight is a little more reliable - so use it if present)
     obj1.dictLookup("Ascent", &obj2);
-    if (obj2.isNum()) {
-      t = 0.001 * obj2.getNum();
-      // some broken font descriptors specify a negative ascent
-      if (t < 0) {
-	t = -t;
+    obj1.dictLookup("CapHeight", &obj3);
+    if (obj2.isNum() || obj3.isNum()) {
+      if (obj2.isNum()) {
+	t = 0.001 * obj2.getNum();
+	// some broken font descriptors specify a negative ascent
+	if (t < 0) {
+	  t = -t;
+	}
+      } else {
+	t = 0;
       }
+      if (obj3.isNum()) {
+	t2 = 0.001 * obj3.getNum();
+	// some broken font descriptors specify a negative ascent
+	if (t2 < 0) {
+	  t2 = -t2;
+	}
+      } else {
+	t2 = 0;
+      }
+      // if both Ascent and CapHeight are set, use the smaller one
+      // (because the most common problem is that Ascent is too large)
+      if (t2 != 0 && (t == 0 || t2 < t)) {
+	t = t2;
+      }
       // some broken font descriptors set ascent and descent to 0;
       // others set it to ridiculous values (e.g., 32768)
       if (t != 0 && t < 1.9) {
@@ -459,6 +480,9 @@
       }
     }
     obj2.free();
+    obj3.free();
+
+    // get Descent
     obj1.dictLookup("Descent", &obj2);
     if (obj2.isNum()) {
       t = 0.001 * obj2.getNum();
@@ -512,6 +536,7 @@
     ctu = CharCodeToUnicode::parseCMap(buf, nBits);
   }
   delete buf;
+  hasToUnicode = gTrue;
   return ctu;
 }
 
@@ -847,7 +872,6 @@
   GString *name2;
   BuiltinFont *builtinFont;
   const char **baseEnc;
-  GBool baseEncFromFontFile;
   char *buf;
   int len;
   FoFiType1 *ffT1;
@@ -924,9 +948,9 @@
   // get info from font descriptor
   readFontDescriptor(xref, fontDict);
 
-  // for non-embedded fonts, don't trust the ascent/descent/bbox
-  // values from the font descriptor
-  if (builtinFont && embFontID.num < 0) {
+  // for Base-14 fonts (even if embedded), don't trust the
+  // ascent/descent/bbox values from the font descriptor
+  if (builtinFont) {
     ascent = 0.001 * builtinFont->ascent;
     descent = 0.001 * builtinFont->descent;
     fontBBox[0] = 0.001 * builtinFont->bbox[0];
@@ -1137,14 +1161,14 @@
 	// name that looks like 'Axx' or 'xx', where 'A' is any letter
 	// and 'xx' is two hex digits
 	if ((strlen(charName) == 3 &&
-	     isalpha(charName[0]) &&
-	     isxdigit(charName[1]) && isxdigit(charName[2]) &&
+	     isalpha(charName[0] & 0xff) &&
+	     isxdigit(charName[1] & 0xff) && isxdigit(charName[2] & 0xff) &&
 	     ((charName[1] >= 'a' && charName[1] <= 'f') ||
 	      (charName[1] >= 'A' && charName[1] <= 'F') ||
 	      (charName[2] >= 'a' && charName[2] <= 'f') ||
 	      (charName[2] >= 'A' && charName[2] <= 'F'))) ||
 	    (strlen(charName) == 2 &&
-	     isxdigit(charName[0]) && isxdigit(charName[1]) &&
+	     isxdigit(charName[0] & 0xff) && isxdigit(charName[1] & 0xff) &&
 	     ((charName[0] >= 'a' && charName[0] <= 'f') ||
 	      (charName[0] >= 'A' && charName[0] <= 'F') ||
 	      (charName[1] >= 'a' && charName[1] <= 'f') ||
@@ -1169,6 +1193,7 @@
   //             use 'uni0628.medi', etc.)
   // where 'A' and 'B' are any letters, 'xx' is two hex digits, 'xxxx'
   // is four hex digits, and 'nn' is 2-4 decimal digits
+  usedNumericHeuristic = gFalse;
   if (missing && globalParams->getMapNumericCharNames()) {
     for (code = 0; code < 256; ++code) {
       if ((charName = enc[code]) && !toUnicode[code] &&
@@ -1175,29 +1200,33 @@
 	  strcmp(charName, ".notdef")) {
 	n = (int)strlen(charName);
 	code2 = -1;
-	if (hex && n == 3 && isalpha(charName[0]) &&
-	    isxdigit(charName[1]) && isxdigit(charName[2])) {
+	if (hex && n == 3 && isalpha(charName[0] & 0xff) &&
+	    isxdigit(charName[1] & 0xff) && isxdigit(charName[2] & 0xff)) {
 	  sscanf(charName+1, "%x", &code2);
 	} else if (hex && n == 2 &&
-		   isxdigit(charName[0]) && isxdigit(charName[1])) {
+		   isxdigit(charName[0] & 0xff) &&
+		   isxdigit(charName[1] & 0xff)) {
 	  sscanf(charName, "%x", &code2);
 	} else if (!hex && n >= 2 && n <= 4 &&
-		   isdigit(charName[0]) && isdigit(charName[1])) {
+		   isdigit(charName[0] & 0xff) && isdigit(charName[1] & 0xff)) {
 	  code2 = atoi(charName);
 	} else if (n >= 3 && n <= 5 &&
-		   isdigit(charName[1]) && isdigit(charName[2])) {
+		   isdigit(charName[1] & 0xff) && isdigit(charName[2] & 0xff)) {
 	  code2 = atoi(charName+1);
 	} else if (n >= 4 && n <= 6 &&
-		   isdigit(charName[2]) && isdigit(charName[3])) {
+		   isdigit(charName[2] & 0xff) && isdigit(charName[3] & 0xff)) {
 	  code2 = atoi(charName+2);
 	} else if (n >= 7 && charName[0] == 'u' && charName[1] == 'n' &&
 		   charName[2] == 'i' &&
-		   isxdigit(charName[3]) && isxdigit(charName[4]) &&
-		   isxdigit(charName[5]) && isxdigit(charName[6])) {
+		   isxdigit(charName[3] & 0xff) &&
+		   isxdigit(charName[4] & 0xff) &&
+		   isxdigit(charName[5] & 0xff) &&
+		   isxdigit(charName[6] & 0xff)) {
 	  sscanf(charName + 3, "%x", &code2);
 	}
 	if (code2 >= 0 && code2 <= 0xffff) {
 	  toUnicode[code] = (Unicode)code2;
+	  usedNumericHeuristic = gTrue;
 	}
       }
     }
@@ -1406,7 +1435,7 @@
     cmapPlatform = ff->getCmapPlatform(i);
     cmapEncoding = ff->getCmapEncoding(i);
     if ((cmapPlatform == 3 && cmapEncoding == 1) ||
-	cmapPlatform == 0) {
+	(cmapPlatform == 0 && cmapEncoding <= 4)) {
       unicodeCmap = i;
     } else if (cmapPlatform == 1 && cmapEncoding == 0) {
       macRomanCmap = i;
@@ -1512,39 +1541,64 @@
   return resources.isDict() ? resources.getDict() : (Dict *)NULL;
 }
 
-//------------------------------------------------------------------------
-// GfxCIDFont
-//------------------------------------------------------------------------
+GBool Gfx8BitFont::problematicForUnicode() {
+  GString *nameLC;
+  GBool symbolic;
 
-#if HAVE_STD_SORT
+  // potential inputs:
+  // - font is embedded (GfxFont.embFontID.num >= 0)
+  // - font name (GfxFont.name)
+  // - font type (GfxFont.type)
+  // - Base-14 font (Gfx8BitFont.base14 != NULL)
+  // - symbolic (GfxFont.flags & fontSymbolic)
+  // - has Encoding array (Gfx8BitFont.hasEncoding)
+  // - extracted base encoding from embedded font file
+  //   (Gfx8BitFont.baseEncFromFontFile)
+  // - has a ToUnicode map (GfxFont.hasToUnicode)
+  // - used the numeric glyph name heuristic
+  //   (Gfx8BitFont.usedNumericHeuristic)
 
-struct cmpWidthExcepFunctor {
-  bool operator()(const GfxFontCIDWidthExcep &w1,
-		  const GfxFontCIDWidthExcep &w2) {
-    return w1.first < w2.first;
+  if (name) {
+    nameLC = name->copy();
+    nameLC->lowerCase();
+    symbolic = strstr(nameLC->getCString(), "dingbat") ||
+               strstr(nameLC->getCString(), "wingding") ||
+               strstr(nameLC->getCString(), "commpi");
+    delete nameLC;
+    if (symbolic) {
+      return gFalse;
+    }
   }
-};
 
-struct cmpWidthExcepVFunctor {
-  bool operator()(const GfxFontCIDWidthExcepV &w1,
-		  const GfxFontCIDWidthExcepV &w2) {
-    return w1.first < w2.first;
-  }
-};
+  if (embFontID.num >= 0) {
+    switch (type) {
+    case fontType1:
+    case fontType1C:
+    case fontType1COT:
+      return !hasToUnicode && (!hasEncoding || usedNumericHeuristic);
 
-#else // HAVE_STD_SORT
+    case fontType3:
+      return !hasToUnicode && !hasEncoding;
 
-static int CDECL cmpWidthExcep(const void *w1, const void *w2) {
-  return ((GfxFontCIDWidthExcep *)w1)->first -
-         ((GfxFontCIDWidthExcep *)w2)->first;
-}
+    case fontTrueType:
+    case fontTrueTypeOT:
+      return !hasToUnicode && !hasEncoding;
 
-static int CDECL cmpWidthExcepV(const void *w1, const void *w2) {
-  return ((GfxFontCIDWidthExcepV *)w1)->first -
-         ((GfxFontCIDWidthExcepV *)w2)->first;
+    default:
+      return !hasToUnicode;
+    }
+
+  } else {
+    // NB: type will be fontTypeUnknown if the PDF specifies an
+    // invalid font type -- which is ok, if we have a ToUnicode map or
+    // an encoding
+    return !hasToUnicode && !hasEncoding;
+  }
 }
 
-#endif
+//------------------------------------------------------------------------
+// GfxCIDFont
+//------------------------------------------------------------------------
 
 GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
 		       GfxFontType typeA, Ref embFontIDA, Dict *fontDict):
@@ -1615,6 +1669,7 @@
   obj1.free();
 
   // look for a ToUnicode CMap
+  hasKnownCollection = gFalse;
   if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) {
     ctuUsesCharCode = gFalse;
 
@@ -1625,9 +1680,15 @@
       ctu = CharCodeToUnicode::makeIdentityMapping();
 
     // look for a user-supplied .cidToUnicode file
-    } else if (!(ctu = globalParams->getCIDToUnicode(collection))) {
+    } else if ((ctu = globalParams->getCIDToUnicode(collection))) {
+      hasKnownCollection = gTrue;
+
+    } else {
       error(errSyntaxError, -1,
 	    "Unknown character collection '{0:t}'", collection);
+
+      // fall back to an identity mapping
+      ctu = CharCodeToUnicode::makeIdentityMapping();
     }
   }
 
@@ -1634,16 +1695,21 @@
   // look for a Unicode-to-Unicode mapping
   if (name && (utu = globalParams->getUnicodeToUnicode(name))) {
     if (ctu) {
-      for (c = 0; c < ctu->getLength(); ++c) {
-	n = ctu->mapToUnicode(c, uBuf, 8);
-	if (n >= 1) {
-	  n = utu->mapToUnicode((CharCode)uBuf[0], uBuf, 8);
+      if (ctu->isIdentity()) {
+	ctu->decRefCnt();
+	ctu = utu;
+      } else {
+	for (c = 0; c < ctu->getLength(); ++c) {
+	  n = ctu->mapToUnicode(c, uBuf, 8);
 	  if (n >= 1) {
-	    ctu->setMapping(c, uBuf, n);
+	    n = utu->mapToUnicode((CharCode)uBuf[0], uBuf, 8);
+	    if (n >= 1) {
+	      ctu->setMapping(c, uBuf, n);
+	    }
 	  }
 	}
+	utu->decRefCnt();
       }
-      utu->decRefCnt();
     } else {
       ctu = utu;
     }
@@ -1660,29 +1726,31 @@
   obj1.free();
 
   // CIDToGIDMap
-  // (the PDF spec only allows these for TrueType fonts, but Acrobat
-  // apparently also allows them for OpenType CFF fonts)
-  if (type == fontCIDType2 || type == fontCIDType0COT) {
-    desFontDict->lookup("CIDToGIDMap", &obj1);
-    if (obj1.isStream()) {
-      cidToGIDLen = 0;
-      i = 64;
-      cidToGID = (int *)gmallocn(i, sizeof(int));
-      obj1.streamReset();
-      while ((c1 = obj1.streamGetChar()) != EOF &&
-	     (c2 = obj1.streamGetChar()) != EOF) {
-	if (cidToGIDLen == i) {
-	  i *= 2;
-	  cidToGID = (int *)greallocn(cidToGID, i, sizeof(int));
-	}
-	cidToGID[cidToGIDLen++] = (c1 << 8) + c2;
+  // (the PDF 1.7 spec only allows these for TrueType fonts, but
+  // Acrobat apparently also allows them for OpenType CFF fonts -- and
+  // the PDF 2.0 spec has removed the prohibition)
+  hasIdentityCIDToGID = gFalse;
+  desFontDict->lookup("CIDToGIDMap", &obj1);
+  if (obj1.isStream()) {
+    cidToGIDLen = 0;
+    i = 64;
+    cidToGID = (int *)gmallocn(i, sizeof(int));
+    obj1.streamReset();
+    while ((c1 = obj1.streamGetChar()) != EOF &&
+	   (c2 = obj1.streamGetChar()) != EOF) {
+      if (cidToGIDLen == i) {
+	i *= 2;
+	cidToGID = (int *)greallocn(cidToGID, i, sizeof(int));
       }
-      obj1.streamClose();
-    } else if (!obj1.isName("Identity") && !obj1.isNull()) {
-      error(errSyntaxError, -1, "Invalid CIDToGIDMap entry in CID font");
+      cidToGID[cidToGIDLen++] = (c1 << 8) + c2;
     }
-    obj1.free();
+    obj1.streamClose();
+  } else if (obj1.isName("Identity")) {
+    hasIdentityCIDToGID = gTrue;
+  } else if (!obj1.isNull()) {
+    error(errSyntaxError, -1, "Invalid CIDToGIDMap entry in CID font");
   }
+  obj1.free();
 
   //----- character metrics -----
 
@@ -1744,13 +1812,6 @@
       obj3.free();
       obj2.free();
     }
-#if HAVE_STD_SORT
-    std::sort(widths.exceps, widths.exceps + widths.nExceps,
-	      cmpWidthExcepFunctor());
-#else
-    qsort(widths.exceps, widths.nExceps, sizeof(GfxFontCIDWidthExcep),
-	  &cmpWidthExcep);
-#endif
   }
   obj1.free();
 
@@ -1833,13 +1894,6 @@
       obj3.free();
       obj2.free();
     }
-#if HAVE_STD_SORT
-    std::sort(widths.excepsV, widths.excepsV + widths.nExcepsV,
-	      cmpWidthExcepVFunctor());
-#else
-    qsort(widths.excepsV, widths.nExcepsV, sizeof(GfxFontCIDWidthExcepV),
-	  &cmpWidthExcepV);
-#endif
   }
   obj1.free();
 
@@ -1879,8 +1933,7 @@
 			    double *dx, double *dy, double *ox, double *oy) {
   CID cid;
   CharCode c;
-  double w, h, vx, vy;
-  int n, a, b, m;
+  int n;
 
   if (!cMap) {
     *code = 0;
@@ -1902,59 +1955,54 @@
 
   // horizontal
   if (cMap->getWMode() == 0) {
-    w = widths.defWidth;
-    h = vx = vy = 0;
-    if (widths.nExceps > 0 && cid >= widths.exceps[0].first) {
-      a = 0;
-      b = widths.nExceps;
-      // invariant: widths.exceps[a].first <= cid < widths.exceps[b].first
-      while (b - a > 1) {
-	m = (a + b) / 2;
-	if (widths.exceps[m].first <= cid) {
-	  a = m;
-	} else {
-	  b = m;
-	}
-      }
-      if (cid <= widths.exceps[a].last) {
-	w = widths.exceps[a].width;
-      }
-    }
+    getHorizontalMetrics(cid, dx);
+    *dy = *ox = *oy = 0;
 
   // vertical
   } else {
-    w = 0;
-    h = widths.defHeight;
-    vx = widths.defWidth / 2;
-    vy = widths.defVY;
-    if (widths.nExcepsV > 0 && cid >= widths.excepsV[0].first) {
-      a = 0;
-      b = widths.nExcepsV;
-      // invariant: widths.excepsV[a].first <= cid < widths.excepsV[b].first
-      while (b - a > 1) {
-	m = (a + b) / 2;
-	if (widths.excepsV[m].last <= cid) {
-	  a = m;
-	} else {
-	  b = m;
-	}
-      }
-      if (cid <= widths.excepsV[a].last) {
-	h = widths.excepsV[a].height;
-	vx = widths.excepsV[a].vx;
-	vy = widths.excepsV[a].vy;
-      }
-    }
+    getVerticalMetrics(cid, dy, ox, oy);
+    *dx = 0;
   }
 
-  *dx = w;
-  *dy = h;
-  *ox = vx;
-  *oy = vy;
-
   return n;
 }
 
+// NB: Section 9.7.4.3 in the PDF 2.0 spec says that, in the case of
+// duplicate entries in the metrics, the first entry should be used.
+// This means we need to leave the metrics in the original order and
+// perform a linear search.  (Or use a more complex data structure.)
+void GfxCIDFont::getHorizontalMetrics(CID cid, double *w) {
+  int i;
+  for (i = 0; i < widths.nExceps; ++i) {
+    if (widths.exceps[i].first <= cid && cid <= widths.exceps[i].last) {
+      *w = widths.exceps[i].width;
+      return;
+    }
+  }
+  *w = widths.defWidth;
+}
+
+// NB: Section 9.7.4.3 in the PDF 2.0 spec says that, in the case of
+// duplicate entries in the metrics, the first entry should be used.
+// This means we need to leave the metrics in the original order and
+// perform a linear search.  (Or use a more complex data structure.)
+void GfxCIDFont::getVerticalMetrics(CID cid, double *h,
+				    double *vx, double *vy) {
+  int i;
+  for (i = 0; i < widths.nExcepsV; ++i) {
+    if (widths.excepsV[i].first <= cid && cid <= widths.excepsV[i].last) {
+      *h = widths.excepsV[i].height;
+      *vx = widths.excepsV[i].vx;
+      *vy = widths.excepsV[i].vy;
+      return;
+    }
+  }
+  *h = widths.defHeight;
+  getHorizontalMetrics(cid, vx);
+  *vx /= 2;
+  *vy = widths.defVY;
+}
+
 int GfxCIDFont::getWMode() {
   return cMap ? cMap->getWMode() : 0;
 }
@@ -1970,43 +2018,97 @@
   return cMap ? cMap->getCollection() : (GString *)NULL;
 }
 
+GBool GfxCIDFont::problematicForUnicode() {
+  GString *nameLC;
+  GBool symbolic;
+
+  // potential inputs:
+  // - font is embedded (GfxFont.embFontID.num >= 0)
+  // - font name (GfxFont.name)
+  // - font type (GfxFont.type)
+  // - symbolic (GfxFont.flags & fontSymbolic)
+  // - has a ToUnicode map (GfxFont.hasToUnicode)
+  // - collection is Adobe-Identity or Adobe-UCS
+  //   (GfxCIDFont.collection - compare string)
+  // - collection is known AdobeCJK (GfxCIDFont.hasKnownCollection)
+  // - has non-Identity CIDToGIDMap (GfxCIDFont.cidToGID != NULL)
+  // - has Identity CIDToGIDMap (GfxCIDFont.hasIdentityCIDToGID)
+
+  if (name) {
+    nameLC = name->copy();
+    nameLC->lowerCase();
+    symbolic = strstr(nameLC->getCString(), "dingbat") ||
+               strstr(nameLC->getCString(), "wingding") ||
+               strstr(nameLC->getCString(), "commpi");
+    delete nameLC;
+    if (symbolic) {
+      return gFalse;
+    }
+  }
+
+  if (embFontID.num >= 0) {
+    switch (type) {
+    case fontCIDType0:
+    case fontCIDType0C:
+    case fontCIDType0COT:
+      return !hasToUnicode && !hasKnownCollection;
+
+    case fontCIDType2:
+    case fontCIDType2OT:
+      return !hasToUnicode && !hasKnownCollection;
+
+    default:
+      return !hasToUnicode;
+    }
+
+  } else {
+    return !hasToUnicode;
+  }
+}
+
 //------------------------------------------------------------------------
 // GfxFontDict
 //------------------------------------------------------------------------
 
 GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) {
-  int i;
+  GfxFont *font;
+  char *tag;
   Object obj1, obj2;
   Ref r;
+  int i;
 
-  numFonts = fontDict->getLength();
-  fonts = (GfxFont **)gmallocn(numFonts, sizeof(GfxFont *));
-  for (i = 0; i < numFonts; ++i) {
+  fonts = new GHash(gTrue);
+  uniqueFonts = new GList();
+  for (i = 0; i < fontDict->getLength(); ++i) {
+    tag = fontDict->getKey(i);
     fontDict->getValNF(i, &obj1);
     obj1.fetch(xref, &obj2);
-    if (obj2.isDict()) {
+    if (!obj2.isDict()) {
+      error(errSyntaxError, -1, "font resource is not a dictionary");
+    } else if (obj1.isRef() && (font = lookupByRef(obj1.getRef()))) {
+      fonts->add(new GString(tag), font);
+    } else {
       if (obj1.isRef()) {
 	r = obj1.getRef();
+      } else if (fontDictRef) {
+	// legal generation numbers are five digits, so we use a
+	// 6-digit number here
+	r.gen = 100000 + fontDictRef->num;
+	r.num = i;
       } else {
-	// no indirect reference for this font, so invent a unique one
-	// (legal generation numbers are five digits, so any 6-digit
-	// number would be safe)
-	r.num = i;
-	if (fontDictRef) {
-	  r.gen = 100000 + fontDictRef->num;
+	// no indirect reference for this font, or for the containing
+	// font dict, so hash the font and use that
+	r.gen = 100000;
+	r.num = hashFontObject(&obj2);
+      }
+      if ((font = GfxFont::makeFont(xref, tag, r, obj2.getDict()))) {
+	if (!font->isOk()) {
+	  delete font;
 	} else {
-	  r.gen = 999999;
+	  uniqueFonts->append(font);
+	  fonts->add(new GString(tag), font);
 	}
       }
-      fonts[i] = GfxFont::makeFont(xref, fontDict->getKey(i),
-				   r, obj2.getDict());
-      if (fonts[i] && !fonts[i]->isOk()) {
-	delete fonts[i];
-	fonts[i] = NULL;
-      }
-    } else {
-      error(errSyntaxError, -1, "font resource is not a dictionary");
-      fonts[i] = NULL;
     }
     obj1.free();
     obj2.free();
@@ -2014,36 +2116,141 @@
 }
 
 GfxFontDict::~GfxFontDict() {
+  deleteGList(uniqueFonts, GfxFont);
+  delete fonts;
+}
+
+GfxFont *GfxFontDict::lookup(char *tag) {
+  return (GfxFont *)fonts->lookup(tag);
+}
+
+GfxFont *GfxFontDict::lookupByRef(Ref ref) {
+  GfxFont *font;
   int i;
 
-  for (i = 0; i < numFonts; ++i) {
-    if (fonts[i]) {
-      delete fonts[i];
+  for (i = 0; i < uniqueFonts->getLength(); ++i) {
+    font = (GfxFont *)uniqueFonts->get(i);
+    if (font->getID()->num == ref.num &&
+	font->getID()->gen == ref.gen) {
+      return font;
     }
   }
-  gfree(fonts);
+  return NULL;
 }
 
-GfxFont *GfxFontDict::lookup(char *tag) {
-  int i;
+int GfxFontDict::getNumFonts() {
+  return uniqueFonts->getLength();
+}
 
-  for (i = 0; i < numFonts; ++i) {
-    if (fonts[i] && fonts[i]->matches(tag)) {
-      return fonts[i];
+GfxFont *GfxFontDict::getFont(int i) {
+  return (GfxFont *)uniqueFonts->get(i);
+}
+
+// FNV-1a hash
+class FNVHash {
+public:
+
+  FNVHash() {
+    h = 2166136261U;
+  }
+
+  void hash(char c) {
+    h ^= c & 0xff;
+    h *= 16777619;
+  }
+
+  void hash(char *p, int n) {
+    int i;
+    for (i = 0; i < n; ++i) {
+      hash(p[i]);
     }
   }
-  return NULL;
+
+  int get31() {
+    return (h ^ (h >> 31)) & 0x7fffffff;
+  }
+
+private:
+
+  Guint h;
+};
+
+int GfxFontDict::hashFontObject(Object *obj) {
+  FNVHash h;
+
+  hashFontObject1(obj, &h);
+  return h.get31();
 }
 
-GfxFont *GfxFontDict::lookupByRef(Ref ref) {
-  int i;
+void GfxFontDict::hashFontObject1(Object *obj, FNVHash *h) {
+  Object obj2;
+  GString *s;
+  char *p;
+  double r;
+  int n, i;
 
-  for (i = 0; i < numFonts; ++i) {
-    if (fonts[i] &&
-	fonts[i]->getID()->num == ref.num &&
-	fonts[i]->getID()->gen == ref.gen) {
-      return fonts[i];
+  switch (obj->getType()) {
+  case objBool:
+    h->hash('b');
+    h->hash(obj->getBool() ? 1 : 0);
+    break;
+  case objInt:
+    h->hash('i');
+    n = obj->getInt();
+    h->hash((char *)&n, sizeof(int));
+    break;
+  case objReal:
+    h->hash('r');
+    r = obj->getReal();
+    h->hash((char *)&r, sizeof(double));
+    break;
+  case objString:
+    h->hash('s');
+    s = obj->getString();
+    h->hash(s->getCString(), s->getLength());
+    break;
+  case objName:
+    h->hash('n');
+    p = obj->getName();
+    h->hash(p, (int)strlen(p));
+    break;
+  case objNull:
+    h->hash('z');
+    break;
+  case objArray:
+    h->hash('a');
+    n = obj->arrayGetLength();
+    h->hash((char *)&n, sizeof(int));
+    for (i = 0; i < n; ++i) {
+      obj->arrayGetNF(i, &obj2);
+      hashFontObject1(&obj2, h);
+      obj2.free();
     }
+    break;
+  case objDict:
+    h->hash('d');
+    n = obj->dictGetLength();
+    h->hash((char *)&n, sizeof(int));
+    for (i = 0; i < n; ++i) {
+      p = obj->dictGetKey(i);
+      h->hash(p, (int)strlen(p));
+      obj->dictGetValNF(i, &obj2);
+      hashFontObject1(&obj2, h);
+      obj2.free();
+    }
+    break;
+  case objStream:
+    // this should never happen - streams must be indirect refs
+    break;
+  case objRef:
+    h->hash('f');
+    n = obj->getRefNum();
+    h->hash((char *)&n, sizeof(int));
+    n = obj->getRefGen();
+    h->hash((char *)&n, sizeof(int));
+    break;
+  default:
+    h->hash('u');
+    break;
   }
-  return NULL;
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxFont.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -20,6 +20,8 @@
 #include "Object.h"
 #include "CharTypes.h"
 
+class GList;
+class GHash;
 class Dict;
 class CMap;
 class CharCodeToUnicode;
@@ -26,6 +28,7 @@
 class FoFiTrueType;
 struct GfxFontCIDWidths;
 struct Base14FontMapEntry;
+class FNVHash;
 
 //------------------------------------------------------------------------
 // GfxFontType
@@ -204,6 +207,10 @@
 			  Unicode *u, int uSize, int *uLen,
 			  double *dx, double *dy, double *ox, double *oy) = 0;
 
+  // Returns true if this font is likely to be problematic when
+  // converting text to Unicode.
+  virtual GBool problematicForUnicode() = 0;
+
 protected:
 
   static GfxFontType getFontType(XRef *xref, Dict *fontDict, Ref *embID);
@@ -225,6 +232,7 @@
   double missingWidth;		// "default" width
   double ascent;		// max height above baseline
   double descent;		// max depth below baseline
+  GBool hasToUnicode;		// true if the font has a ToUnicode map
   GBool ok;
 };
 
@@ -276,6 +284,8 @@
   // Return the Type 3 Resources dictionary, or NULL if none.
   Dict *getResources();
 
+  virtual GBool problematicForUnicode();
+
 private:
 
   Base14FontMapEntry *base14;	// for Base-14 fonts only; NULL otherwise
@@ -285,6 +295,8 @@
   CharCodeToUnicode *ctu;	// char code --> Unicode
   GBool hasEncoding;
   GBool usesMacRomanEnc;
+  GBool baseEncFromFontFile;
+  GBool usedNumericHeuristic;
   double widths[256];		// character widths
   Object charProcs;		// Type 3 CharProcs dictionary
   Object resources;		// Type 3 Resources dictionary
@@ -324,8 +336,14 @@
   int *getCIDToGID() { return cidToGID; }
   int getCIDToGIDLen() { return cidToGIDLen; }
 
+  virtual GBool problematicForUnicode();
+
 private:
 
+  void getHorizontalMetrics(CID cid, double *w);
+  void getVerticalMetrics(CID cid, double *h,
+			  double *vx, double *vy);
+
   GString *collection;		// collection name
   CMap *cMap;			// char code --> CID
   CharCodeToUnicode *ctu;	// CID/char code --> Unicode
@@ -335,6 +353,8 @@
   int *cidToGID;		// CID --> GID mapping (for embedded
 				//   TrueType fonts)
   int cidToGIDLen;
+  GBool hasKnownCollection;
+  GBool hasIdentityCIDToGID;
 };
 
 //------------------------------------------------------------------------
@@ -355,13 +375,18 @@
   GfxFont *lookupByRef(Ref ref);
 
   // Iterative access.
-  int getNumFonts() { return numFonts; }
-  GfxFont *getFont(int i) { return fonts[i]; }
+  int getNumFonts();
+  GfxFont *getFont(int i);
 
 private:
 
-  GfxFont **fonts;		// list of fonts
-  int numFonts;			// number of fonts
+  int hashFontObject(Object *obj);
+  void hashFontObject1(Object *obj, FNVHash *h);
+
+  GHash *fonts;			// hash table of fonts -- this may
+				//   include duplicates, i.e., when
+				//   two tags map to the same font
+  GList *uniqueFonts;		// list of all unique font objects (no dups)
 };
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2,7 +2,7 @@
 //
 // GfxState.cc
 //
-// Copyright 1996-2003 Glyph & Cog, LLC
+// Copyright 1996-2016 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -16,7 +16,9 @@
 #include <math.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "Error.h"
+#include "GlobalParams.h"
 #include "Object.h"
 #include "Array.h"
 #include "Page.h"
@@ -29,6 +31,7 @@
 // loops in the color space object structure.
 #define colorSpaceRecursionLimit 8
 
+
 //------------------------------------------------------------------------
 
 static inline GfxColorComp clip01(GfxColorComp x) {
@@ -90,6 +93,7 @@
 #define nGfxColorSpaceModes ((sizeof(gfxColorSpaceModeNames) / sizeof(char *)))
 
 
+
 //------------------------------------------------------------------------
 // GfxColorSpace
 //------------------------------------------------------------------------
@@ -212,15 +216,18 @@
 }
 
 
-void GfxDeviceGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxDeviceGrayColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				      GfxRenderingIntent ri) {
   *gray = clip01(color->c[0]);
 }
 
-void GfxDeviceGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxDeviceGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				     GfxRenderingIntent ri) {
   rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
 }
 
-void GfxDeviceGrayColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxDeviceGrayColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				      GfxRenderingIntent ri) {
   cmyk->c = cmyk->m = cmyk->y = 0;
   cmyk->k = clip01(gfxColorComp1 - color->c[0]);
 }
@@ -307,15 +314,18 @@
   return cs;
 }
 
-void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				   GfxRenderingIntent ri) {
   *gray = clip01(color->c[0]);
 }
 
-void GfxCalGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+ void GfxCalGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				   GfxRenderingIntent ri) {
   rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
 }
 
-void GfxCalGrayColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxCalGrayColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				   GfxRenderingIntent ri) {
   cmyk->c = cmyk->m = cmyk->y = 0;
   cmyk->k = clip01(gfxColorComp1 - color->c[0]);
 }
@@ -343,19 +353,22 @@
 }
 
 
-void GfxDeviceRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxDeviceRGBColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				     GfxRenderingIntent ri) {
   *gray = clip01((GfxColorComp)(0.3  * color->c[0] +
 				0.59 * color->c[1] +
 				0.11 * color->c[2] + 0.5));
 }
 
-void GfxDeviceRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxDeviceRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				    GfxRenderingIntent ri) {
   rgb->r = clip01(color->c[0]);
   rgb->g = clip01(color->c[1]);
   rgb->b = clip01(color->c[2]);
 }
 
-void GfxDeviceRGBColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxDeviceRGBColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				     GfxRenderingIntent ri) {
   GfxColorComp c, m, y, k;
 
   c = clip01(gfxColorComp1 - color->c[0]);
@@ -486,19 +499,22 @@
 }
 
 
-void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				  GfxRenderingIntent ri) {
   *gray = clip01((GfxColorComp)(0.299 * color->c[0] +
 				0.587 * color->c[1] +
 				0.114 * color->c[2] + 0.5));
 }
 
-void GfxCalRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxCalRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				 GfxRenderingIntent ri) {
   rgb->r = clip01(color->c[0]);
   rgb->g = clip01(color->c[1]);
   rgb->b = clip01(color->c[2]);
 }
 
-void GfxCalRGBColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxCalRGBColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				  GfxRenderingIntent ri) {
   GfxColorComp c, m, y, k;
 
   c = clip01(gfxColorComp1 - color->c[0]);
@@ -542,7 +558,8 @@
 }
 
 
-void GfxDeviceCMYKColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxDeviceCMYKColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				      GfxRenderingIntent ri) {
   *gray = clip01((GfxColorComp)(gfxColorComp1 - color->c[3]
 				- 0.3  * color->c[0]
 				- 0.59 * color->c[1]
@@ -549,7 +566,8 @@
 				- 0.11 * color->c[2] + 0.5));
 }
 
-void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxDeviceCMYKColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				     GfxRenderingIntent ri) {
   double c, m, y, k, c1, m1, y1, k1, r, g, b, x;
 
   c = colToDbl(color->c[0]);
@@ -611,7 +629,8 @@
   rgb->b = clip01(dblToCol(b));
 }
 
-void GfxDeviceCMYKColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxDeviceCMYKColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				      GfxRenderingIntent ri) {
   cmyk->c = clip01(color->c[0]);
   cmyk->m = clip01(color->c[1]);
   cmyk->y = clip01(color->c[2]);
@@ -626,6 +645,7 @@
   color->c[3] = gfxColorComp1;
 }
 
+
 //------------------------------------------------------------------------
 // GfxLabColorSpace
 //------------------------------------------------------------------------
@@ -741,16 +761,18 @@
 }
 
 
-void GfxLabColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxLabColorSpace::getGray(GfxColor *color, GfxGray *gray,
+			       GfxRenderingIntent ri) {
   GfxRGB rgb;
 
-  getRGB(color, &rgb);
+  getRGB(color, &rgb, ri);
   *gray = clip01((GfxColorComp)(0.299 * rgb.r +
 				0.587 * rgb.g +
 				0.114 * rgb.b + 0.5));
 }
 
-void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+			      GfxRenderingIntent ri) {
   double X, Y, Z;
   double t1, t2;
   double r, g, b;
@@ -788,12 +810,13 @@
   rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
 }
 
-void GfxLabColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxLabColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+			       GfxRenderingIntent ri) {
   GfxRGB rgb;
   GfxColorComp c, m, y, k;
 
 
-  getRGB(color, &rgb);
+  getRGB(color, &rgb, ri);
   c = clip01(gfxColorComp1 - rgb.r);
   m = clip01(gfxColorComp1 - rgb.g);
   y = clip01(gfxColorComp1 - rgb.b);
@@ -950,16 +973,19 @@
 }
 
 
-void GfxICCBasedColorSpace::getGray(GfxColor *color, GfxGray *gray) {
-  alt->getGray(color, gray);
+void GfxICCBasedColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				    GfxRenderingIntent ri) {
+  alt->getGray(color, gray, ri);
 }
 
-void GfxICCBasedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
-  alt->getRGB(color, rgb);
+void GfxICCBasedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				   GfxRenderingIntent ri) {
+  alt->getRGB(color, rgb, ri);
 }
 
-void GfxICCBasedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
-  alt->getCMYK(color, cmyk);
+void GfxICCBasedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				    GfxRenderingIntent ri) {
+  alt->getCMYK(color, cmyk, ri);
 }
 
 
@@ -994,6 +1020,7 @@
 #endif
 }
 
+
 //------------------------------------------------------------------------
 // GfxIndexedColorSpace
 //------------------------------------------------------------------------
@@ -1107,11 +1134,17 @@
 					       GfxColor *baseColor) {
   Guchar *p;
   double low[gfxColorMaxComps], range[gfxColorMaxComps];
-  int n, i;
+  int n, i, k;
 
   n = base->getNComps();
   base->getDefaultRanges(low, range, indexHigh);
-  p = &lookup[(int)(colToDbl(color->c[0]) + 0.5) * n];
+  k = (int)(colToDbl(color->c[0]) + 0.5);
+  if (k < 0) {
+    k = 0;
+  } else if (k > indexHigh) {
+    k = indexHigh;
+  }
+  p = &lookup[k * n];
   for (i = 0; i < n; ++i) {
     baseColor->c[i] = dblToCol(low[i] + (p[i] / 255.0) * range[i]);
   }
@@ -1118,22 +1151,25 @@
   return baseColor;
 }
 
-void GfxIndexedColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxIndexedColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				   GfxRenderingIntent ri) {
   GfxColor color2;
 
-  base->getGray(mapColorToBase(color, &color2), gray);
+  base->getGray(mapColorToBase(color, &color2), gray, ri);
 }
 
-void GfxIndexedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxIndexedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				  GfxRenderingIntent ri) {
   GfxColor color2;
 
-  base->getRGB(mapColorToBase(color, &color2), rgb);
+  base->getRGB(mapColorToBase(color, &color2), rgb, ri);
 }
 
-void GfxIndexedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxIndexedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				   GfxRenderingIntent ri) {
   GfxColor color2;
 
-  base->getCMYK(mapColorToBase(color, &color2), cmyk);
+  base->getCMYK(mapColorToBase(color, &color2), cmyk, ri);
 }
 
 
@@ -1196,7 +1232,6 @@
   return cs;
 }
 
-//~ handle the 'All' and 'None' colorants
 GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr,
 					      int recursion) {
   GfxSeparationColorSpace *cs;
@@ -1242,7 +1277,8 @@
 }
 
 
-void GfxSeparationColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxSeparationColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				      GfxRenderingIntent ri) {
   double x;
   double c[gfxColorMaxComps];
   GfxColor color2;
@@ -1253,10 +1289,11 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getGray(&color2, gray);
+  alt->getGray(&color2, gray, ri);
 }
 
-void GfxSeparationColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxSeparationColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				     GfxRenderingIntent ri) {
   double x;
   double c[gfxColorMaxComps];
   GfxColor color2;
@@ -1267,10 +1304,11 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getRGB(&color2, rgb);
+  alt->getRGB(&color2, rgb, ri);
 }
 
-void GfxSeparationColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxSeparationColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				      GfxRenderingIntent ri) {
   double x;
   double c[gfxColorMaxComps];
   GfxColor color2;
@@ -1281,7 +1319,7 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getCMYK(&color2, cmyk);
+  alt->getCMYK(&color2, cmyk, ri);
 }
 
 
@@ -1296,12 +1334,14 @@
 GfxDeviceNColorSpace::GfxDeviceNColorSpace(int nCompsA,
 					   GString **namesA,
 					   GfxColorSpace *altA,
-					   Function *funcA) {
+					   Function *funcA,
+					   Object *attrsA) {
   int i;
 
   nComps = nCompsA;
   alt = altA;
   func = funcA;
+  attrsA->copy(&attrs);
   nonMarking = gTrue;
   overprintMask = 0;
   for (i = 0; i < nComps; ++i) {
@@ -1327,6 +1367,7 @@
 					   GString **namesA,
 					   GfxColorSpace *altA,
 					   Function *funcA,
+					   Object *attrsA,
 					   GBool nonMarkingA,
 					   Guint overprintMaskA) {
   int i;
@@ -1334,6 +1375,7 @@
   nComps = nCompsA;
   alt = altA;
   func = funcA;
+  attrsA->copy(&attrs);
   nonMarking = nonMarkingA;
   overprintMask = overprintMaskA;
   for (i = 0; i < nComps; ++i) {
@@ -1349,6 +1391,7 @@
   }
   delete alt;
   delete func;
+  attrs.free();
 }
 
 GfxColorSpace *GfxDeviceNColorSpace::copy() {
@@ -1355,11 +1398,10 @@
   GfxDeviceNColorSpace *cs;
 
   cs = new GfxDeviceNColorSpace(nComps, names, alt->copy(), func->copy(),
-				nonMarking, overprintMask);
+				&attrs, nonMarking, overprintMask);
   return cs;
 }
 
-//~ handle the 'None' colorant
 GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr,
 					   int recursion) {
   GfxDeviceNColorSpace *cs;
@@ -1367,7 +1409,7 @@
   GString *namesA[gfxColorMaxComps];
   GfxColorSpace *altA;
   Function *funcA;
-  Object obj1, obj2;
+  Object attrsA, obj1, obj2;
   int i;
 
   if (arr->getLength() != 4 && arr->getLength() != 5) {
@@ -1408,7 +1450,13 @@
     goto err4;
   }
   obj1.free();
-  cs = new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA);
+  if (arr->getLength() == 5) {
+    arr->get(4, &attrsA);
+  } else {
+    attrsA.initNull();
+  }
+  cs = new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, &attrsA);
+  attrsA.free();
   return cs;
 
  err4:
@@ -1424,7 +1472,8 @@
 }
 
 
-void GfxDeviceNColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxDeviceNColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				   GfxRenderingIntent ri) {
   double x[gfxColorMaxComps], c[gfxColorMaxComps];
   GfxColor color2;
   int i;
@@ -1436,10 +1485,11 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getGray(&color2, gray);
+  alt->getGray(&color2, gray, ri);
 }
 
-void GfxDeviceNColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxDeviceNColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				  GfxRenderingIntent ri) {
   double x[gfxColorMaxComps], c[gfxColorMaxComps];
   GfxColor color2;
   int i;
@@ -1451,10 +1501,11 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getRGB(&color2, rgb);
+  alt->getRGB(&color2, rgb, ri);
 }
 
-void GfxDeviceNColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxDeviceNColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				   GfxRenderingIntent ri) {
   double x[gfxColorMaxComps], c[gfxColorMaxComps];
   GfxColor color2;
   int i;
@@ -1466,7 +1517,7 @@
   for (i = 0; i < alt->getNComps(); ++i) {
     color2.c[i] = dblToCol(c[i]);
   }
-  alt->getCMYK(&color2, cmyk);
+  alt->getCMYK(&color2, cmyk, ri);
 }
 
 
@@ -1527,15 +1578,18 @@
 }
 
 
-void GfxPatternColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+void GfxPatternColorSpace::getGray(GfxColor *color, GfxGray *gray,
+				   GfxRenderingIntent ri) {
   *gray = 0;
 }
 
-void GfxPatternColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+void GfxPatternColorSpace::getRGB(GfxColor *color, GfxRGB *rgb,
+				  GfxRenderingIntent ri) {
   rgb->r = rgb->g = rgb->b = 0;
 }
 
-void GfxPatternColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+void GfxPatternColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk,
+				   GfxRenderingIntent ri) {
   cmyk->c = cmyk->m = cmyk->y = 0;
   cmyk->k = 1;
 }
@@ -2162,6 +2216,7 @@
   } else {
     error(errSyntaxError, -1,
 	  "Missing or invalid Coords in shading dictionary");
+    obj1.free();
     goto err1;
   }
   obj1.free();
@@ -3129,7 +3184,7 @@
 	p->x[1][0] = x[7];
 	p->y[1][0] = y[7];
 	for (j = 0; j < nCompsA; ++j) {
-	  p->color[0][1][j] = patchesA[nPatchesA-1].color[1][0][j];
+	  p->color[0][0][j] = patchesA[nPatchesA-1].color[1][0][j];
 	  p->color[0][1][j] = patchesA[nPatchesA-1].color[0][0][j];
 	  p->color[1][1][j] = c[0][j];
 	  p->color[1][0][j] = c[1][j];
@@ -3572,7 +3627,8 @@
   }
 }
 
-void GfxImageColorMap::getGray(Guchar *x, GfxGray *gray) {
+void GfxImageColorMap::getGray(Guchar *x, GfxGray *gray,
+			       GfxRenderingIntent ri) {
   GfxColor color;
   int i;
 
@@ -3580,16 +3636,16 @@
     for (i = 0; i < nComps2; ++i) {
       color.c[i] = lookup2[i][x[0]];
     }
-    colorSpace2->getGray(&color, gray);
+    colorSpace2->getGray(&color, gray, ri);
   } else {
     for (i = 0; i < nComps; ++i) {
       color.c[i] = lookup[i][x[i]];
     }
-    colorSpace->getGray(&color, gray);
+    colorSpace->getGray(&color, gray, ri);
   }
 }
 
-void GfxImageColorMap::getRGB(Guchar *x, GfxRGB *rgb) {
+void GfxImageColorMap::getRGB(Guchar *x, GfxRGB *rgb, GfxRenderingIntent ri) {
   GfxColor color;
   int i;
 
@@ -3597,16 +3653,17 @@
     for (i = 0; i < nComps2; ++i) {
       color.c[i] = lookup2[i][x[0]];
     }
-    colorSpace2->getRGB(&color, rgb);
+    colorSpace2->getRGB(&color, rgb, ri);
   } else {
     for (i = 0; i < nComps; ++i) {
       color.c[i] = lookup[i][x[i]];
     }
-    colorSpace->getRGB(&color, rgb);
+    colorSpace->getRGB(&color, rgb, ri);
   }
 }
 
-void GfxImageColorMap::getCMYK(Guchar *x, GfxCMYK *cmyk) {
+void GfxImageColorMap::getCMYK(Guchar *x, GfxCMYK *cmyk,
+			       GfxRenderingIntent ri) {
   GfxColor color;
   int i;
 
@@ -3614,12 +3671,12 @@
     for (i = 0; i < nComps2; ++i) {
       color.c[i] = lookup2[i][x[0]];
     }
-    colorSpace2->getCMYK(&color, cmyk);
+    colorSpace2->getCMYK(&color, cmyk, ri);
   } else {
     for (i = 0; i < nComps; ++i) {
       color.c[i] = lookup[i][x[i]];
     }
-    colorSpace->getCMYK(&color, cmyk);
+    colorSpace->getCMYK(&color, cmyk, ri);
   }
 }
 
@@ -3637,7 +3694,8 @@
   }
 }
 
-void GfxImageColorMap::getGrayByteLine(Guchar *in, Guchar *out, int n) {
+void GfxImageColorMap::getGrayByteLine(Guchar *in, Guchar *out, int n,
+				       GfxRenderingIntent ri) {
   GfxColor color;
   GfxGray gray;
   int i, j;
@@ -3647,7 +3705,7 @@
       for (i = 0; i < nComps2; ++i) {
 	color.c[i] = lookup2[i][in[j]];
       }
-      colorSpace2->getGray(&color, &gray);
+      colorSpace2->getGray(&color, &gray, ri);
       out[j] = colToByte(gray);
     }
   } else {
@@ -3655,13 +3713,14 @@
       for (i = 0; i < nComps; ++i) {
 	color.c[i] = lookup[i][in[j * nComps + i]];
       }
-      colorSpace->getGray(&color, &gray);
+      colorSpace->getGray(&color, &gray, ri);
       out[j] = colToByte(gray);
     }
   }
 }
 
-void GfxImageColorMap::getRGBByteLine(Guchar *in, Guchar *out, int n) {
+void GfxImageColorMap::getRGBByteLine(Guchar *in, Guchar *out, int n,
+				      GfxRenderingIntent ri) {
   GfxColor color;
   GfxRGB rgb;
   int i, j;
@@ -3671,7 +3730,7 @@
       for (i = 0; i < nComps2; ++i) {
 	color.c[i] = lookup2[i][in[j]];
       }
-      colorSpace2->getRGB(&color, &rgb);
+      colorSpace2->getRGB(&color, &rgb, ri);
       out[j*3] = colToByte(rgb.r);
       out[j*3 + 1] = colToByte(rgb.g);
       out[j*3 + 2] = colToByte(rgb.b);
@@ -3681,7 +3740,7 @@
       for (i = 0; i < nComps; ++i) {
 	color.c[i] = lookup[i][in[j * nComps + i]];
       }
-      colorSpace->getRGB(&color, &rgb);
+      colorSpace->getRGB(&color, &rgb, ri);
       out[j*3] = colToByte(rgb.r);
       out[j*3 + 1] = colToByte(rgb.g);
       out[j*3 + 2] = colToByte(rgb.b);
@@ -3689,7 +3748,8 @@
   }
 }
 
-void GfxImageColorMap::getCMYKByteLine(Guchar *in, Guchar *out, int n) {
+void GfxImageColorMap::getCMYKByteLine(Guchar *in, Guchar *out, int n,
+				       GfxRenderingIntent ri) {
   GfxColor color;
   GfxCMYK cmyk;
   int i, j;
@@ -3699,7 +3759,7 @@
       for (i = 0; i < nComps2; ++i) {
 	color.c[i] = lookup2[i][in[j]];
       }
-      colorSpace2->getCMYK(&color, &cmyk);
+      colorSpace2->getCMYK(&color, &cmyk, ri);
       out[j*4] = colToByte(cmyk.c);
       out[j*4 + 1] = colToByte(cmyk.m);
       out[j*4 + 2] = colToByte(cmyk.y);
@@ -3710,7 +3770,7 @@
       for (i = 0; i < nComps; ++i) {
 	color.c[i] = lookup[i][in[j * nComps + i]];
       }
-      colorSpace->getCMYK(&color, &cmyk);
+      colorSpace->getCMYK(&color, &cmyk, ri);
       out[j*4] = colToByte(cmyk.c);
       out[j*4 + 1] = colToByte(cmyk.m);
       out[j*4 + 2] = colToByte(cmyk.y);
@@ -3983,6 +4043,7 @@
   strokeOpacity = 1;
   fillOverprint = gFalse;
   strokeOverprint = gFalse;
+  renderingIntent = gfxRenderingIntentRelativeColorimetric;
   overprintMode = 0;
   transfer[0] = transfer[1] = transfer[2] = transfer[3] = NULL;
 
@@ -4165,8 +4226,8 @@
 
 void GfxState::getFontTransMat(double *m11, double *m12,
 			       double *m21, double *m22) {
-  *m11 = (textMat[0] * ctm[0] + textMat[1] * ctm[2]) * fontSize;
-  *m12 = (textMat[0] * ctm[1] + textMat[1] * ctm[3]) * fontSize;
+  *m11 = (textMat[0] * ctm[0] + textMat[1] * ctm[2]) * fontSize * horizScaling;
+  *m12 = (textMat[0] * ctm[1] + textMat[1] * ctm[3]) * fontSize * horizScaling;
   *m21 = (textMat[2] * ctm[0] + textMat[3] * ctm[2]) * fontSize;
   *m22 = (textMat[2] * ctm[1] + textMat[3] * ctm[3]) * fontSize;
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GfxState.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2,7 +2,7 @@
 //
 // GfxState.h
 //
-// Copyright 1996-2003 Glyph & Cog, LLC
+// Copyright 1996-2016 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -23,6 +23,7 @@
 class GfxFont;
 class PDFRectangle;
 class GfxShading;
+class GfxState;
 
 //------------------------------------------------------------------------
 // GfxBlendMode
@@ -48,6 +49,19 @@
 };
 
 //------------------------------------------------------------------------
+// GfxRenderingIntent
+//------------------------------------------------------------------------
+
+enum GfxRenderingIntent {
+  gfxRenderingIntentAbsoluteColorimetric,
+  gfxRenderingIntentRelativeColorimetric,
+  gfxRenderingIntentSaturation,
+  gfxRenderingIntentPerceptual
+};
+
+#define gfxNumRenderingIntents 4
+
+//------------------------------------------------------------------------
 // GfxColorComp
 //------------------------------------------------------------------------
 
@@ -111,6 +125,7 @@
 
 
 
+
 //------------------------------------------------------------------------
 // GfxColorSpace
 //------------------------------------------------------------------------
@@ -149,9 +164,12 @@
 
 
   // Convert to gray, RGB, or CMYK.
-  virtual void getGray(GfxColor *color, GfxGray *gray) = 0;
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb) = 0;
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk) = 0;
+  virtual void getGray(GfxColor *color, GfxGray *gray,
+		       GfxRenderingIntent ri) = 0;
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb,
+		      GfxRenderingIntent ri) = 0;
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk,
+		       GfxRenderingIntent ri) = 0;
 
   // Return the number of color components.
   virtual int getNComps() = 0;
@@ -168,6 +186,7 @@
   // mark the page (e.g., the "None" colorant).
   virtual GBool isNonMarking() { return gFalse; }
 
+
   // Return the color space's overprint mask.
   Guint getOverprintMask() { return overprintMask; }
 
@@ -194,9 +213,9 @@
   virtual GfxColorSpace *copy();
   virtual GfxColorSpaceMode getMode() { return csDeviceGray; }
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 1; }
   virtual void getDefaultColor(GfxColor *color);
@@ -219,9 +238,9 @@
   // Construct a CalGray color space.  Returns NULL if unsuccessful.
   static GfxColorSpace *parse(Array *arr, int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 1; }
   virtual void getDefaultColor(GfxColor *color);
@@ -254,9 +273,9 @@
   virtual GfxColorSpace *copy();
   virtual GfxColorSpaceMode getMode() { return csDeviceRGB; }
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 3; }
   virtual void getDefaultColor(GfxColor *color);
@@ -279,9 +298,9 @@
   // Construct a CalRGB color space.  Returns NULL if unsuccessful.
   static GfxColorSpace *parse(Array *arr, int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 3; }
   virtual void getDefaultColor(GfxColor *color);
@@ -318,13 +337,14 @@
   virtual GfxColorSpace *copy();
   virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; }
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 4; }
   virtual void getDefaultColor(GfxColor *color);
 
+
 private:
 };
 
@@ -343,9 +363,9 @@
   // Construct a Lab color space.  Returns NULL if unsuccessful.
   static GfxColorSpace *parse(Array *arr, int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 3; }
   virtual void getDefaultColor(GfxColor *color);
@@ -390,9 +410,9 @@
   static GfxColorSpace *parse(Array *arr,
 			      int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return nComps; }
   virtual void getDefaultColor(GfxColor *color);
@@ -400,8 +420,10 @@
   virtual void getDefaultRanges(double *decodeLow, double *decodeRange,
 				int maxImgPixel);
 
+
   // ICCBased-specific access.
   GfxColorSpace *getAlt() { return alt; }
+  Ref getICCProfileStreamRef() { return iccProfileStream; }
 
 private:
 
@@ -428,9 +450,9 @@
   static GfxColorSpace *parse(Array *arr,
 			      int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 1; }
   virtual void getDefaultColor(GfxColor *color);
@@ -468,9 +490,9 @@
   static GfxColorSpace *parse(Array *arr,
 			      int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 1; }
   virtual void getDefaultColor(GfxColor *color);
@@ -502,7 +524,8 @@
 public:
 
   GfxDeviceNColorSpace(int nCompsA, GString **namesA,
-		       GfxColorSpace *alt, Function *func);
+		       GfxColorSpace *alt, Function *func,
+		       Object *attrsA);
   virtual ~GfxDeviceNColorSpace();
   virtual GfxColorSpace *copy();
   virtual GfxColorSpaceMode getMode() { return csDeviceN; }
@@ -511,9 +534,9 @@
   static GfxColorSpace *parse(Array *arr,
 			      int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return nComps; }
   virtual void getDefaultColor(GfxColor *color);
@@ -524,11 +547,13 @@
   GString *getColorantName(int i) { return names[i]; }
   GfxColorSpace *getAlt() { return alt; }
   Function *getTintTransformFunc() { return func; }
+  Object *getAttrs() { return &attrs; }
 
 private:
 
   GfxDeviceNColorSpace(int nCompsA, GString **namesA,
 		       GfxColorSpace *alt, Function *func,
+		       Object *attrsA,
 		       GBool nonMarkingA, Guint overprintMaskA);
 
   int nComps;			// number of components
@@ -536,6 +561,7 @@
     *names[gfxColorMaxComps];
   GfxColorSpace *alt;		// alternate color space
   Function *func;		// tint transform (into alternate color space)
+  Object attrs;
   GBool nonMarking;
 };
 
@@ -555,9 +581,9 @@
   static GfxColorSpace *parse(Array *arr,
 			      int recursion);
 
-  virtual void getGray(GfxColor *color, GfxGray *gray);
-  virtual void getRGB(GfxColor *color, GfxRGB *rgb);
-  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
+  virtual void getGray(GfxColor *color, GfxGray *gray, GfxRenderingIntent ri);
+  virtual void getRGB(GfxColor *color, GfxRGB *rgb, GfxRenderingIntent ri);
+  virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk, GfxRenderingIntent ri);
 
   virtual int getNComps() { return 0; }
   virtual void getDefaultColor(GfxColor *color);
@@ -915,15 +941,15 @@
   double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
 
   // Convert an image pixel to a color.
-  void getGray(Guchar *x, GfxGray *gray);
-  void getRGB(Guchar *x, GfxRGB *rgb);
-  void getCMYK(Guchar *x, GfxCMYK *cmyk);
+  void getGray(Guchar *x, GfxGray *gray, GfxRenderingIntent ri);
+  void getRGB(Guchar *x, GfxRGB *rgb, GfxRenderingIntent ri);
+  void getCMYK(Guchar *x, GfxCMYK *cmyk, GfxRenderingIntent ri);
   void getColor(Guchar *x, GfxColor *color);
 
   // Convert a line of <n> pixels to 8-bit colors.
-  void getGrayByteLine(Guchar *in, Guchar *out, int n);
-  void getRGBByteLine(Guchar *in, Guchar *out, int n);
-  void getCMYKByteLine(Guchar *in, Guchar *out, int n);
+  void getGrayByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri);
+  void getRGBByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri);
+  void getCMYKByteLine(Guchar *in, Guchar *out, int n, GfxRenderingIntent ri);
 
 private:
 
@@ -1090,17 +1116,17 @@
   GfxColor *getFillColor() { return &fillColor; }
   GfxColor *getStrokeColor() { return &strokeColor; }
   void getFillGray(GfxGray *gray)
-    { fillColorSpace->getGray(&fillColor, gray); }
+    { fillColorSpace->getGray(&fillColor, gray, renderingIntent); }
   void getStrokeGray(GfxGray *gray)
-    { strokeColorSpace->getGray(&strokeColor, gray); }
+    { strokeColorSpace->getGray(&strokeColor, gray, renderingIntent); }
   void getFillRGB(GfxRGB *rgb)
-    { fillColorSpace->getRGB(&fillColor, rgb); }
+    { fillColorSpace->getRGB(&fillColor, rgb, renderingIntent); }
   void getStrokeRGB(GfxRGB *rgb)
-    { strokeColorSpace->getRGB(&strokeColor, rgb); }
+    { strokeColorSpace->getRGB(&strokeColor, rgb, renderingIntent); }
   void getFillCMYK(GfxCMYK *cmyk)
-    { fillColorSpace->getCMYK(&fillColor, cmyk); }
+    { fillColorSpace->getCMYK(&fillColor, cmyk, renderingIntent); }
   void getStrokeCMYK(GfxCMYK *cmyk)
-    { strokeColorSpace->getCMYK(&strokeColor, cmyk); }
+    { strokeColorSpace->getCMYK(&strokeColor, cmyk, renderingIntent); }
   GfxColorSpace *getFillColorSpace() { return fillColorSpace; }
   GfxColorSpace *getStrokeColorSpace() { return strokeColorSpace; }
   GfxPattern *getFillPattern() { return fillPattern; }
@@ -1111,11 +1137,12 @@
   GBool getFillOverprint() { return fillOverprint; }
   GBool getStrokeOverprint() { return strokeOverprint; }
   int getOverprintMode() { return overprintMode; }
+  GfxRenderingIntent getRenderingIntent() { return renderingIntent; }
   Function **getTransfer() { return transfer; }
   double getLineWidth() { return lineWidth; }
   void getLineDash(double **dash, int *length, double *start)
     { *dash = lineDash; *length = lineDashLength; *start = lineDashStart; }
-  int getFlatness() { return flatness; }
+  double getFlatness() { return flatness; }
   int getLineJoin() { return lineJoin; }
   int getLineCap() { return lineCap; }
   double getMiterLimit() { return miterLimit; }
@@ -1180,10 +1207,11 @@
   void setFillOverprint(GBool op) { fillOverprint = op; }
   void setStrokeOverprint(GBool op) { strokeOverprint = op; }
   void setOverprintMode(int opm) { overprintMode = opm; }
+  void setRenderingIntent(GfxRenderingIntent ri) { renderingIntent = ri; }
   void setTransfer(Function **funcs);
   void setLineWidth(double width) { lineWidth = width; }
   void setLineDash(double *dash, int length, double start);
-  void setFlatness(int flatness1) { flatness = flatness1; }
+  void setFlatness(double flatness1) { flatness = flatness1; }
   void setLineJoin(int lineJoin1) { lineJoin = lineJoin1; }
   void setLineCap(int lineCap1) { lineCap = lineCap1; }
   void setMiterLimit(double limit) { miterLimit = limit; }
@@ -1223,6 +1251,8 @@
   void clip();
   void clipToStrokePath();
   void clipToRect(double xMin, double yMin, double xMax, double yMax);
+  void resetDevClipRect(double xMin, double yMin, double xMax, double yMax)
+    { clipXMin = xMin; clipYMin = yMin; clipXMax = xMax; clipYMax = yMax; }
 
   // Text position.
   void textSetPos(double tx, double ty) { lineX = tx; lineY = ty; }
@@ -1259,6 +1289,7 @@
   GBool fillOverprint;		// fill overprint
   GBool strokeOverprint;	// stroke overprint
   int overprintMode;		// overprint mode ("OPM")
+  GfxRenderingIntent renderingIntent;	// rendering intent
   Function *transfer[4];	// transfer function (entries may be: all
 				//   NULL = identity; last three NULL =
 				//   single function; all four non-NULL =
@@ -1268,7 +1299,7 @@
   double *lineDash;		// line dash
   int lineDashLength;
   double lineDashStart;
-  int flatness;			// curve flatness
+  double flatness;		// curve flatness
   int lineJoin;			// line join style
   int lineCap;			// line cap style
   double miterLimit;		// line miter limit

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,20 +15,9 @@
 #pragma implementation
 #endif
 
-#ifdef _WIN32
-#  ifndef _WIN32_WINNT
-#  define _WIN32_WINNT 0x0500 // for GetSystemWindowsDirectory
-#  endif
-#  include <windows.h>
-#endif
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
-#ifdef ENABLE_PLUGINS
-#  ifndef _WIN32
-#    include <dlfcn.h>
-#  endif
-#endif
 #ifdef _WIN32
 #  include <shlobj.h>
 #endif
@@ -36,6 +25,7 @@
 #include <paper.h>
 #endif
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "GHash.h"
@@ -48,9 +38,6 @@
 #include "CMap.h"
 #include "BuiltinFontTables.h"
 #include "FontEncodingTables.h"
-#ifdef ENABLE_PLUGINS
-#  include "XpdfPluginAPI.h"
-#endif
 #include "GlobalParams.h"
 
 #ifdef _WIN32
@@ -82,12 +69,6 @@
 #include "UnicodeMapTables.h"
 #include "UTF8.h"
 
-#ifdef ENABLE_PLUGINS
-#  ifdef _WIN32
-extern XpdfPluginVecTable xpdfPluginVecTable;
-#  endif
-#endif
-
 //------------------------------------------------------------------------
 
 #define cidToUnicodeCacheSize     4
@@ -362,7 +343,7 @@
 #ifdef _WIN32
 void SysFontList::scanWindowsFonts(char *winFontDir) {
   OSVERSIONINFO version;
-  char *path;
+  const char *path;
   DWORD idx, valNameLen, dataLen, type;
   HKEY regKey;
   char valName[1024], data[1024];
@@ -513,146 +494,20 @@
   deleteGList(cmds, GString);
 }
 
-#ifdef ENABLE_PLUGINS
 //------------------------------------------------------------------------
-// Plugin
+// PopupMenuCmd
 //------------------------------------------------------------------------
 
-class Plugin {
-public:
-
-  static Plugin *load(char *type, char *name);
-  ~Plugin();
-
-private:
-
-#ifdef _WIN32
-  Plugin(HMODULE libA);
-  HMODULE lib;
-#else
-  Plugin(void *dlA);
-  void *dl;
-#endif
-};
-
-Plugin *Plugin::load(char *type, char *name) {
-  GString *path;
-  Plugin *plugin;
-  XpdfPluginVecTable *vt;
-  XpdfBool (*xpdfInitPlugin)(void);
-#ifdef _WIN32
-  HMODULE libA;
-#else
-  void *dlA;
-#endif
-
-  path = globalParams->getBaseDir();
-  appendToPath(path, "plugins");
-  appendToPath(path, type);
-  appendToPath(path, name);
-
-#ifdef _WIN32
-  path->append(".dll");
-  if (!(libA = LoadLibraryA(path->getCString()))) {
-    error(errIO, -1, "Failed to load plugin '{0:t}'", path);
-    goto err1;
-  }
-  if (!(vt = (XpdfPluginVecTable *)
-	         GetProcAddress(libA, "xpdfPluginVecTable"))) {
-    error(errIO, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
-	  path);
-    goto err2;
-  }
-#else
-  //~ need to deal with other extensions here
-  path->append(".so");
-  if (!(dlA = dlopen(path->getCString(), RTLD_NOW))) {
-    error(errIO, -1, "Failed to load plugin '{0:t}': {1:s}",
-	  path, dlerror());
-    goto err1;
-  }
-  if (!(vt = (XpdfPluginVecTable *)dlsym(dlA, "xpdfPluginVecTable"))) {
-    error(errIO, -1, "Failed to find xpdfPluginVecTable in plugin '{0:t}'",
-	  path);
-    goto err2;
-  }
-#endif
-
-  if (vt->version != xpdfPluginVecTable.version) {
-    error(errIO, -1, "Plugin '{0:t}' is wrong version", path);
-    goto err2;
-  }
-  memcpy(vt, &xpdfPluginVecTable, sizeof(xpdfPluginVecTable));
-
-#ifdef _WIN32
-  if (!(xpdfInitPlugin = (XpdfBool (*)(void))
-	                     GetProcAddress(libA, "xpdfInitPlugin"))) {
-    error(errIO, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
-	  path);
-    goto err2;
-  }
-#else
-  if (!(xpdfInitPlugin = (XpdfBool (*)(void))dlsym(dlA, "xpdfInitPlugin"))) {
-    error(errIO, -1, "Failed to find xpdfInitPlugin in plugin '{0:t}'",
-	  path);
-    goto err2;
-  }
-#endif
-
-  if (!(*xpdfInitPlugin)()) {
-    error(errIO, -1, "Initialization of plugin '{0:t}' failed", path);
-    goto err2;
-  }
-
-#ifdef _WIN32
-  plugin = new Plugin(libA);
-#else
-  plugin = new Plugin(dlA);
-#endif
-
-  delete path;
-  return plugin;
-
- err2:
-#ifdef _WIN32
-  FreeLibrary(libA);
-#else
-  dlclose(dlA);
-#endif
- err1:
-  delete path;
-  return NULL;
+PopupMenuCmd::PopupMenuCmd(GString *labelA, GList *cmdsA) {
+  label = labelA;
+  cmds = cmdsA;
 }
 
-#ifdef _WIN32
-Plugin::Plugin(HMODULE libA) {
-  lib = libA;
+PopupMenuCmd::~PopupMenuCmd() {
+  delete label;
+  deleteGList(cmds, GString);
 }
-#else
-Plugin::Plugin(void *dlA) {
-  dl = dlA;
-}
-#endif
 
-Plugin::~Plugin() {
-  void (*xpdfFreePlugin)(void);
-
-#ifdef _WIN32
-  if ((xpdfFreePlugin = (void (*)(void))
-                            GetProcAddress(lib, "xpdfFreePlugin"))) {
-    (*xpdfFreePlugin)();
-  }
-  FreeLibrary(lib);
-#else
-  if ((xpdfFreePlugin = (void (*)(void))dlsym(dl, "xpdfFreePlugin"))) {
-    (*xpdfFreePlugin)();
-  }
-  dlclose(dl);
-#endif
-}
-
-#endif // ENABLE_PLUGINS
-
 //------------------------------------------------------------------------
 // parsing
 //------------------------------------------------------------------------
@@ -669,6 +524,10 @@
   gInitMutex(&cMapCacheMutex);
 #endif
 
+#ifdef _WIN32
+  tlsWin32ErrorInfo = TlsAlloc();
+#endif
+
   initBuiltinFontTables();
 
   // scan the encoding in reverse because we want the lowest-numbered
@@ -745,11 +604,10 @@
   psRasterMono = gFalse;
   psRasterSliceSize = 20000000;
   psAlwaysRasterize = gFalse;
+  psNeverRasterize = gFalse;
   textEncoding = new GString("Latin1");
 #if defined(_WIN32)
   textEOL = eolDOS;
-#elif defined(MACOS)
-  textEOL = eolMac;
 #else
   textEOL = eolUnix;
 #endif
@@ -756,13 +614,18 @@
   textPageBreaks = gTrue;
   textKeepTinyChars = gTrue;
   initialZoom = new GString("125");
-  continuousView = gFalse;
+  defaultFitZoom = 0;
+  initialSidebarState = gTrue;
+  maxTileWidth = 1500;
+  maxTileHeight = 1500;
+  tileCacheSize = 10;
+  workerThreads = 1;
   enableFreeType = gTrue;
   disableFreeTypeHinting = gFalse;
   antialias = gTrue;
   vectorAntialias = gTrue;
   antialiasPrinting = gFalse;
-  strokeAdjust = gTrue;
+  strokeAdjust = strokeAdjustNormal;
   screenType = screenUnset;
   screenSize = -1;
   screenDotRadius = -1;
@@ -770,10 +633,14 @@
   screenBlackThreshold = 0.0;
   screenWhiteThreshold = 1.0;
   minLineWidth = 0.0;
+  enablePathSimplification = gFalse;
   drawAnnotations = gTrue;
+  drawFormFields = gTrue;
   overprintPreview = gFalse;
+  paperColor = new GString("#ffffff");
+  matteColor = new GString("#808080");
+  fullScreenMatteColor = new GString("#000000");
   launchCommand = NULL;
-  urlCommand = NULL;
   movieCommand = NULL;
   mapNumericCharNames = gTrue;
   mapUnknownCharNames = gFalse;
@@ -780,6 +647,7 @@
   mapExtTrueTypeFontsViaUnicode = gTrue;
   enableXFA = gTrue;
   createDefaultKeyBindings();
+  popupMenuCmds = new GList();
   printCommands = gFalse;
   errQuiet = gFalse;
 
@@ -789,11 +657,6 @@
   unicodeMapCache = new UnicodeMapCache();
   cMapCache = new CMapCache();
 
-#ifdef ENABLE_PLUGINS
-  plugins = new GList();
-  securityHandlers = new GList();
-#endif
-
   // set up the initial nameToUnicode table
   for (i = 0; nameToUnicodeTab[i].name; ++i) {
     nameToUnicode->add(nameToUnicodeTab[i].name, nameToUnicodeTab[i].u);
@@ -865,8 +728,12 @@
   keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress1, xpdfKeyModNone,
 				     xpdfKeyContextAny, "startSelection"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease1, xpdfKeyModNone,
-				     xpdfKeyContextAny, "endSelection",
-				     "followLinkNoSel"));
+				     xpdfKeyContextAny, "endSelection"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeMouseClick1, xpdfKeyModNone,
+				     xpdfKeyContextAny, "followLinkNoSel"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeMouseClick2, xpdfKeyModNone,
+				     xpdfKeyContextOverLink,
+				     "followLinkInNewTab"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress2, xpdfKeyModNone,
 				     xpdfKeyContextAny, "startPan"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeMouseRelease2, xpdfKeyModNone,
@@ -884,7 +751,52 @@
   keyBindings->append(new KeyBinding(xpdfKeyCodeMousePress7, xpdfKeyModNone,
 				     xpdfKeyContextAny, "scrollRight(16)"));
 
-  //----- keys
+  //----- control keys
+  keyBindings->append(new KeyBinding('o', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "open"));
+  keyBindings->append(new KeyBinding('r', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "reload"));
+  keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "find"));
+  keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "findNext"));
+  keyBindings->append(new KeyBinding('c', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "copy"));
+  keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "print"));
+  keyBindings->append(new KeyBinding('0', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "zoomPercent(125)"));
+  keyBindings->append(new KeyBinding('+', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "zoomIn"));
+  keyBindings->append(new KeyBinding('=', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "zoomIn"));
+  keyBindings->append(new KeyBinding('-', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "zoomOut"));
+  keyBindings->append(new KeyBinding('s', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "saveAs"));
+  keyBindings->append(new KeyBinding('t', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "newTab"));
+  keyBindings->append(new KeyBinding('n', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "newWindow"));
+  keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "closeTabOrQuit"));
+  keyBindings->append(new KeyBinding('q', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "quit"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeTab, xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "nextTab"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeTab,
+				     xpdfKeyModShift | xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "prevTab"));
+  keyBindings->append(new KeyBinding('?', xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "help"));
+
+  //----- alt keys
+  keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModAlt,
+				     xpdfKeyContextAny, "goBackward"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModAlt,
+				     xpdfKeyContextAny, "goForward"));
+
+  //----- home/end keys
   keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModCtrl,
 				     xpdfKeyContextAny, "gotoPage(1)"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeHome, xpdfKeyModNone,
@@ -894,16 +806,29 @@
   keyBindings->append(new KeyBinding(xpdfKeyCodeEnd, xpdfKeyModNone,
 				     xpdfKeyContextAny,
 				     "scrollToBottomRight"));
+
+  //----- pgup/pgdn keys
   keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModNone,
 				     xpdfKeyContextAny, "pageUp"));
-  keyBindings->append(new KeyBinding(xpdfKeyCodeBackspace, xpdfKeyModNone,
-				     xpdfKeyContextAny, "pageUp"));
-  keyBindings->append(new KeyBinding(xpdfKeyCodeDelete, xpdfKeyModNone,
-				     xpdfKeyContextAny, "pageUp"));
   keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModNone,
 				     xpdfKeyContextAny, "pageDown"));
-  keyBindings->append(new KeyBinding(' ', xpdfKeyModNone,
-				     xpdfKeyContextAny, "pageDown"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "prevPage"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "nextPage"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodePgUp, xpdfKeyModCtrl,
+				     xpdfKeyContextScrLockOn,
+				     "prevPageNoScroll"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodePgDn, xpdfKeyModCtrl,
+				     xpdfKeyContextScrLockOn,
+				     "nextPageNoScroll"));
+
+  //----- esc key
+  keyBindings->append(new KeyBinding(xpdfKeyCodeEsc, xpdfKeyModNone,
+				     xpdfKeyContextFullScreen,
+				     "windowMode"));
+
+  //----- arrow keys
   keyBindings->append(new KeyBinding(xpdfKeyCodeLeft, xpdfKeyModNone,
 				     xpdfKeyContextAny, "scrollLeft(16)"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeRight, xpdfKeyModNone,
@@ -912,73 +837,26 @@
 				     xpdfKeyContextAny, "scrollUp(16)"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModNone,
 				     xpdfKeyContextAny, "scrollDown(16)"));
-  keyBindings->append(new KeyBinding('o', xpdfKeyModNone,
-				     xpdfKeyContextAny, "open"));
-  keyBindings->append(new KeyBinding('O', xpdfKeyModNone,
-				     xpdfKeyContextAny, "open"));
-  keyBindings->append(new KeyBinding('r', xpdfKeyModNone,
-				     xpdfKeyContextAny, "reload"));
-  keyBindings->append(new KeyBinding('R', xpdfKeyModNone,
-				     xpdfKeyContextAny, "reload"));
-  keyBindings->append(new KeyBinding('f', xpdfKeyModNone,
-				     xpdfKeyContextAny, "find"));
-  keyBindings->append(new KeyBinding('F', xpdfKeyModNone,
-				     xpdfKeyContextAny, "find"));
-  keyBindings->append(new KeyBinding('f', xpdfKeyModCtrl,
-				     xpdfKeyContextAny, "find"));
-  keyBindings->append(new KeyBinding('g', xpdfKeyModCtrl,
-				     xpdfKeyContextAny, "findNext"));
-  keyBindings->append(new KeyBinding('p', xpdfKeyModCtrl,
-				     xpdfKeyContextAny, "print"));
-  keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOff, "nextPage"));
-  keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOff, "nextPage"));
-  keyBindings->append(new KeyBinding('n', xpdfKeyModNone,
+  keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "prevPage"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModCtrl,
+				     xpdfKeyContextAny, "nextPage"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeUp, xpdfKeyModCtrl,
 				     xpdfKeyContextScrLockOn,
-				     "nextPageNoScroll"));
-  keyBindings->append(new KeyBinding('N', xpdfKeyModNone,
+				     "prevPageNoScroll"));
+  keyBindings->append(new KeyBinding(xpdfKeyCodeDown, xpdfKeyModCtrl,
 				     xpdfKeyContextScrLockOn,
 				     "nextPageNoScroll"));
-  keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOff, "prevPage"));
-  keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOff, "prevPage"));
-  keyBindings->append(new KeyBinding('p', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOn,
-				     "prevPageNoScroll"));
-  keyBindings->append(new KeyBinding('P', xpdfKeyModNone,
-				     xpdfKeyContextScrLockOn,
-				     "prevPageNoScroll"));
-  keyBindings->append(new KeyBinding('v', xpdfKeyModNone,
-				     xpdfKeyContextAny, "goForward"));
-  keyBindings->append(new KeyBinding('b', xpdfKeyModNone,
-				     xpdfKeyContextAny, "goBackward"));
+
+  //----- letter keys
+  keyBindings->append(new KeyBinding(' ', xpdfKeyModNone,
+				     xpdfKeyContextAny, "pageDown"));
   keyBindings->append(new KeyBinding('g', xpdfKeyModNone,
 				     xpdfKeyContextAny, "focusToPageNum"));
-  keyBindings->append(new KeyBinding('0', xpdfKeyModNone,
-				     xpdfKeyContextAny, "zoomPercent(125)"));
-  keyBindings->append(new KeyBinding('+', xpdfKeyModNone,
-				     xpdfKeyContextAny, "zoomIn"));
-  keyBindings->append(new KeyBinding('-', xpdfKeyModNone,
-				     xpdfKeyContextAny, "zoomOut"));
   keyBindings->append(new KeyBinding('z', xpdfKeyModNone,
 				     xpdfKeyContextAny, "zoomFitPage"));
   keyBindings->append(new KeyBinding('w', xpdfKeyModNone,
 				     xpdfKeyContextAny, "zoomFitWidth"));
-  keyBindings->append(new KeyBinding('f', xpdfKeyModAlt,
-				     xpdfKeyContextAny,
-				     "toggleFullScreenMode"));
-  keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl,
-				     xpdfKeyContextAny, "redraw"));
-  keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
-				     xpdfKeyContextAny, "closeWindowOrQuit"));
-  keyBindings->append(new KeyBinding('?', xpdfKeyModNone,
-				     xpdfKeyContextAny, "about"));
-  keyBindings->append(new KeyBinding('q', xpdfKeyModNone,
-				     xpdfKeyContextAny, "quit"));
-  keyBindings->append(new KeyBinding('Q', xpdfKeyModNone,
-				     xpdfKeyContextAny, "quit"));
 }
 
 void GlobalParams::parseFile(GString *fileName, FILE *f) {
@@ -1120,6 +998,9 @@
     } else if (!cmd->cmp("psAlwaysRasterize")) {
       parseYesNo("psAlwaysRasterize", &psAlwaysRasterize,
 		 tokens, fileName, line);
+    } else if (!cmd->cmp("psNeverRasterize")) {
+      parseYesNo("psNeverRasterize", &psNeverRasterize,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("textEncoding")) {
       parseTextEncoding(tokens, fileName, line);
     } else if (!cmd->cmp("textEOL")) {
@@ -1132,8 +1013,19 @@
 		 tokens, fileName, line);
     } else if (!cmd->cmp("initialZoom")) {
       parseInitialZoom(tokens, fileName, line);
-    } else if (!cmd->cmp("continuousView")) {
-      parseYesNo("continuousView", &continuousView, tokens, fileName, line);
+    } else if (!cmd->cmp("defaultFitZoom")) {
+      parseInteger("defaultFitZoom", &defaultFitZoom, tokens, fileName, line);
+    } else if (!cmd->cmp("initialSidebarState")) {
+      parseYesNo("initialSidebarState", &initialSidebarState,
+		 tokens, fileName, line);
+    } else if (!cmd->cmp("maxTileWidth")) {
+      parseInteger("maxTileWidth", &maxTileWidth, tokens, fileName, line);
+    } else if (!cmd->cmp("maxTileHeight")) {
+      parseInteger("maxTileHeight", &maxTileHeight, tokens, fileName, line);
+    } else if (!cmd->cmp("tileCacheSize")) {
+      parseInteger("tileCacheSize", &tileCacheSize, tokens, fileName, line);
+    } else if (!cmd->cmp("workerThreads")) {
+      parseInteger("workerThreads", &workerThreads, tokens, fileName, line);
     } else if (!cmd->cmp("enableFreeType")) {
       parseYesNo("enableFreeType", &enableFreeType, tokens, fileName, line);
     } else if (!cmd->cmp("disableFreeTypeHinting")) {
@@ -1148,7 +1040,7 @@
       parseYesNo("antialiasPrinting", &antialiasPrinting,
 		 tokens, fileName, line);
     } else if (!cmd->cmp("strokeAdjust")) {
-      parseYesNo("strokeAdjust", &strokeAdjust, tokens, fileName, line);
+      parseStrokeAdjust(tokens, fileName, line);
     } else if (!cmd->cmp("screenType")) {
       parseScreenType(tokens, fileName, line);
     } else if (!cmd->cmp("screenSize")) {
@@ -1168,16 +1060,27 @@
     } else if (!cmd->cmp("minLineWidth")) {
       parseFloat("minLineWidth", &minLineWidth,
 		 tokens, fileName, line);
+    } else if (!cmd->cmp("enablePathSimplification")) {
+      parseYesNo("enablePathSimplification", &enablePathSimplification,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("drawAnnotations")) {
       parseYesNo("drawAnnotations", &drawAnnotations,
 		 tokens, fileName, line);
+    } else if (!cmd->cmp("drawFormFields")) {
+      parseYesNo("drawFormFields", &drawFormFields,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("overprintPreview")) {
       parseYesNo("overprintPreview", &overprintPreview,
 		 tokens, fileName, line);
+    } else if (!cmd->cmp("paperColor")) {
+      parseColor("paperColor", &paperColor, tokens, fileName, line);
+    } else if (!cmd->cmp("matteColor")) {
+      parseColor("matteColor", &matteColor, tokens, fileName, line);
+    } else if (!cmd->cmp("fullScreenMatteColor")) {
+      parseColor("fullScreenMatteColor", &fullScreenMatteColor,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("launchCommand")) {
       parseCommand("launchCommand", &launchCommand, tokens, fileName, line);
-    } else if (!cmd->cmp("urlCommand")) {
-      parseCommand("urlCommand", &urlCommand, tokens, fileName, line);
     } else if (!cmd->cmp("movieCommand")) {
       parseCommand("movieCommand", &movieCommand, tokens, fileName, line);
     } else if (!cmd->cmp("mapNumericCharNames")) {
@@ -1196,6 +1099,8 @@
       parseBind(tokens, fileName, line);
     } else if (!cmd->cmp("unbind")) {
       parseUnbind(tokens, fileName, line);
+    } else if (!cmd->cmp("popupMenuCmd")) {
+      parsePopupMenuCmd(tokens, fileName, line);
     } else if (!cmd->cmp("printCommands")) {
       parseYesNo("printCommands", &printCommands, tokens, fileName, line);
     } else if (!cmd->cmp("errQuiet")) {
@@ -1436,10 +1341,14 @@
     psLevel = psLevel1Sep;
   } else if (!tok->cmp("level2")) {
     psLevel = psLevel2;
+  } else if (!tok->cmp("level2gray")) {
+    psLevel = psLevel2Gray;
   } else if (!tok->cmp("level2sep")) {
     psLevel = psLevel2Sep;
   } else if (!tok->cmp("level3")) {
     psLevel = psLevel3;
+  } else if (!tok->cmp("level3gray")) {
+    psLevel = psLevel3Gray;
   } else if (!tok->cmp("level3Sep")) {
     psLevel = psLevel3Sep;
   } else {
@@ -1559,6 +1468,30 @@
   initialZoom = ((GString *)tokens->get(1))->copy();
 }
 
+void GlobalParams::parseStrokeAdjust(GList *tokens, GString *fileName,
+				     int line) {
+  GString *tok;
+
+  if (tokens->getLength() != 2) {
+    error(errConfig, -1,
+	  "Bad 'strokeAdjust' config file command ({0:t}:{1:d})",
+	  fileName, line);
+    return;
+  }
+  tok = (GString *)tokens->get(1);
+  if (!tok->cmp("no")) {
+    strokeAdjust = strokeAdjustOff;
+  } else if (!tok->cmp("yes")) {
+    strokeAdjust = strokeAdjustNormal;
+  } else if (!tok->cmp("cad")) {
+    strokeAdjust = strokeAdjustCAD;
+  } else {
+    error(errConfig, -1,
+	  "Bad 'strokeAdjust' config file command ({0:t}:{1:d})",
+	  fileName, line);
+  }
+}
+
 void GlobalParams::parseScreenType(GList *tokens, GString *fileName,
 				   int line) {
   GString *tok;
@@ -1692,6 +1625,8 @@
     *code = xpdfKeyCodeUp;
   } else if (!strcmp(p0, "down")) {
     *code = xpdfKeyCodeDown;
+  } else if (!strcmp(p0, "esc")) {
+    *code = xpdfKeyCodeEsc;
   } else if (p0[0] == 'f' && p0[1] >= '1' && p0[1] <= '9' && !p0[2]) {
     *code = xpdfKeyCodeF1 + (p0[1] - '1');
   } else if (p0[0] == 'f' &&
@@ -1709,6 +1644,11 @@
 	     (!p0[13] || (p0[13] >= '0' && p0[13] <= '9' && !p0[14])) &&
 	     (btn = atoi(p0 + 12)) >= 1 && btn <= 32) {
     *code = xpdfKeyCodeMouseRelease1 + btn - 1;
+  } else if (!strncmp(p0, "mouseClick", 10) &&
+	     p0[10] >= '0' && p0[10] <= '9' &&
+	     (!p0[11] || (p0[11] >= '0' && p0[11] <= '9' && !p0[12])) &&
+	     (btn = atoi(p0 + 10)) >= 1 && btn <= 32) {
+    *code = xpdfKeyCodeMouseClick1 + btn - 1;
   } else if (*p0 >= 0x20 && *p0 <= 0x7e && !p0[1]) {
     *code = (int)*p0;
   } else {
@@ -1776,6 +1716,25 @@
   return gTrue;
 }
 
+void GlobalParams::parsePopupMenuCmd(GList *tokens,
+				     GString *fileName, int line) {
+  GList *cmds;
+  int i;
+
+  if (tokens->getLength() < 3) {
+    error(errConfig, -1,
+	  "Bad 'popupMenuCmd' config file command ({0:t}:{1:d})",
+	  fileName, line);
+    return;
+  }
+  cmds = new GList();
+  for (i = 2; i < tokens->getLength(); ++i) {
+    cmds->append(((GString *)tokens->get(i))->copy());
+  }
+  popupMenuCmds->append(new PopupMenuCmd(((GString *)tokens->get(1))->copy(),
+					 cmds));
+}
+
 void GlobalParams::parseCommand(const char *cmdName, GString **val,
 				GList *tokens, GString *fileName, int line) {
   if (tokens->getLength() != 2) {
@@ -1816,6 +1775,19 @@
   return gTrue;
 }
 
+void GlobalParams::parseColor(const char *cmdName, GString **val,
+			      GList *tokens, GString *fileName, int line) {
+  if (tokens->getLength() != 2) {
+    error(errConfig, -1, "Bad '{0:s}' config file command ({1:t}:{2:d})",
+	  cmdName, fileName, line);
+    return;
+  }
+  if (*val) {
+    delete *val;
+  }
+  *val = ((GString *)tokens->get(1))->copy();
+}
+
 void GlobalParams::parseInteger(const char *cmdName, int *val,
 				GList *tokens, GString *fileName, int line) {
   GString *tok;
@@ -1908,16 +1880,23 @@
   deleteGList(psResidentFontsCC, PSFontParam16);
   delete textEncoding;
   delete initialZoom;
+  if (paperColor) {
+    delete paperColor;
+  }
+  if (matteColor) {
+    delete matteColor;
+  }
+  if (fullScreenMatteColor) {
+    delete fullScreenMatteColor;
+  }
   if (launchCommand) {
     delete launchCommand;
   }
-  if (urlCommand) {
-    delete urlCommand;
-  }
   if (movieCommand) {
     delete movieCommand;
   }
   deleteGList(keyBindings, KeyBinding);
+  deleteGList(popupMenuCmds, PopupMenuCmd);
 
   cMapDirs->startIter(&iter);
   while (cMapDirs->getNext(&iter, &key, (void **)&list)) {
@@ -1930,11 +1909,6 @@
   delete unicodeMapCache;
   delete cMapCache;
 
-#ifdef ENABLE_PLUGINS
-  delete securityHandlers;
-  deleteGList(plugins, Plugin);
-#endif
-
 #if MULTITHREADED
   gDestroyMutex(&mutex);
   gDestroyMutex(&unicodeMapCacheMutex);
@@ -1944,7 +1918,7 @@
 
 //------------------------------------------------------------------------
 
-void GlobalParams::setBaseDir(char *dir) {
+void GlobalParams::setBaseDir(const char *dir) {
   delete baseDir;
   baseDir = new GString(dir);
 }
@@ -1997,7 +1971,7 @@
 }
 #endif
 
-void GlobalParams::setupBaseFonts(char *dir) {
+void GlobalParams::setupBaseFonts(const char *dir) {
   GString *fontName;
   GString *fileName;
   int fontNum;
@@ -2634,6 +2608,15 @@
   return rast;
 }
 
+GBool GlobalParams::getPSNeverRasterize() {
+  GBool rast;
+
+  lockGlobalParams;
+  rast = psNeverRasterize;
+  unlockGlobalParams;
+  return rast;
+}
+
 GString *GlobalParams::getTextEncodingName() {
   GString *s;
 
@@ -2679,15 +2662,60 @@
   return s;
 }
 
-GBool GlobalParams::getContinuousView() {
-  GBool f;
+int GlobalParams::getDefaultFitZoom() {
+  int z;
 
   lockGlobalParams;
-  f = continuousView;
+  z = defaultFitZoom;
   unlockGlobalParams;
-  return f;
+  return z;
 }
 
+GBool GlobalParams::getInitialSidebarState() {
+  GBool state;
+
+  lockGlobalParams;
+  state = initialSidebarState;
+  unlockGlobalParams;
+  return state;
+}
+
+int GlobalParams::getMaxTileWidth() {
+  int w;
+
+  lockGlobalParams;
+  w = maxTileWidth;
+  unlockGlobalParams;
+  return w;
+}
+
+int GlobalParams::getMaxTileHeight() {
+  int h;
+
+  lockGlobalParams;
+  h = maxTileHeight;
+  unlockGlobalParams;
+  return h;
+}
+
+int GlobalParams::getTileCacheSize() {
+  int n;
+
+  lockGlobalParams;
+  n = tileCacheSize;
+  unlockGlobalParams;
+  return n;
+}
+
+int GlobalParams::getWorkerThreads() {
+  int n;
+
+  lockGlobalParams;
+  n = workerThreads;
+  unlockGlobalParams;
+  return n;
+}
+
 GBool GlobalParams::getEnableFreeType() {
   GBool f;
 
@@ -2734,13 +2762,13 @@
   return f;
 }
 
-GBool GlobalParams::getStrokeAdjust() {
-  GBool f;
+StrokeAdjustMode GlobalParams::getStrokeAdjust() {
+  StrokeAdjustMode mode;
 
   lockGlobalParams;
-  f = strokeAdjust;
+  mode = strokeAdjust;
   unlockGlobalParams;
-  return f;
+  return mode;
 }
 
 ScreenType GlobalParams::getScreenType() {
@@ -2806,6 +2834,15 @@
   return w;
 }
 
+GBool GlobalParams::getEnablePathSimplification() {
+  GBool en;
+
+  lockGlobalParams;
+  en = enablePathSimplification;
+  unlockGlobalParams;
+  return en;
+}
+
 GBool GlobalParams::getDrawAnnotations() {
   GBool draw;
 
@@ -2815,7 +2852,44 @@
   return draw;
 }
 
+GBool GlobalParams::getDrawFormFields() {
+  GBool draw;
 
+  lockGlobalParams;
+  draw = drawFormFields;
+  unlockGlobalParams;
+  return draw;
+}
+
+
+
+GString *GlobalParams::getPaperColor() {
+  GString *s;
+
+  lockGlobalParams;
+  s = paperColor->copy();
+  unlockGlobalParams;
+  return s;
+}
+
+GString *GlobalParams::getMatteColor() {
+  GString *s;
+
+  lockGlobalParams;
+  s = matteColor->copy();
+  unlockGlobalParams;
+  return s;
+}
+
+GString *GlobalParams::getFullScreenMatteColor() {
+  GString *s;
+
+  lockGlobalParams;
+  s = fullScreenMatteColor->copy();
+  unlockGlobalParams;
+  return s;
+}
+
 GBool GlobalParams::getMapNumericCharNames() {
   GBool map;
 
@@ -2861,7 +2935,7 @@
   lockGlobalParams;
   cmds = NULL;
   // for ASCII chars, ignore the shift modifier
-  modMask = code <= 0xff ? ~xpdfKeyModShift : ~0;
+  modMask = (code >= 0x21 && code <= 0xff) ? ~xpdfKeyModShift : ~0;
   for (i = 0; i < keyBindings->getLength(); ++i) {
     binding = (KeyBinding *)keyBindings->get(i);
     if (binding->code == code &&
@@ -2878,6 +2952,28 @@
   return cmds;
 }
 
+int GlobalParams::getNumPopupMenuCmds() {
+  int n;
+
+  lockGlobalParams;
+  n = popupMenuCmds->getLength();
+  unlockGlobalParams;
+  return n;
+}
+
+PopupMenuCmd *GlobalParams::getPopupMenuCmd(int idx) {
+  PopupMenuCmd *cmd;
+
+  lockGlobalParams;
+  if (idx < popupMenuCmds->getLength()) {
+    cmd = (PopupMenuCmd *)popupMenuCmds->get(idx);
+  } else {
+    cmd = NULL;
+  }
+  unlockGlobalParams;
+  return cmd;
+}
+
 GBool GlobalParams::getPrintCommands() {
   GBool p;
 
@@ -3167,12 +3263,6 @@
   unlockGlobalParams;
 }
 
-void GlobalParams::setContinuousView(GBool cont) {
-  lockGlobalParams;
-  continuousView = cont;
-  unlockGlobalParams;
-}
-
 GBool GlobalParams::setEnableFreeType(char *s) {
   GBool ok;
 
@@ -3237,6 +3327,20 @@
   unlockGlobalParams;
 }
 
+void GlobalParams::setDrawFormFields(GBool draw) {
+  lockGlobalParams;
+  drawFormFields = draw;
+  unlockGlobalParams;
+}
+
+void GlobalParams::setOverprintPreview(GBool preview) {
+  lockGlobalParams;
+  overprintPreview = preview;
+  unlockGlobalParams;
+}
+
+
+
 void GlobalParams::setMapNumericCharNames(GBool map) {
   lockGlobalParams;
   mapNumericCharNames = map;
@@ -3273,62 +3377,35 @@
   unlockGlobalParams;
 }
 
-void GlobalParams::addSecurityHandler(XpdfSecurityHandler *handler) {
-#ifdef ENABLE_PLUGINS
-  lockGlobalParams;
-  securityHandlers->append(handler);
-  unlockGlobalParams;
-#endif
-}
+#ifdef _WIN32
+void GlobalParams::setWin32ErrorInfo(const char *func, DWORD code) {
+  XpdfWin32ErrorInfo *errorInfo;
 
-XpdfSecurityHandler *GlobalParams::getSecurityHandler(char *name) {
-#ifdef ENABLE_PLUGINS
-  XpdfSecurityHandler *hdlr;
-  int i;
-
-  lockGlobalParams;
-  for (i = 0; i < securityHandlers->getLength(); ++i) {
-    hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
-    if (!strcasecmp(hdlr->name, name)) {
-      unlockGlobalParams;
-      return hdlr;
-    }
+  if (tlsWin32ErrorInfo == TLS_OUT_OF_INDEXES) {
+    return;
   }
-  unlockGlobalParams;
-
-  if (!loadPlugin("security", name)) {
-    return NULL;
+  errorInfo = (XpdfWin32ErrorInfo *)TlsGetValue(tlsWin32ErrorInfo);
+  if (!errorInfo) {
+    errorInfo = new XpdfWin32ErrorInfo();
+    TlsSetValue(tlsWin32ErrorInfo, errorInfo);
   }
-
-  lockGlobalParams;
-  for (i = 0; i < securityHandlers->getLength(); ++i) {
-    hdlr = (XpdfSecurityHandler *)securityHandlers->get(i);
-    if (!strcmp(hdlr->name, name)) {
-      unlockGlobalParams;
-      return hdlr;
-    }
-  }
-  unlockGlobalParams;
-#endif
-
-  return NULL;
+  errorInfo->func = func;
+  errorInfo->code = code;
 }
 
-#ifdef ENABLE_PLUGINS
-//------------------------------------------------------------------------
-// plugins
-//------------------------------------------------------------------------
+XpdfWin32ErrorInfo *GlobalParams::getWin32ErrorInfo() {
+  XpdfWin32ErrorInfo *errorInfo;
 
-GBool GlobalParams::loadPlugin(char *type, char *name) {
-  Plugin *plugin;
-
-  if (!(plugin = Plugin::load(type, name))) {
-    return gFalse;
+  if (tlsWin32ErrorInfo == TLS_OUT_OF_INDEXES) {
+    return NULL;
   }
-  lockGlobalParams;
-  plugins->append(plugin);
-  unlockGlobalParams;
-  return gTrue;
+  errorInfo = (XpdfWin32ErrorInfo *)TlsGetValue(tlsWin32ErrorInfo);
+  if (!errorInfo) {
+    errorInfo = new XpdfWin32ErrorInfo();
+    TlsSetValue(tlsWin32ErrorInfo, errorInfo);
+    errorInfo->func = NULL;
+    errorInfo->code = 0;
+  }
+  return errorInfo;
 }
-
-#endif // ENABLE_PLUGINS
+#endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/GlobalParams.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -19,6 +19,9 @@
 #endif
 
 #include <stdio.h>
+#ifdef _WIN32
+#  include <windows.h>
+#endif
 #include "gtypes.h"
 #include "CharTypes.h"
 
@@ -76,9 +79,11 @@
   psLevel1,
   psLevel1Sep,
   psLevel2,
+  psLevel2Gray,
   psLevel2Sep,
   psLevel3,
-  psLevel3Sep
+  psLevel3Gray,
+  psLevel3Sep,
 };
 
 //------------------------------------------------------------------------
@@ -91,6 +96,14 @@
 
 //------------------------------------------------------------------------
 
+enum StrokeAdjustMode {
+  strokeAdjustOff,
+  strokeAdjustNormal,
+  strokeAdjustCAD
+};
+
+//------------------------------------------------------------------------
+
 enum ScreenType {
   screenUnset,
   screenDispersed,
@@ -123,16 +136,17 @@
 #define xpdfKeyCodeReturn         0x1001
 #define xpdfKeyCodeEnter          0x1002
 #define xpdfKeyCodeBackspace      0x1003
-#define xpdfKeyCodeInsert         0x1004
-#define xpdfKeyCodeDelete         0x1005
-#define xpdfKeyCodeHome           0x1006
-#define xpdfKeyCodeEnd            0x1007
-#define xpdfKeyCodePgUp           0x1008
-#define xpdfKeyCodePgDn           0x1009
-#define xpdfKeyCodeLeft           0x100a
-#define xpdfKeyCodeRight          0x100b
-#define xpdfKeyCodeUp             0x100c
-#define xpdfKeyCodeDown           0x100d
+#define xpdfKeyCodeEsc            0x1004
+#define xpdfKeyCodeInsert         0x1005
+#define xpdfKeyCodeDelete         0x1006
+#define xpdfKeyCodeHome           0x1007
+#define xpdfKeyCodeEnd            0x1008
+#define xpdfKeyCodePgUp           0x1009
+#define xpdfKeyCodePgDn           0x100a
+#define xpdfKeyCodeLeft           0x100b
+#define xpdfKeyCodeRight          0x100c
+#define xpdfKeyCodeUp             0x100d
+#define xpdfKeyCodeDown           0x100e
 #define xpdfKeyCodeF1             0x1100
 #define xpdfKeyCodeF35            0x1122
 #define xpdfKeyCodeMousePress1    0x2001
@@ -153,6 +167,15 @@
 #define xpdfKeyCodeMouseRelease7  0x2107
 // ...
 #define xpdfKeyCodeMouseRelease32 0x2120
+#define xpdfKeyCodeMouseClick1    0x2201
+#define xpdfKeyCodeMouseClick2    0x2202
+#define xpdfKeyCodeMouseClick3    0x2203
+#define xpdfKeyCodeMouseClick4    0x2204
+#define xpdfKeyCodeMouseClick5    0x2205
+#define xpdfKeyCodeMouseClick6    0x2206
+#define xpdfKeyCodeMouseClick7    0x2207
+// ...
+#define xpdfKeyCodeMouseClick32   0x2220
 #define xpdfKeyModNone            0
 #define xpdfKeyModShift           (1 << 0)
 #define xpdfKeyModCtrl            (1 << 1)
@@ -171,6 +194,27 @@
 
 //------------------------------------------------------------------------
 
+class PopupMenuCmd {
+public:
+
+  GString *label;		// label for display in the menu
+  GList *cmds;			// list of commands [GString]
+
+  PopupMenuCmd(GString *labelA, GList *cmdsA);
+  ~PopupMenuCmd();
+};
+
+//------------------------------------------------------------------------
+
+#ifdef _WIN32
+struct XpdfWin32ErrorInfo {
+  const char *func;		// last Win32 API function call to fail
+  DWORD code;			// error code returned by that function
+};
+#endif
+
+//------------------------------------------------------------------------
+
 class GlobalParams {
 public:
 
@@ -180,8 +224,8 @@
 
   ~GlobalParams();
 
-  void setBaseDir(char *dir);
-  void setupBaseFonts(char *dir);
+  void setBaseDir(const char *dir);
+  void setupBaseFonts(const char *dir);
 
   void parseLine(char *buf, GString *fileName, int line);
 
@@ -231,18 +275,24 @@
   GBool getPSRasterMono();
   int getPSRasterSliceSize();
   GBool getPSAlwaysRasterize();
+  GBool getPSNeverRasterize();
   GString *getTextEncodingName();
   EndOfLineKind getTextEOL();
   GBool getTextPageBreaks();
   GBool getTextKeepTinyChars();
   GString *getInitialZoom();
-  GBool getContinuousView();
+  int getDefaultFitZoom();
+  GBool getInitialSidebarState();
+  int getMaxTileWidth();
+  int getMaxTileHeight();
+  int getTileCacheSize();
+  int getWorkerThreads();
   GBool getEnableFreeType();
   GBool getDisableFreeTypeHinting();
   GBool getAntialias();
   GBool getVectorAntialias();
   GBool getAntialiasPrinting();
-  GBool getStrokeAdjust();
+  StrokeAdjustMode getStrokeAdjust();
   ScreenType getScreenType();
   int getScreenSize();
   int getScreenDotRadius();
@@ -250,10 +300,14 @@
   double getScreenBlackThreshold();
   double getScreenWhiteThreshold();
   double getMinLineWidth();
+  GBool getEnablePathSimplification();
   GBool getDrawAnnotations();
+  GBool getDrawFormFields();
   GBool getOverprintPreview() { return overprintPreview; }
+  GString *getPaperColor();
+  GString *getMatteColor();
+  GString *getFullScreenMatteColor();
   GString *getLaunchCommand() { return launchCommand; }
-  GString *getURLCommand() { return urlCommand; }
   GString *getMovieCommand() { return movieCommand; }
   GBool getMapNumericCharNames();
   GBool getMapUnknownCharNames();
@@ -260,6 +314,8 @@
   GBool getMapExtTrueTypeFontsViaUnicode();
   GBool getEnableXFA();
   GList *getKeyBinding(int code, int mods, int context);
+  int getNumPopupMenuCmds();
+  PopupMenuCmd *getPopupMenuCmd(int idx);
   GBool getPrintCommands();
   GBool getErrQuiet();
 
@@ -297,7 +353,6 @@
   void setTextPageBreaks(GBool pageBreaks);
   void setTextKeepTinyChars(GBool keep);
   void setInitialZoom(char *s);
-  void setContinuousView(GBool cont);
   GBool setEnableFreeType(char *s);
   GBool setAntialias(char *s);
   GBool setVectorAntialias(char *s);
@@ -307,6 +362,8 @@
   void setScreenGamma(double gamma);
   void setScreenBlackThreshold(double thresh);
   void setScreenWhiteThreshold(double thresh);
+  void setDrawFormFields(GBool draw);
+  void setOverprintPreview(GBool preview);
   void setMapNumericCharNames(GBool map);
   void setMapUnknownCharNames(GBool map);
   void setMapExtTrueTypeFontsViaUnicode(GBool map);
@@ -314,11 +371,11 @@
   void setPrintCommands(GBool printCommandsA);
   void setErrQuiet(GBool errQuietA);
 
-  //----- security handlers
+#ifdef _WIN32
+  void setWin32ErrorInfo(const char *func, DWORD code);
+  XpdfWin32ErrorInfo *getWin32ErrorInfo();
+#endif
 
-  void addSecurityHandler(XpdfSecurityHandler *handler);
-  XpdfSecurityHandler *getSecurityHandler(char *name);
-
 private:
 
   void createDefaultKeyBindings();
@@ -343,6 +400,7 @@
   void parseTextEncoding(GList *tokens, GString *fileName, int line);
   void parseTextEOL(GList *tokens, GString *fileName, int line);
   void parseInitialZoom(GList *tokens, GString *fileName, int line);
+  void parseStrokeAdjust(GList *tokens, GString *fileName, int line);
   void parseScreenType(GList *tokens, GString *fileName, int line);
   void parseBind(GList *tokens, GString *fileName, int line);
   void parseUnbind(GList *tokens, GString *fileName, int line);
@@ -350,19 +408,19 @@
 		 int *code, int *mods, int *context,
 		 const char *cmdName,
 		 GList *tokens, GString *fileName, int line);
+  void parsePopupMenuCmd(GList *tokens, GString *fileName, int line);
   void parseCommand(const char *cmdName, GString **val,
 		    GList *tokens, GString *fileName, int line);
   void parseYesNo(const char *cmdName, GBool *flag,
 		  GList *tokens, GString *fileName, int line);
   GBool parseYesNo2(char *token, GBool *flag);
+  void parseColor(const char *cmdName, GString **val,
+		  GList *tokens, GString *fileName, int line);
   void parseInteger(const char *cmdName, int *val,
 		    GList *tokens, GString *fileName, int line);
   void parseFloat(const char *cmdName, double *val,
 		  GList *tokens, GString *fileName, int line);
   UnicodeMap *getUnicodeMap2(GString *encodingName);
-#ifdef ENABLE_PLUGINS
-  GBool loadPlugin(char *type, char *name);
-#endif
 
   //----- static tables
 
@@ -436,6 +494,7 @@
   int psRasterSliceSize;	// maximum size (pixels) of PostScript
 				//   rasterization slice
   GBool psAlwaysRasterize;	// force PostScript rasterization
+  GBool psNeverRasterize;	// prevent PostScript rasterization
   GString *textEncoding;	// encoding (unicodeMap) to use for text
 				//   output
   EndOfLineKind textEOL;	// type of EOL marker to use for text
@@ -443,13 +502,20 @@
   GBool textPageBreaks;		// insert end-of-page markers?
   GBool textKeepTinyChars;	// keep all characters in text output
   GString *initialZoom;		// initial zoom level
-  GBool continuousView;		// continuous view mode
+  int defaultFitZoom;		// default zoom factor if initialZoom is
+				//   'page' or 'width'.
+  GBool initialSidebarState;	// initial sidebar state - open (true)
+				//   or closed (false)
+  int maxTileWidth;		// maximum rasterization tile width
+  int maxTileHeight;		// maximum rasterization tile height
+  int tileCacheSize;		// number of rasterization tiles in cache
+  int workerThreads;		// number of rasterization worker threads
   GBool enableFreeType;		// FreeType enable flag
   GBool disableFreeTypeHinting;	// FreeType hinting disable flag
   GBool antialias;		// font anti-aliasing enable flag
   GBool vectorAntialias;	// vector anti-aliasing enable flag
   GBool antialiasPrinting;	// allow anti-aliasing when printing
-  GBool strokeAdjust;		// stroke adjustment enable flag
+  StrokeAdjustMode strokeAdjust; // stroke adjustment mode
   ScreenType screenType;	// halftone screen type
   int screenSize;		// screen matrix size
   int screenDotRadius;		// screen dot radius
@@ -457,10 +523,15 @@
   double screenBlackThreshold;	// screen black clamping threshold
   double screenWhiteThreshold;	// screen white clamping threshold
   double minLineWidth;		// minimum line width
+  GBool				// enable path simplification
+    enablePathSimplification;
   GBool drawAnnotations;	// draw annotations or not
+  GBool drawFormFields;		// draw form fields or not
   GBool overprintPreview;	// enable overprint preview
+  GString *paperColor;		// paper (page background) color
+  GString *matteColor;		// matte (background outside of page) color
+  GString *fullScreenMatteColor; // matte color in full-screen mode
   GString *launchCommand;	// command executed for 'launch' links
-  GString *urlCommand;		// command executed for URL links
   GString *movieCommand;	// command executed for movie annotations
   GBool mapNumericCharNames;	// map numeric char names (from font subsets)?
   GBool mapUnknownCharNames;	// map unknown char names?
@@ -468,6 +539,7 @@
 				        //   for external TrueType fonts?
   GBool enableXFA;		// enable XFA form rendering
   GList *keyBindings;		// key & mouse button bindings [KeyBinding]
+  GList *popupMenuCmds;		// popup menu commands [PopupMenuCmd]
   GBool printCommands;		// print the drawing commands
   GBool errQuiet;		// suppress error messages?
 
@@ -476,17 +548,14 @@
   UnicodeMapCache *unicodeMapCache;
   CMapCache *cMapCache;
 
-#ifdef ENABLE_PLUGINS
-  GList *plugins;		// list of plugins [Plugin]
-  GList *securityHandlers;	// list of loaded security handlers
-				//   [XpdfSecurityHandler]
-#endif
-
 #if MULTITHREADED
   GMutex mutex;
   GMutex unicodeMapCacheMutex;
   GMutex cMapCacheMutex;
 #endif
+#ifdef _WIN32
+  DWORD tlsWin32ErrorInfo;	// TLS index for error info
+#endif
 };
 
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <png.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "SplashBitmap.h"
@@ -36,12 +37,6 @@
 #include "TextOutputDev.h"
 #include "SplashOutputDev.h"
 #include "ErrorCodes.h"
-#if EVAL_MODE
-#  include "SplashMath.h"
-#  include "Splash.h"
-#  include "BuiltinFontTables.h"
-#  include "FontEncodingTables.h"
-#endif
 #include "HTMLGen.h"
 
 #ifdef _WIN32
@@ -74,6 +69,7 @@
   {"Bold",                     4, gTrue,  gFalse},
   {"Italic",                   6, gFalse, gTrue},
   {"Oblique",                  7, gFalse, gTrue},
+  {"Light",                    5, gFalse, gFalse},
   {NULL,                       0, gFalse, gFalse}
 };
 
@@ -159,70 +155,23 @@
   0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x0178
 };
 
-//------------------------------------------------------------------------
+enum VerticalAlignment {
+  vertAlignBaseline,
+  vertAlignSub,
+  vertAlignSuper,
+  vertAlignTop
+};
 
-#if EVAL_MODE
+static const char *vertAlignNames[] = {
+  "baseline",
+  "sub",
+  "super",
+  "top"
+};
 
-#define EVAL_MODE_MSG "XpdfHTML evaluation - www.glyphandcog.com"
+//------------------------------------------------------------------------
 
-static void drawEvalModeMsg(SplashOutputDev *out) {
-  BuiltinFont *bf;
-  SplashFont *font;
-  GString *fontName;
-  char *msg;
-  SplashCoord mat[4], ident[6];
-  SplashCoord diag, size, textW, x, y;
-  Gushort cw;
-  int w, h, n, i;
 
-  // get the Helvetica font info
-  bf = builtinFontSubst[4];
-
-  msg = EVAL_MODE_MSG;
-  n = strlen(msg);
-
-  w = out->getBitmap()->getWidth();
-  h = out->getBitmap()->getHeight();
-
-  ident[0] = 1;  ident[1] = 0;
-  ident[2] = 0;  ident[3] = -1;
-  ident[4] = 0;  ident[5] = h;
-  out->getSplash()->setMatrix(ident);
-
-  diag = splashSqrt((SplashCoord)(w*w + h*h));
-  size = diag / (0.67 * n);
-  if (size < 8) {
-    size = 8;
-  }
-  mat[0] = size * (SplashCoord)w / diag;
-  mat[3] = mat[0];
-  mat[1] = size * (SplashCoord)h / diag;
-  mat[2] = -mat[1];
-  fontName = new GString(bf->name);
-  font = out->getFont(fontName, mat);
-  delete fontName;
-  if (!font) {
-    return;
-  }
-
-  textW = 0;
-  for (i = 0; i < n; ++i) {
-    bf->widths->getWidth(winAnsiEncoding[msg[i] & 0xff], &cw);
-    textW += size * cw * 0.001;
-  }
-
-  out->setFillColor(255, 0, 0);
-  x = 0.5 * (diag - textW) * (SplashCoord)w / diag;
-  y = 0.5 * (diag - textW) * (SplashCoord)h / diag;
-  for (i = 0; i < n; ++i) {
-    out->getSplash()->fillChar(x, y, msg[i], font);
-    bf->widths->getWidth(winAnsiEncoding[msg[i] & 0xff], &cw);
-    x += mat[0] * cw * 0.001;
-    y += mat[1] * cw * 0.001;
-  }
-}
-#endif
-
 //------------------------------------------------------------------------
 
 HTMLGen::HTMLGen(double backgroundResolutionA) {
@@ -232,7 +181,9 @@
   ok = gTrue;
 
   backgroundResolution = backgroundResolutionA;
+  zoom = 1.0;
   drawInvisibleText = gTrue;
+  allTextInvisible = gFalse;
 
   // set up the TextOutputDev
   textOutControl.mode = textOutReadingOrder;
@@ -245,7 +196,6 @@
   // set up the SplashOutputDev
   paperColor[0] = paperColor[1] = paperColor[2] = 0xff;
   splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
-  splashOut->setSkipText(gTrue, gFalse);
 }
 
 HTMLGen::~HTMLGen() {
@@ -302,26 +252,21 @@
   Guchar *p;
   double pageW, pageH;
   TextPage *text;
-  GList *fonts, *cols, *pars, *lines, *words;
-  double *fontScales;
+  GList *cols, *pars, *lines, *words;
   TextFontInfo *font;
   TextColumn *col;
   TextParagraph *par;
   TextLine *line;
-  TextWord *word0, *word1;
   GString *s;
-  double base, base1;
-  int subSuper0, subSuper1;
-  double r0, g0, b0, r1, g1, b1;
-  int colIdx, parIdx, lineIdx, wordIdx;
-  int y, i, u;
+  double base;
+  int primaryDir, spanDir;
+  int colIdx, parIdx, lineIdx, firstWordIdx, lastWordIdx;
+  int y, i;
 
   // generate the background bitmap
+  splashOut->setSkipText(!allTextInvisible, gFalse);
   doc->displayPage(splashOut, pg, backgroundResolution, backgroundResolution,
 		   0, gFalse, gTrue, gFalse);
-#if EVAL_MODE
-  drawEvalModeMsg(splashOut);
-#endif
   bitmap = splashOut->getBitmap();
   if (!(png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 				       NULL, NULL, NULL)) ||
@@ -354,6 +299,7 @@
   doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse);
   doc->processLinks(textOut, pg);
   text = textOut->takeText();
+  primaryDir = text->primaryDirectionIsLR() ? 1 : -1;
 
   // HTML header
   pr(writeHTML, htmlStream, "<html>\n");
@@ -371,9 +317,18 @@
   }
   pr(writeHTML, htmlStream, "</style>\n");
   pr(writeHTML, htmlStream, "</head>\n");
-  pr(writeHTML, htmlStream, "<body onload=\"start()\">\n");
-  pf(writeHTML, htmlStream, "<img id=\"background\" style=\"position:absolute; left:0px; top:0px;\" width=\"{0:d}\" height=\"{1:d}\" src=\"{2:s}\">\n",
-	 (int)pageW, (int)pageH, pngURL);
+  if (primaryDir >= 0) {
+    pr(writeHTML, htmlStream, "<body>\n");
+  } else {
+    pr(writeHTML, htmlStream, "<body dir=\"rtl\">\n");
+  }
+  if (primaryDir >= 0) {
+    pf(writeHTML, htmlStream, "<img id=\"background\" style=\"position:absolute; left:0px; top:0px;\" width=\"{0:d}\" height=\"{1:d}\" src=\"{2:s}\">\n",
+       (int)(pageW * zoom), (int)(pageH * zoom), pngURL);
+  } else {
+    pf(writeHTML, htmlStream, "<img id=\"background\" style=\"position:absolute; right:0px; top:0px;\" width=\"{0:d}\" height=\"{1:d}\" src=\"{2:s}\">\n",
+       (int)(pageW * zoom), (int)(pageH * zoom), pngURL);
+  }
 
   // generate the HTML text
   cols = text->makeColumns();
@@ -389,101 +344,32 @@
 	  continue;
 	}
 	words = line->getWords();
-	base = line->getBaseline();
+	if (lineIdx == 0 && par->hasDropCap() && words->getLength() >= 2) {
+	  base = ((TextWord *)words->get(1))->getBaseline();
+	} else {
+	  base = line->getBaseline();
+	}
 	s = new GString();
-	word0 = NULL;
-	subSuper0 = 0; // make gcc happy
-	r0 = g0 = b0 = 0; // make gcc happy
-	for (wordIdx = 0; wordIdx < words->getLength(); ++wordIdx) {
-	  word1 = (TextWord *)words->get(wordIdx);
-	  if (!drawInvisibleText && word1->isInvisible()) {
-	    continue;
-	  }
-	  word1->getColor(&r1, &g1, &b1);
-	  base1 = word1->getBaseline();
-	  if (base1 - base < -1) {
-	    subSuper1 = -1;  // superscript
-	  } else if (base1 - base > 1) {
-	    subSuper1 = 1;   // subscript
-	  } else {
-	    subSuper1 = 0;
-	  }
-	  if (!word0 ||
-	      word1->getFontInfo() != word0->getFontInfo() ||
-	      word1->getFontSize() != word0->getFontSize() ||
-	      subSuper1 != subSuper0 ||
-	      r1 != r0 || g1 != g0 || b1 != b0) {
-	    if (word0) {
-	      s->append("</span>");
-	    }
-	    for (i = 0; i < fonts->getLength(); ++i) {
-	      if (word1->getFontInfo() == (TextFontInfo *)fonts->get(i)) {
-		break;
-	      }
-	    }
-	    s->appendf("<span id=\"f{0:d}\" style=\"font-size:{1:d}px;vertical-align:{2:s};color:#{3:02x}{4:02x}{5:02x};\">",
-		       i, (int)(fontScales[i] * word1->getFontSize()),
-		       subSuper1 < 0 ? "super"
-		                     : subSuper1 > 0 ? "sub"
-		                                     : "baseline",
-		       (int)(r1 * 255), (int)(g1 * 255), (int)(b1 * 255));
-	  }
-	  for (i = 0; i < word1->getLength(); ++i) {
-	    u = word1->getChar(i);
-	    if (u >= privateUnicodeMapStart &&
-		u <= privateUnicodeMapEnd &&
-		privateUnicodeMap[u - privateUnicodeMapStart]) {
-	      u = privateUnicodeMap[u - privateUnicodeMapStart];
-	    }
-	    if (u <= 0x7f) {
-	      if (u == '&') {
-		s->append("&");
-	      } else if (u == '<') {
-		s->append("<");
-	      } else if (u == '>') {
-		s->append(">");
-	      } else {
-		s->append((char)u);
-	      }
-	    } else if (u <= 0x7ff) {
-	      s->append((char)(0xc0 + (u >> 6)));
-	      s->append((char)(0x80 + (u & 0x3f)));
-	    } else if (u <= 0xffff) {
-	      s->append((char)0xe0 + (u >> 12));
-	      s->append((char)0x80 + ((u >> 6) & 0x3f));
-	      s->append((char)0x80 + (u & 0x3f));
-	    } else if (u <= 0x1fffff) {
-	      s->append((char)0xf0 + (u >> 18));
-	      s->append((char)0x80 + ((u >> 12) & 0x3f));
-	      s->append((char)0x80 + ((u >> 6) & 0x3f));
-	      s->append((char)0x80 + (u & 0x3f));
-	    } else if (u <= 0x3ffffff) {
-	      s->append((char)0xf8 + (u >> 24));
-	      s->append((char)0x80 + ((u >> 18) & 0x3f));
-	      s->append((char)0x80 + ((u >> 12) & 0x3f));
-	      s->append((char)0x80 + ((u >> 6) & 0x3f));
-	      s->append((char)0x80 + (u & 0x3f));
-	    } else if (u <= 0x7fffffff) {
-	      s->append((char)0xfc + (u >> 30));
-	      s->append((char)0x80 + ((u >> 24) & 0x3f));
-	      s->append((char)0x80 + ((u >> 18) & 0x3f));
-	      s->append((char)0x80 + ((u >> 12) & 0x3f));
-	      s->append((char)0x80 + ((u >> 6) & 0x3f));
-	      s->append((char)0x80 + (u & 0x3f));
-	    }
-	  }
-	  if (word1->getSpaceAfter()) {
-	    s->append(' ');
-	  }
-	  word0 = word1;
-	  subSuper0 = subSuper1;
-	  r0 = r1;
-	  g0 = g1;
-	  b0 = b1;
+	for (firstWordIdx = (primaryDir >= 0) ? 0 : words->getLength() - 1;
+	     (primaryDir >= 0) ? firstWordIdx < words->getLength()
+	                       : firstWordIdx >= 0;
+	     firstWordIdx = lastWordIdx + primaryDir) {
+	  lastWordIdx = findDirSpan(words, firstWordIdx,
+				    primaryDir, &spanDir);
+	  appendSpans(words, firstWordIdx, lastWordIdx,
+		      primaryDir, spanDir,
+		      base, lineIdx == 0 && par->hasDropCap(),
+		      s);
 	}
-	s->append("</span>");
-	pf(writeHTML, htmlStream, "<div class=\"txt\" style=\"position:absolute; left:{0:d}px; top:{1:d}px;\">{2:t}</div>\n",
-	   (int)line->getXMin(), (int)line->getYMin(), s);
+	if (primaryDir >= 0) {
+	  pf(writeHTML, htmlStream, "<div class=\"txt\" style=\"position:absolute; left:{0:d}px; top:{1:d}px;\">{2:t}</div>\n",
+	     (int)(line->getXMin() * zoom),
+	     (int)(line->getYMin() * zoom), s);
+	} else {
+	  pf(writeHTML, htmlStream, "<div class=\"txt\" style=\"position:absolute; right:{0:d}px; top:{1:d}px;\">{2:t}</div>\n",
+	     (int)((pageW - line->getXMax()) * zoom),
+	     (int)(line->getYMin() * zoom), s);
+	}
 	delete s;
       }
     }
@@ -499,6 +385,208 @@
   return errNone;
 }
 
+// Find a sequence of words, starting at <firstWordIdx>, that have the
+// same writing direction.  Returns the index of the last word, and
+// sets *<spanDir> to the span direction.
+int HTMLGen::findDirSpan(GList *words, int firstWordIdx, int primaryDir,
+			 int *spanDir) {
+  int dir0, dir1, nextWordIdx;
+
+  dir0 = ((TextWord *)words->get(firstWordIdx))->getDirection();
+  for (nextWordIdx = firstWordIdx + primaryDir;
+       (primaryDir >= 0) ? nextWordIdx < words->getLength()
+	                 : nextWordIdx >= 0;
+       nextWordIdx += primaryDir) {
+    dir1 = ((TextWord *)words->get(nextWordIdx))->getDirection();
+    if (dir0 == 0) {
+      dir0 = dir1;
+    } else if (dir1 != 0 && dir1 != dir0) {
+      break;
+    }
+  }
+
+  if (dir0 == 0) {
+    *spanDir = primaryDir;
+  } else {
+    *spanDir = dir0;
+  }
+
+  return nextWordIdx - primaryDir;
+}
+
+// Create HTML spans for words <firstWordIdx> .. <lastWordIdx>, and
+// append them to <s>.
+void HTMLGen::appendSpans(GList *words, int firstWordIdx, int lastWordIdx,
+			  int primaryDir, int spanDir,
+			  double base, GBool dropCapLine, GString *s) {
+  TextWord *word0, *word1;
+  VerticalAlignment vertAlign0, vertAlign1;
+  const char *dirTag;
+  Unicode u;
+  GBool invisible, sp;
+  double r0, g0, b0, r1, g1, b1;
+  double base1;
+  int wordIdx, t, i;
+
+  if (spanDir != primaryDir) {
+    t = firstWordIdx;
+    firstWordIdx = lastWordIdx;
+    lastWordIdx = t;
+  }
+
+  word0 = NULL;
+  vertAlign0 = vertAlignBaseline; // make gcc happy
+  r0 = g0 = b0 = 0; // make gcc happy
+  for (wordIdx = firstWordIdx;
+       (spanDir >= 0) ? wordIdx <= lastWordIdx : wordIdx >= lastWordIdx;
+       wordIdx += spanDir) {
+    word1 = (TextWord *)words->get(wordIdx);
+    invisible = allTextInvisible || word1->isInvisible();
+    if (!drawInvisibleText && invisible) {
+      continue;
+    }
+    word1->getColor(&r1, &g1, &b1);
+    base1 = word1->getBaseline();
+    if (dropCapLine) {
+      //~ this will fail if there are subscripts or superscripts in
+      //~   the first line of a paragraph with a drop cap
+      vertAlign1 = vertAlignTop;
+    } else if (base1 - base < -1) {
+      vertAlign1 = vertAlignSuper;
+    } else if (base1 - base > 1) {
+      vertAlign1 = vertAlignSub;
+    } else {
+      vertAlign1 = vertAlignBaseline;
+    }
+    if (!word0 ||
+	word1->getFontInfo() != word0->getFontInfo() ||
+	word1->getFontSize() != word0->getFontSize() ||
+	word1->isInvisible() != word0->isInvisible() ||
+	vertAlign1 != vertAlign0 ||
+	r1 != r0 || g1 != g0 || b1 != b0) {
+      if (word0) {
+	s->append("</span>");
+      }
+      for (i = 0; i < fonts->getLength(); ++i) {
+	if (word1->getFontInfo() == (TextFontInfo *)fonts->get(i)) {
+	  break;
+	}
+      }
+      // we force spans to be LTR or RTL; this is a kludge, but it's
+      // far easier than implementing the full Unicode bidi algorithm
+      if (spanDir == primaryDir) {
+	dirTag = "";
+      } else if (spanDir < 0) {
+	dirTag = " dir=\"rtl\"";
+      } else {
+	dirTag = " dir=\"ltr\"";
+      }
+      s->appendf("<span id=\"f{0:d}\"{1:s} style=\"font-size:{2:d}px;vertical-align:{3:s};{4:s}color:rgba({5:d},{6:d},{7:d},{8:d});\">",
+		 i,
+		 dirTag,
+		 (int)(fontScales[i] * word1->getFontSize() * zoom),
+		 vertAlignNames[vertAlign1],
+		 (dropCapLine && wordIdx == 0) ? "line-height:75%;" : "",
+		 (int)(r1 * 255), (int)(g1 * 255), (int)(b1 * 255),
+		 invisible ? 0 : 1);
+    }
+
+    // add a space before the word, if needed
+    // -- this only happens with the first word in a reverse section
+    if (spanDir != primaryDir && wordIdx == firstWordIdx) {
+      if (spanDir >= 0) {
+	if (wordIdx > 0) {
+	  sp = ((TextWord *)words->get(wordIdx - 1))->getSpaceAfter();
+	} else {
+	  sp = gFalse;
+	}
+      } else {
+	sp = word1->getSpaceAfter();
+      }
+      if (sp) {
+	s->append(' ');
+      }
+    }
+
+    for (i = (spanDir >= 0) ? 0 : word1->getLength() - 1;
+	 (spanDir >= 0) ? i < word1->getLength() : i >= 0;
+	 i += spanDir) {
+      u = word1->getChar(i);
+      if (u >= privateUnicodeMapStart &&
+	  u <= privateUnicodeMapEnd &&
+	  privateUnicodeMap[u - privateUnicodeMapStart]) {
+	u = privateUnicodeMap[u - privateUnicodeMapStart];
+      }
+      appendUTF8(u, s);
+    }
+
+    // add a space after the word, if needed
+    // -- there is never a space after the last word in a reverse
+    //    section (this will be handled as a space after the last word
+    //    in the previous primary-direction section)
+    if (spanDir != primaryDir && wordIdx == lastWordIdx) {
+      sp = gFalse;
+    } else if (spanDir >= 0) {
+      sp = word1->getSpaceAfter();
+    } else {
+      if (wordIdx > 0) {
+	sp = ((TextWord *)words->get(wordIdx - 1))->getSpaceAfter();
+      } else {
+	sp = gFalse;
+      }
+    }
+    if (sp) {
+      s->append(' ');
+    }
+
+    word0 = word1;
+    vertAlign0 = vertAlign1;
+    r0 = r1;
+    g0 = g1;
+    b0 = b1;
+  }
+  s->append("</span>");
+}
+
+void HTMLGen::appendUTF8(Unicode u, GString *s) {
+  if (u <= 0x7f) {
+    if (u == '&') {
+      s->append("&");
+    } else if (u == '<') {
+      s->append("<");
+    } else if (u == '>') {
+      s->append(">");
+    } else {
+      s->append((char)u);
+    }
+  } else if (u <= 0x7ff) {
+    s->append((char)(0xc0 + (u >> 6)));
+    s->append((char)(0x80 + (u & 0x3f)));
+  } else if (u <= 0xffff) {
+    s->append((char)0xe0 + (u >> 12));
+    s->append((char)0x80 + ((u >> 6) & 0x3f));
+    s->append((char)0x80 + (u & 0x3f));
+  } else if (u <= 0x1fffff) {
+    s->append((char)0xf0 + (u >> 18));
+    s->append((char)0x80 + ((u >> 12) & 0x3f));
+    s->append((char)0x80 + ((u >> 6) & 0x3f));
+    s->append((char)0x80 + (u & 0x3f));
+  } else if (u <= 0x3ffffff) {
+    s->append((char)0xf8 + (u >> 24));
+    s->append((char)0x80 + ((u >> 18) & 0x3f));
+    s->append((char)0x80 + ((u >> 12) & 0x3f));
+    s->append((char)0x80 + ((u >> 6) & 0x3f));
+    s->append((char)0x80 + (u & 0x3f));
+  } else if (u <= 0x7fffffff) {
+    s->append((char)0xfc + (u >> 30));
+    s->append((char)0x80 + ((u >> 24) & 0x3f));
+    s->append((char)0x80 + ((u >> 18) & 0x3f));
+    s->append((char)0x80 + ((u >> 12) & 0x3f));
+    s->append((char)0x80 + ((u >> 6) & 0x3f));
+    s->append((char)0x80 + (u & 0x3f));
+  }
+}
+
 GString *HTMLGen::getFontDefn(TextFontInfo *font, double *scale) {
   GString *fontName;
   char *fontName2;

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/HTMLGen.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -35,10 +35,17 @@
   void setBackgroundResolution(double backgroundResolutionA)
     { backgroundResolution = backgroundResolutionA; }
 
+  double getZoom() { return zoom; }
+  void setZoom(double zoomA) { zoom = zoomA; }
+
   GBool getDrawInvisibleText() { return drawInvisibleText; }
   void setDrawInvisibleText(GBool drawInvisibleTextA)
     { drawInvisibleText = drawInvisibleTextA; }
 
+  GBool getAllTextInvisible() { return allTextInvisible; }
+  void setAllTextInvisible(GBool allTextInvisibleA)
+    { allTextInvisible = allTextInvisibleA; }
+
   void startDoc(PDFDoc *docA);
   int convertPage(int pg, const char *pngURL,
 		  int (*writeHTML)(void *stream, const char *data, int size),
@@ -48,15 +55,26 @@
 
 private:
 
+  int findDirSpan(GList *words, int firstWordIdx, int primaryDir,
+		  int *spanDir);
+  void appendSpans(GList *words, int firstWordIdx, int lastWordIdx,
+		   int primaryDir, int spanDir,
+		   double base, GBool dropCapLine, GString *s);
+  void appendUTF8(Unicode u, GString *s);
   GString *getFontDefn(TextFontInfo *font, double *scale);
 
   double backgroundResolution;
+  double zoom;
   GBool drawInvisibleText;
+  GBool allTextInvisible;
 
   PDFDoc *doc;
   TextOutputDev *textOut;
   SplashOutputDev *splashOut;
 
+  GList *fonts;
+  double *fontScales;
+
   GBool ok;
 };
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,7 +16,9 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <ctype.h>
+#include <math.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "config.h"
 #include "Error.h"
 #include "GfxState.h"
@@ -24,11 +26,15 @@
 #include "Stream.h"
 #include "ImageOutputDev.h"
 
-ImageOutputDev::ImageOutputDev(char *fileRootA, GBool dumpJPEGA) {
+ImageOutputDev::ImageOutputDev(char *fileRootA, GBool dumpJPEGA,
+			       GBool dumpRawA, GBool listA) {
   fileRoot = copyString(fileRootA);
-  fileName = (char *)gmalloc((int)strlen(fileRoot) + 20);
+  fileName = (char *)gmalloc((int)strlen(fileRoot) + 30);
   dumpJPEG = dumpJPEGA;
+  dumpRaw = dumpRawA;
+  list = listA;
   imgNum = 0;
+  curPageNum = 0;
   ok = gTrue;
 }
 
@@ -37,9 +43,14 @@
   gfree(fileRoot);
 }
 
+void ImageOutputDev::startPage(int pageNum, GfxState *state) {
+  curPageNum = pageNum;
+}
+
 void ImageOutputDev::tilingPatternFill(GfxState *state, Gfx *gfx,
 				       Object *strRef,
-				       int paintType, Dict *resDict,
+				       int paintType, int tilingType,
+				       Dict *resDict,
 				       double *mat, double *bbox,
 				       int x0, int y0, int x1, int y1,
 				       double xStep, double yStep) {
@@ -53,8 +64,32 @@
   char buf[4096];
   int size, n, i;
 
+  // dump raw file
+  if (dumpRaw && !inlineImg) {
+
+    // open the image file
+    sprintf(fileName, "%s-%04d.%s",
+	    fileRoot, imgNum, getRawFileExtension(str));
+    ++imgNum;
+    if (!(f = fopen(fileName, "wb"))) {
+      error(errIO, -1, "Couldn't open image file '{0:s}'", fileName);
+      return;
+    }
+
+    // initialize stream
+    str = getRawStream(str);
+    str->reset();
+
+    // copy the stream
+    while ((n = str->getBlock(buf, sizeof(buf))) > 0) {
+      fwrite(buf, 1, n, f);
+    }
+
+    str->close();
+    fclose(f);
+
   // dump JPEG file
-  if (dumpJPEG && str->getKind() == strDCT && !inlineImg) {
+  } else if (dumpJPEG && str->getKind() == strDCT && !inlineImg) {
 
     // open the image file
     sprintf(fileName, "%s-%04d.jpg", fileRoot, imgNum);
@@ -107,6 +142,10 @@
     str->close();
     fclose(f);
   }
+
+  if (list) {
+    writeImageInfo(width, height, state, NULL);
+  }
 }
 
 void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
@@ -114,19 +153,51 @@
 			       GfxImageColorMap *colorMap,
 			       int *maskColors, GBool inlineImg,
 			       GBool interpolate) {
+  GfxColorSpaceMode csMode;
   FILE *f;
   ImageStream *imgStr;
   Guchar *p;
   GfxRGB rgb;
+  GfxGray gray;
   int x, y;
   char buf[4096];
-  int size, n, i;
+  int size, n, i, j;
 
+  csMode = colorMap->getColorSpace()->getMode();
+  if (csMode == csIndexed) {
+    csMode = ((GfxIndexedColorSpace *)colorMap->getColorSpace())
+             ->getBase()->getMode();
+  }
+
+  // dump raw file
+  if (dumpRaw && !inlineImg) {
+
+    // open the image file
+    sprintf(fileName, "%s-%04d.%s",
+	    fileRoot, imgNum, getRawFileExtension(str));
+    ++imgNum;
+    if (!(f = fopen(fileName, "wb"))) {
+      error(errIO, -1, "Couldn't open image file '{0:s}'", fileName);
+      return;
+    }
+
+    // initialize stream
+    str = getRawStream(str);
+    str->reset();
+
+    // copy the stream
+    while ((n = str->getBlock(buf, sizeof(buf))) > 0) {
+      fwrite(buf, 1, n, f);
+    }
+
+    str->close();
+    fclose(f);
+
   // dump JPEG file
-  if (dumpJPEG && str->getKind() == strDCT &&
-      (colorMap->getNumPixelComps() == 1 ||
-       colorMap->getNumPixelComps() == 3) &&
-      !inlineImg) {
+  } else if (dumpJPEG && str->getKind() == strDCT &&
+	     (colorMap->getNumPixelComps() == 1 ||
+	      colorMap->getNumPixelComps() == 3) &&
+	     !inlineImg) {
 
     // open the image file
     sprintf(fileName, "%s-%04d.jpg", fileRoot, imgNum);
@@ -170,6 +241,9 @@
     while (size > 0) {
       i = size < (int)sizeof(buf) ? size : (int)sizeof(buf);
       n = str->getBlock(buf, i);
+      for (j = 0; j < n; ++j) {
+	buf[j] ^= 0xff;
+      }
       fwrite(buf, 1, n, f);
       if (n < i) {
 	break;
@@ -180,6 +254,48 @@
     str->close();
     fclose(f);
 
+  // dump PGM file
+  } else if (colorMap->getNumPixelComps() == 1 &&
+	     (csMode == csDeviceGray || csMode == csCalGray)) {
+
+    // open the image file and write the PGM header
+    sprintf(fileName, "%s-%04d.pgm", fileRoot, imgNum);
+    ++imgNum;
+    if (!(f = fopen(fileName, "wb"))) {
+      error(errIO, -1, "Couldn't open image file '{0:s}'", fileName);
+      return;
+    }
+    fprintf(f, "P5\n");
+    fprintf(f, "%d %d\n", width, height);
+    fprintf(f, "255\n");
+
+    // initialize stream
+    imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(),
+			     colorMap->getBits());
+    imgStr->reset();
+
+    // for each line...
+    for (y = 0; y < height; ++y) {
+
+      // write the line
+      if ((p = imgStr->getLine())) {
+	for (x = 0; x < width; ++x) {
+	  colorMap->getGray(p, &gray, state->getRenderingIntent());
+	  fputc(colToByte(gray), f);
+	  ++p;
+	}
+      } else {
+	for (x = 0; x < width; ++x) {
+	  fputc(0, f);
+	}
+      }
+    }
+
+    imgStr->close();
+    delete imgStr;
+
+    fclose(f);
+
   // dump PPM file
   } else {
 
@@ -205,7 +321,7 @@
       // write the line
       if ((p = imgStr->getLine())) {
 	for (x = 0; x < width; ++x) {
-	  colorMap->getRGB(p, &rgb);
+	  colorMap->getRGB(p, &rgb, state->getRenderingIntent());
 	  fputc(colToByte(rgb.r), f);
 	  fputc(colToByte(rgb.g), f);
 	  fputc(colToByte(rgb.b), f);
@@ -225,6 +341,10 @@
 
     fclose(f);
   }
+
+  if (list) {
+    writeImageInfo(width, height, state, colorMap);
+  }
 }
 
 void ImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
@@ -246,9 +366,75 @@
 					 Stream *maskStr,
 					 int maskWidth, int maskHeight,
 					 GfxImageColorMap *maskColorMap,
-					 GBool interpolate) {
+					 double *matte, GBool interpolate) {
   drawImage(state, ref, str, width, height, colorMap,
 	    NULL, gFalse, interpolate);
   drawImage(state, ref, maskStr, maskWidth, maskHeight, maskColorMap,
 	    NULL, gFalse, interpolate);
 }
+
+Stream *ImageOutputDev::getRawStream(Stream *str) {
+  switch (str->getKind()) {
+  case strLZW:
+  case strRunLength:
+  case strCCITTFax:
+  case strDCT:
+  case strFlate:
+  case strJBIG2:
+  case strJPX:
+    return ((FilterStream *)str)->getNextStream();
+  default:
+    return str;
+  }
+}
+
+const char *ImageOutputDev::getRawFileExtension(Stream *str) {
+  switch (str->getKind()) {
+  case strLZW:       return "lzw";
+  case strRunLength: return "rle";
+  case strCCITTFax:  return "fax";
+  case strDCT:       return "jpg";
+  case strFlate:     return "flate";
+  case strJBIG2:     return "jb2";
+  case strJPX:       return "jpx";
+  default:           return "unknown";
+  }
+}
+
+void ImageOutputDev::writeImageInfo(int width, int height, GfxState *state,
+				    GfxImageColorMap *colorMap) {
+  const char *mode;
+  double hdpi, vdpi, x0, y0, x1, y1;
+  int bpc;
+
+  // this works for 0/90/180/270-degree rotations, along with
+  // horizontal/vertical flips
+  state->transformDelta(1, 0, &x0, &y0);
+  state->transformDelta(0, 1, &x1, &y1);
+  x0 = fabs(x0);
+  y0 = fabs(y0);
+  x1 = fabs(x1);
+  y1 = fabs(y1);
+  if (x0 > y0) {
+    hdpi = (72 * width) / x0;
+    vdpi = (72 * height) / y1;
+  } else {
+    hdpi = (72 * height) / x1;
+    vdpi = (72 * width) / y0;
+  }
+
+  if (colorMap) {
+    mode = GfxColorSpace::getColorSpaceModeName(
+			      colorMap->getColorSpace()->getMode());
+    bpc = colorMap->getBits();
+  } else {
+    mode = NULL;
+    bpc = 1;
+  }
+
+  printf("%s: page=%d width=%d height=%d hdpi=%.2f vdpi=%.2f %s%s bpc=%d\n",
+	 fileName, curPageNum, width, height, hdpi, vdpi,
+	 mode ? "colorspace=" : "mask",
+	 mode ? mode : "",
+	 bpc);
+}

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/ImageOutputDev.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -19,6 +19,7 @@
 #include "gtypes.h"
 #include "OutputDev.h"
 
+class GfxImageColorMap;
 class GfxState;
 
 //------------------------------------------------------------------------
@@ -30,9 +31,12 @@
 
   // Create an OutputDev which will write images to files named
   // <fileRoot>-NNN.<type>.  Normally, all images are written as PBM
-  // (.pbm) or PPM (.ppm) files.  If <dumpJPEG> is set, JPEG images are
-  // written as JPEG (.jpg) files.
-  ImageOutputDev(char *fileRootA, GBool dumpJPEGA);
+  // (.pbm) or PPM (.ppm) files.  If <dumpJPEG> is set, JPEG images
+  // are written as JPEG (.jpg) files.  If <dumpRaw> is set, all
+  // images are written in PDF-native formats.  If <list> is set, a
+  // one-line summary will be written to stdout for each image.
+  ImageOutputDev(char *fileRootA, GBool dumpJPEGA, GBool dumpRawA,
+		 GBool listA);
 
   // Destructor.
   virtual ~ImageOutputDev();
@@ -61,9 +65,12 @@
   // Does this device use drawChar() or drawString()?
   virtual GBool useDrawChar() { return gFalse; }
 
+  //----- initialization and control
+  virtual void startPage(int pageNum, GfxState *state);
+
   //----- path painting
   virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *strRef,
-				 int paintType, Dict *resDict,
+				 int paintType, int tilingType, Dict *resDict,
 				 double *mat, double *bbox,
 				 int x0, int y0, int x1, int y1,
 				 double xStep, double yStep);
@@ -86,14 +93,22 @@
 				   Stream *maskStr,
 				   int maskWidth, int maskHeight,
 				   GfxImageColorMap *maskColorMap,
-				   GBool interpolate);
+				   double *matte, GBool interpolate);
 
 private:
 
+  Stream *getRawStream(Stream *str);
+  const char *getRawFileExtension(Stream *str);
+  void writeImageInfo(int width, int height, GfxState *state,
+		      GfxImageColorMap *colorMap);
+
   char *fileRoot;		// root of output file names
   char *fileName;		// buffer for output file names
   GBool dumpJPEG;		// set to dump native JPEG files
+  GBool dumpRaw;		// set to dump raw PDF-native image files
+  GBool list;			// set to write image info to stdout
   int imgNum;			// current image number
+  int curPageNum;		// current page number
   GBool ok;			// set up ok?
 };
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JArithmeticDecoder.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JArithmeticDecoder.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JArithmeticDecoder.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "Object.h"
 #include "Stream.h"
 #include "JArithmeticDecoder.h"

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <stdlib.h>
 #include <limits.h>
+#include "gmempp.h"
 #include "GList.h"
 #include "Error.h"
 #include "JArithmeticDecoder.h"
@@ -1195,6 +1196,10 @@
   delete str;
 }
 
+Stream *JBIG2Stream::copy() {
+  return new JBIG2Stream(str->copy(), &globalsStream);
+}
+
 void JBIG2Stream::reset() {
   // read the globals stream
   globalSegments = new GList();
@@ -1288,8 +1293,10 @@
   Guint *refSegs;
   int c1, c2, c3;
   Guint i;
+  GBool done;
 
-  while (readULong(&segNum)) {
+  done = gFalse;
+  while (!done && readULong(&segNum)) {
 
     // segment header flags
     if (!readUByte(&segFlags)) {
@@ -1424,6 +1431,10 @@
     case 50:
       readEndOfStripeSeg(segLength);
       break;
+    case 51:
+      // end of file segment
+      done = gTrue;
+      break;
     case 52:
       readProfilesSeg(segLength);
       break;
@@ -1557,7 +1568,7 @@
     if ((seg = findSegment(refSegs[i]))) {
       if (seg->getType() == jbig2SegSymbolDict) {
 	j = ((JBIG2SymbolDict *)seg)->getSize();
-	if (numInputSyms > UINT_MAX - j) {
+	if (j > INT_MAX || numInputSyms > INT_MAX - j) {
 	  error(errSyntaxError, getPos(),
 		"Too many input symbols in JBIG2 symbol dictionary");
 	  delete codeTables;
@@ -1569,7 +1580,7 @@
       }
     }
   }
-  if (numInputSyms > UINT_MAX - numNewSyms) {
+  if (numNewSyms > INT_MAX || numInputSyms > INT_MAX - numNewSyms) {
     error(errSyntaxError, getPos(),
 	  "Too many input symbols in JBIG2 symbol dictionary");
     delete codeTables;
@@ -1695,7 +1706,8 @@
     } else {
       arithDecoder->decodeInt(&dh, iadhStats);
     }
-    if (dh < 0 && (Guint)-dh >= symHeight) {
+    if ((dh <= 0 && (Guint)-dh >= symHeight) ||
+	(dh > 0 && (Guint)dh > UINT_MAX - symHeight)) {
       error(errSyntaxError, getPos(),
 	    "Bad delta-height value in JBIG2 symbol dictionary");
       goto syntaxError;
@@ -1718,7 +1730,8 @@
 	  break;
 	}
       }
-      if (dw < 0 && (Guint)-dw >= symWidth) {
+      if ((dw <= 0 && (Guint)-dw >= symWidth) ||
+	  (dw > 0 && (Guint)dw > UINT_MAX - symWidth)) {
 	error(errSyntaxError, getPos(),
 	      "Bad delta-height value in JBIG2 symbol dictionary");
 	goto syntaxError;
@@ -1800,6 +1813,11 @@
 
     // read the collective bitmap
     if (huff && !refAgg) {
+      if (totalWidth == 0) {
+	error(errSyntaxError, getPos(),
+	      "Invalid height class width in JBIG2 symbol dictionary");
+	goto syntaxError;
+      }
       huffDecoder->decodeInt(&bmSize, huffBMSizeTable);
       huffDecoder->reset();
       if (bmSize == 0) {
@@ -1928,6 +1946,10 @@
       !readUByte(&segInfoFlags)) {
     goto eofError;
   }
+  if (w == 0 || h == 0) {
+    error(errSyntaxError, getPos(), "Bad size in JBIG2 text region segment");
+    return;
+  }
   extCombOp = segInfoFlags & 7;
 
   // rest of the text region header
@@ -2258,17 +2280,25 @@
 
     // decode delta-T
     if (huff) {
-      huffDecoder->decodeInt(&dt, huffDTTable);
+      if (!huffDecoder->decodeInt(&dt, huffDTTable)) {
+	break;
+      }
     } else {
-      arithDecoder->decodeInt(&dt, iadtStats);
+      if (!arithDecoder->decodeInt(&dt, iadtStats)) {
+	break;
+      }
     }
     t += dt * strips;
 
     // first S value
     if (huff) {
-      huffDecoder->decodeInt(&ds, huffFSTable);
+      if (!huffDecoder->decodeInt(&ds, huffFSTable)) {
+	break;
+      }
     } else {
-      arithDecoder->decodeInt(&ds, iafsStats);
+      if (!arithDecoder->decodeInt(&ds, iafsStats)) {
+	break;
+      }
     }
     sFirst += ds;
     s = sFirst;
@@ -2421,6 +2451,11 @@
       !readULong(&grayMax)) {
     goto eofError;
   }
+  if (patternW == 0 || patternH == 0) {
+    error(errSyntaxError, getPos(),
+	  "Bad size in JBIG2 pattern dictionary segment");
+    return;
+  }
   templ = (flags >> 1) & 3;
   mmr = flags & 1;
 
@@ -2504,7 +2539,7 @@
 	  "Bad bitmap size in JBIG2 halftone segment");
     return;
   }
-  if (gridH == 0 || gridW >= INT_MAX / gridH) {
+  if (gridW == 0 || gridH == 0 || gridW >= INT_MAX / gridH) {
     error(errSyntaxError, getPos(), "Bad grid size in JBIG2 halftone segment");
     return;
   }
@@ -2642,6 +2677,11 @@
       !readUByte(&segInfoFlags)) {
     goto eofError;
   }
+  if (w == 0 || h == 0) {
+    error(errSyntaxError, getPos(),
+	  "Bad bitmap size in JBIG2 generic region segment");
+    return;
+  }
   extCombOp = segInfoFlags & 7;
 
   // rest of the generic region segment header
@@ -2939,10 +2979,13 @@
       // convert the run lengths to a bitmap line
       i = 0;
       while (1) {
+	if (codingLine[i] >= w) {
+	  break;
+	}
 	for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
 	  bitmap->setPixel(x, y);
 	}
-	if (codingLine[i+1] >= w || codingLine[i+2] >= w) {
+	if (codingLine[i+1] >= w) {
 	  break;
 	}
 	i += 2;
@@ -3026,7 +3069,7 @@
 	    atx[2] >= -8 && atx[2] <= 8 &&
 	    atx[3] >= -8 && atx[3] <= 8) {
 	  // set up the adaptive context
-	  if (y + aty[0] >= 0) {
+	  if (aty[0] <= 0 && y + aty[0] >= 0) {
 	    atP0 = bitmap->getDataPtr() + (y + aty[0]) * bitmap->getLineSize();
 	    atBuf0 = *atP0++ << 8;
 	  } else {
@@ -3034,7 +3077,7 @@
 	    atBuf0 = 0;
 	  }
 	  atShift0 = 15 - atx[0];
-	  if (y + aty[1] >= 0) {
+	  if (aty[1] <= 0 && y + aty[1] >= 0) {
 	    atP1 = bitmap->getDataPtr() + (y + aty[1]) * bitmap->getLineSize();
 	    atBuf1 = *atP1++ << 8;
 	  } else {
@@ -3042,7 +3085,7 @@
 	    atBuf1 = 0;
 	  }
 	  atShift1 = 15 - atx[1];
-	  if (y + aty[2] >= 0) {
+	  if (aty[2] <= 0 && y + aty[2] >= 0) {
 	    atP2 = bitmap->getDataPtr() + (y + aty[2]) * bitmap->getLineSize();
 	    atBuf2 = *atP2++ << 8;
 	  } else {
@@ -3050,7 +3093,7 @@
 	    atBuf2 = 0;
 	  }
 	  atShift2 = 15 - atx[2];
-	  if (y + aty[3] >= 0) {
+	  if (aty[3] <= 0 && y + aty[3] >= 0) {
 	    atP3 = bitmap->getDataPtr() + (y + aty[3]) * bitmap->getLineSize();
 	    atBuf3 = *atP3++ << 8;
 	  } else {
@@ -3192,7 +3235,7 @@
 
 	if (atx[0] >= -8 && atx[0] <= 8) {
 	  // set up the adaptive context
-	  if (y + aty[0] >= 0) {
+	  if (aty[0] <= 0 && y + aty[0] >= 0) {
 	    atP0 = bitmap->getDataPtr() + (y + aty[0]) * bitmap->getLineSize();
 	    atBuf0 = *atP0++ << 8;
 	  } else {
@@ -3307,7 +3350,7 @@
 
 	if (atx[0] >= -8 && atx[0] <= 8) {
 	  // set up the adaptive context
-	  if (y + aty[0] >= 0) {
+	  if (aty[0] <= 0 && y + aty[0] >= 0) {
 	    atP0 = bitmap->getDataPtr() + (y + aty[0]) * bitmap->getLineSize();
 	    atBuf0 = *atP0++ << 8;
 	  } else {
@@ -3415,7 +3458,7 @@
 
 	if (atx[0] >= -8 && atx[0] <= 8) {
 	  // set up the adaptive context
-	  if (y + aty[0] >= 0) {
+	  if (aty[0] <= 0 && y + aty[0] >= 0) {
 	    atP0 = bitmap->getDataPtr() + (y + aty[0]) * bitmap->getLineSize();
 	    atBuf0 = *atP0++ << 8;
 	  } else {
@@ -3520,6 +3563,11 @@
       !readUByte(&segInfoFlags)) {
     goto eofError;
   }
+  if (w == 0 || h == 0) {
+    error(errSyntaxError, getPos(),
+	  "Bad size in JBIG2 generic refinement region segment");
+    return;
+  }
   extCombOp = segInfoFlags & 7;
 
   // rest of the generic refinement region segment header
@@ -3780,6 +3828,10 @@
       !readUByte(&flags) || !readUWord(&striping)) {
     goto eofError;
   }
+  if (pageW == 0 || pageH == 0 || pageW > INT_MAX / pageW) {
+    error(errSyntaxError, getPos(), "Bad page size in JBIG2 stream");
+    return;
+  }
   pageDefPixel = (flags >> 2) & 1;
   defCombOp = (flags >> 3) & 3;
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -35,6 +35,7 @@
 
   JBIG2Stream(Stream *strA, Object *globalsStreamA);
   virtual ~JBIG2Stream();
+  virtual Stream *copy();
   virtual StreamKind getKind() { return strJBIG2; }
   virtual void reset();
   virtual void close();

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <limits.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "Error.h"
 #include "JArithmeticDecoder.h"
 #include "JPXStream.h"
@@ -264,6 +265,10 @@
   delete bufStr;
 }
 
+Stream *JPXStream::copy() {
+  return new JPXStream(str->copy());
+}
+
 void JPXStream::reset() {
   bufStr->reset();
   if (readBoxes() == jpxDecodeFatalError) {
@@ -405,7 +410,7 @@
   GBool eol;
 
   do {
-    if (curY >= img.ySizeR) {
+    if (curY >= (img.ySize >> reduction)) {
       return;
     }
     tileIdx = ((curY - img.yTileOffsetR) / img.yTileSizeR) * img.nXTiles
@@ -434,7 +439,7 @@
     if (++curComp == (Guint)(havePalette ? palette.nComps : img.nComps)) {
 #endif
       curComp = 0;
-      if (++curX == img.xSizeR) {
+      if (++curX == (img.xSize >> reduction)) {
 	curX = img.xOffsetR;
 	++curY;
 	eol = gTrue;
@@ -582,11 +587,13 @@
 
 JPXDecodeResult JPXStream::readBoxes() {
   JPXDecodeResult result;
+  GBool haveCodestream;
   Guint boxType, boxLen, dataLen;
   Guint bpc1, compression, unknownColorspace, ipr;
   Guint i, j;
 
   haveImgHdr = gFalse;
+  haveCodestream = gFalse;
 
   // check for a naked JPEG 2000 codestream (without the JP2/JPX
   // wrapper) -- this appears to be a violation of the PDF spec, but
@@ -746,12 +753,13 @@
       if ((result = readCodestream(dataLen)) != jpxDecodeOk) {
 	return result;
       }
+      haveCodestream = gTrue;
       break;
     default:
       cover(16);
       if (bufStr->discardChars(dataLen) != dataLen) {
 	error(errSyntaxError, getPos(), "Unexpected EOF in JPX stream");
-	return jpxDecodeFatalError;
+	return haveCodestream ? jpxDecodeNonFatalError : jpxDecodeFatalError;
       }
       break;
     }
@@ -937,14 +945,14 @@
 	error(errSyntaxError, getPos(), "Error in JPX SIZ marker segment");
 	return jpxDecodeFatalError;
       }
-      img.xSizeR = img.xSize >> reduction;
-      img.ySizeR = img.ySize >> reduction;
-      img.xOffsetR = img.xOffset >> reduction;
-      img.yOffsetR = img.yOffset >> reduction;
-      img.xTileSizeR = img.xTileSize >> reduction;
-      img.yTileSizeR = img.yTileSize >> reduction;
-      img.xTileOffsetR = img.xTileOffset >> reduction;
-      img.yTileOffsetR = img.yTileOffset >> reduction;
+      img.xSizeR = jpxCeilDivPow2(img.xSize, reduction);
+      img.ySizeR = jpxCeilDivPow2(img.ySize, reduction);
+      img.xOffsetR = jpxCeilDivPow2(img.xOffset, reduction);
+      img.yOffsetR = jpxCeilDivPow2(img.yOffset, reduction);
+      img.xTileSizeR = jpxCeilDivPow2(img.xTileSize, reduction);
+      img.yTileSizeR = jpxCeilDivPow2(img.yTileSize, reduction);
+      img.xTileOffsetR = jpxCeilDivPow2(img.xTileOffset, reduction);
+      img.yTileOffsetR = jpxCeilDivPow2(img.yTileOffset, reduction);
       img.nXTiles = (img.xSize - img.xTileOffset + img.xTileSize - 1)
 	            / img.xTileSize;
       img.nYTiles = (img.ySize - img.yTileOffset + img.yTileSize - 1)
@@ -1916,10 +1924,8 @@
       tileComp->y1 = jpxCeilDiv(tile->y1, tileComp->vSep);
       tileComp->cbW = 1 << tileComp->codeBlockW;
       tileComp->cbH = 1 << tileComp->codeBlockH;
-      tileComp->w = (tileComp->x1 - tileComp->x0 + (1 << reduction) - 1)
-	              >> reduction;
-      tileComp->h = (tileComp->y1 - tileComp->y0 + (1 << reduction) - 1)
-	              >> reduction;
+      tileComp->w = jpxCeilDivPow2(tileComp->x1 - tileComp->x0, reduction);
+      tileComp->h = jpxCeilDivPow2(tileComp->y1 - tileComp->y0, reduction);
       tileComp->data = (int *)gmallocn(tileComp->w * tileComp->h, sizeof(int));
       if (tileComp->x1 - tileComp->x0 > tileComp->y1 - tileComp->y0) {
 	n = tileComp->x1 - tileComp->x0;
@@ -1940,6 +1946,8 @@
 	  resLevel->by0[0] = resLevel->y0;
 	  resLevel->bx1[0] = resLevel->x1;
 	  resLevel->by1[0] = resLevel->y1;
+	  resLevel->empty = resLevel->bx0[0] == resLevel->bx1[0] ||
+	                    resLevel->by0[0] == resLevel->by1[0];
 	} else {
 	  resLevel->bx0[0] = jpxCeilDivPow2(tileComp->x0 - (1 << (k-1)), k);
 	  resLevel->by0[0] = resLevel->y0;
@@ -1953,6 +1961,12 @@
 	  resLevel->by0[2] = jpxCeilDivPow2(tileComp->y0 - (1 << (k-1)), k);
 	  resLevel->bx1[2] = jpxCeilDivPow2(tileComp->x1 - (1 << (k-1)), k);
 	  resLevel->by1[2] = jpxCeilDivPow2(tileComp->y1 - (1 << (k-1)), k);
+	  resLevel->empty = (resLevel->bx0[0] == resLevel->bx1[0] ||
+			     resLevel->by0[0] == resLevel->by1[0]) &&
+	                    (resLevel->bx0[1] == resLevel->bx1[1] ||
+			     resLevel->by0[1] == resLevel->by1[1]) &&
+	                    (resLevel->bx0[2] == resLevel->bx1[2] ||
+			     resLevel->by0[2] == resLevel->by1[2]);
 	}
 	resLevel->precincts = (JPXPrecinct *)gmallocn(1, sizeof(JPXPrecinct));
 	for (pre = 0; pre < 1; ++pre) {
@@ -2114,6 +2128,10 @@
     resLevel = &tileComp->resLevels[tile->res];
     precinct = &resLevel->precincts[tile->precinct];
 
+    if (resLevel->empty) {
+      goto nextPacket;
+    }
+
     //----- packet header
 
     // setup
@@ -2343,6 +2361,7 @@
 
     //----- next packet
 
+  nextPacket:
     switch (tile->progOrder) {
     case 0: // layer, resolution level, component, precinct
       cover(58);
@@ -2873,11 +2892,31 @@
   Guint nx1, nx2, ny1, ny2, offset;
   Guint x, y, sb, cbX, cbY;
 
-  //----- fixed-point adjustment and dequantization
-
   qStyle = tileComp->quantStyle & 0x1f;
   guard = (tileComp->quantStyle >> 5) & 7;
   precinct = &resLevel->precincts[0];
+
+  //----- compute subband bounds
+
+  //    0   nx1  nx2
+  //    |    |    |
+  //    v    v    v
+  //   +----+----+
+  //   | LL | HL | <- 0
+  //   +----+----+
+  //   | LH | HH | <- ny1
+  //   +----+----+
+  //               <- ny2
+  nx1 = precinct->subbands[1].x1 - precinct->subbands[1].x0;
+  nx2 = nx1 + precinct->subbands[0].x1 - precinct->subbands[0].x0;
+  ny1 = precinct->subbands[0].y1 - precinct->subbands[0].y0;
+  ny2 = ny1 + precinct->subbands[1].y1 - precinct->subbands[1].y0;
+  if (nx2 == 0 || ny2 == 0) {
+    return;
+  }
+
+  //----- fixed-point adjustment and dequantization
+
   for (sb = 0; sb < 3; ++sb) {
 
     // i-quant parameters
@@ -2946,21 +2985,6 @@
 
   //----- inverse transform
 
-  // compute the subband bounds:
-  //    0   nx1  nx2
-  //    |    |    |
-  //    v    v    v
-  //   +----+----+
-  //   | LL | HL | <- 0
-  //   +----+----+
-  //   | LH | HH | <- ny1
-  //   +----+----+
-  //               <- ny2
-  nx1 = precinct->subbands[1].x1 - precinct->subbands[1].x0;
-  nx2 = nx1 + precinct->subbands[0].x1 - precinct->subbands[0].x0;
-  ny1 = precinct->subbands[0].y1 - precinct->subbands[0].y0;
-  ny2 = ny1 + precinct->subbands[1].y1 - precinct->subbands[1].y0;
-
   // horizontal (row) transforms
   if (r == tileComp->nDecompLevels) {
     offset = 3 + (tileComp->x0 & 1);

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/JPXStream.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -170,6 +170,7 @@
   Guint x0, y0, x1, y1;		// bounds of the tile-comp (for this res level)
   Guint bx0[3], by0[3],		// subband bounds
         bx1[3], by1[3];
+  GBool empty;			// true if all subbands are zero width or height
 
   //---- children
   JPXPrecinct *precincts;	// the precincts
@@ -280,6 +281,7 @@
 
   JPXStream(Stream *strA);
   virtual ~JPXStream();
+  virtual Stream *copy();
   virtual StreamKind getKind() { return strJPX; }
   virtual void reset();
   virtual void close();

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -16,6 +16,7 @@
 #include <stddef.h>
 #include <string.h>
 #include <ctype.h>
+#include "gmempp.h"
 #include "Lexer.h"
 #include "Error.h"
 
@@ -111,7 +112,7 @@
 Object *Lexer::getObj(Object *obj) {
   char *p;
   int c, c2;
-  GBool comment, neg, done;
+  GBool comment, neg, doubleMinus, done;
   int numParen;
   int xi;
   double xf, scale;
@@ -141,10 +142,31 @@
   case '0': case '1': case '2': case '3': case '4':
   case '5': case '6': case '7': case '8': case '9':
   case '-': case '.':
+    // Adobe's number lexer has some "interesting" behavior:
+    // "--123" is interpreted as 0
+    // "--123.4" is interpreted as -123.4 [I've seen this in the wild]
+    // "50-100" is interpreted as 50 [I've seen this in the wild]
+    // "50--100" is interpreted as 50
+    // "50-100.0" is an error -- but older versions of Acrobat may
+    //   have interpreted it as 50100.0 (?)
+    // "50--100.0" is an error -- but older versions of Acrobat may
+    //   have interpreted it as 50100.0 (?)
+    // "50.0-100" is interpreted as 50.0 (or maybe 50.0100?)
+    // "50.0--100" is interpreted as 50.0 (or maybe 50.0100?)
+    // "-50-100" is interpreted as -50
+    // "-" is interpreted as 0
+    // "-." is interpreted as 0.0
     neg = gFalse;
+    doubleMinus = gFalse;
     xf = xi = 0;
     if (c == '-') {
       neg = gTrue;
+      if (lookChar() == '-') {
+	doubleMinus = gTrue;
+	do {
+	  getChar();
+	} while (lookChar() == '-');
+      }
     } else if (c == '.') {
       goto doReal;
     } else {
@@ -163,9 +185,15 @@
 	break;
       }
     }
+    while ((c = lookChar()) == '-' || isdigit(c)) {
+      getChar();
+    }
     if (neg) {
       xi = -xi;
     }
+    if (doubleMinus) {
+      xi = 0;
+    }
     obj->initInt(xi);
     break;
   doReal:
@@ -173,8 +201,6 @@
     while (1) {
       c = lookChar();
       if (c == '-') {
-	// ignore minus signs in the middle of numbers to match
-	// Adobe's behavior
 	error(errSyntaxWarning, getPos(), "Badly formatted number");
 	getChar();
 	continue;
@@ -186,6 +212,9 @@
       xf = xf + scale * (c - '0');
       scale *= 0.1;
     }
+    while ((c = lookChar()) == '-' || isdigit(c)) {
+      getChar();
+    }
     if (neg) {
       xf = -xf;
     }
@@ -321,20 +350,22 @@
 	} else if (c2 >= 'a' && c2 <= 'f') {
 	  c = c2 - 'a' + 10;
 	} else {
+	  error(errSyntaxError, getPos(), "Invalid hex escape in name");
 	  goto notEscChar;
 	}
 	getChar();
-	c <<= 4;
-	c2 = getChar();
+	c2 = lookChar();
 	if (c2 >= '0' && c2 <= '9') {
-	  c += c2 - '0';
+	  c = (c << 4) + (c2 - '0');
 	} else if (c2 >= 'A' && c2 <= 'F') {
-	  c += c2 - 'A' + 10;
+	  c = (c << 4) + (c2 - 'A' + 10);
 	} else if (c2 >= 'a' && c2 <= 'f') {
-	  c += c2 - 'a' + 10;
+	  c = (c << 4) + (c2 - 'a' + 10);
 	} else {
-	  error(errSyntaxError, getPos(), "Illegal digit in hex char in name");
+	  error(errSyntaxError, getPos(), "Invalid hex escape in name");
+	  goto notEscChar;
 	}
+	getChar();
       }
      notEscChar:
       // the PDF spec claims that names are limited to 127 chars, but
@@ -496,6 +527,10 @@
   }
 }
 
+void Lexer::skipToEOF() {
+  while (getChar() != EOF) ;
+}
+
 GBool Lexer::isSpace(int c) {
   return c >= 0 && c <= 0xff && specialChars[c] == 1;
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Lexer.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -46,9 +46,15 @@
   // Skip to the beginning of the next line in the input stream.
   void skipToNextLine();
 
+  // Skip to the end of the input stream.
+  void skipToEOF();
+
   // Skip over one character.
   void skipChar() { getChar(); }
 
+  // Get stream index (for arrays of streams).
+  int getStreamIndex() { return strPtr; }
+
   // Get stream.
   Stream *getStream()
     { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Link.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Link.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Link.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -15,6 +15,7 @@
 #include <stddef.h>
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "Error.h"
 #include "Object.h"

Deleted: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.dep
===================================================================
Deleted: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.in
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.in	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Makefile.in	2017-08-13 07:14:48 UTC (rev 45031)
@@ -1,687 +0,0 @@
-#========================================================================
-#
-# Xpdf Makefile
-#
-# Copyright 1996-2003 Glyph & Cog, LLC
-#
-#========================================================================
-
-SHELL = /bin/sh
-
-prefix = @prefix@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-GOOSRCDIR = $(srcdir)/../goo
-GOOLIBDIR = ../goo
-FOFISRCDIR = $(srcdir)/../fofi
-FOFILIBDIR = ../fofi
-SPLASHSRCDIR = $(srcdir)/../splash
-SPLASHLIBDIR = ../splash
-
-CXXFLAGS = @CXXFLAGS@ @DEFS@ -I.. -I$(srcdir)/.. -I$(GOOSRCDIR) -I$(FOFISRCDIR) -I$(SPLASHSRCDIR) -I$(srcdir) @freetype2_CFLAGS@ @Sgm_CFLAGS@ @Xm_CFLAGS@ @Xt_CFLAGS@ @Xp_CFLAGS@ @Xext_CFLAGS@ @Xpm_CFLAGS@ @libpng_CFLAGS@ @libpaper_CFLAGS@ @X_CFLAGS@ @EXTRA_CFLAGS@
-
-LDFLAGS = @LDFLAGS@
-
-FTLIBS = @freetype2_LIBS@ -lz
-
-XLIBS = @Sgm_LIBS@ @Xm_LIBS@ @Xt_LIBS@ @Xp_LIBS@ @Xext_LIBS@ @Xpm_LIBS@ @X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@
-
-PNGLIBS = @libpng_LIBS@
-
-SPLASHLIBS = -L$(SPLASHLIBDIR) -lsplash
-
-OTHERLIBS = @LIBS@ @libpaper_LIBS@ @EXTRA_LIBS@ \
-	-L$(FOFILIBDIR) -lfofi \
-	-L$(GOOLIBDIR) -lGoo
-
-CXX = @CXX@
-
-LIBPREFIX = @LIBPREFIX@
-EXE = @EXE@
-
-#------------------------------------------------------------------------
-
-.SUFFIXES: .cc
-
-.cc.o:
-	$(CXX) $(CXXFLAGS) -c $<
-
-#------------------------------------------------------------------------
-
-CXX_SRC = \
-	$(srcdir)/AcroForm.cc \
-	$(srcdir)/Annot.cc \
-	$(srcdir)/Array.cc \
-	$(srcdir)/BuiltinFont.cc \
-	$(srcdir)/BuiltinFontTables.cc \
-	$(srcdir)/CMap.cc \
-	$(srcdir)/Catalog.cc \
-	$(srcdir)/CharCodeToUnicode.cc \
-	$(srcdir)/CoreOutputDev.cc \
-	$(srcdir)/Decrypt.cc \
-	$(srcdir)/Dict.cc \
-	$(srcdir)/Error.cc \
-	$(srcdir)/FontEncodingTables.cc \
-	$(srcdir)/Form.cc \
-	$(srcdir)/Function.cc \
-	$(srcdir)/Gfx.cc \
-	$(srcdir)/GfxFont.cc \
-	$(srcdir)/GfxState.cc \
-	$(srcdir)/GlobalParams.cc \
-	$(srcdir)/HTMLGen.cc \
-	$(srcdir)/ImageOutputDev.cc \
-	$(srcdir)/JArithmeticDecoder.cc \
-	$(srcdir)/JBIG2Stream.cc \
-	$(srcdir)/JPXStream.cc \
-	$(srcdir)/Lexer.cc \
-	$(srcdir)/Link.cc \
-	$(srcdir)/NameToCharCode.cc \
-	$(srcdir)/Object.cc \
-	$(srcdir)/OptionalContent.cc \
-	$(srcdir)/Outline.cc \
-	$(srcdir)/OutputDev.cc \
-	$(srcdir)/PDFCore.cc \
-	$(srcdir)/PDFDoc.cc \
-	$(srcdir)/PDFDocEncoding.cc \
-	$(srcdir)/PSOutputDev.cc \
-	$(srcdir)/PSTokenizer.cc \
-	$(srcdir)/Page.cc \
-	$(srcdir)/Parser.cc \
-	$(srcdir)/PreScanOutputDev.cc \
-	$(srcdir)/SecurityHandler.cc \
-	$(srcdir)/SplashOutputDev.cc \
-	$(srcdir)/Stream.cc \
-	$(srcdir)/TextOutputDev.cc \
-	$(srcdir)/TextString.cc \
-	$(srcdir)/UnicodeMap.cc \
-	$(srcdir)/UnicodeTypeTable.cc \
-	$(srcdir)/XFAForm.cc \
-	$(srcdir)/XPDFApp.cc \
-	$(srcdir)/XPDFCore.cc \
-	$(srcdir)/XPDFTree.cc \
-	$(srcdir)/XPDFViewer.cc \
-	$(srcdir)/XpdfPluginAPI.cc \
-	$(srcdir)/XRef.cc \
-	$(srcdir)/Zoox.cc \
-	$(srcdir)/pdftops.cc \
-	$(srcdir)/pdftotext.cc \
-	$(srcdir)/pdftohtml.cc \
-	$(srcdir)/pdfinfo.cc \
-	$(srcdir)/pdffonts.cc \
-	$(srcdir)/pdfdetach.cc \
-	$(srcdir)/pdftoppm.cc \
-	$(srcdir)/pdftopng.cc \
-	$(srcdir)/pdfimages.cc \
-	$(srcdir)/xpdf.cc
-
-#------------------------------------------------------------------------
-
-all: xpdf$(EXE) pdftops$(EXE) pdftotext$(EXE) pdftohtml$(EXE) \
-	pdfinfo$(EXE) pdffonts$(EXE) pdfdetach$(EXE) pdftoppm$(EXE) \
-	pdftopng$(EXE) pdfimages$(EXE)
-
-all-no-x: pdftops$(EXE) pdftotext$(EXE) pdftohtml$(EXE) pdfinfo$(EXE) \
-	pdffonts$(EXE) pdfdetach$(EXE) pdfimages$(EXE)
-
-#------------------------------------------------------------------------
-
-XPDF_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	CoreOutputDev.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFCore.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PreScanOutputDev.o \
-	PSOutputDev.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	SplashOutputDev.o \
-	Stream.o \
-	TextOutputDev.o \
-	TextString.o \
-	UnicodeMap.o \
-	UnicodeTypeTable.o \
-	XFAForm.o \
-	XPDFApp.o \
-	XPDFCore.o \
-	XPDFTree.o \
-	XPDFViewer.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	xpdf.o
-XPDF_LIBS = -L$(GOOLIBDIR) -lGoo $(SPLASHLIBS) $(FTLIBS) \
-	$(XLIBS) $(OTHERLIBS) -lm
-
-xpdf$(EXE): $(XPDF_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o xpdf$(EXE) $(XPDF_OBJS) $(XPDF_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFTOPS_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	OptionalContent.o \
-	Outline.o \
-	Object.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PreScanOutputDev.o \
-	PSOutputDev.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	SplashOutputDev.o \
-	Stream.o \
-	TextString.o \
-	UnicodeMap.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdftops.o
-PDFTOPS_LIBS = -L$(GOOLIBDIR) -lGoo $(SPLASHLIBS) $(FTLIBS) \
-	$(OTHERLIBS) -lm
-
-pdftops$(EXE): $(PDFTOPS_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdftops$(EXE) $(PDFTOPS_OBJS) \
-		$(PDFTOPS_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFTOTEXT_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	Stream.o \
-	TextOutputDev.o \
-	TextString.o \
-	UnicodeMap.o \
-	UnicodeTypeTable.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdftotext.o
-PDFTOTEXT_LIBS = -L$(GOOLIBDIR) -lGoo $(OTHERLIBS) -lm
-
-pdftotext$(EXE): $(PDFTOTEXT_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdftotext$(EXE) $(PDFTOTEXT_OBJS) \
-		$(PDFTOTEXT_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFTOHTML_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	HTMLGen.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	SplashOutputDev.o \
-	Stream.o \
-	TextOutputDev.o \
-	TextString.o \
-	UnicodeMap.o \
-	UnicodeTypeTable.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdftohtml.o
-PDFTOHTML_LIBS = -L$(GOOLIBDIR) -lGoo $(SPLASHLIBS) $(FTLIBS) \
-	$(OTHERLIBS) $(PNGLIBS) -lm
-
-pdftohtml$(EXE): $(PDFTOHTML_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdftohtml$(EXE) $(PDFTOHTML_OBJS) \
-		$(PDFTOHTML_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFINFO_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	Stream.o \
-	TextString.o \
-	UnicodeMap.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdfinfo.o
-PDFINFO_LIBS = -L$(GOOLIBDIR) -lGoo $(OTHERLIBS) -lm
-
-pdfinfo$(EXE): $(PDFINFO_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdfinfo$(EXE) $(PDFINFO_OBJS) \
-		$(PDFINFO_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFFONTS_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	Stream.o \
-	TextString.o \
-	UnicodeMap.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdffonts.o
-PDFFONTS_LIBS = -L$(GOOLIBDIR) -lGoo $(OTHERLIBS) -lm
-
-pdffonts$(EXE): $(PDFFONTS_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdffonts$(EXE) $(PDFFONTS_OBJS) \
-		$(PDFFONTS_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFDETACH_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	Stream.o \
-	TextString.o \
-	UnicodeMap.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdfdetach.o
-PDFDETACH_LIBS = -L$(GOOLIBDIR) -lGoo $(OTHERLIBS) -lm
-
-pdfdetach$(EXE): $(PDFDETACH_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdfdetach$(EXE) $(PDFDETACH_OBJS) \
-		$(PDFDETACH_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFTOPPM_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	SplashOutputDev.o \
-	Stream.o \
-	TextOutputDev.o \
-	TextString.o \
-	UnicodeMap.o \
-	UnicodeTypeTable.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdftoppm.o
-PDFTOPPM_LIBS = -L$(GOOLIBDIR) -lGoo $(SPLASHLIBS) $(FTLIBS) \
-	$(OTHERLIBS) -lm
-
-pdftoppm$(EXE): $(PDFTOPPM_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdftoppm$(EXE) $(PDFTOPPM_OBJS) \
-		$(PDFTOPPM_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFTOPNG_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	SplashOutputDev.o \
-	Stream.o \
-	TextOutputDev.o \
-	TextString.o \
-	UnicodeMap.o \
-	UnicodeTypeTable.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdftopng.o
-PDFTOPNG_LIBS = -L$(GOOLIBDIR) -lGoo $(SPLASHLIBS) $(FTLIBS) \
-	$(OTHERLIBS) $(PNGLIBS) -lm
-
-pdftopng$(EXE): $(PDFTOPNG_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdftopng$(EXE) $(PDFTOPNG_OBJS) \
-		$(PDFTOPNG_LIBS)
-
-#------------------------------------------------------------------------
-
-PDFIMAGES_OBJS = \
-	AcroForm.o \
-	Annot.o \
-	Array.o \
-	BuiltinFont.o \
-	BuiltinFontTables.o \
-	Catalog.o \
-	CharCodeToUnicode.o \
-	CMap.o \
-	Decrypt.o \
-	Dict.o \
-	Error.o \
-	FontEncodingTables.o \
-	Form.o \
-	Function.o \
-	Gfx.o \
-	GfxFont.o \
-	GfxState.o \
-	GlobalParams.o \
-	ImageOutputDev.o \
-	JArithmeticDecoder.o \
-	JBIG2Stream.o \
-	JPXStream.o \
-	Lexer.o \
-	Link.o \
-	NameToCharCode.o \
-	Object.o \
-	OptionalContent.o \
-	Outline.o \
-	OutputDev.o \
-	Page.o \
-	Parser.o \
-	PDFDoc.o \
-	PDFDocEncoding.o \
-	PSTokenizer.o \
-	SecurityHandler.o \
-	Stream.o \
-	TextString.o \
-	UnicodeMap.o \
-	XFAForm.o \
-	XpdfPluginAPI.o \
-	XRef.o \
-	Zoox.o \
-	pdfimages.o
-PDFIMAGES_LIBS = -L$(GOOLIBDIR) -lGoo $(OTHERLIBS) -lm
-
-pdfimages$(EXE): $(PDFIMAGES_OBJS) $(GOOLIBDIR)/$(LIBPREFIX)Goo.a
-	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o pdfimages$(EXE) $(PDFIMAGES_OBJS) \
-		$(PDFIMAGES_LIBS)
-
-#------------------------------------------------------------------------
-
-clean:
-	rm -f $(XPDF_OBJS) xpdf$(EXE)
-	rm -f $(PDFTOPS_OBJS) pdftops$(EXE)
-	rm -f $(PDFTOTEXT_OBJS) pdftotext$(EXE)
-	rm -f $(PDFTOHTML_OBJS) pdftohtml$(EXE)
-	rm -f $(PDFINFO_OBJS) pdfinfo$(EXE)
-	rm -f $(PDFFONTS_OBJS) pdffonts$(EXE)
-	rm -f $(PDFDETACH_OBJS) pdfdetach$(EXE)
-	rm -f $(PDFTOPPM_OBJS) pdftoppm$(EXE)
-	rm -f $(PDFTOPNG_OBJS) pdftopng$(EXE)
-	rm -f $(PDFIMAGES_OBJS) pdfimages$(EXE)
-
-#------------------------------------------------------------------------
-
-depend:
-	$(CXX) $(CXXFLAGS) -MM $(CXX_SRC) >Makefile.dep
-
--include Makefile.dep

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/NameToCharCode.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/NameToCharCode.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/NameToCharCode.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -14,6 +14,7 @@
 
 #include <string.h>
 #include "gmem.h"
+#include "gmempp.h"
 #include "NameToCharCode.h"
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -13,6 +13,7 @@
 #endif
 
 #include <stddef.h>
+#include "gmempp.h"
 #include "Object.h"
 #include "Array.h"
 #include "Dict.h"
@@ -42,7 +43,11 @@
 };
 
 #ifdef DEBUG_MEM
+#if MULTITHREADED
+GAtomicCounter Object::numAlloc[numObjTypes] =
+#else
 int Object::numAlloc[numObjTypes] =
+#endif
   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
 
@@ -87,7 +92,7 @@
     dict->incRef();
     break;
   case objStream:
-    stream->incRef();
+    obj->stream = stream->copy();
     break;
   case objCmd:
     obj->cmd = copyString(cmd);
@@ -96,8 +101,12 @@
     break;
   }
 #ifdef DEBUG_MEM
+#if MULTITHREADED
+  gAtomicIncrement(&numAlloc[type]);
+#else
   ++numAlloc[type];
 #endif
+#endif
   return obj;
 }
 
@@ -125,9 +134,7 @@
     }
     break;
   case objStream:
-    if (!stream->decRef()) {
-      delete stream;
-    }
+    delete stream;
     break;
   case objCmd:
     gfree(cmd);
@@ -136,8 +143,12 @@
     break;
   }
 #ifdef DEBUG_MEM
+#if MULTITHREADED
+  gAtomicDecrement(&numAlloc[type]);
+#else
   --numAlloc[type];
 #endif
+#endif
   type = objNone;
 }
 
@@ -224,7 +235,7 @@
     fprintf(f, "Allocated objects:\n");
     for (i = 0; i < numObjTypes; ++i) {
       if (numAlloc[i] > 0)
-	fprintf(f, "  %-20s: %6d\n", objTypeNames[i], numAlloc[i]);
+	fprintf(f, "  %-20s: %6ld\n", objTypeNames[i], numAlloc[i]);
     }
   }
 #endif

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Object.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -21,6 +21,9 @@
 #include "gmem.h"
 #include "gfile.h"
 #include "GString.h"
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
 
 class XRef;
 class Array;
@@ -69,7 +72,11 @@
 //------------------------------------------------------------------------
 
 #ifdef DEBUG_MEM
-#define initObj(t) ++numAlloc[type = t]
+#  if MULTITHREADED
+#    define initObj(t) gAtomicIncrement(&numAlloc[type = t])
+#  else
+#    define initObj(t) ++numAlloc[type = t]
+#  endif
 #else
 #define initObj(t) type = t
 #endif
@@ -210,9 +217,14 @@
   };
 
 #ifdef DEBUG_MEM
+#if MULTITHREADED
+  static GAtomicCounter		// number of each type of object
+    numAlloc[numObjTypes];	//   currently allocated
+#else
   static int			// number of each type of object
     numAlloc[numObjTypes];	//   currently allocated
 #endif
+#endif
 };
 
 //------------------------------------------------------------------------

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -12,6 +12,7 @@
 #pragma implementation
 #endif
 
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "Error.h"
@@ -69,7 +70,7 @@
       //----- read the default viewing OCCD
       if (ocProps->dictLookup("D", &defView)->isDict()) {
 
-	//----- initial state
+	//----- initial state from OCCD
 	if (defView.dictLookup("OFF", &obj1)->isArray()) {
 	  for (i = 0; i < obj1.arrayGetLength(); ++i) {
 	    if (obj1.arrayGetNF(i, &obj2)->isRef()) {
@@ -85,7 +86,35 @@
 	  }
 	}
 	obj1.free();
+	// the default OCCD is required to have a BaseState of ON, so
+	// the ON array is redundant -- but some (broken) PDF files
+	// include OCGs in both the OFF and ON arrays
+	if (defView.dictLookup("ON", &obj1)->isArray()) {
+	  for (i = 0; i < obj1.arrayGetLength(); ++i) {
+	    if (obj1.arrayGetNF(i, &obj2)->isRef()) {
+	      ref1 = obj2.getRef();
+	      if ((ocg = findOCG(&ref1))) {
+		ocg->setState(gTrue);
+	      } else {
+		error(errSyntaxError, -1,
+		      "Invalid OCG reference in ON array in default viewing OCCD");
+	      }
+	    }
+	    obj2.free();
+	  }
+	}
+	obj1.free();
 
+	//----- initial state from OCG usage dict
+	for (i = 0; i < ocgs->getLength(); ++i) {
+	  ocg = (OptionalContentGroup *)ocgs->get(i);
+	  //~ should this look at PrintState when printing, or is it
+	  //~   better to always print the ViewState?
+	  if (ocg->getViewState() == ocUsageOff) {
+	    ocg->setState(gFalse);
+	  }
+	}
+
 	//----- display order
 	if (defView.dictLookup("Order", &obj1)->isArray()) {
 	  display = OCDisplayNode::parse(&obj1, this, xref);
@@ -418,6 +447,7 @@
 OCDisplayNode::OCDisplayNode() {
   name = new TextString();
   ocg = NULL;
+  parent = NULL;
   children = NULL;
 }
 
@@ -438,21 +468,31 @@
     children = new GList();
   }
   children->append(child);
+  child->parent = this;
 }
 
 void OCDisplayNode::addChildren(GList *childrenA) {
+  int i;
+
   if (!children) {
     children = new GList();
   }
   children->append(childrenA);
+  for (i = 0; i < childrenA->getLength(); ++i) {
+    ((OCDisplayNode *)childrenA->get(i))->parent = this;
+  }
   delete childrenA;
 }
 
 GList *OCDisplayNode::takeChildren() {
   GList *childrenA;
+  int i;
 
   childrenA = children;
   children = NULL;
+  for (i = 0; i < childrenA->getLength(); ++i) {
+    ((OCDisplayNode *)childrenA->get(i))->parent = NULL;
+  }
   return childrenA;
 }
 

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OptionalContent.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -115,6 +115,7 @@
   OptionalContentGroup *getOCG() { return ocg; }
   int getNumChildren();
   OCDisplayNode *getChild(int idx);
+  OCDisplayNode *getParent() { return parent; }
 
 private:
 
@@ -126,6 +127,7 @@
 
   TextString *name;		// display name
   OptionalContentGroup *ocg;	// NULL for display labels
+  OCDisplayNode *parent;	// parent node; NULL at root
   GList *children;		// NULL if there are no children
 				//   [OCDisplayNode]
 };

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -13,6 +13,7 @@
 #endif
 
 #include "gmem.h"
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "Error.h"
@@ -83,6 +84,8 @@
     }
   }
   obj1.free();
+
+  pageNum = -1;
 }
 
 OutlineItem::~OutlineItem() {

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/Outline.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -61,9 +61,12 @@
   GBool isOpen() { return startsOpen; }
   GBool hasKids() { return firstRef.isRef(); }
   GList *getKids() { return kids; }
+  OutlineItem *getParent() { return parent; }
 
 private:
 
+  friend class PDFDoc;
+
   XRef *xref;
   TextString *title;		// may be NULL
   LinkAction *action;
@@ -72,6 +75,8 @@
   Object lastRef;
   Object nextRef;
   GBool startsOpen;
+  int pageNum;			// page number (used by
+				//   PDFDoc::getOutlineTargetPage)
   GList *kids;			// NULL unless this item is open [OutlineItem]
   OutlineItem *parent;
 };

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -13,6 +13,7 @@
 #endif
 
 #include <stddef.h>
+#include "gmempp.h"
 #include "Object.h"
 #include "Stream.h"
 #include "GfxState.h"
@@ -125,7 +126,7 @@
 				    Stream *maskStr,
 				    int maskWidth, int maskHeight,
 				    GfxImageColorMap *maskColorMap,
-				    GBool interpolate) {
+				    double *matte, GBool interpolate) {
   drawImage(state, ref, str, width, height, colorMap, NULL, gFalse,
 	    interpolate);
 }

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.h
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.h	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/OutputDev.h	2017-08-13 07:14:48 UTC (rev 45031)
@@ -105,9 +105,6 @@
   // End a page.
   virtual void endPage() {}
 
-  // Dump page contents to display.
-  virtual void dump() {}
-
   //----- coordinate conversion
 
   // Convert between device and user coordinates.
@@ -143,6 +140,7 @@
   virtual void updateFillOverprint(GfxState *state) {}
   virtual void updateStrokeOverprint(GfxState *state) {}
   virtual void updateOverprintMode(GfxState *state) {}
+  virtual void updateRenderingIntent(GfxState *state) {}
   virtual void updateTransfer(GfxState *state) {}
 
   //----- update text state
@@ -163,7 +161,7 @@
   virtual void fill(GfxState *state) {}
   virtual void eoFill(GfxState *state) {}
   virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *strRef,
-				 int paintType, Dict *resDict,
+				 int paintType, int tilingType, Dict *resDict,
 				 double *mat, double *bbox,
 				 int x0, int y0, int x1, int y1,
 				 double xStep, double yStep) {}
@@ -221,7 +219,7 @@
 				   Stream *maskStr,
 				   int maskWidth, int maskHeight,
 				   GfxImageColorMap *maskColorMap,
-				   GBool interpolate);
+				   double *matte, GBool interpolate);
 
 #if OPI_SUPPORT
   //----- OPI functions

Modified: trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc
===================================================================
--- trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc	2017-08-13 00:21:21 UTC (rev 45030)
+++ trunk/Build/source/libs/xpdf/xpdf-src/xpdf/PDFCore.cc	2017-08-13 07:14:48 UTC (rev 45031)
@@ -2,7 +2,7 @@
 //
 // PDFCore.cc
 //
-// Copyright 2004-2013 Glyph & Cog, LLC
+// Copyright 2004-2014 Glyph & Cog, LLC
 //
 //========================================================================
 
@@ -13,6 +13,7 @@
 #endif
 
 #include <math.h>
+#include "gmempp.h"
 #include "GString.h"
 #include "GList.h"
 #include "GlobalParams.h"
@@ -24,106 +25,83 @@
 #include "ErrorCodes.h"
 #include "PDFDoc.h"
 #include "Link.h"
-#include "TextOutputDev.h"
-#include "CoreOutputDev.h"
+#include "Annot.h"
+#include "Form.h"
+#include "OptionalContent.h"
+#include "TileMap.h"
+#include "TileCache.h"
+#include "TileCompositor.h"
 #include "PDFCore.h"
 
 //------------------------------------------------------------------------
-// PDFCorePage
+// PDFCore
 //------------------------------------------------------------------------
 
-PDFCorePage::PDFCorePage(int pageA, int wA, int hA, int tileWA, int tileHA) {
-  page = pageA;
-  tiles = new GList();
-  w = wA;
-  h = hA;
-  tileW = tileWA;
-  tileH = tileHA;
+PDFCore::PDFCore(SplashColorMode colorMode, int bitmapRowPad,
+		 GBool reverseVideo, SplashColorPtr paperColor) {
+  GString *initialZoom;
+  int z, i;
+
+  doc = NULL;
+
+  linksPage = 0;
   links = NULL;
-  text = NULL;
-}
 
-PDFCorePage::~PDFCorePage() {
-  deleteGList(tiles, PDFCoreTile);
-  if (links) {
-    delete links;
-  }
-  if (text) {
-    delete text;
-  }
-}
+  annotsPage = 0;
+  annots = NULL;
 
-//------------------------------------------------------------------------
-// PDFCoreTile
-//------------------------------------------------------------------------
+  textPage = 0;
+  textDPI = 0;
+  textRotate = 0;
+  textOutCtrl.mode = textOutPhysLayout;
+  text = NULL;
 
-PDFCoreTile::PDFCoreTile(int xDestA, int yDestA) {
-  xMin = 0;
-  yMin = 0;
-  xMax = 0;
-  yMax = 0;
-  xDest = xDestA;
-  yDest = yDestA;
-  bitmap = NULL;
-}
+  state = new DisplayState(globalParams->getMaxTileWidth(),
+			   globalParams->getMaxTileHeight(),
+			   globalParams->getTileCacheSize(),
+			   globalParams->getWorkerThreads(),
+			   colorMode, bitmapRowPad);
+  tileMap = new TileMap(state);
+  tileCache = new TileCache(state);
+  tileCompositor = new TileCompositor(state, tileMap, tileCache);
+  bitmapFinished = gTrue;
 
-PDFCoreTile::~PDFCoreTile() {
-  if (bitmap) {
-    delete bitmap;
+  state->setReverseVideo(reverseVideo);
+  state->setPaperColor(paperColor);
+  initialZoom = globalParams->getInitialZoom();
+  if (!initialZoom->cmp("page")) {
+    state->setZoom(zoomPage);
+  } else if (!initialZoom->cmp("width")) {
+    state->setZoom(zoomWidth);
+  } else {
+    z = atoi(initialZoom->getCString());
+    if (z <= 0) {
+      z = zoomWidth;
+    }
+    state->setZoom(z);
   }
-}
+  delete initialZoom;
 
-
-//------------------------------------------------------------------------
-// PDFCore
-//------------------------------------------------------------------------
-
-PDFCore::PDFCore(SplashColorMode colorModeA, int bitmapRowPadA,
-		 GBool reverseVideoA, SplashColorPtr paperColorA,
-		 GBool incrementalUpdate) {
-  int i;
-
-  doc = NULL;
-  continuousMode = globalParams->getContinuousView();
-  drawAreaWidth = drawAreaHeight = 0;
-  maxPageW = totalDocH = 0;
-  pageY = NULL;
-  topPage = 0;
-  midPage = 0;
-  scrollX = scrollY = 0;
-  zoom = defZoom;
-  dpi = 0;
-  rotate = 0;
-
+  selectMode = selectModeBlock;
   selectPage = 0;
-  selectULX = selectLRX = 0;
-  selectULY = selectLRY = 0;
-  dragging = gFalse;
-  lastDragLeft = lastDragTop = gTrue;
-  selectXorColor[0] = selectXorColor[1] = selectXorColor[2] =
-      reverseVideoA ? 0xff : 0x00;
-  splashColorXor(selectXorColor, paperColorA);
+  selectStartX = selectStartY = 0;
 
   historyCur = pdfHistorySize - 1;
   historyBLen = historyFLen = 0;
   for (i = 0; i < pdfHistorySize; ++i) {
     history[i].fileName = NULL;
+    history[i].page = 0;
   }
-
-
-  pages = new GList();
-  curTile = NULL;
-
-  splashColorCopy(paperColor, paperColorA);
-  out = new CoreOutputDev(colorModeA, bitmapRowPadA,
-			  reverseVideoA, paperColorA, incrementalUpdate,
-			  &redrawCbk, this);
-  out->startDoc(NULL);
 }
 
 PDFCore::~PDFCore() {
   int i;
 
+  delete tileCompositor;
+  delete tileCache;
+  delete tileMap;
+  delete state;
+  clearPage();
   if (doc) {
     delete doc;
   }
@@ -136,9 +114,6 @@
 #endif
     }
   }
-  gfree(pageY);
-  deleteGList(pages, PDFCorePage);
-  delete out;
 }
 
 int PDFCore::loadFile(GString *fileName, GString *ownerPassword,
@@ -181,11 +156,25 @@
   setBusyCursor(gFalse);
 }
 
+int PDFCore::reload() {
+  int err;
+
+  if (!doc->getFileName()) {
+    return errOpenFile;
+  }
+  setBusyCursor(gTrue);
+  err = loadFile2(new PDFDoc(doc->getFileName()->copy(), NULL, NULL, this));
+  setBusyCursor(gFalse);
+  startUpdate();
+  finishUpdate(gTrue, gFalse);
+  return err;
+}
+
 int PDFCore::loadFile2(PDFDoc *newDoc) {
   int err;
-  double w, h, t;
-  int i;
 
+  clearSelection();
+
   // open the PDF file
   if (!newDoc->isOk()) {
     err = newDoc->getErrorCode();
@@ -193,38 +182,19 @@
     return err;
   }
 
+  preLoad();
+
   // replace old document
+  // NB: do not delete doc until after DisplayState::setDoc() returns
+  state->setDoc(newDoc);
   if (doc) {
     delete doc;
   }
   doc = newDoc;
-  if (out) {
-    out->startDoc(doc->getXRef());
-  }
+  clearPage();
 
-  // nothing displayed yet
-  topPage = -99;
-  midPage = -99;
-  while (pages->getLength() > 0) {
-    delete (PDFCorePage *)pages->del(0);
-  }
+  postLoad();
 
-  // compute the max unscaled page size
-  maxUnscaledPageW = maxUnscaledPageH = 0;
-  for (i = 1; i <= doc->getNumPages(); ++i) {
-    w = doc->getPageCropWidth(i);
-    h = doc->getPageCropHeight(i);
-    if (doc->getPageRotate(i) == 90 || doc->getPageRotate(i) == 270) {
-      t = w; w = h; h = t;
-    }
-    if (w > maxUnscaledPageW) {
-      maxUnscaledPageW = w;
-    }
-    if (h > maxUnscaledPageH) {
-      maxUnscaledPageH = h;
-    }
-  }
-
   return errNone;
 }
 
@@ -234,20 +204,15 @@
   }
 
   // no document
+  // NB: do not delete doc until after DisplayState::setDoc() returns
+  state->setDoc(NULL);
   delete doc;
   doc = NULL;
-  out->clear();
+  clearPage();
 
-  // no page displayed
-  topPage = -99;
-  midPage = -99;
-  while (pages->getLength() > 0) {
-    delete (PDFCorePage *)pages->del(0);
-  }
-
   // redraw
-  scrollX = scrollY = 0;
-  redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
+  state->setScrollPosition(1, 0, 0);
+  invalidateWholeWindow();
   updateScrollbars();
 }
 
@@ -259,21 +224,16 @@
   }
 
   // no document
+  // NB: do not delete doc until after DisplayState::setDoc() returns
+  state->setDoc(NULL);
   docA = doc;
   doc = NULL;
-  out->clear();
+  clearPage();
 
-  // no page displayed
-  topPage = -99;
-  midPage = -99;
-  while (pages->getLength() > 0) {
-    delete (PDFCorePage *)pages->del(0);
-  }
-
   // redraw
-  scrollX = scrollY = 0;
+  state->setScrollPosition(1, 0, 0);
   if (redraw) {
-    redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
+    invalidateWholeWindow();
     updateScrollbars();
   }
 
@@ -280,700 +240,282 @@
   return docA;
 }
 
-void PDFCore::displayPage(int topPageA, double zoomA, int rotateA,
-			  GBool scrollToTop, GBool addToHist) {
-  int scrollXA, scrollYA;
+void PDFCore::displayPage(int page, GBool scrollToTop,
+			  GBool scrollToBottom, GBool addToHist) {
+  int scrollX, scrollY;
 
-  scrollXA = scrollX;
-  if (continuousMode) {
-    scrollYA = -1;
-  } else if (scrollToTop) {
-    scrollYA = 0;
+  if (page <= 0 || page > doc->getNumPages()) {
+    return;
+  }
+  if (scrollToTop ||
+      state->getDisplayMode() == displayContinuous ||
+      state->getDisplayMode() == displaySideBySideContinuous) {
+    scrollY = tileMap->getPageTopY(page);
+  } else if (scrollToBottom) {
+    scrollY = tileMap->getPageBottomY(page);
   } else {
-    scrollYA = scrollY;
+    scrollY = state->getScrollY();
   }
-  if (zoomA != zoom) {
-    scrollXA = 0;
-    scrollYA = continuousMode ? -1 : 0;
+  if (state->getDisplayMode() == displayHorizontalContinuous) {
+    scrollX = tileMap->getPageLeftX(page);
+  } else {
+    scrollX = state->getScrollX();
   }
-
-  dragging = gFalse;
-  lastDragLeft = lastDragTop = gTrue;
-
-  update(topPageA, scrollXA, scrollYA, zoomA, rotateA, gTrue, addToHist,
-	 gTrue);
+  startUpdate();
+  state->setScrollPosition(page, scrollX, scrollY);
+  finishUpdate(addToHist, gTrue);
 }
 
-void PDFCore::displayDest(LinkDest *dest, double zoomA, int rotateA,
-			  GBool addToHist) {
+void PDFCore::displayDest(LinkDest *dest) {
   Ref pageRef;
-  int topPageA;
-  int dx, dy, scrollXA, scrollYA;
+  int page;
+  int dx, dy, scrollX, scrollY;
 
   if (dest->isPageRef()) {
     pageRef = dest->getPageRef();
-    topPageA = doc->findPage(pageRef.num, pageRef.gen);
+    page = doc->findPage(pageRef.num, pageRef.gen);
   } else {
-    topPageA = dest->getPageNum();
+    page = dest->getPageNum();
   }
-  if (topPageA <= 0 || topPageA > doc->getNumPages()) {
-    topPageA = 1;
+  if (page <= 0 || page > doc->getNumPages()) {
+    page = 1;
   }
-  scrollXA = scrollX;
-  scrollYA = continuousMode ? -1 : scrollY;
+
   switch (dest->getKind()) {
   case destXYZ:
-    cvtUserToDev(topPageA, dest->getLeft(), dest->getTop(), &dx, &dy);
-    scrollXA = dest->getChangeLeft() ? dx : scrollX;
-    if (continuousMode) {
-      if (topPage <= 0) {
-	scrollYA = -1;
-      } else if (dest->getChangeTop()) {
-	scrollYA = pageY[topPageA - 1] + dy;
-      } else {
-	scrollYA = pageY[topPageA - 1] + (scrollY - pageY[topPage - 1]);
-      }
-    } else {
-      if (dest->getChangeTop()) {
-	scrollYA = dy;
-      } else if (topPage > 0) {
-	scrollYA = scrollY;
-      } else {
-	scrollYA = 0;
-      }
+    cvtUserToDev(page, dest->getLeft(), dest->getTop(), &dx, &dy);
+    scrollX = tileMap->getPageLeftX(page);
+    if (dest->getChangeLeft()) {
+      scrollX += dx;
     }
-    //~ this doesn't currently handle the zoom parameter
-    update(topPageA, scrollXA, scrollYA, zoom, rotate, gFalse,
-	   addToHist && topPageA != topPage, gTrue);
+    scrollY = tileMap->getPageTopY(page);
+    if (dest->getChangeTop()) {
+      scrollY += dy;
+    }
+    startUpdate();
+    state->setScrollPosition(page, scrollX, scrollY);
+    finishUpdate(gTrue, gTrue);
     break;
   case destFit:
   case destFitB:
-    scrollXA = 0;
-    scrollYA = continuousMode ? -1 : 0;
-    update(topPageA, scrollXA, scrollYA, zoomPage, rotate, gFalse,
-	   addToHist && topPageA != topPage, gTrue);
+    state->setZoom(zoomPage);
+    scrollX = tileMap->getPageLeftX(page);
+    scrollY = tileMap->getPageTopY(page);
+    startUpdate();
+    state->setScrollPosition(page, scrollX, scrollY);
+    finishUpdate(gTrue, gTrue);
     break;
   case destFitH:
   case destFitBH:
-    //~ do fit: need a function similar to zoomToRect which will
-    //~ accept an absolute top coordinate (rather than centering)
-    scrollXA = 0;
-    cvtUserToDev(topPageA, 0, dest->getTop(), &dx, &dy);
-    if (continuousMode) {
-      if (topPage <= 0) {
-	scrollYA = -1;
-      } else if (dest->getChangeTop()) {
-	scrollYA = pageY[topPageA - 1] + dy;
-      } else {
-	scrollYA = pageY[topPageA - 1] + (scrollY - pageY[topPage - 1]);
-      }
-    } else {
-      if (dest->getChangeTop()) {
-	scrollYA = dy;
-      } else if (topPage > 0) {
-	scrollYA = scrollY;
-      } else {
-	scrollYA = 0;
-      }
+    state->setZoom(zoomWidth);
+    scrollX = tileMap->getPageLeftX(page);
+    scrollY = tileMap->getPageTopY(page);
+    if (dest->getChangeTop()) {
+      cvtUserToDev(page, 0, dest->getTop(), &dx, &dy);
+      scrollY += dy;
     }
-    update(topPageA, scrollXA, scrollYA, zoom, rotate, gFalse,
-	   addToHist && topPageA != topPage, gTrue);
+    startUpdate();
+    state->setScrollPosition(page, scrollX, scrollY);
+    finishUpdate(gTrue, gTrue);
     break;
   case destFitV:
   case destFitBV:
-    //~ do fit: need a function similar to zoomToRect which will
-    //~ accept an absolute left coordinate (rather than centering)
-    if (dest->getChangeLeft()) {
-      cvtUserToDev(topPageA, dest->getLeft(), 0, &dx, &dy);
-      scrollXA = dx;
-    } else {
-      scrollXA = scrollX;
+    state->setZoom(zoomHeight);
+    scrollX = tileMap->getPageLeftX(page);
+    scrollY = tileMap->getPageTopY(page);
+    if (dest->getChangeTop()) {
+      cvtUserToDev(page, dest->getLeft(), 0, &dx, &dy);
+      scrollX += dx;
     }
-    scrollYA = continuousMode ? -1 : 0;
-    update(topPageA, scrollXA, scrollYA, zoom, rotate, gFalse,
-	   addToHist && topPageA != topPage, gTrue);
+    startUpdate();
+    state->setScrollPosition(page, scrollX, scrollY);
+    finishUpdate(gTrue, gTrue);
     break;
   case destFitR:
-    zoomToRect(topPageA, dest->getLeft(), dest->getTop(),
+    zoomToRect(page, dest->getLeft(), dest->getTop(),
 	       dest->getRight(), dest->getBottom());
     break;
   }
 }
 
-void PDFCore::update(int topPageA, int scrollXA, int scrollYA,
-		     double zoomA, int rotateA, GBool force,
-		     GBool addToHist, GBool adjustScrollX) {
-  double hDPI, vDPI, dpiA, uw, uh, ut;
-  int w, h, t, x0, x1, y0, y1, x, y;
-  int rot;
-  int pg0, pg1;
-  PDFCoreTile *tile;
-  PDFCorePage *page;
-  PDFHistory *hist;
-  GBool needUpdate;
-  int i, j;
+void PDFCore::startUpdate() {
+}
 
-  // check for document and valid page number
+void PDFCore::finishUpdate(GBool addToHist, GBool checkForChangedFile) {
+  int scrollPage, scrollX, scrollY, maxScrollX, maxScrollY;
+
   if (!doc) {
-    // save the new settings
-    zoom = zoomA;
-    rotate = rotateA;
+    invalidateWholeWindow();
+    updateScrollbars();
     return;
   }
-  if (topPageA <= 0 || topPageA > doc->getNumPages()) {
-    return;
-  }
 
-  needUpdate = gFalse;
-
   // check for changes to the PDF file
-  if ((force || (!continuousMode && topPage != topPageA)) &&
+  if (checkForChangedFile &&
       doc->getFileName() &&
       checkForNewFile()) {
-    if (loadFile(doc->getFileName()) == errNone) {
-      if (topPageA > doc->getNumPages()) {
-	topPageA = doc->getNumPages();
-      }
-      needUpdate = gTrue;
-    }
+    loadFile(doc->getFileName());
   }
 
-  // compute the DPI
-  if (continuousMode) {
-    uw = maxUnscaledPageW;
-    uh = maxUnscaledPageH;
-    rot = rotateA;
-  } else {
-    uw = doc->getPageCropWidth(topPageA);
-    uh = doc->getPageCropHeight(topPageA);
-    rot = rotateA + doc->getPageRotate(topPageA);
-    if (rot >= 360) {
-      rot -= 360;
-    } else if (rot < 0) {
-      rot += 360;
-    }
+  // zero-page documents are a special case
+  // (check for this *after* checking for changes to the file)
+  if (!doc->getNumPages()) {
+    invalidateWholeWindow();
+    updateScrollbars();
+    return;
   }
-  if (rot == 90 || rot == 270) {
-    ut = uw; uw = uh; uh = ut;
-  }
-  if (zoomA == zoomPage) {
-    hDPI = (drawAreaWidth / uw) * 72;
-    if (continuousMode) {
-      vDPI = ((drawAreaHeight - continuousModePageSpacing) / uh) * 72;
-    } else {
-      vDPI = (drawAreaHeight / uh) * 72;
-    }
-    dpiA = (hDPI < vDPI) ? hDPI : vDPI;
-  } else if (zoomA == zoomWidth) {
-    dpiA = (drawAreaWidth / uw) * 72;
-  } else {
-    dpiA = 0.01 * zoomA * 72;
-  }
-  // this can happen if the window hasn't been sized yet
-  if (dpiA <= 0) {
-    dpiA = 1;
-  }
 
-  // if the display properties have changed, create a new PDFCorePage
-  // object
-  if (force || pages->getLength() == 0 ||
-      (!continuousMode && topPageA != topPage) ||
-      fabs(zoomA - zoom) > 1e-8 || fabs(dpiA - dpi) > 1e-8 ||
-      rotateA != rotate) {
-    needUpdate = gTrue;
-    setSelection(0, 0, 0, 0, 0);
-    while (pages->getLength() > 0) {
-      delete (PDFCorePage *)pages->del(0);
-    }
-    zoom = zoomA;
-    rotate = rotateA;
-    dpi = dpiA;
-    if (continuousMode) {
-      maxPageW = totalDocH = 0;
-      pageY = (int *)greallocn(pageY, doc->getNumPages(), sizeof(int));
-      for (i = 1; i <= doc->getNumPages(); ++i) {
-	pageY[i-1] = totalDocH;
-	w = (int)((doc->getPageCropWidth(i) * dpi) / 72 + 0.5);
-	h = (int)((doc->getPageCropHeight(i) * dpi) / 72 + 0.5);
-	rot = rotate + doc->getPageRotate(i);
-	if (rot >= 360) {
-	  rot -= 360;
-	} else if (rot < 0) {
-	  rot += 360;
-	}
-	if (rot == 90 || rot == 270) {
-	  t = w; w = h; h = t;
-	}
-	if (w > maxPageW) {
-	  maxPageW = w;
-	}
-	totalDocH += h;
-	if (i < doc->getNumPages()) {
-	  totalDocH += continuousModePageSpacing;
-	}
-      }
-    } else {
-      rot = rotate + doc->getPageRotate(topPageA);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      addPage(topPageA, rot);
-    }
-  } else {
-    // erase the selection
-    if (selectULX != selectLRX && selectULY != selectLRY) {
-      xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
-		   new SplashSolidColor(selectXorColor));
-    }
+  // check the scroll position
+  scrollPage = state->getScrollPage();
+  if (state->getDisplayMode() == displaySideBySideSingle &&
+      !(scrollPage & 1)) {
+    --scrollPage;
   }
-  if (continuousMode) {
-    page = NULL; // make gcc happy
-  } else {
-    page = (PDFCorePage *)pages->get(0);
+  if (state->displayModeIsContinuous()) {
+    scrollPage = 0;
+  } else if (scrollPage <= 0 || scrollPage > doc->getNumPages()) {
+    scrollPage = 1;
   }
-  topPage = topPageA;
-  midPage = topPage;
-
-  // adjust the scroll position
-  scrollX = scrollXA;
-  if (continuousMode && scrollYA < 0) {
-    scrollY = pageY[topPage - 1];
-  } else {
-    scrollY = scrollYA;
+  scrollX = state->getScrollX();
+  scrollY = state->getScrollY();
+  // we need to set scrollPage before calling getScrollLimits()
+  state->setScrollPosition(scrollPage, scrollX, scrollY);
+  tileMap->getScrollLimits(&maxScrollX, &maxScrollY);
+  maxScrollX -= state->getWinW();
+  maxScrollY -= state->getWinH();
+  if (scrollX > maxScrollX) {
+    scrollX = maxScrollX;
   }
-  if (continuousMode && adjustScrollX) {
-    rot = rotate + doc->getPageRotate(topPage);
-    if (rot >= 360) {
-      rot -= 360;
-    } else if (rot < 0) {
-      rot += 360;
-    }
-    if (rot == 90 || rot == 270) {
-      w = (int)((doc->getPageCropHeight(topPage) * dpi) / 72 + 0.5);
-    } else {
-      w = (int)((doc->getPageCropWidth(topPage) * dpi) / 72 + 0.5);
-    }
-    if (scrollX < (maxPageW - w) / 2) {
-      scrollX = (maxPageW - w) / 2;
-    }
-  }
-  w = continuousMode ? maxPageW : page->w;
-  if (scrollX > w - drawAreaWidth) {
-    scrollX = w - drawAreaWidth;
-  }
   if (scrollX < 0) {
     scrollX = 0;
   }
-  h = continuousMode ? totalDocH : page->h;
-  if (scrollY > h - drawAreaHeight) {
-    scrollY = h - drawAreaHeight;
+  if (scrollY > maxScrollY) {
+    scrollY = maxScrollY;
   }
   if (scrollY < 0) {
     scrollY = 0;
   }
-
-  // find topPage, and the first and last pages to be rasterized
-  if (continuousMode) {
-    //~ should use a binary search
-    for (i = 2; i <= doc->getNumPages(); ++i) {
-      if (pageY[i-1] > scrollY - drawAreaHeight / 2) {
-	break;
-      }
-    }
-    pg0 = i - 1;
-    for (i = pg0 + 1; i <= doc->getNumPages(); ++i) {
-      if (pageY[i-1] > scrollY) {
-	break;
-      }
-    }
-    topPage = i - 1;
-    for (i = topPage + 1; i <= doc->getNumPages(); ++i) {
-      if (pageY[i-1] > scrollY + drawAreaHeight / 2) {
-	break;
-      }
-    }
-    midPage = i - 1;
-    for (i = midPage + 1; i <= doc->getNumPages(); ++i) {
-      if (pageY[i-1] > scrollY + drawAreaHeight + drawAreaHeight / 2) {
-	break;
-      }
-    }
-    pg1 = i - 1;
-
-    // delete pages that are no longer needed and insert new pages
-    // objects that are needed
-    while (pages->getLength() > 0 &&
-	   ((PDFCorePage *)pages->get(0))->page < pg0) {
-      delete (PDFCorePage *)pages->del(0);
-    }
-    i = pages->getLength() - 1;
-    while (i > 0 && ((PDFCorePage *)pages->get(i))->page > pg1) {
-      delete (PDFCorePage *)pages->del(i--);
-    }
-    j = pages->getLength() > 0 ? ((PDFCorePage *)pages->get(0))->page - 1
-                               : pg1;
-    for (i = pg0; i <= j; ++i) {
-      rot = rotate + doc->getPageRotate(i);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      addPage(i, rot);
-    }      
-    j = ((PDFCorePage *)pages->get(pages->getLength() - 1))->page;
-    for (i = j + 1; i <= pg1; ++i) {
-      rot = rotate + doc->getPageRotate(i);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      addPage(i, rot);
-    }
-
-  } else {
-    pg0 = pg1 = topPage;
+  if (scrollPage != state->getScrollPage() ||
+      scrollX != state->getScrollX() ||
+      scrollY != state->getScrollY()) {
+    state->setScrollPosition(scrollPage, scrollX, scrollY);
   }
 
-  // delete tiles that are no longer needed
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    j = 0;
-    while (j < page->tiles->getLength()) {
-      tile = (PDFCoreTile *)page->tiles->get(j);
-      if (continuousMode) {
-	y0 = pageY[page->page - 1] + tile->yMin;
-	y1 = pageY[page->page - 1] + tile->yMax;
-      } else {
-	y0 = tile->yMin;
-	y1 = tile->yMax;
-      }
-      if (tile->xMax < scrollX - drawAreaWidth / 2 ||
-	  tile->xMin > scrollX + drawAreaWidth + drawAreaWidth / 2 ||
-	  y1 < scrollY - drawAreaHeight / 2 ||
-	  y0 > scrollY + drawAreaHeight + drawAreaHeight / 2) {
-	delete (PDFCoreTile *)page->tiles->del(j);
-      } else {
-	++j;
-      }
-    }
-  }
+  // redraw
+  invalidateWholeWindow();
+  updateScrollbars();
 
-  // update page positions
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    page->xDest = -scrollX;
-    if (continuousMode) {
-      page->yDest = pageY[page->page - 1] - scrollY;
-    } else {
-      page->yDest = -scrollY;
-    }
-    if (continuousMode) {
-      if (page->w < maxPageW) {
-	page->xDest += (maxPageW - page->w) / 2;
-      }
-      if (maxPageW < drawAreaWidth) {
-	page->xDest += (drawAreaWidth - maxPageW) / 2;
-      }
-    } else if (page->w < drawAreaWidth) {
-      page->xDest += (drawAreaWidth - page->w) / 2;
-    }
-    if (continuousMode && totalDocH < drawAreaHeight) {
-      page->yDest += (drawAreaHeight - totalDocH) / 2;
-    } else if (!continuousMode && page->h < drawAreaHeight) {
-      page->yDest += (drawAreaHeight - page->h) / 2;
-    }
+  // add to history
+  if (addToHist) {
+    addToHistory();
   }
+}
 
-  // rasterize any new tiles
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    x0 = page->xDest;
-    x1 = x0 + page->w - 1;
-    if (x0 < -drawAreaWidth / 2) {
-      x0 = -drawAreaWidth / 2;
-    }
-    if (x1 > drawAreaWidth + drawAreaWidth / 2) {
-      x1 = drawAreaWidth + drawAreaWidth / 2;
-    }
-    x0 = ((x0 - page->xDest) / page->tileW) * page->tileW;
-    x1 = ((x1 - page->xDest) / page->tileW) * page->tileW;
-    y0 = page->yDest;
-    y1 = y0 + page->h - 1;
-    if (y0 < -drawAreaHeight / 2) {
-      y0 = -drawAreaHeight / 2;
-    }
-    if (y1 > drawAreaHeight + drawAreaHeight / 2) {
-      y1 = drawAreaHeight + drawAreaHeight / 2;
-    }
-    y0 = ((y0 - page->yDest) / page->tileH) * page->tileH;
-    y1 = ((y1 - page->yDest) / page->tileH) * page->tileH;
-    for (y = y0; y <= y1; y += page->tileH) {
-      for (x = x0; x <= x1; x += page->tileW) {
-	needTile(page, x, y);
-      }
-    }
-  }
+void PDFCore::addToHistory() {
+  PDFHistory h;
+  PDFHistory *cur;
 
-  // update tile positions
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    for (j = 0; j < page->tiles->getLength(); ++j) {
-      tile = (PDFCoreTile *)page->tiles->get(j);
-      tile->xDest = tile->xMin - scrollX;
-      if (continuousMode) {
-	tile->yDest = tile->yMin + pageY[page->page - 1] - scrollY;
-      } else {
-	tile->yDest = tile->yMin - scrollY;
-      }
-      if (continuousMode) {
-	if (page->w < maxPageW) {
-	  tile->xDest += (maxPageW - page->w) / 2;
-	}
-	if (maxPageW < drawAreaWidth) {
-	  tile->xDest += (drawAreaWidth - maxPageW) / 2;
-	}
-      } else if (page->w < drawAreaWidth) {
-	tile->xDest += (drawAreaWidth - page->w) / 2;
-      }
-      if (continuousMode && totalDocH < drawAreaHeight) {
-	tile->yDest += (drawAreaHeight - totalDocH) / 2;
-      } else if (!continuousMode && page->h < drawAreaHeight) {
-	tile->yDest += (drawAreaHeight - page->h) / 2;
-      }
+  cur = &history[historyCur];
+  h.page = tileMap->getMidPage();
+#ifdef _WIN32
+  if (doc->getFileNameU()) {
+    h.fileName = (wchar_t *)gmallocn(MAX_PATH + 1, sizeof(wchar_t));
+    if (GetFullPathNameW(doc->getFileNameU(), MAX_PATH + 1,
+			 h.fileName, NULL) == 0) {
+      h.fileName = NULL;
     }
+  } else {
+    h.fileName = NULL;
   }
-
-  // redraw the selection
-  if (selectULX != selectLRX && selectULY != selectLRY) {
-    xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
-		 new SplashSolidColor(selectXorColor));
+#else
+  if (doc->getFileName()) {
+    h.fileName = doc->getFileName()->copy();
+  } else {
+    h.fileName = NULL;
   }
-
-  // redraw the window
-  redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, needUpdate);
-  updateScrollbars();
-
-  // add to history
-  if (addToHist) {
-    if (++historyCur == pdfHistorySize) {
-      historyCur = 0;
-    }
-    hist = &history[historyCur];
-    if (hist->fileName) {
-#ifdef _WIN32
-      delete[] hist->fileName;
-#else
-      delete hist->fileName;
 #endif
+  if (historyBLen > 0 && h.page == cur->page) {
+    if (!h.fileName && !cur->fileName) {
+      return;
     }
 #ifdef _WIN32
-    if (doc->getFileNameU()) {
-      hist->fileName = (wchar_t *)gmallocn(MAX_PATH + 1, sizeof(wchar_t));
-      if (GetFullPathNameW(doc->getFileNameU(), MAX_PATH + 1,
-			   hist->fileName, NULL) == 0) {
-	delete[] hist->fileName;
-	hist->fileName = NULL;
-      }
-    } else {
-      hist->fileName = NULL;
+    if (h.fileName && cur->fileName && !wcscmp(h.fileName, cur->fileName)) {
+      gfree(h.fileName);
+      return;
     }
 #else
-    if (doc->getFileName()) {
-      hist->fileName = doc->getFileName()->copy();
-    } else {
-      hist->fileName = NULL;
+    if (h.fileName && cur->fileName && !h.fileName->cmp(cur->fileName)) {
+      delete h.fileName;
+      return;
     }
 #endif
-    hist->page = topPage;
-    if (historyBLen < pdfHistorySize) {
-      ++historyBLen;
-    }
-    historyFLen = 0;
   }
-}
-
-void PDFCore::addPage(int pg, int rot) {
-  PDFCorePage *page;
-  int w, h, t, tileW, tileH, i;
-
-  w = (int)((doc->getPageCropWidth(pg) * dpi) / 72 + 0.5);
-  h = (int)((doc->getPageCropHeight(pg) * dpi) / 72 + 0.5);
-  if (rot == 90 || rot == 270) {
-    t = w; w = h; h = t;
+  if (++historyCur == pdfHistorySize) {
+    historyCur = 0;
   }
-  tileW = 2 * drawAreaWidth;
-  if (tileW < 1500) {
-    tileW = 1500;
+  if (history[historyCur].fileName) {
+#ifdef _WIN32
+    gfree(history[historyCur].fileName);
+#else
+    delete history[historyCur].fileName;
+#endif
   }
-  if (tileW > w) {
-    // tileW can't be zero -- we end up with div-by-zero problems
-    tileW = w ? w : 1;
+  history[historyCur] = h;
+  if (historyBLen < pdfHistorySize) {
+    ++historyBLen;
   }
-  tileH = 2 * drawAreaHeight;
-  if (tileH < 1500) {
-    tileH = 1500;
-  }
-  if (tileH > h) {
-    // tileH can't be zero -- we end up with div-by-zero problems
-    tileH = h ? h : 1;
-  }
-  page = new PDFCorePage(pg, w, h, tileW, tileH);
-  for (i = 0;
-       i < pages->getLength() && pg > ((PDFCorePage *)pages->get(i))->page;
-       ++i) ;
-  pages->insert(i, page);
+  historyFLen = 0;
 }
 
-void PDFCore::needTile(PDFCorePage *page, int x, int y) {
-  PDFCoreTile *tile;
-  TextOutputControl textOutCtrl;
-  TextOutputDev *textOut;
-  int xDest, yDest, sliceW, sliceH;
-  int i;
+GBool PDFCore::gotoNextPage(int inc, GBool top) {
+  GBool sideBySide;
+  int pg;
 
-  for (i = 0; i < page->tiles->getLength(); ++i) {
-    tile = (PDFCoreTile *)page->tiles->get(i);
-    if (x == tile->xMin && y == tile->yMin) {
-      return;
-    }
+  if (!doc || !doc->getNumPages()) {
+    return gFalse;
   }
-
-  setBusyCursor(gTrue);
-
-  sliceW = page->tileW;
-  if (x + sliceW > page->w) {
-    sliceW = page->w - x;
+  pg = tileMap->getFirstPage();
+  sideBySide = state->displayModeIsSideBySide();
+  if (pg + (sideBySide ? 2 : 1) > doc->getNumPages()) {
+    return gFalse;
   }
-  sliceH = page->tileH;
-  if (y + sliceH > page->h) {
-    sliceH = page->h - y;
+  if (sideBySide && inc < 2) {
+    inc = 2;
   }
-
-  xDest = x - scrollX;
-  if (continuousMode) {
-    yDest = y + pageY[page->page - 1] - scrollY;
-  } else {
-    yDest = y - scrollY;
-  }
-  if (continuousMode) {
-    if (page->w < maxPageW) {
-      xDest += (maxPageW - page->w) / 2;
-    }
-    if (maxPageW < drawAreaWidth) {
-      xDest += (drawAreaWidth - maxPageW) / 2;
-    }
-  } else if (page->w < drawAreaWidth) {
-    xDest += (drawAreaWidth - page->w) / 2;
-  }
-  if (continuousMode && totalDocH < drawAreaHeight) {
-    yDest += (drawAreaHeight - totalDocH) / 2;
-  } else if (!continuousMode && page->h < drawAreaHeight) {
-    yDest += (drawAreaHeight - page->h) / 2;
-  }
-  curTile = tile = newTile(xDest, yDest);
-  curPage = page;
-  tile->xMin = x;
-  tile->yMin = y;
-  tile->xMax = x + sliceW;
-  tile->yMax = y + sliceH;
-  tile->edges = 0;
-  if (tile->xMin == 0) {
-    tile->edges |= pdfCoreTileLeftEdge;
-  }
-  if (tile->xMax == page->w) {
-    tile->edges |= pdfCoreTileRightEdge;
-  }
-  if (continuousMode) {
-    if (tile->yMin == 0) {
-      tile->edges |= pdfCoreTileTopSpace;
-      if (page->page == 1) {
-	tile->edges |= pdfCoreTileTopEdge;
-      }
-    }
-    if (tile->yMax == page->h) {
-      tile->edges |= pdfCoreTileBottomSpace;
-      if (page->page == doc->getNumPages()) {
-	tile->edges |= pdfCoreTileBottomEdge;
-      }
-    }
-  } else {
-    if (tile->yMin == 0) {
-      tile->edges |= pdfCoreTileTopEdge;
-    }
-    if (tile->yMax == page->h) {
-      tile->edges |= pdfCoreTileBottomEdge;
-    }
-  }
-  doc->displayPageSlice(out, page->page, dpi, dpi, rotate,
-			gFalse, gTrue, gFalse, x, y, sliceW, sliceH);
-  tile->bitmap = out->takeBitmap();
-  memcpy(tile->ctm, out->getDefCTM(), 6 * sizeof(double));
-  memcpy(tile->ictm, out->getDefICTM(), 6 * sizeof(double));
-  if (!page->links) {
-    page->links = doc->getLinks(page->page);
-  }
-  if (!page->text) {
-    textOutCtrl.mode = textOutPhysLayout;
-    if ((textOut = new TextOutputDev(NULL, &textOutCtrl, gFalse))) {
-      doc->displayPage(textOut, page->page, dpi, dpi, rotate,
-		       gFalse, gTrue, gFalse);
-      page->text = textOut->takeText();
-      delete textOut;
-    }
-  }
-  page->tiles->append(tile);
-  curTile = NULL;
-  curPage = NULL;
-
-  setBusyCursor(gFalse);
-}
-
-GBool PDFCore::gotoNextPage(int inc, GBool top) {
-  int pg, scrollYA;
-
-  if (!doc || doc->getNumPages() == 0 || topPage >= doc->getNumPages()) {
-    return gFalse;
-  }
-  if ((pg = topPage + inc) > doc->getNumPages()) {
+  if ((pg += inc) > doc->getNumPages()) {
     pg = doc->getNumPages();
   }
-  if (continuousMode) {
-    scrollYA = -1;
-  } else if (top) {
-    scrollYA = 0;
-  } else {
-    scrollYA = scrollY;
-  }
-  update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue, gTrue);
+  displayPage(pg, top, gFalse);
   return gTrue;
 }
 
 GBool PDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
-  int pg, scrollYA;
+  int pg;
 
-  if (!doc || doc->getNumPages() == 0 || topPage <= 1) {
+  if (!doc || !doc->getNumPages()) {
     return gFalse;
   }
-  if ((pg = topPage - dec) < 1) {
+  pg = tileMap->getFirstPage();
+  if (state->getDisplayMode() == displayContinuous &&
+      state->getScrollY() > tileMap->getPageTopY(pg)) {
+    ++pg;
+  } else if (state->getDisplayMode() == displaySideBySideContinuous &&
+	     state->getScrollY() > tileMap->getPageTopY(pg)) {
+    pg += 2;
+  } else if (state->getDisplayMode() == displayHorizontalContinuous &&
+	     state->getScrollX() > tileMap->getPageLeftX(pg)) {
+    ++pg;
+  }
+  if (pg <= 1) {
+    return gFalse;
+  }
+  if (state->displayModeIsSideBySide() && dec < 2) {
+    dec = 2;
+  }
+  if ((pg -= dec) < 1) {
     pg = 1;
   }
-  if (continuousMode) {
-    scrollYA = -1;
-  } else if (top) {
-    scrollYA = 0;
-  } else if (bottom) {
-    scrollYA = ((PDFCorePage *)pages->get(0))->h - drawAreaHeight;
-    if (scrollYA < 0) {
-      scrollYA = 0;
-    }
-  } else {
-    scrollYA = scrollY;
-  }
-  update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue, gTrue);
+  displayPage(pg, top, bottom);
   return gTrue;
 }
 
@@ -986,7 +528,7 @@
   if (!(d = doc->findDest(dest))) {
     return gFalse;
   }
-  displayDest(d, zoom, rotate, gTrue);
+  displayDest(d);
   delete d;
   return gTrue;
 }
@@ -1010,7 +552,7 @@
       !doc->getFileNameU() ||
       wcscmp(history[historyCur].fileName, doc->getFileNameU()) != 0) {
     if (loadFile(history[historyCur].fileName,
-		 wcslen(history[historyCur].fileName)) != errNone) {
+		 (int)wcslen(history[historyCur].fileName)) != errNone) {
       return gFalse;
     }
   }
@@ -1024,8 +566,7 @@
   }
 #endif
   pg = history[historyCur].page;
-  update(pg, scrollX, continuousMode ? -1 : scrollY,
-	 zoom, rotate, gFalse, gFalse, gTrue);
+  displayPage(pg, gFalse, gFalse, gFalse);
   return gTrue;
 }
 
@@ -1048,7 +589,7 @@
       !doc->getFileNameU() ||
       wcscmp(history[historyCur].fileName, doc->getFileNameU()) != 0) {
     if (loadFile(history[historyCur].fileName,
-		 wcslen(history[historyCur].fileName)) != errNone) {
+		 (int)wcslen(history[historyCur].fileName)) != errNone) {
       return gFalse;
     }
   }
@@ -1062,627 +603,726 @@
   }
 #endif
   pg = history[historyCur].page;
-  update(pg, scrollX, continuousMode ? -1 : scrollY,
-	 zoom, rotate, gFalse, gFalse, gTrue);
+  displayPage(pg, gFalse, gFalse, gFalse);
   return gTrue;
 }
 
 void PDFCore::scrollLeft(int nCols) {
-  scrollTo(scrollX - nCols, scrollY);
+  scrollTo(state->getScrollX() - nCols, state->getScrollY());
 }
 
 void PDFCore::scrollRight(int nCols) {
-  scrollTo(scrollX + nCols, scrollY);
+  scrollTo(state->getScrollX() + nCols, state->getScrollY());
 }
 
 void PDFCore::scrollUp(int nLines) {
-  scrollTo(scrollX, scrollY - nLines);
+  scrollTo(state->getScrollX(), state->getScrollY() - nLines);
 }
 
 void PDFCore::scrollUpPrevPage(int nLines) {
-  if (!continuousMode && scrollY == 0) {
+  if (!state->displayModeIsContinuous() &&
+      state->getScrollY() == 0) {
     gotoPrevPage(1, gFalse, gTrue);
   } else {
-    scrollTo(scrollX, scrollY - nLines);
+    scrollUp(nLines);
   }
 }
 
 void PDFCore::scrollDown(int nLines) {
-  scrollTo(scrollX, scrollY + nLines);
+  scrollTo(state->getScrollX(), state->getScrollY() + nLines);
 }
 
 void PDFCore::scrollDownNextPage(int nLines) {
-  if (!continuousMode &&
-      scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
-    gotoNextPage(1, gTrue);
+  int horizMax, vertMax;
+
+  if (!state->displayModeIsContinuous()) {
+    tileMap->getScrollLimits(&horizMax, &vertMax);
+    if (state->getScrollY() >= vertMax - state->getWinH()) {
+      gotoNextPage(1, gTrue);
+    } else {
+      scrollDown(nLines);
+    }
   } else {
-    scrollTo(scrollX, scrollY + nLines);
+    scrollDown(nLines);
   }
 }
 
 void PDFCore::scrollPageUp() {
-  if (!continuousMode && scrollY == 0) {
-    gotoPrevPage(1, gFalse, gTrue);
-  } else {
-    scrollTo(scrollX, scrollY - drawAreaHeight);
-  }
+  scrollUpPrevPage(state->getWinH());
 }
 
 void PDFCore::scrollPageDown() {
-  if (!continuousMode &&
-      pages->getLength() > 0 &&
-      scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
-    gotoNextPage(1, gTrue);
-  } else {
-    scrollTo(scrollX, scrollY + drawAreaHeight);
-  }
+  scrollDownNextPage(state->getWinH());
 }
 
 void PDFCore::scrollTo(int x, int y) {
-  update(topPage, x, y < 0 ? 0 : y, zoom, rotate, gFalse, gFalse, gFalse);
+  startUpdate();
+  state->setScrollPosition(state->getScrollPage(), x, y);
+  finishUpdate(gTrue, gTrue);
 }
 
 void PDFCore::scrollToLeftEdge() {
-  update(topPage, 0, scrollY, zoom, rotate, gFalse, gFalse, gFalse);
+  scrollTo(0, state->getScrollY());
 }
 
 void PDFCore::scrollToRightEdge() {
-  PDFCorePage *page;
+  int horizMax, vertMax;
 
-  page = (PDFCorePage *)pages->get(0);
-  update(topPage, page->w - drawAreaWidth, scrollY,
-	 zoom, rotate, gFalse, gFalse, gFalse);
+  tileMap->getScrollLimits(&horizMax, &vertMax);
+  scrollTo(horizMax - state->getWinW(), state->getScrollY());
 }
 
 void PDFCore::scrollToTopEdge() {
-  int y;
-
-  y = continuousMode ? pageY[topPage - 1] : 0;
-  update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse, gFalse);
+  scrollTo(state->getScrollX(), tileMap->getPageTopY(tileMap->getFirstPage()));
 }
 
 void PDFCore::scrollToBottomEdge() {
-  PDFCorePage *page;
-  int y, i;
+  int horizMax, vertMax;
 
-  for (i = pages->getLength() - 1; i > 0; --i) {
-    page = (PDFCorePage *)pages->get(i);
-    if (page->yDest < drawAreaHeight) {
-      break;
-    }
-  }
-  page = (PDFCorePage *)pages->get(i);
-  if (continuousMode) {
-    y = pageY[page->page - 1] + page->h - drawAreaHeight;
-  } else {
-    y = page->h - drawAreaHeight;
-  }
-  update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse, gFalse);
+  tileMap->getScrollLimits(&horizMax, &vertMax);
+  scrollTo(state->getScrollX(), vertMax - state->getWinH());
 }
 
 void PDFCore::scrollToTopLeft() {
-  int y;
-
-  y = continuousMode ? pageY[topPage - 1] : 0;
-  update(topPage, 0, y, zoom, rotate, gFalse, gFalse, gFalse);
+  scrollTo(0, tileMap->getPageTopY(tileMap->getFirstPage()));
 }
 
 void PDFCore::scrollToBottomRight() {
-  PDFCorePage *page;
-  int x, y, i;
+  int horizMax, vertMax;
 
-  for (i = pages->getLength() - 1; i > 0; --i) {
-    page = (PDFCorePage *)pages->get(i);
-    if (page->yDest < drawAreaHeight) {
-      break;
-    }
+  tileMap->getScrollLimits(&horizMax, &vertMax);
+  scrollTo(horizMax - state->getWinW(), vertMax - state->getWinH());
+}
+
+void PDFCore::setZoom(double zoom) {
+  int page;
+
+  if (state->getZoom() == zoom) {
+    return;
   }
-  page = (PDFCorePage *)pages->get(i);
-  x = page->w - drawAreaWidth;
-  if (continuousMode) {
-    y = pageY[page->page - 1] + page->h - drawAreaHeight;
-  } else {
-    y = page->h - drawAreaHeight;
+  if (!doc || !doc->getNumPages()) {
+    state->setZoom(zoom);
+    return;
   }
-  update(topPage, x, y, zoom, rotate, gFalse, gFalse, gFalse);
+  startUpdate();
+  page = tileMap->getFirstPage();
+  state->setZoom(zoom);
+  state->setScrollPosition(page, tileMap->getPageLeftX(page),
+			   tileMap->getPageTopY(page));
+  finishUpdate(gTrue, gTrue);
 }
 
-void PDFCore::zoomToRect(int pg, double ulx, double uly,
+void PDFCore::zoomToRect(int page, double ulx, double uly,
 			 double lrx, double lry) {
-  int x0, y0, x1, y1, u, sx, sy;
-  double rx, ry, newZoom, t;
-  PDFCorePage *p;
+  int x0, y0, x1, y1, sx, sy, t;
+  double dpi, rx, ry, zoom;
 
-  cvtUserToDev(pg, ulx, uly, &x0, &y0);
-  cvtUserToDev(pg, lrx, lry, &x1, &y1);
+  startUpdate();
+
+  // set the new zoom level
+  cvtUserToDev(page, ulx, uly, &x0, &y0);
+  cvtUserToDev(page, lrx, lry, &x1, &y1);
   if (x0 > x1) {
-    u = x0; x0 = x1; x1 = u;
+    t = x0;  x0 = x1;  x1 = t;
   }
   if (y0 > y1) {
-    u = y0; y0 = y1; y1 = u;
+    t = y0;  y0 = y1;  y1 = t;
   }
-  rx = (double)drawAreaWidth / (double)(x1 - x0);
-  ry = (double)drawAreaHeight / (double)(y1 - y0);
+  rx = (double)state->getWinW() / (double)(x1 - x0);
+  ry = (double)state->getWinH() / (double)(y1 - y0);
+  dpi = tileMap->getDPI(page);
   if (rx < ry) {
-    newZoom = rx * (dpi / (0.01 * 72));
-    sx = (int)(rx * x0);
-    t = (drawAreaHeight * (x1 - x0)) / drawAreaWidth;
-    sy = (int)(rx * (y0 + y1 - t) / 2);
-    if (continuousMode) {
-      if ((p = findPage(pg)) && p->w < maxPageW) {
-	sx += (int)(0.5 * rx * (maxPageW - p->w));
-      }
-      u = (pg - 1) * continuousModePageSpacing;
-      sy += (int)(rx * (pageY[pg - 1] - u)) + u;
-    }
+    zoom = rx * (dpi / (0.01 * 72));
   } else {
-    newZoom = ry * (dpi / (0.01 * 72));
-    t = (drawAreaWidth * (y1 - y0)) / drawAreaHeight;
-    sx = (int)(ry * (x0 + x1 - t) / 2);
-    sy = (int)(ry * y0);
-    if (continuousMode) {
-      if ((p = findPage(pg)) && p->w < maxPageW) {
-	sx += (int)(0.5 * rx * (maxPageW - p->w));
-      }
-      u = (pg - 1) * continuousModePageSpacing;
-      sy += (int)(ry * (pageY[pg - 1] - u)) + u;
-    }
+    zoom = ry * (dpi / (0.01 * 72));
   }
-  update(pg, sx, sy, newZoom, rotate, gFalse, gFalse, gFalse);
-}
+  state->setZoom(zoom);
 
-void PDFCore::zoomCentered(double zoomA) {
-  int sx, sy, rot, hAdjust, vAdjust, i;
-  double dpi1, dpi2, pageW, pageH;
-  PDFCorePage *page;
+  // scroll to the requested page
+  state->setScrollPosition(page, tileMap->getPageLeftX(page),
+			   tileMap->getPageTopY(page));
 
-  if (zoomA == zoomPage) {
-    if (continuousMode) {
-      pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
-	                                      : maxUnscaledPageW;
-      pageH = (rotate == 90 || rotate == 270) ? maxUnscaledPageW
-	                                      : maxUnscaledPageH;
-      dpi1 = 72.0 * (double)drawAreaWidth / pageW;
-      dpi2 = 72.0 * (double)(drawAreaHeight - continuousModePageSpacing) /
-	     pageH;
-      if (dpi2 < dpi1) {
-	dpi1 = dpi2;
-      }
-    } else {
-      // in single-page mode, sx=sy=0 -- so dpi1 is irrelevant
-      dpi1 = dpi;
-    }
-    sx = 0;
+  // scroll the requested rectangle to the center of the window
+  cvtUserToWindow(page, 0.5 * (ulx + lrx), 0.5 * (uly + lry), &x0, &y0);
+  sx = state->getScrollX() + x0 - state->getWinW() / 2;
+  sy = state->getScrollY() + y0 - state->getWinH() / 2;
+  state->setScrollPosition(page, sx, sy);
 
-  } else if (zoomA == zoomWidth) {
-    if (continuousMode) {
-      pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
-	                                      : maxUnscaledPageW;
-    } else {
-      rot = rotate + doc->getPageRotate(topPage);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      pageW = (rot == 90 || rot == 270) ? doc->getPageCropHeight(topPage)
-	                                : doc->getPageCropWidth(topPage);
-    }
-    dpi1 = 72.0 * (double)drawAreaWidth / pageW;
-    sx = 0;
+  finishUpdate(gTrue, gFalse);
+}
 
-  } else if (zoomA <= 0) {
+void PDFCore::zoomCentered(double zoom) {
+  int page, wx, wy, sx, sy;
+  double cx, cy;
+
+  if (state->getZoom() == zoom) {
     return;
-
-  } else {
-    dpi1 = 72.0 * zoomA / 100.0;
-    if ((page = (PDFCorePage *)pages->get(0)) && page->xDest > 0) {
-      hAdjust = page->xDest;
-    } else {
-      hAdjust = 0;
-    }
-    sx = (int)((scrollX - hAdjust + drawAreaWidth / 2) * (dpi1 / dpi)) -
-         drawAreaWidth / 2;
-    if (sx < 0) {
-      sx = 0;
-    }
   }
 
-  if (continuousMode) {
-    // we can't just multiply scrollY by dpi1/dpi -- the rounding
-    // errors add up (because the pageY values are integers) -- so
-    // we compute the pageY values at the new zoom level instead
-    sy = 0;
-    for (i = 1; i < topPage; ++i) {
-      rot = rotate + doc->getPageRotate(i);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      if (rot == 90 || rot == 270) {
-	sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
-      } else {
-	sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
-      }
-    }
-    vAdjust = (topPage - 1) * continuousModePageSpacing;
-    sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
-		    * (dpi1 / dpi))
-         + vAdjust - drawAreaHeight / 2;
-  } else {
-    sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
-         - drawAreaHeight / 2;
-  }
+  startUpdate();
 
-  update(topPage, sx, sy, zoomA, rotate, gFalse, gFalse, gFalse);
+  // get the center of the window, in user coords
+  cvtWindowToUser(state->getWinW() / 2, state->getWinH() / 2,
+		  &page, &cx, &cy);
+
+  // set the new zoom level
+  state->setZoom(zoom);
+
+  // scroll to re-center
+  cvtUserToWindow(page, cx, cy, &wx, &wy);
+  sx = state->getScrollX() + wx - state->getWinW() / 2;
+  sy = state->getScrollY() + wy - state->getWinH() / 2;
+  state->setScrollPosition(page, sx, sy);
+
+  finishUpdate(gTrue, gFalse);
 }
 
 // Zoom so that the current page(s) fill the window width.  Maintain
 // the vertical center.
 void PDFCore::zoomToCurrentWidth() {
-  double w, maxW, dpi1;
-  int sx, sy, vAdjust, rot, i;
+  int page0, page1, page, gap;
+  double w, w1, zoom;
 
-  // compute the maximum page width of visible pages
-  rot = rotate + doc->getPageRotate(topPage);
-  if (rot >= 360) {
-    rot -= 360;
-  } else if (rot < 0) {
-    rot += 360;
-  }
-  if (rot == 90 || rot == 270) {
-    maxW = doc->getPageCropHeight(topPage);
-  } else {
-    maxW = doc->getPageCropWidth(topPage);
-  }
-  if (continuousMode) {
-    for (i = topPage + 1;
-	 i < doc->getNumPages() && pageY[i-1] < scrollY + drawAreaHeight;
-	 ++i) {
-      rot = rotate + doc->getPageRotate(i);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
+  startUpdate();
+
+  // get first and last pages
+  page0 = tileMap->getFirstPage();
+  page1 = tileMap->getLastPage();
+
+  // compute the desired width (in points)
+  gap = 0;
+  switch (state->getDisplayMode()) {
+  case displaySingle:
+  default:
+    w = tileMap->getPageBoxWidth(page0);
+    break;
+  case displayContinuous:
+    w = 0;
+    for (page = page0; page <= page1; ++page) {
+      w1 = tileMap->getPageBoxWidth(page);
+      if (w1 > w) {
+	w = w1;
       }
-      if (rot == 90 || rot == 270) {
-	w = doc->getPageCropHeight(i);
-      } else {
-	w = doc->getPageCropWidth(i);
+    }
+    break;
+  case displaySideBySideSingle:
+    w = tileMap->getPageBoxWidth(page0);
+    if (page1 != page0) {
+      w += tileMap->getPageBoxWidth(page1);
+      gap = tileMap->getSideBySidePageSpacing();
+    }
+    break;
+  case displaySideBySideContinuous:
+    w = 0;
+    for (page = page0; w <= page1; w += 2) {
+      w1 = tileMap->getPageBoxWidth(page);
+      if (page + 1 <= doc->getNumPages()) {
+	w1 += tileMap->getPageBoxWidth(page + 1);
       }
-      if (w > maxW) {
-	maxW = w;
+      if (w1 > w) {
+	w = w1;
       }
     }
+    gap = tileMap->getSideBySidePageSpacing();
+    break;
+  case displayHorizontalContinuous:
+    w = 0;
+    gap = 0;
+    for (page = page0; page <= page1; ++page) {
+      w += tileMap->getPageBoxWidth(page);
+      if (page != page0) {
+	gap += tileMap->getHorizContinuousPageSpacing();
+      }
+    }
+    break;
   }
 
-  // compute the resolution
-  dpi1 = (drawAreaWidth / maxW) * 72;
+  // set the new zoom level
+  zoom = 100.0 * (state->getWinW() - gap) / w;
+  state->setZoom(zoom);
 
-  // compute the horizontal scroll position
-  if (continuousMode) {
-    sx = ((int)(maxPageW * dpi1 / dpi) - drawAreaWidth) / 2;
-  } else {
-    sx = 0;
+  // scroll so that the first page is at the left edge of the window
+  state->setScrollPosition(page0, tileMap->getPageLeftX(page0),
+			   tileMap->getPageTopY(page0));
+
+  finishUpdate(gTrue, gFalse);
+}
+
+void PDFCore::setRotate(int rotate) {
+  int page;
+
+  if (state->getRotate() == rotate) {
+    return;
   }
+  if (!doc || !doc->getNumPages()) {
+    state->setRotate(rotate);
+    return;
+  }
+  startUpdate();
+  page = tileMap->getFirstPage();
+  state->setRotate(rotate);
+  state->setScrollPosition(page, tileMap->getPageLeftX(page),
+			   tileMap->getPageTopY(page));
+  finishUpdate(gTrue, gTrue);
+}
 
-  // compute the vertical scroll position
-  if (continuousMode) {
-    // we can't just multiply scrollY by dpi1/dpi -- the rounding
-    // errors add up (because the pageY values are integers) -- so
-    // we compute the pageY values at the new zoom level instead
-    sy = 0;
-    for (i = 1; i < topPage; ++i) {
-      rot = rotate + doc->getPageRotate(i);
-      if (rot >= 360) {
-	rot -= 360;
-      } else if (rot < 0) {
-	rot += 360;
-      }
-      if (rot == 90 || rot == 270) {
-	sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
-      } else {
-	sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
-      }
-    }
-    vAdjust = (topPage - 1) * continuousModePageSpacing;
-    sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
-		    * (dpi1 / dpi))
-         + vAdjust - drawAreaHeight / 2;
-  } else {
-    sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
-         - drawAreaHeight / 2;
+void PDFCore::setDisplayMode(DisplayMode mode) {
+  int page;
+
+  if (state->getDisplayMode() == mode) {
+    return;
   }
+  if (!doc || !doc->getNumPages()) {
+    state->setDisplayMode(mode);
+    return;
+  }
+  startUpdate();
+  page = tileMap->getFirstPage();
+  state->setDisplayMode(mode);
+  state->setScrollPosition(page, tileMap->getPageLeftX(page),
+			   tileMap->getPageTopY(page));
+  finishUpdate(gTrue, gTrue);
+}
 
-  update(topPage, sx, sy, (dpi1 * 100) / 72, rotate, gFalse, gFalse, gFalse);
+void PDFCore::setOCGState(OptionalContentGroup *ocg, GBool ocgState) {
+  if (ocgState != ocg->getState()) {
+    ocg->setState(ocgState);
+    state->optionalContentChanged();
+    invalidateWholeWindow();
+  }
 }
 
-void PDFCore::setContinuousMode(GBool cm) {
-  if (continuousMode != cm) {
-    continuousMode = cm;
-    update(topPage, scrollX, -1, zoom, rotate, gTrue, gFalse, gTrue);
+void PDFCore::setSelectMode(SelectMode mode) {
+  if (mode != selectMode) {
+    selectMode = mode;
+    clearSelection();
   }
 }
 
 void PDFCore::setSelectionColor(SplashColor color) {
-  splashColorCopy(selectXorColor, color);
-  splashColorXor(selectXorColor, paperColor);
+  int wx0, wy0, wx1, wy1;
+
+  state->setSelectColor(color);
+  if (state->hasSelection()) {
+    getSelectionBBox(&wx0, &wy0, &wx1, &wy1);
+    checkInvalidate(wx0, wy0, wx1 - wx0, wy1 - wy0);
+  }
 }
 
-void PDFCore::setSelection(int newSelectPage,
-			   int newSelectULX, int newSelectULY,
-			   int newSelectLRX, int newSelectLRY) {
-  int x0, y0, x1, y1, py;
-  GBool haveSel, newHaveSel;
-  GBool needRedraw, needScroll;
-  GBool moveLeft, moveRight, moveTop, moveBottom;
-  PDFCorePage *page;
+void PDFCore::setSelection(int page, int x0, int y0, int x1, int y1) {
+  SelectRect *rect;
+  GBool moveLeft, moveTop, moveRight, moveBottom, needScroll;
+  double selectX0, selectY0, selectX1, selectY1;
+  int oldWx0, oldWy0, oldWx1, oldWy1, ix0, iy0, ix1, iy1;
+  int wx0, wy0, wx1, wy1, sx, sy, t;
 
 
-  haveSel = selectULX != selectLRX && selectULY != selectLRY;
-  newHaveSel = newSelectULX != newSelectLRX && newSelectULY != newSelectLRY;
+  // if selection rectangle is empty, clear the selection
+  if (x0 == x1 || y0 == y1) {
+    clearSelection();
+    return;
+  }
 
-  // erase old selection on off-screen bitmap
-  needRedraw = gFalse;
-  if (haveSel) {
-    xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
-		 new SplashSolidColor(selectXorColor));
-    needRedraw = gTrue;
+  // x0 = left, x1 = right
+  // y0 = top, y1 = bottom
+  if (x0 > x1) {
+    t = x0;  x0 = x1;  x1 = t;
   }
+  if (y0 > y1) {
+    t = y0;  y0 = y1;  y1 = t;
+  }
 
-  // draw new selection on off-screen bitmap
-  if (newHaveSel) {
-    xorRectangle(newSelectPage, newSelectULX, newSelectULY,
-		 newSelectLRX, newSelectLRY,
-		 new SplashSolidColor(selectXorColor));
-    needRedraw = gTrue;
+  // convert new selection coords to user space and window space
+  tileMap->cvtDevToUser(page, x0, y0, &selectX0, &selectY0);
+  tileMap->cvtDevToUser(page, x1, y1, &selectX1, &selectY1);
+  cvtUserToWindow(page, selectX0, selectY0, &wx0, &wy0);
+  cvtUserToWindow(page, selectX1, selectY1, &wx1, &wy1);
+  if (wx0 > wx1) {
+    t = wx0;  wx0 = wx1;  wx1 = t;
   }
+  if (wy0 > wy1) {
+    t = wy0;  wy0 = wy1;  wy1 = t;
+  }
 
+  // convert current selection coords to window space;
   // check which edges moved
-  if (!haveSel || newSelectPage != selectPage) {
+  if (state->hasSelection()) {
+    rect = state->getSelectRect(0);
+    tileMap->cvtUserToWindow(rect->page, rect->x0, rect->y0, &oldWx0, &oldWy0);
+    tileMap->cvtUserToWindow(rect->page, rect->x1, rect->y1, &oldWx1, &oldWy1);
+    if (oldWx0 > oldWx1) {
+      t = oldWx0;  oldWx0 = oldWx1;  oldWx1 = t;
+    }
+    if (oldWy0 > oldWy1) {
+      t = oldWy0;  oldWy0 = oldWy1;  oldWy1 = t;
+    }
+    moveLeft = wx0 != oldWx0;
+    moveTop = wy0 != oldWy0;
+    moveRight = wx1 != oldWx1;
+    moveBottom = wy1 != oldWy1;
+  } else {
+    oldWx0 = wx0;
+    oldWy0 = wy0;
+    oldWx1 = wx1;
+    oldWy1 = wy1;
     moveLeft = moveTop = moveRight = moveBottom = gTrue;
+  }
+
+  // set the new selection
+  state->setSelection(page, selectX0, selectY0, selectX1, selectY1);
+
+  // scroll if necessary
+  needScroll = gFalse;
+  sx = state->getScrollX();
+  sy = state->getScrollY();
+  if (moveLeft && wx0 < 0) {
+    sx += wx0;
+    needScroll = gTrue;
+  } else if (moveRight && wx1 >= state->getWinW()) {
+    sx += wx1 - state->getWinW();
+    needScroll = gTrue;
+  } else if (moveLeft && wx0 >= state->getWinW()) {
+    sx += wx0 - state->getWinW();
+    needScroll = gTrue;
+  } else if (moveRight && wx1 < 0) {
+    sx += wx1;
+    needScroll = gTrue;
+  }
+  if (moveTop && wy0 < 0) {
+    sy += wy0;
+    needScroll = gTrue;
+  } else if (moveBottom && wy1 >= state->getWinH()) {
+    sy += wy1 - state->getWinH();
+    needScroll = gTrue;
+  } else if (moveTop && wy0 >= state->getWinH()) {
+    sy += wy0 - state->getWinH();
+    needScroll = gTrue;
+  } else if (moveBottom && wy1 < 0) {
+    sy += wy1;
+    needScroll = gTrue;
+  }
+  if (needScroll) {
+    scrollTo(sx, sy);
   } else {
-    moveLeft = newSelectULX != selectULX;
-    moveTop = newSelectULY != selectULY;
-    moveRight = newSelectLRX != selectLRX;
-    moveBottom = newSelectLRY != selectLRY;
+    ix0 = (wx0 < oldWx0) ? wx0 : oldWx0;
+    iy0 = (wy0 < oldWy0) ? wy0 : oldWy0;
+    ix1 = (wx1 > oldWx1) ? wx1 : oldWx1;
+    iy1 = (wy1 > oldWy1) ? wy1 : oldWy1;
+    checkInvalidate(ix0, iy0, ix1 - ix0, iy1 - iy0);
   }
+}
 
-  // redraw currently visible part of bitmap
-  if (needRedraw) {
-    if (!haveSel) {
-      page = findPage(newSelectPage);
-      x0 = newSelectULX;
-      y0 = newSelectULY;
-      x1 = newSelectLRX;
-      y1 = newSelectLRY;
-      redrawWindow(page->xDest + x0, page->yDest + y0,
-		   x1 - x0 + 1, y1 - y0 + 1, gFalse);
-    } else if (!newHaveSel) {
-      if ((page = findPage(selectPage))) {
-	x0 = selectULX;
-	y0 = selectULY;
-	x1 = selectLRX;
-	y1 = selectLRY;
-	redrawWindow(page->xDest + x0, page->yDest + y0,
-		     x1 - x0 + 1, y1 - y0 + 1, gFalse);
-      }
-    } else {
-      page = findPage(newSelectPage);
-      if (moveLeft) {
-	x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
-	y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
-	x1 = newSelectULX > selectULX ? newSelectULX : selectULX;
-	y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
-	redrawWindow(page->xDest + x0, page->yDest + y0,
-		     x1 - x0 + 1, y1 - y0 + 1, gFalse);
-      }
-      if (moveRight) {
-	x0 = newSelectLRX < selectLRX ? newSelectLRX : selectLRX;
-	y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
-	x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
-	y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
-	redrawWindow(page->xDest + x0, page->yDest + y0,
-		     x1 - x0 + 1, y1 - y0 + 1, gFalse);
-      }
-      if (moveTop) {
-	x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
-	y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
-	x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
-	y1 = newSelectULY > selectULY ? newSelectULY : selectULY;
-	redrawWindow(page->xDest + x0, page->yDest + y0,
-		     x1 - x0 + 1, y1 - y0 + 1, gFalse);
-      }
-      if (moveBottom) {
-	x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
-	y0 = newSelectLRY < selectLRY ? newSelectLRY : selectLRY;
-	x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
-	y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
-	redrawWindow(page->xDest + x0, page->yDest + y0,
-		     x1 - x0 + 1, y1 - y0 + 1, gFalse);
-      }
+void PDFCore::setLinearSelection(int page, TextPosition *pos0,
+				 TextPosition *pos1) {
+  TextPosition begin, end;
+  GList *rects;
+  GBool moveLeft, moveTop, moveRight, moveBottom, needScroll;
+  double x0, y0, x1, y1, x2, y2, x3, y3;
+  double ux0, uy0, ux1, uy1;
+  int oldWx0, oldWy0, oldWx1, oldWy1, ix0, iy0, ix1, iy1;
+  int wx0, wy0, wx1, wy1;
+  int sx, sy, colIdx;
+
+
+  // if selection rectangle is empty, clear the selection
+  if (*pos0 == *pos1) {
+    clearSelection();
+    return;
+  }
+
+  // swap into correct order
+  if (*pos0 < *pos1) {
+    begin = *pos0;
+    end = *pos1;
+  } else {
+    begin = *pos1;
+    end = *pos0;
+  }
+
+  // build the list of rectangles
+  //~ this doesn't handle RtL, vertical, or rotated text
+  loadText(selectPage);
+  rects = new GList();
+  if (begin.colIdx == end.colIdx &&
+      begin.parIdx == end.parIdx &&
+      begin.lineIdx == end.lineIdx) {
+    // same line
+    text->convertPosToPointUpper(&begin, &x0, &y0);
+    text->convertPosToPointLower(&end, &x1, &y1);
+    cvtDevToUser(selectPage, (int)(x0 + 0.5), (int)(y0 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y1 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+  } else if (begin.colIdx == end.colIdx) {
+    // same column
+    text->convertPosToPointUpper(&begin, &x0, &y0);
+    text->convertPosToPointRightEdge(&begin, &x1, &y1);
+    text->convertPosToPointLeftEdge(&end, &x2, &y2);
+    text->convertPosToPointLower(&end, &x3, &y3);
+    cvtDevToUser(selectPage, (int)(x0 + 0.5), (int)(y0 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y1 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+    cvtDevToUser(selectPage, (int)(x2 + 0.5), (int)(y1 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y2 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+    cvtDevToUser(selectPage, (int)(x2 + 0.5), (int)(y2 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x3 + 0.5), (int)(y3 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+  } else {
+    // different columns
+    text->convertPosToPointUpper(&begin, &x0, &y0);
+    text->convertPosToPointRightEdge(&begin, &x1, &y1);
+    text->getColumnLowerLeft(begin.colIdx, &x2, &y2);
+    cvtDevToUser(selectPage, (int)(x0 + 0.5), (int)(y0 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y1 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+    cvtDevToUser(selectPage, (int)(x2 + 0.5), (int)(y1 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y2 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+    for (colIdx = begin.colIdx + 1; colIdx < end.colIdx; ++colIdx) {
+      text->getColumnLowerLeft(colIdx, &x0, &y0);
+      text->getColumnUpperRight(colIdx, &x1, &y1);
+      cvtDevToUser(selectPage, (int)(x0 + 0.5), (int)(y1 + 0.5), &ux0, &uy0);
+      cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y0 + 0.5), &ux1, &uy1);
+      rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
     }
+    text->getColumnUpperRight(end.colIdx, &x0, &y0);
+    text->convertPosToPointLeftEdge(&end, &x1, &y1);
+    text->convertPosToPointLower(&end, &x2, &y2);
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y0 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x0 + 0.5), (int)(y1 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
+    cvtDevToUser(selectPage, (int)(x1 + 0.5), (int)(y1 + 0.5), &ux0, &uy0);
+    cvtDevToUser(selectPage, (int)(x2 + 0.5), (int)(y2 + 0.5), &ux1, &uy1);
+    rects->append(new SelectRect(selectPage, ux0, uy0, ux1, uy1));
   }
 
-  // switch to new selection coords
-  selectPage = newSelectPage;
-  selectULX = newSelectULX;
-  selectULY = newSelectULY;
-  selectLRX = newSelectLRX;
-  selectLRY = newSelectLRY;
+  // get window coord bboxes for old selection and new selection;
+  // check which edges moved
+  if (state->hasSelection()) {
+    getSelectionBBox(&oldWx0, &oldWy0, &oldWx1, &oldWy1);
+    getSelectRectListBBox(rects, &wx0, &wy0, &wx1, &wy1);
+    moveLeft = wx0 != oldWx0;
+    moveTop = wy0 != oldWy0;
+    moveRight = wx1 != oldWx1;
+    moveBottom = wy1 != oldWy1;
+  } else {
+    getSelectRectListBBox(rects, &wx0, &wy0, &wx1, &wy1);
+    oldWx0 = wx0;
+    oldWy0 = wy0;
+    oldWx1 = wx1;
+    oldWy1 = wy1;
+    moveLeft = moveTop = moveRight = moveBottom = gTrue;
+  }
 
+  // set the new selection
+  state->setSelection(rects);
+
   // scroll if necessary
-  if (newHaveSel) {
-    page = findPage(selectPage);
-    needScroll = gFalse;
-    x0 = scrollX;
-    y0 = scrollY;
-    if (moveLeft && page->xDest + selectULX < 0) {
-      x0 += page->xDest + selectULX;
-      needScroll = gTrue;
-    } else if (moveRight && page->xDest + selectLRX >= drawAreaWidth) {
-      x0 += page->xDest + selectLRX - drawAreaWidth;
-      needScroll = gTrue;
-    } else if (moveLeft && page->xDest + selectULX >= drawAreaWidth) {
-      x0 += page->xDest + selectULX - drawAreaWidth;
-      needScroll = gTrue;
-    } else if (moveRight && page->xDest + selectLRX < 0) {
-      x0 += page->xDest + selectLRX;
-      needScroll = gTrue;
+  needScroll = gFalse;
+  sx = state->getScrollX();
+  sy = state->getScrollY();
+  if (moveLeft && wx0 < 0) {
+    sx += wx0;
+    needScroll = gTrue;
+  } else if (moveRight && wx1 >= state->getWinW()) {
+    sx += wx1 - state->getWinW();
+    needScroll = gTrue;
+  } else if (moveLeft && wx0 >= state->getWinW()) {
+    sx += wx0 - state->getWinW();
+    needScroll = gTrue;
+  } else if (moveRight && wx1 < 0) {
+    sx += wx1;
+    needScroll = gTrue;
+  }
+  if (moveTop && wy0 < 0) {
+    sy += wy0;
+    needScroll = gTrue;
+  } else if (moveBottom && wy1 >= state->getWinH()) {
+    sy += wy1 - state->getWinH();
+    needScroll = gTrue;
+  } else if (moveTop && wy0 >= state->getWinH()) {
+    sy += wy0 - state->getWinH();
+    needScroll = gTrue;
+  } else if (moveBottom && wy1 < 0) {
+    sy += wy1;
+    needScroll = gTrue;
+  }
+  if (needScroll) {
+    scrollTo(sx, sy);
+  } else {
+    ix0 = (wx0 < oldWx0) ? wx0 : oldWx0;
+    iy0 = (wy0 < oldWy0) ? wy0 : oldWy0;
+    ix1 = (wx1 > oldWx1) ? wx1 : oldWx1;
+    iy1 = (wy1 > oldWy1) ? wy1 : oldWy1;
+    checkInvalidate(ix0, iy0, ix1 - ix0, iy1 - iy0);
+  }
+}
+
+void PDFCore::clearSelection() {
+  int wx0, wy0, wx1, wy1;
+
+  if (state->hasSelection()) {
+    getSelectionBBox(&wx0, &wy0, &wx1, &wy1);
+    state->clearSelection();
+    checkInvalidate(wx0, wy0, wx1 - wx0, wy1 - wy0);
+  }
+}
+
+void PDFCore::startSelectionDrag(int pg, int x, int y) {
+  clearSelection();
+  if (selectMode == selectModeBlock) {
+    selectPage = pg;
+    selectStartX = x;
+    selectStartY = y;
+  } else { // selectModeLinear
+    loadText(pg);
+    if (text->findPointInside(x, y, &selectStartPos)) {
+      selectPage = pg;
+    } else {
+      selectPage = 0;
     }
-    py = continuousMode ? pageY[selectPage - 1] : 0;
-    if (moveTop && py + selectULY < y0) {
-      y0 = py + selectULY;
-      needScroll = gTrue;
-    } else if (moveBottom && py + selectLRY >= y0 + drawAreaHeight) {
-      y0 = py + selectLRY - drawAreaHeight;
-      needScroll = gTrue;
-    } else if (moveTop && py + selectULY >= y0 + drawAreaHeight) {
-      y0 = py + selectULY - drawAreaHeight;
-      needScroll = gTrue;
-    } else if (moveBottom && py + selectLRY < y0) {
-      y0 = py + selectLRY;
-      needScroll = gTrue;
-    }
-    if (needScroll) {
-      scrollTo(x0, y0);
-    }
   }
 }
 
-void PDFCore::moveSelection(int pg, int x, int y) {
-  int newSelectULX, newSelectULY, newSelectLRX, newSelectLRY;
+void PDFCore::moveSelectionDrag(int pg, int x, int y) {
+  TextPosition pos;
 
   // don't allow selections to span multiple pages
+  // -- this also handles the case where a linear selection was started
+  //    outside any text column, in which case selectPage = 0
   if (pg != selectPage) {
     return;
   }
 
-  // move appropriate edges of selection
-  if (lastDragLeft) {
-    if (x < selectLRX) {
-      newSelectULX = x;
-      newSelectLRX = selectLRX;
-    } else {
-      newSelectULX = selectLRX;
-      newSelectLRX = x;
-      lastDragLeft = gFalse;
+  if (selectMode == selectModeBlock) {
+    setSelection(pg, selectStartX, selectStartY, x, y);
+  } else { // selectModeLinear
+    loadText(pg);
+    if (text->findPointNear(x, y, &pos)) {
+      setLinearSelection(pg, &selectStartPos, &pos);
     }
-  } else {
-    if (x > selectULX) {
-      newSelectULX = selectULX;
-      newSelectLRX = x;
-    } else {
-      newSelectULX = x;
-      newSelectLRX = selectULX;
-      lastDragLeft = gTrue;
-    }
   }
-  if (lastDragTop) {
-    if (y < selectLRY) {
-      newSelectULY = y;
-      newSelectLRY = selectLRY;
-    } else {
-      newSelectULY = selectLRY;
-      newSelectLRY = y;
-      lastDragTop = gFalse;
+}
+
+void PDFCore::finishSelectionDrag() {
+  selectPage = 0;
+  selectStartX = selectStartY = 0;
+}
+
+GBool PDFCore::getSelection(int *pg, double *ulx, double *uly,
+			    double *lrx, double *lry) {
+  SelectRect *rect;
+  double xMin, yMin, xMax, yMax;
+  int page, i;
+
+  if (!state->hasSelection()) {
+    return gFalse;
+  }
+  page = state->getSelectRect(0)->page;
+  xMin = yMin = xMax = yMax = 0;
+  for (i = 0; i < state->getNumSelectRects(); ++i) {
+    rect = state->getSelectRect(i);
+    if (rect->page != page) {
+      continue;
     }
-  } else {
-    if (y > selectULY) {
-      newSelectULY = selectULY;
-      newSelectLRY = y;
+    if (i == 0) {
+      xMin = xMax = rect->x0;
+      yMin = yMax = rect->y0;
     } else {
-      newSelectULY = y;
-      newSelectLRY = selectULY;
-      lastDragTop = gTrue;
+      if (rect->x0 < xMin) {
+	xMin = rect->x0;
+      } else if (rect->x0 > xMax) {
+	xMax = rect->x0;
+      }
+      if (rect->y0 < yMin) {
+	yMin = rect->y0;
+      } else if (rect->y0 > yMax) {
+	yMax = rect->y0;
+      }
     }
+    if (rect->x1 < xMin) {
+      xMin = rect->x1;
+    } else if (rect->x1 > xMax) {
+      xMax = rect->x1;
+    }
+    if (rect->y1 < yMin) {
+      yMin = rect->y1;
+    } else if (rect->y1 > yMax) {
+      yMax = rect->y1;
+    }
   }
+  *pg = page;
+  *ulx = xMin;
+  *uly = yMax;
+  *lrx = xMax;
+  *lry = yMin;
+  return gTrue;
+}
 
-  // redraw the selection
-  setSelection(selectPage, newSelectULX, newSelectULY,
-	       newSelectLRX, newSelectLRY);
+GBool PDFCore::hasSelection() {
+  return state->hasSelection();
 }
 
-void PDFCore::xorRectangle(int pg, int x0, int y0, int x1, int y1,
-			   SplashPattern *pattern, PDFCoreTile *oneTile) {
-  Splash *splash;
-  SplashPath *path;
-  PDFCorePage *page;
-  PDFCoreTile *tile;
-  SplashCoord xx0, yy0, xx1, yy1;
-  int xi, yi, wi, hi;
-  int i;
-
-  if ((page = findPage(pg))) {
-    for (i = 0; i < page->tiles->getLength(); ++i) {
-      tile = (PDFCoreTile *)page->tiles->get(i);
-      if (!oneTile || tile == oneTile) {
-	splash = new Splash(tile->bitmap, gFalse);
-	splash->setFillPattern(pattern->copy());
-	xx0 = (SplashCoord)(x0 - tile->xMin);
-	yy0 = (SplashCoord)(y0 - tile->yMin);
-	xx1 = (SplashCoord)(x1 - tile->xMin);
-	yy1 = (SplashCoord)(y1 - tile->yMin);
-	path = new SplashPath();
-	path->moveTo(xx0, yy0);
-	path->lineTo(xx1, yy0);
-	path->lineTo(xx1, yy1);
-	path->lineTo(xx0, yy1);
-	path->close();
-	splash->xorFill(path, gTrue);
-	delete path;
-	delete splash;
-	xi = x0 - tile->xMin;
-	wi = x1 - x0;
-	if (xi < 0) {
-	  wi += xi;
-	  xi = 0;
-	}
-	if (xi + wi > tile->bitmap->getWidth()) {
-	  wi = tile->bitmap->getWidth() - xi;
-	}
-	yi = y0 - tile->yMin;
-	hi = y1 - y0;
-	if (yi < 0) {
-	  hi += yi;
-	  yi = 0;
-	}
-	if (yi + hi > tile->bitmap->getHeight()) {
-	  hi = tile->bitmap->getHeight() - yi;
-	}
-	updateTileData(tile, xi, yi, wi, hi, gTrue);
-      }
+void PDFCore::setTextExtractionMode(TextOutputMode mode) {
+  if (textOutCtrl.mode != mode) {
+    textOutCtrl.mode = mode;
+    if (text) {
+      delete text;
+      text = NULL;
     }
+    textPage = 0;
+    textDPI = 0;
+    textRotate = 0;
   }
-  delete pattern;
 }
 
-GBool PDFCore::getSelection(int *pg, double *ulx, double *uly,
-			    double *lrx, double *lry) {
-  if (selectULX == selectLRX || selectULY == selectLRY) {
-    return gFalse;
+GBool PDFCore::getDiscardDiagonalText() {
+  return textOutCtrl.discardDiagonalText;
+}
+
+void PDFCore::setDiscardDiagonalText(GBool discard) {
+  if (textOutCtrl.discardDiagonalText != discard) {
+    textOutCtrl.discardDiagonalText = discard;
+    if (text) {
+      delete text;
+      text = NULL;
+    }
+    textPage = 0;
+    textDPI = 0;
+    textRotate = 0;
   }
-  *pg = selectPage;
-  cvtDevToUser(selectPage, selectULX, selectULY, ulx, uly);
-  cvtDevToUser(selectPage, selectLRX, selectLRY, lrx, lry);
-  return gTrue;
 }
 
 GString *PDFCore::extractText(int pg, double xMin, double yMin,
 			      double xMax, double yMax) {
-  PDFCorePage *page;
-  TextOutputControl textOutCtrl;
-  TextOutputDev *textOut;
   int x0, y0, x1, y1, t;
-  GString *s;
 
-  if (!doc->okToCopy()) {
+  loadText(pg);
+  cvtUserToDev(pg, xMin, yMin, &x0, &y0);
+  cvtUserToDev(pg, xMax, yMax, &x1, &y1);
+  if (x0 > x1) {
+    t = x0; x0 = x1; x1 = t;
+  }
+  if (y0 > y1) {
+    t = y0; y0 = y1; y1 = t;
+  }
+  return text->getText(x0, y0, x1, y1);
+}
+
+GString *PDFCore::getSelectedText() {
+  SelectRect *rect;
+  GString *ret, *s;
+  int x0, y0, x1, y1, t, i;
+
+  if (!state->hasSelection()) {
     return NULL;
   }
-  if ((page = findPage(pg))) {
-    cvtUserToDev(pg, xMin, yMin, &x0, &y0);
-    cvtUserToDev(pg, xMax, yMax, &x1, &y1);
+  ret = new GString();
+  for (i = 0; i < state->getNumSelectRects(); ++i) {
+    rect = state->getSelectRect(i);
+    loadText(rect->page);
+    cvtUserToDev(rect->page, rect->x0, rect->y0, &x0, &y0);
+    cvtUserToDev(rect->page, rect->x1, rect->y1, &x1, &y1);
     if (x0 > x1) {
       t = x0; x0 = x1; x1 = t;
     }
@@ -1689,27 +1329,11 @@
     if (y0 > y1) {
       t = y0; y0 = y1; y1 = t;
     }
-    s = page->text->getText(x0, y0, x1, y1);
-  } else {
-    textOutCtrl.mode = textOutPhysLayout;
-    textOut = new TextOutputDev(NULL, &textOutCtrl, gFalse);
-    if (textOut->isOk()) {
-      doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse);
-      textOut->cvtUserToDev(xMin, yMin, &x0, &y0);
-      textOut->cvtUserToDev(xMax, yMax, &x1, &y1);
-      if (x0 > x1) {
-	t = x0; x0 = x1; x1 = t;
-      }
-      if (y0 > y1) {
-	t = y0; y0 = y1; y1 = t;
-      }
-      s = textOut->getText(x0, y0, x1, y1);
-    } else {
-      s = new GString();
-    }
-    delete textOut;
+    s = text->getText(x0, y0, x1, y1, state->getNumSelectRects() > 1);
+    ret->append(s);
+    delete s;
   }
-  return s;
+  return ret;
 }
 
 GBool PDFCore::find(char *s, GBool caseSensitive, GBool next, GBool backward,
@@ -1734,11 +1358,10 @@
 GBool PDFCore::findU(Unicode *u, int len, GBool caseSensitive,
 		     GBool next, GBool backward, GBool wholeWord,
 		     GBool onePageOnly) {
-  TextOutputControl textOutCtrl;
   TextOutputDev *textOut;
+  SelectRect *rect;
   double xMin, yMin, xMax, yMax;
-  PDFCorePage *page;
-  int pg;
+  int topPage, pg, x, y, x2, y2;
   GBool startAtTop, startAtLast, stopAtLast;
 
   // check for zero-length string
@@ -1751,29 +1374,40 @@
   // search current page starting at previous result, current
   // selection, or top/bottom of page
   startAtTop = startAtLast = gFalse;
+  rect = NULL;
   xMin = yMin = xMax = yMax = 0;
+  topPage = tileMap->getFirstPage();
   pg = topPage;
   if (next) {
-    startAtLast = gTrue;
-  } else if (selectULX != selectLRX && selectULY != selectLRY) {
-    pg = selectPage;
+    if (textPage >= 1 && textPage <= doc->getNumPages()) {
+      startAtLast = gTrue;
+      pg = textPage;
+    }
+  } else if (state->hasSelection()) {
+    rect = state->getSelectRect(0);
+    pg = rect->page;
+    cvtUserToDev(pg, rect->x0, rect->y0, &x, &y);
+    cvtUserToDev(pg, rect->x1, rect->y1, &x2, &y2);
+    if (x2 < x) {
+      x = x2;
+    }
+    if (y2 < y) {
+      y = y2;
+    }
     if (backward) {
-      xMin = selectULX - 1;
-      yMin = selectULY - 1;
+      xMin = x - 1;
+      yMin = y - 1;
     } else {
-      xMin = selectULX + 1;
-      yMin = selectULY + 1;
+      xMin = x + 1;
+      yMin = y + 1;
     }
   } else {
     startAtTop = gTrue;
   }
-  if (!(page = findPage(pg))) {
-    displayPage(pg, zoom, rotate, gTrue, gFalse);
-    page = findPage(pg);
-  }
-  if (page->text->findText(u, len, startAtTop, gTrue, startAtLast, gFalse,
-			   caseSensitive, backward, wholeWord,
-			   &xMin, &yMin, &xMax, &yMax)) {
+  loadText(pg);
+  if (text->findText(u, len, startAtTop, gTrue, startAtLast, gFalse,
+		     caseSensitive, backward, wholeWord,
+		     &xMin, &yMin, &xMax, &yMax)) {
     goto found;
   }
 
@@ -1780,7 +1414,6 @@
   if (!onePageOnly) {
 
     // search following/previous pages
-    textOutCtrl.mode = textOutPhysLayout;
     textOut = new TextOutputDev(NULL, &textOutCtrl, gFalse);
     if (!textOut->isOk()) {
       delete textOut;
@@ -1822,12 +1455,13 @@
       stopAtLast = gTrue;
     } else {
       stopAtLast = gFalse;
-      xMax = selectLRX;
-      yMax = selectLRY;
+      cvtUserToDev(pg, rect->x1, rect->y1, &x, &y);
+      xMax = x;
+      yMax = y;
     }
-    if (page->text->findText(u, len, gTrue, gFalse, gFalse, stopAtLast,
-			     caseSensitive, backward, wholeWord,
-			     &xMin, &yMin, &xMax, &yMax)) {
+    if (text->findText(u, len, gTrue, gFalse, gFalse, stopAtLast,
+		       caseSensitive, backward, wholeWord,
+		       &xMin, &yMin, &xMax, &yMax)) {
       goto found;
     }
   }
@@ -1839,12 +1473,11 @@
 
   // found on a different page
  foundPage:
-  update(pg, scrollX, continuousMode ? -1 : 0, zoom, rotate, gFalse, gTrue,
-	 gTrue);
-  page = findPage(pg);
-  if (!page->text->findText(u, len, gTrue, gTrue, gFalse, gFalse,
-			    caseSensitive, backward, wholeWord,
-			    &xMin, &yMin, &xMax, &yMax)) {
+  displayPage(pg, gTrue, gFalse);
+  loadText(pg);
+  if (!text->findText(u, len, gTrue, gTrue, gFalse, gFalse,
+		      caseSensitive, backward, wholeWord,
+		      &xMin, &yMin, &xMax, &yMax)) {
     // this can happen if coalescing is bad
     goto notFound;
   }
@@ -1861,304 +1494,380 @@
 
 GBool PDFCore::cvtWindowToUser(int xw, int yw,
 			       int *pg, double *xu, double *yu) {
-  PDFCorePage *page;
-  PDFCoreTile *tile;
-  int i;
+  return tileMap->cvtWindowToUser(xw, yw, pg, xu, yu);
+}
 
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    if (xw >= page->xDest && xw < page->xDest + page->w &&
-	yw >= page->yDest && yw < page->yDest + page->h) {
-      if (page->tiles->getLength() == 0) {
-	break;
-      }
-      tile = (PDFCoreTile *)page->tiles->get(0);
-      *pg = page->page;
-      xw -= tile->xDest;
-      yw -= tile->yDest;
-      *xu = tile->ictm[0] * xw + tile->ictm[2] * yw + tile->ictm[4];
-      *yu = tile->ictm[1] * xw + tile->ictm[3] * yw + tile->ictm[5];
-      return gTrue;
-    }
+GBool PDFCore::cvtWindowToDev(int xw, int yw, int *pg, int *xd, int *yd) {
+  return tileMap->cvtWindowToDev(xw, yw, pg, xd, yd);
+}
+
+GBool PDFCore::cvtUserToWindow(int pg, double xu, double yu, int *xw, int *yw) {
+  return tileMap->cvtUserToWindow(pg, xu, yu, xw, yw);
+}
+
+void PDFCore::cvtUserToDev(int pg, double xu, double yu, int *xd, int *yd) {
+  tileMap->cvtUserToDev(pg, xu, yu, xd, yd);
+}
+
+GBool PDFCore::cvtDevToWindow(int pg, int xd, int yd, int *xw, int *yw) {
+  return tileMap->cvtDevToWindow(pg, xd, yd, xw, yw);
+}
+
+void PDFCore::cvtDevToUser(int pg, int xd, int yd, double *xu, double *yu) {
+  tileMap->cvtDevToUser(pg, xd, yd, xu, yu);
+}
+
+void PDFCore::getWindowPageRange(int x, int y, int w, int h,
+				 int *firstPage, int *lastPage) {
+  tileMap->getWindowPageRange(x, y, w, h, firstPage, lastPage);
+}
+
+int PDFCore::getPageNum() {
+  if (!doc || !doc->getNumPages()) {
+    return 0;
   }
-  *pg = 0;
-  *xu = *yu = 0;
-  return gFalse;
+  return tileMap->getFirstPage();
 }
 
-GBool PDFCore::cvtWindowToDev(int xw, int yw, int *pg, int *xd, int *yd) {
-  PDFCorePage *page;
+int PDFCore::getMidPageNum() {
+  if (!doc || !doc->getNumPages()) {
+    return 0;
+  }
+  return tileMap->getMidPage();
+}
+
+double PDFCore::getZoom() {
+  return state->getZoom();
+}
+
+double PDFCore::getZoomDPI(int page) {
+  if (!doc) {
+    return 0;
+  }
+  return tileMap->getDPI(page);
+}
+
+int PDFCore::getRotate() {
+  return state->getRotate();
+}
+
+DisplayMode PDFCore::getDisplayMode() {
+  return state->getDisplayMode();
+}
+
+int PDFCore::getScrollX() {
+  return state->getScrollX();
+}
+
+int PDFCore::getScrollY() {
+  return state->getScrollY();
+}
+
+int PDFCore::getWindowWidth() {
+  return state->getWinW();
+}
+
+int PDFCore::getWindowHeight() {
+  return state->getWinH();
+}
+
+void PDFCore::setPaperColor(SplashColorPtr paperColor) {
+  state->setPaperColor(paperColor);
+  invalidateWholeWindow();
+}
+
+void PDFCore::setMatteColor(SplashColorPtr matteColor) {
+  state->setMatteColor(matteColor);
+  invalidateWholeWindow();
+}
+
+void PDFCore::setReverseVideo(GBool reverseVideo) {
+  SplashColorPtr oldPaperColor;
+  SplashColor newPaperColor;
   int i;
 
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    if (xw >= page->xDest && xw < page->xDest + page->w &&
-	yw >= page->yDest && yw < page->yDest + page->h) {
-      *pg = page->page;
-      *xd = xw - page->xDest;
-      *yd = yw - page->yDest;
-      return gTrue;
+  if (reverseVideo != state->getReverseVideo()) {
+    state->setReverseVideo(reverseVideo);
+    oldPaperColor = state->getPaperColor();
+    for (i = 0; i < splashColorModeNComps[state->getColorMode()]; ++i) {
+      newPaperColor[i] = oldPaperColor[i] ^ 0xff;
     }
+    state->setPaperColor(newPaperColor);
+    invalidateWholeWindow();
   }
-  *pg = 0;
-  *xd = *yd = 0;
-  return gFalse;
 }
 
-void PDFCore::cvtUserToWindow(int pg, double xu, double yu, int *xw, int *yw) {
-  PDFCorePage *page;
-  PDFCoreTile *tile;
 
-  if ((page = findPage(pg)) &&
-      page->tiles->getLength() > 0) {
-    tile = (PDFCoreTile *)page->tiles->get(0);
-  } else if (curTile && curPage->page == pg) {
-    tile = curTile;
-  } else {
-    tile = NULL;
-  }
-  if (tile) {
-    *xw = tile->xDest + (int)(tile->ctm[0] * xu + tile->ctm[2] * yu +
-			      tile->ctm[4] + 0.5);
-    *yw = tile->yDest + (int)(tile->ctm[1] * xu + tile->ctm[3] * yu +
-			      tile->ctm[5] + 0.5);
-  } else {
-    // this should never happen
-    *xw = *yw = 0;
-  }
+
+LinkAction *PDFCore::findLink(int pg, double x, double y) {
+  loadLinks(pg);
+  return links->find(x, y);
 }
 
-void PDFCore::cvtUserToDev(int pg, double xu, double yu, int *xd, int *yd) {
-  PDFCorePage *page;
-  PDFCoreTile *tile;
-  double ctm[6];
+Annot *PDFCore::findAnnot(int pg, double x, double y) {
+  loadAnnots(pg);
+  return annots->find(x, y);
+}
 
-  if ((page = findPage(pg)) &&
-      page->tiles->getLength() > 0) {
-    tile = (PDFCoreTile *)page->tiles->get(0);
-  } else if (curTile && curPage->page == pg) {
-    tile = curTile;
-  } else {
-    tile = NULL;
+int PDFCore::findAnnotIdx(int pg, double x, double y) {
+  loadAnnots(pg);
+  return annots->findIdx(x, y);
+}
+
+Annot *PDFCore::getAnnot(int idx) {
+  if (!annots) {
+    return NULL;
   }
-  if (tile) {
-    *xd = (int)(tile->xMin + tile->ctm[0] * xu +
-		tile->ctm[2] * yu + tile->ctm[4] + 0.5);
-    *yd = (int)(tile->yMin + tile->ctm[1] * xu +
-		tile->ctm[3] * yu + tile->ctm[5] + 0.5);
-  } else {
-    doc->getCatalog()->getPage(pg)->getDefaultCTM(ctm, dpi, dpi, rotate,
-						  gFalse, out->upsideDown());
-    *xd = (int)(ctm[0] * xu + ctm[2] * yu + ctm[4] + 0.5);
-    *yd = (int)(ctm[1] * xu + ctm[3] * yu + ctm[5] + 0.5);
+  if (idx < 0 || idx >= annots->getNumAnnots()) {
+    return NULL;
   }
+  return annots->getAnnot(idx);
 }
 
-void PDFCore::cvtDevToWindow(int pg, int xd, int yd, int *xw, int *yw) {
-  PDFCorePage *page;
+FormField *PDFCore::findFormField(int pg, double x, double y) {
+  if (!doc->getCatalog()->getForm()) {
+    return NULL;
+  }
+  return doc->getCatalog()->getForm()->findField(pg, x, y);
+}
 
-  if ((page = findPage(pg))) {
-    *xw = page->xDest + xd;
-    *yw = page->yDest + yd;
-  } else {
-    // this should never happen
-    *xw = *yw = 0;
+int PDFCore::findFormFieldIdx(int pg, double x, double y) {
+  if (!doc->getCatalog()->getForm()) {
+    return -1;
   }
+  return doc->getCatalog()->getForm()->findFieldIdx(pg, x, y);
 }
 
-void PDFCore::cvtDevToUser(int pg, int xd, int yd, double *xu, double *yu) {
-  PDFCorePage *page;
-  PDFCoreTile *tile;
-
-  if ((page = findPage(pg)) &&
-      page->tiles->getLength() > 0) {
-    tile = (PDFCoreTile *)page->tiles->get(0);
-  } else if (curTile && curPage->page == pg) {
-    tile = curTile;
-  } else {
-    tile = NULL;
+FormField *PDFCore::getFormField(int idx) {
+  if (!doc->getCatalog()->getForm()) {
+    return NULL;
   }
-  if (tile) {
-    xd -= tile->xMin;
-    yd -= tile->yMin;
-    *xu = tile->ictm[0] * xd + tile->ictm[2] * yd + tile->ictm[4];
-    *yu = tile->ictm[1] * xd + tile->ictm[3] * yd + tile->ictm[5];
-  } else {
-    // this should never happen
-    *xu = *yu = 0;
+  if (idx < 0 || idx >= doc->getCatalog()->getForm()->getNumFields()) {
+    return NULL;
   }
+  return doc->getCatalog()->getForm()->getField(idx);
 }
 
-void PDFCore::setReverseVideo(GBool reverseVideoA) {
-  out->setReverseVideo(reverseVideoA);
-  update(topPage, scrollX, scrollY, zoom, rotate, gTrue, gFalse, gFalse);
+void PDFCore::forceRedraw() {
+  startUpdate();
+  state->forceRedraw();
+  finishUpdate(gFalse, gFalse);
 }
 
-LinkAction *PDFCore::findLink(int pg, double x, double y) {
-  PDFCorePage *page;
+void PDFCore::setTileDoneCbk(void (*cbk)(void *data), void *data) {
+  tileCache->setTileDoneCbk(cbk, data);
+}
 
-  if ((page = findPage(pg))) {
-    return page->links ? page->links->find(x, y) : (LinkAction *)NULL;
+void PDFCore::setWindowSize(int winWidth, int winHeight) {
+  GBool doScroll;
+  int page, wx0, wy0, wx, wy, sx, sy;
+  double ux, uy;
+
+  startUpdate();
+
+  wx0 = wy0 = 0; // make gcc happy
+  doScroll = gFalse;
+  if (state->getZoom() < 0 && state->displayModeIsContinuous()) {
+    // save the user coordinates of the appropriate edge of the window
+    if (state->getDisplayMode() == displayHorizontalContinuous) {
+      wx0 = 0;
+      wy0 = state->getWinH() / 2;
+    } else {
+      wx0 = state->getWinW() / 2;
+      wy0 = 0;
+    }
+    if (!(doScroll = cvtWindowToUser(wx0, wy0, &page, &ux, &uy))) {
+      // tweak the save position if it happens to fall in a gutter
+      if (state->getDisplayMode() == displayContinuous) {
+	wy0 += tileMap->getContinuousPageSpacing();
+      } else if (state->getDisplayMode() == displaySideBySideContinuous) {
+	wx0 += tileMap->getSideBySidePageSpacing();
+	wy0 += tileMap->getContinuousPageSpacing();
+      } else { // state->getDisplayMode() == displayHorizontalContinuous
+	wx0 += tileMap->getHorizContinuousPageSpacing();
+      }
+      doScroll = cvtWindowToUser(wx0, wy0, &page, &ux, &uy);
+    }
   }
-  return NULL;
-}
 
-PDFCorePage *PDFCore::findPage(int pg) {
-  PDFCorePage *page;
-  int i;
+  state->setWindowSize(winWidth, winHeight);
 
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    if (page->page == pg) {
-      return page;
+  if (doScroll) {
+    // restore the saved scroll position
+    cvtUserToWindow(page, ux, uy, &wx, &wy);
+    sx = state->getScrollX();
+    sy = state->getScrollY();
+    if (state->getDisplayMode() == displayHorizontalContinuous) {
+      sx += wx - wx0;
+    } else {
+      sy += wy - wy0;
     }
+    state->setScrollPosition(page, sx, sy);
   }
-  return NULL;
+
+  finishUpdate(gTrue, gFalse);
 }
 
-void PDFCore::redrawCbk(void *data, int x0, int y0, int x1, int y1,
-			GBool composited) {
-  PDFCore *core = (PDFCore *)data;
+SplashBitmap *PDFCore::getWindowBitmap(GBool wholeWindow) {
+  GBool dummy;
 
-  core->curTile->bitmap = core->out->getBitmap();
+  return tileCompositor->getBitmap(wholeWindow ? &bitmapFinished : &dummy);
+}
 
-  // the default CTM is set by the Gfx constructor; tile->ctm is
-  // needed by the coordinate conversion functions (which may be
-  // called during redraw)
-  memcpy(core->curTile->ctm, core->out->getDefCTM(), 6 * sizeof(double));
-  memcpy(core->curTile->ictm, core->out->getDefICTM(), 6 * sizeof(double));
+void PDFCore::tick() {
+  if (!bitmapFinished) {
+    invalidateWholeWindow();
+  }
+}
 
-  // the bitmap created by Gfx and SplashOutputDev can be a slightly
-  // different size due to rounding errors
-  if (x1 >= core->curTile->xMax - core->curTile->xMin) {
-    x1 = core->curTile->xMax - core->curTile->xMin - 1;
+// Clear cached info (links, text) that's tied to a PDFDoc.
+void PDFCore::clearPage() {
+  if (links) {
+    delete links;
   }
-  if (y1 >= core->curTile->yMax - core->curTile->yMin) {
-    y1 = core->curTile->yMax - core->curTile->yMin - 1;
+  links = NULL;
+  linksPage = 0;
+
+  if (annots) {
+    delete annots;
   }
+  annots = NULL;
+  annotsPage = 0;
 
-  core->clippedRedrawRect(core->curTile, x0, y0,
-			  core->curTile->xDest + x0, core->curTile->yDest + y0,
-			  x1 - x0 + 1, y1 - y0 + 1,
-			  0, 0, core->drawAreaWidth, core->drawAreaHeight,
-			  gTrue, composited);
+  if (text) {
+    delete text;
+  }
+  text = NULL;
+  textPage = 0;
+  textDPI = 0;
+  textRotate = 0;
 }
 
-void PDFCore::redrawWindow(int x, int y, int width, int height,
-			   GBool needUpdate) {
-  PDFCorePage *page;
-  PDFCoreTile *tile;
-  int xDest, yDest, w, i, j;
+// Load the links for <pg>.
+void PDFCore::loadLinks(int pg) {
+  if (links && linksPage == pg) {
+    return;
+  }
+  if (links) {
+    delete links;
+  }
+  links = doc->getLinks(pg);
+  linksPage = pg;
+}
 
-  if (pages->getLength() == 0) {
-    redrawRect(NULL, 0, 0, x, y, width, height, gTrue);
+// Load the annotations for <pg>.
+void PDFCore::loadAnnots(int pg) {
+  Object annotsObj;
+
+  if (annots && annotsPage == pg) {
     return;
   }
+  if (annots) {
+    delete annots;
+  }
+  doc->getCatalog()->getPage(pg)->getAnnots(&annotsObj);
+  annots = new Annots(doc, &annotsObj);
+  annotsObj.free();
+  annotsPage = pg;
+}
 
-  for (i = 0; i < pages->getLength(); ++i) {
-    page = (PDFCorePage *)pages->get(i);
-    for (j = 0; j < page->tiles->getLength(); ++j) {
-      tile = (PDFCoreTile *)page->tiles->get(j);
-      if (tile->edges & pdfCoreTileTopEdge) {
-	if (tile->edges & pdfCoreTileLeftEdge) {
-	  xDest = 0;
-	} else {
-	  xDest = tile->xDest;
-	}
-	if (tile->edges & pdfCoreTileRightEdge) {
-	  w = drawAreaWidth - xDest;
-	} else {
-	  w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
-	}
-	clippedRedrawRect(NULL, 0, 0,
-			  xDest, 0, w, tile->yDest,
-			  x, y, width, height, gFalse);
-      }
-      if (tile->edges & pdfCoreTileBottomEdge) {
-	if (tile->edges & pdfCoreTileLeftEdge) {
-	  xDest = 0;
-	} else {
-	  xDest = tile->xDest;
-	}
-	if (tile->edges & pdfCoreTileRightEdge) {
-	  w = drawAreaWidth - xDest;
-	} else {
-	  w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
-	}
-	yDest = tile->yDest + (tile->yMax - tile->yMin);
-	clippedRedrawRect(NULL, 0, 0,
-			  xDest, yDest, w, drawAreaHeight - yDest,
-			  x, y, width, height, gFalse);
-      } else if ((tile->edges & pdfCoreTileBottomSpace) &&
-		 i+1 < pages->getLength()) {
-	if (tile->edges & pdfCoreTileLeftEdge) {
-	  xDest = 0;
-	} else {
-	  xDest = tile->xDest;
-	}
-	if (tile->edges & pdfCoreTileRightEdge) {
-	  w = drawAreaWidth - xDest;
-	} else {
-	  w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
-	}
-	yDest = tile->yDest + (tile->yMax - tile->yMin);
-	clippedRedrawRect(NULL, 0, 0,
-			  xDest, yDest,
-			  w, ((PDFCorePage *)pages->get(i+1))->yDest - yDest,
-			  x, y, width, height, gFalse);
-      }
-      if (tile->edges & pdfCoreTileLeftEdge) {
-	clippedRedrawRect(NULL, 0, 0,
-			  0, tile->yDest,
-			  tile->xDest, tile->yMax - tile->yMin,
-			  x, y, width, height, gFalse);
-      }
-      if (tile->edges & pdfCoreTileRightEdge) {
-	xDest = tile->xDest + (tile->xMax - tile->xMin);
-	clippedRedrawRect(NULL, 0, 0,
-			  xDest, tile->yDest,
-			  drawAreaWidth - xDest, tile->yMax - tile->yMin,
-			  x, y, width, height, gFalse);
-      }
-      clippedRedrawRect(tile, 0, 0, tile->xDest, tile->yDest,
-			tile->bitmap->getWidth(), tile->bitmap->getHeight(),
-			x, y, width, height, needUpdate);
-    }
+// Extract text from <pg>.
+void PDFCore::loadText(int pg) {
+  TextOutputDev *textOut;
+  double dpi;
+  int rotate;
+
+  dpi = tileMap->getDPI(pg);
+  rotate = state->getRotate();
+  if (text && textPage == pg && textDPI == dpi && textRotate == rotate) {
+    return;
   }
+  if (text) {
+    delete text;
+  }
+  textOut = new TextOutputDev(NULL, &textOutCtrl, gFalse);
+  if (!textOut->isOk()) {
+    text = new TextPage(&textOutCtrl);
+  } else {
+    doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse);
+    text = textOut->takeText();
+  }
+  delete textOut;
+  textPage = pg;
+  textDPI = dpi;
+  textRotate = rotate;
 }
 
-PDFCoreTile *PDFCore::newTile(int xDestA, int yDestA) {
-  return new PDFCoreTile(xDestA, yDestA);
+void PDFCore::getSelectionBBox(int *wxMin, int *wyMin, int *wxMax, int *wyMax) {
+  *wxMin = *wyMin = *wxMax = *wyMax = 0;
+  if (!state->hasSelection()) {
+    return;
+  }
+  getSelectRectListBBox(state->getSelectRects(), wxMin, wyMin, wxMax, wyMax);
 }
 
-void PDFCore::updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
-			     int width, int height, GBool composited) {
+void PDFCore::getSelectRectListBBox(GList *rects, int *wxMin, int *wyMin,
+				    int *wxMax, int *wyMax) {
+  SelectRect *rect;
+  int x, y, i;
+
+  *wxMin = *wyMin = *wxMax = *wyMax = 0;
+  for (i = 0; i < rects->getLength(); ++i) {
+    rect = (SelectRect *)rects->get(i);
+    tileMap->cvtUserToWindow(rect->page, rect->x0, rect->y0, &x, &y);
+    if (i == 0) {
+      *wxMin = *wxMax = x;
+      *wyMin = *wyMax = y;
+    } else {
+      if (x < *wxMin) {
+	*wxMin = x;
+      } else if (x > *wxMax) {
+	*wxMax = x;
+      }
+      if (y < *wyMin) {
+	*wyMin = y;
+      } else if (y > *wyMax) {
+	*wyMax = y;
+      }
+    }
+    tileMap->cvtUserToWindow(rect->page, rect->x1, rect->y1, &x, &y);
+    if (x < *wxMin) {
+      *wxMin = x;
+    } else if (x > *wxMax) {
+      *wxMax = x;
+    }
+    if (y < *wyMin) {
+      *wyMin = y;
+    } else if (y > *wyMax) {
+      *wyMax = y;
+    }
+  }
 }
 
-void PDFCore::clippedRedrawRect(PDFCoreTile *tile, int xSrc, int ySrc,
-				int xDest, int yDest, int width, int height,
-				int xClip, int yClip, int wClip, int hClip,
-				GBool needUpdate, GBool composited) {
-  if (tile && needUpdate) {
-    updateTileData(tile, xSrc, ySrc, width, height, composited);
+void PDFCore::checkInvalidate(int x, int y, int w, int h) {
+  if (x < 0) {
+    w += x;
+    x = 0;
   }
-  if (xDest < xClip) {
-    xSrc += xClip - xDest;
-    width -= xClip - xDest;
-    xDest = xClip;
+  if (x + w > state->getWinW()) {
+    w = state->getWinW() - x;
   }
-  if (xDest + width > xClip + wClip) {
-    width = xClip + wClip - xDest;
+  if (w <= 0) {
+    return;
   }
-  if (yDest < yClip) {
-    ySrc += yClip - yDest;
-    height -= yClip - yDest;
-    yDest = yClip;
+  if (y < 0) {
+    h += y;
+    y = 0;
   }
-  if (yDest + height > yClip + hClip) {
-    height = yClip + hClip - yDest;
+  if (y + h > state->getWinH()) {
+    h = state->getWinH() - y;
   }
-  if (width > 0 && height > 0) {

@@ Diff output truncated at 1234567 characters. @@


More information about the tex-live-commits mailing list