pdftex[816] branches/stable/source/src: sync with TL r52901

commits+karl at tug.org commits+karl at tug.org
Sun Nov 24 00:34:02 CET 2019


Revision: 816
          http://tug.org/svn/pdftex?view=revision&revision=816
Author:   karl
Date:     2019-11-24 00:34:02 +0100 (Sun, 24 Nov 2019)
Log Message:
-----------
sync with TL r52901

Revision Links:
--------------
    http://tug.org/svn/pdftex?view=revision&revision=52901

Modified Paths:
--------------
    branches/stable/source/src/build-aux/ar-lib
    branches/stable/source/src/build-aux/compile
    branches/stable/source/src/build-aux/config.guess
    branches/stable/source/src/build-aux/config.sub
    branches/stable/source/src/build-aux/depcomp
    branches/stable/source/src/build-aux/install-sh
    branches/stable/source/src/build-aux/texinfo.tex
    branches/stable/source/src/doc/ChangeLog
    branches/stable/source/src/doc/build-tools.txt
    branches/stable/source/src/doc/tlbuild.info
    branches/stable/source/src/doc/tlbuild.texi
    branches/stable/source/src/libs/README
    branches/stable/source/src/libs/xpdf/ChangeLog
    branches/stable/source/src/libs/xpdf/TLpatches/ChangeLog
    branches/stable/source/src/libs/xpdf/TLpatches/TL-Changes
    branches/stable/source/src/libs/xpdf/TLpatches/patch-bunched
    branches/stable/source/src/libs/xpdf/configure
    branches/stable/source/src/libs/xpdf/version.ac
    branches/stable/source/src/libs/xpdf/xpdf-src/ANNOUNCE
    branches/stable/source/src/libs/xpdf/xpdf-src/CHANGES
    branches/stable/source/src/libs/xpdf/xpdf-src/INSTALL
    branches/stable/source/src/libs/xpdf/xpdf-src/README
    branches/stable/source/src/libs/xpdf/xpdf-src/aconf2.h
    branches/stable/source/src/libs/xpdf/xpdf-src/cmake-config.txt
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.1
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.5
    branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.cat
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiBase.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.h
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/FixedPoint.h
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/GMutex.h
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.h
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.h
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.h
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.h
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.h
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashMath.h
    branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashXPath.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/AcroForm.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Annot.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Lexer.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDoc.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDocEncoding.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PSOutputDev.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileCompositor.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileMap.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/UTF8.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/config.h
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdffonts.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftopng.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftotext.cc
    branches/stable/source/src/texk/kpathsea/ChangeLog
    branches/stable/source/src/texk/kpathsea/Makefile.am
    branches/stable/source/src/texk/kpathsea/Makefile.in
    branches/stable/source/src/texk/kpathsea/cnf.c
    branches/stable/source/src/texk/kpathsea/cnf.h
    branches/stable/source/src/texk/kpathsea/doc/kpathsea.info
    branches/stable/source/src/texk/kpathsea/doc/kpathsea.texi
    branches/stable/source/src/texk/kpathsea/hash.c
    branches/stable/source/src/texk/kpathsea/kpsewhich.c
    branches/stable/source/src/texk/kpathsea/progname.c
    branches/stable/source/src/texk/kpathsea/progname.h
    branches/stable/source/src/texk/kpathsea/tex-file.c
    branches/stable/source/src/texk/kpathsea/texmf.cnf
    branches/stable/source/src/texk/kpathsea/types.h
    branches/stable/source/src/texk/tests/TeXLive/TLConfig.pm
    branches/stable/source/src/texk/tests/TeXLive/TLUtils.pm
    branches/stable/source/src/texk/web2c/ChangeLog
    branches/stable/source/src/texk/web2c/Makefile.in
    branches/stable/source/src/texk/web2c/NEWS
    branches/stable/source/src/texk/web2c/cpascal.h
    branches/stable/source/src/texk/web2c/doc/web2c.info
    branches/stable/source/src/texk/web2c/doc/web2c.texi
    branches/stable/source/src/texk/web2c/lib/ChangeLog
    branches/stable/source/src/texk/web2c/lib/lib.h
    branches/stable/source/src/texk/web2c/lib/texmfmp.c
    branches/stable/source/src/texk/web2c/man/Makefile.in
    branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
    branches/stable/source/src/texk/web2c/pdftexdir/am/pdftex.am
    branches/stable/source/src/texk/web2c/synctexdir/ChangeLog
    branches/stable/source/src/texk/web2c/synctexdir/am/synctex.am
    branches/stable/source/src/texk/web2c/synctexdir/synctex-p-rec.ch0
    branches/stable/source/src/texk/web2c/synctexdir/synctex.c
    branches/stable/source/src/texk/web2c/tex.ch
    branches/stable/source/src/texk/web2c/texmfmp-help.h
    branches/stable/source/src/texk/web2c/web2c/ChangeLog
    branches/stable/source/src/texk/web2c/web2c/texmf.defines
    branches/stable/source/src/utils/README

Added Paths:
-----------
    branches/stable/source/src/doc/buildinfo.sh
    branches/stable/source/src/doc/tlbuild.cp
    branches/stable/source/src/doc/tlbuild.cps
    branches/stable/source/src/doc/tlbuild.pdf
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.cc
    branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.h
    branches/stable/source/src/texk/kpathsea/tests/cnfline/
    branches/stable/source/src/texk/kpathsea/tests/cnfline/texmf.cnf
    branches/stable/source/src/texk/kpathsea/tests/cnfline.test
    branches/stable/source/src/texk/kpathsea/tests/cnfprog/
    branches/stable/source/src/texk/kpathsea/tests/cnfprog/texmf.cnf
    branches/stable/source/src/texk/kpathsea/tests/cnfprog.test
    branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.test
    branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.tex
    branches/stable/source/src/texk/web2c/synctexdir/synctex-ep-rec.ch0

Modified: branches/stable/source/src/build-aux/ar-lib
===================================================================
--- branches/stable/source/src/build-aux/ar-lib	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/ar-lib	2019-11-23 23:34:02 UTC (rev 816)
@@ -53,7 +53,7 @@
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN* | MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -65,7 +65,7 @@
 	mingw)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin)
+	cygwin | msys)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine)

Modified: branches/stable/source/src/build-aux/compile
===================================================================
--- branches/stable/source/src/build-aux/compile	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/compile	2019-11-23 23:34:02 UTC (rev 816)
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2019 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -53,7 +53,7 @@
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN* | MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -67,7 +67,7 @@
 	mingw/*)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin/*)
+	cygwin/* | msys/*)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine/*)

Modified: branches/stable/source/src/build-aux/config.guess
===================================================================
--- branches/stable/source/src/build-aux/config.guess	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/config.guess	2019-11-23 23:34:02 UTC (rev 816)
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2019-06-10'
+timestamp='2019-09-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -274,12 +274,15 @@
     *:Sortix:*:*)
 	echo "$UNAME_MACHINE"-unknown-sortix
 	exit ;;
+    *:Twizzler:*:*)
+	echo "$UNAME_MACHINE"-unknown-twizzler
+	exit ;;
     *:Redox:*:*)
 	echo "$UNAME_MACHINE"-unknown-redox
 	exit ;;
     mips:OSF1:*.*)
-        echo mips-dec-osf1
-        exit ;;
+	echo mips-dec-osf1
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)

Modified: branches/stable/source/src/build-aux/config.sub
===================================================================
--- branches/stable/source/src/build-aux/config.sub	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/config.sub	2019-11-23 23:34:02 UTC (rev 816)
@@ -1343,7 +1343,7 @@
 	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
 	     | sym* | kopensolaris* | plan9* \
 	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
-	     | aos* | aros* | cloudabi* | sortix* \
+	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
 	     | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
 	     | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
 	     | knetbsd* | mirbsd* | netbsd* \

Modified: branches/stable/source/src/build-aux/depcomp
===================================================================
--- branches/stable/source/src/build-aux/depcomp	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/depcomp	2019-11-23 23:34:02 UTC (rev 816)
@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

Modified: branches/stable/source/src/build-aux/install-sh
===================================================================
--- branches/stable/source/src/build-aux/install-sh	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/install-sh	2019-11-23 23:34:02 UTC (rev 816)
@@ -451,7 +451,18 @@
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
 
     # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+    (umask $cp_umask &&
+     { test -z "$stripcmd" || {
+	 # Create $dsttmp read-write so that cp doesn't create it read-only,
+	 # which would cause strip to fail.
+	 if test -z "$doit"; then
+	   : >"$dsttmp" # No need to fork-exec 'touch'.
+	 else
+	   $doit touch "$dsttmp"
+	 fi
+       }
+     } &&
+     $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #

Modified: branches/stable/source/src/build-aux/texinfo.tex
===================================================================
--- branches/stable/source/src/build-aux/texinfo.tex	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/build-aux/texinfo.tex	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,9 +1,9 @@
 % texinfo.tex -- TeX macros to handle Texinfo files.
-% 
+%
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2019-06-01.23}
+\def\texinfoversion{2019-09-24.13}
 %
 % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc.
 %
@@ -218,7 +218,7 @@
 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
 % aren't perfect, it's not the end of the world, being an error message,
 % after all.
-% 
+%
 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
 \def\doerrormsg#1{\errmessage{#1}}
 
@@ -323,9 +323,9 @@
 % the output routine.  The saved contents are valid until we actually
 % \shipout a page.
 %
-% (We used to run a short output routine to actually set \topmark and 
-% \firstmark to the right values, but if this was called with an empty page 
-% containing whatsits for writing index entries, the whatsits would be thrown 
+% (We used to run a short output routine to actually set \topmark and
+% \firstmark to the right values, but if this was called with an empty page
+% containing whatsits for writing index entries, the whatsits would be thrown
 % away and the index auxiliary file would remain empty.)
 %
 \newtoks\savedtopmark
@@ -365,7 +365,7 @@
     \let\thischapterheading\thischapter
   \else
     % \thischapterheading is the same as \thischapter except it is blank
-    % for the first page of a chapter.  This is to prevent the chapter name 
+    % for the first page of a chapter.  This is to prevent the chapter name
     % being shown twice.
     \def\thischapterheading{}%
   \fi
@@ -448,7 +448,7 @@
   }%
 }
 
-% First remove any @comment, then any @c comment.  Pass the result on to 
+% First remove any @comment, then any @c comment.  Pass the result on to
 % \argcheckspaces.
 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
@@ -1052,7 +1052,7 @@
             tex.sprint(
               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o',
-                            (c / 256), (c % 256)))
+                            math.floor(c / 256), math.floor(c % 256)))
           else
             c = c - 0x10000
             local c_hi = c / 1024 + 0xd800
@@ -1062,8 +1062,8 @@
                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o',
-                            (c_hi / 256), (c_hi % 256),
-                            (c_lo / 256), (c_lo % 256)))
+                            math.floor(c_hi / 256), math.floor(c_hi % 256),
+                            math.floor(c_lo / 256), math.floor(c_lo % 256)))
           end
         end
       end
@@ -1076,15 +1076,19 @@
       function PDFescstr(str)
         for c in string.bytes(str) do
           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
-            tex.sprint(
+            tex.sprint(-2,
               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
                             c))
           else
-            tex.sprint(string.char(c))
+            tex.sprint(-2, string.char(c))
           end
         end
       end
     }
+    % The -2 in the arguments here gives all the input to TeX catcode 12
+    % (other) or 10 (space), preventing undefined control sequence errors. See
+    % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
+    %
   \endgroup
   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
   \ifnum\luatexversion>84
@@ -1137,7 +1141,7 @@
 % for display in the outlines, and in other places.  Thus, we have to
 % double any backslashes.  Otherwise, a name like "\node" will be
 % interpreted as a newline (\n), followed by o, d, e.  Not good.
-% 
+%
 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
 % related messages.  The final outcome is that it is up to the TeX user
 % to double the backslashes and otherwise make the string valid, so
@@ -1442,7 +1446,7 @@
       % their "best" equivalent, based on the @documentencoding.  Too
       % much work for too little return.  Just use the ASCII equivalents
       % we use for the index sort strings.
-      % 
+      %
       \indexnofonts
       \setupdatafile
       % We can have normal brace characters in the PDF outlines, unlike
@@ -2726,7 +2730,7 @@
 }
 
 % Commands to set the quote options.
-% 
+%
 \parseargdef\codequoteundirected{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -2767,7 +2771,7 @@
 % If we are in a monospaced environment, however, 1) always use \ttsl,
 % and 2) do not add an italic correction.
 \def\dosmartslant#1#2{%
-  \ifusingtt 
+  \ifusingtt
     {{\ttsl #2}\let\next=\relax}%
     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
   \next
@@ -2914,7 +2918,7 @@
   \gdef\codedash{\futurelet\next\codedashfinish}
   \gdef\codedashfinish{%
     \normaldash % always output the dash character itself.
-    % 
+    %
     % Now, output a discretionary to allow a line break, unless
     % (a) the next character is a -, or
     % (b) the preceding character is a -.
@@ -2921,7 +2925,7 @@
     % E.g., given --posix, we do not want to allow a break after either -.
     % Given --foo-bar, we do want to allow a break between the - and the b.
     \ifx\next\codedash \else
-      \ifx\codedashprev\codedash 
+      \ifx\codedashprev\codedash
       \else \discretionary{}{}{}\fi
     \fi
     % we need the space after the = for the case when \next itself is a
@@ -3003,7 +3007,7 @@
         % For pdfTeX and LuaTeX
         \ifurefurlonlylink
           % PDF plus option to not display url, show just arg
-          \unhbox0             
+          \unhbox0
         \else
           % PDF, normally display both arg and url for consistency,
           % visibility, if the pdf is eventually used to print, etc.
@@ -3016,7 +3020,7 @@
           % For XeTeX
           \ifurefurlonlylink
             % PDF plus option to not display url, show just arg
-            \unhbox0             
+            \unhbox0
           \else
             % PDF, normally display both arg and url for consistency,
             % visibility, if the pdf is eventually used to print, etc.
@@ -3074,10 +3078,10 @@
   }
 }
 
-% By default we'll break after the special characters, but some people like to 
-% break before the special chars, so allow that.  Also allow no breaking at 
+% By default we'll break after the special characters, but some people like to
+% break before the special chars, so allow that.  Also allow no breaking at
 % all, for manual control.
-% 
+%
 \parseargdef\urefbreakstyle{%
   \def\txiarg{#1}%
   \ifx\txiarg\wordnone
@@ -3095,11 +3099,16 @@
 \def\wordbefore{before}
 \def\wordnone{none}
 
-% Allow a ragged right output to aid breaking long URL's.  Putting stretch in 
-% between characters of the URL doesn't look good.
+% Allow a ragged right output to aid breaking long URL's.  There can
+% be a break at the \allowbreak with no extra glue (if the existing stretch in
+% the line is sufficent), a break at the \penalty100 with extra glue added
+% at the end of the line, or no break at all here.
+%   Changing the value of the penalty and/or the amount of stretch affects how
+% preferrable one choice is over the other.
 \def\urefallowbreak{%
+  \allowbreak
   \hskip 0pt plus 4 em\relax
-  \allowbreak
+  \penalty100
   \hskip 0pt plus -4 em\relax
 }
 
@@ -3299,7 +3308,7 @@
 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
 % except specified as a normal braced arg, so no newlines to worry about.
-% 
+%
 \def\outfmtnametex{tex}
 %
 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
@@ -3307,7 +3316,7 @@
   \def\inlinefmtname{#1}%
   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
 }
-% 
+%
 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
 % FMTNAME is tex, else ELSE-TEXT.
 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
@@ -3323,7 +3332,7 @@
 % *right* brace they would have to use a command anyway, so they may as
 % well use a command to get a left brace too.  We could re-use the
 % delimiter character idea from \verb, but it seems like overkill.
-% 
+%
 \long\def\inlineraw{\tex \doinlineraw}
 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
 \def\doinlinerawtwo#1,#2,\finish{%
@@ -3600,7 +3609,7 @@
 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
 % package and follow the same conventions.
-% 
+%
 \def\ecfont{\etcfont{e}}
 \def\tcfont{\etcfont{t}}
 %
@@ -3672,7 +3681,7 @@
               after the title page.}}%
 \def\setshortcontentsaftertitlepage{%
   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
-              command; move your @shortcontents and @contents commands if you 
+              command; move your @shortcontents and @contents commands if you
               want the contents after the title page.}}%
 
 \parseargdef\shorttitlepage{%
@@ -3727,7 +3736,7 @@
 % don't worry much about spacing, ragged right.  This should be used
 % inside a \vbox, and fonts need to be set appropriately first. \par should
 % be specified before the end of the \vbox, since a vbox is a group.
-% 
+%
 \def\raggedtitlesettings{%
   \rm
   \hyphenpenalty=10000
@@ -4350,7 +4359,7 @@
 }
 
 % multitable-only commands.
-% 
+%
 % @headitem starts a heading row, which we typeset in bold.  Assignments
 % have to be global since we are inside the implicit group of an
 % alignment entry.  \everycr below resets \everytab so we don't have to
@@ -4669,13 +4678,13 @@
 % Like \expandablevalue, but completely expandable (the \message in the
 % definition above operates at the execution level of TeX).  Used when
 % writing to auxiliary files, due to the expansion that \write does.
-% If flag is undefined, pass through an unexpanded @value command: maybe it 
+% If flag is undefined, pass through an unexpanded @value command: maybe it
 % will be set by the time it is read back in.
 %
 % NB flag names containing - or _ may not work here.
 \def\dummyvalue#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
-    \noexpand\value{#1}%
+    \string\value{#1}%
   \else
     \csname SET#1\endcsname
   \fi
@@ -4693,7 +4702,7 @@
 
 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 % with @set.
-% 
+%
 % To get the special treatment we need for `@end ifset,' we call
 % \makecond and then redefine.
 %
@@ -4726,7 +4735,7 @@
 % without the @) is in fact defined.  We can only feasibly check at the
 % TeX level, so something like `mathcode' is going to considered
 % defined even though it is not a Texinfo command.
-% 
+%
 \makecond{ifcommanddefined}
 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
 %
@@ -4834,8 +4843,8 @@
 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
 
-

-% Used for the aux, toc and index files to prevent expansion of Texinfo 
+
+% Used for the aux, toc and index files to prevent expansion of Texinfo
 % commands.
 %
 \def\atdummies{%
@@ -4843,6 +4852,7 @@
   \definedummyletter\ %
   \definedummyletter\{%
   \definedummyletter\}%
+  \definedummyletter\&%
   %
   % Do the redefinitions.
   \definedummies
@@ -4913,6 +4923,7 @@
   \definedummyword\TeX
   %
   % Assorted special characters.
+  \definedummyword\ampchar
   \definedummyword\atchar
   \definedummyword\arrow
   \definedummyword\backslashchar
@@ -5180,9 +5191,9 @@
 }
 \def\defglyph#1#2{\def#1##1{#2}} % see above
 
-

 
 
+
 % #1 is the index name, #2 is the entry text.
 \def\doind#1#2{%
   \iflinks
@@ -5207,7 +5218,7 @@
   \ifx\suffix\indexisfl\def\suffix{f1}\fi
   % Open the file
   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
-  % Using \immediate above here prevents an object entering into the current 
+  % Using \immediate above here prevents an object entering into the current
   % box, which could confound checks such as those in \safewhatsit for
   % preceding skips.
   \typeout{Writing index file \jobname.\suffix}%
@@ -5259,7 +5270,7 @@
   \ifx\segment\isfinish
   \else
     %
-    % Fully expand the segment, throwing away any @sortas directives, and 
+    % Fully expand the segment, throwing away any @sortas directives, and
     % trim spaces.
     \edef\trimmed{\segment}%
     \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
@@ -5317,12 +5328,12 @@
 % the current value of \escapechar.
 \def\escapeisbackslash{\escapechar=`\\}
 
-% Use \ in index files by default.  texi2dvi didn't support @ as the escape 
-% character (as it checked for "\entry" in the files, and not "@entry").  When 
-% the new version of texi2dvi has had a chance to become more prevalent, then 
-% the escape character can change back to @ again.  This should be an easy 
-% change to make now because both @ and \ are only used as escape characters in 
-% index files, never standing for themselves. 
+% Use \ in index files by default.  texi2dvi didn't support @ as the escape
+% character (as it checked for "\entry" in the files, and not "@entry").  When
+% the new version of texi2dvi has had a chance to become more prevalent, then
+% the escape character can change back to @ again.  This should be an easy
+% change to make now because both @ and \ are only used as escape characters in
+% index files, never standing for themselves.
 %
 \set txiindexescapeisbackslash
 
@@ -5342,7 +5353,7 @@
   \def\}{\rbracechar{}}%
   \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
   %
-  % Split the entry into primary entry and any subentries, and get the index 
+  % Split the entry into primary entry and any subentries, and get the index
   % sort key.
   \splitindexentry\indextext
   %
@@ -5523,18 +5534,18 @@
     \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
       \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
 \errmessage{%
-ERROR: A sorted index file in an obsolete format was skipped.  
+ERROR: A sorted index file in an obsolete format was skipped.
 To fix this problem, please upgrade your version of 'texi2dvi'
 or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
-If you are using an old version of 'texindex' (part of the Texinfo 
+If you are using an old version of 'texindex' (part of the Texinfo
 distribution), you may also need to upgrade to a newer version (at least 6.0).
 You may be able to typeset the index if you run
 'texindex \jobname.\indexname' yourself.
-You could also try setting the 'txiindexescapeisbackslash' flag by 
+You could also try setting the 'txiindexescapeisbackslash' flag by
 running a command like
-'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do 
+'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
 this, Texinfo will try to use index files in the old format.
-If you continue to have problems, deleting the index files and starting again 
+If you continue to have problems, deleting the index files and starting again
 might help (with 'rm \jobname.?? \jobname.??s')%
 }%
       \else
@@ -5603,7 +5614,7 @@
   % bottom of a column to reduce an increase in inter-line spacing.
   \nobreak
   \vskip 0pt plus 5\baselineskip
-  \penalty -300 
+  \penalty -300
   \vskip 0pt plus -5\baselineskip
   %
   % Typeset the initial.  Making this add up to a whole number of
@@ -5719,7 +5730,7 @@
       \advance\dimen at ii by 1\dimen at i
       \ifdim\wd\boxA > \dimen at ii % If the entry doesn't fit in one line
       \ifdim\dimen@ > 0.8\dimen at ii   % due to long index text
-        % Try to split the text roughly evenly.  \dimen@ will be the length of 
+        % Try to split the text roughly evenly.  \dimen@ will be the length of
         % the first line.
         \dimen@ = 0.7\dimen@
         \dimen at ii = \hsize
@@ -5927,7 +5938,7 @@
 \newbox\balancedcolumns
 \setbox\balancedcolumns=\vbox{shouldnt see this}%
 %
-% Only called for the last of the double column material.  \doublecolumnout 
+% Only called for the last of the double column material.  \doublecolumnout
 % does the others.
 \def\balancecolumns{%
   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
@@ -5955,7 +5966,7 @@
     }%
     % Now the left column is in box 1, and the right column in box 3.
     %
-    % Check whether the left column has come out higher than the page itself.  
+    % Check whether the left column has come out higher than the page itself.
     % (Note that we have doubled \vsize for the double columns, so
     % the actual height of the page is 0.5\vsize).
     \ifdim2\ht1>\vsize
@@ -6252,7 +6263,7 @@
 \let\top\unnumbered
 
 % Sections.
-% 
+%
 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
 \def\seczzz#1{%
   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
@@ -6275,7 +6286,7 @@
 }
 
 % Subsections.
-% 
+%
 % normally calls numberedsubseczzz:
 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
 \def\numberedsubseczzz#1{%
@@ -6300,7 +6311,7 @@
 }
 
 % Subsubsections.
-% 
+%
 % normally numberedsubsubseczzz:
 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
 \def\numberedsubsubseczzz#1{%
@@ -7358,7 +7369,7 @@
 
 % @indentedblock is like @quotation, but indents only on the left and
 % has no optional argument.
-% 
+%
 \makedispenvdef{indentedblock}{\indentedblockstart}
 %
 \def\indentedblockstart{%
@@ -7658,7 +7669,7 @@
 % @deftypefnnewline on|off says whether the return type of typed functions
 % are printed on their own line.  This affects @deftypefn, @deftypefun,
 % @deftypeop, and @deftypemethod.
-% 
+%
 \parseargdef\deftypefnnewline{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -7677,8 +7688,8 @@
 % \dosubind {index}{topic}{subtopic}
 %
 % If SUBTOPIC is present, precede it with a space, and call \doind.
-% (At some time during the 20th century, this made a two-level entry in an 
-% index such as the operation index.  Nobody seemed to notice the change in 
+% (At some time during the 20th century, this made a two-level entry in an
+% index such as the operation index.  Nobody seemed to notice the change in
 % behaviour though.)
 \def\dosubind#1#2#3{%
   \def\thirdarg{#3}%
@@ -7853,7 +7864,7 @@
       \tclose{\temp}% typeset the return type
       \ifrettypeownline
         % put return type on its own line; prohibit line break following:
-        \hfil\vadjust{\nobreak}\break  
+        \hfil\vadjust{\nobreak}\break
       \else
         \space  % type on same line, so just followed by a space
       \fi
@@ -8000,7 +8011,7 @@
   \scantokens{#1 at comment}%
   %
   % The \comment is to remove the \newlinechar added by \scantokens, and
-  % can be noticed by \parsearg.  Note \c isn't used because this means cedilla 
+  % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
   % in math mode.
 }
 
@@ -8201,7 +8212,7 @@
 % list to some hook where the argument is to be expanded.  If there are
 % less than 10 arguments that hook is to be replaced by ##N where N
 % is the position in that list, that is to say the macro arguments are to be
-% defined `a la TeX in the macro body.  
+% defined `a la TeX in the macro body.
 %
 % That gets used by \mbodybackslash (above).
 %
@@ -8232,8 +8243,8 @@
 %
 % Read recursive and nonrecursive macro bodies. (They're different since
 % rec and nonrec macros end differently.)
-% 
-% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
+%
+% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
 % body to be transformed.
 % Set \macrobody to the body of the macro, and call \defmacro.
 %
@@ -8267,7 +8278,7 @@
 % twice the \macarg.BLAH macros does not cost too much processing power.
 \def\parsemmanyargdef@@#1,{%
   \if#1;\let\next=\relax
-  \else 
+  \else
     \let\next=\parsemmanyargdef@@
     \edef\tempb{\eatspaces{#1}}%
     \expandafter\def\expandafter\tempa
@@ -8352,7 +8363,7 @@
 
 % Replace arguments by their values in the macro body, and place the result
 % in macro \@tempa.
-% 
+%
 \def\macvalstoargs@{%
   %  To do this we use the property that token registers that are \the'ed
   % within an \edef  expand only once. So we are going to place all argument
@@ -8376,9 +8387,9 @@
   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
   }
 
-% Define the named-macro outside of this group and then close this group. 
-% 
-\def\macargexpandinbody@{% 
+% Define the named-macro outside of this group and then close this group.
+%
+\def\macargexpandinbody@{%
   \expandafter
   \endgroup
   \macargdeflist@
@@ -8416,7 +8427,7 @@
 }
 
 % Trailing missing arguments are set to empty.
-% 
+%
 \def\setemptyargvalues@{%
   \ifx\paramlist\nilm@
     \let\next\macargexpandinbody@
@@ -8493,7 +8504,7 @@
   \else % at most 9
     \ifnum\paramno<10\relax
       % @MACNAME sets the context for reading the macro argument
-      % @MACNAME@@ gets the argument, processes backslashes and appends a 
+      % @MACNAME@@ gets the argument, processes backslashes and appends a
       % comma.
       % @MACNAME@@@ removes braces surrounding the argument list.
       % @MACNAME@@@@ scans the macro body with arguments substituted.
@@ -8537,11 +8548,11 @@
 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
 % compressed to one.
 %
-% This implementation works by expansion, and not execution (so we cannot use 
-% \def or similar).  This reduces the risk of this failing in contexts where 
-% complete expansion is done with no execution (for example, in writing out to 
+% This implementation works by expansion, and not execution (so we cannot use
+% \def or similar).  This reduces the risk of this failing in contexts where
+% complete expansion is done with no execution (for example, in writing out to
 % an auxiliary file for an index entry).
-% 
+%
 % State is kept in the input stream: the argument passed to
 % @look_ahead, @gobble_and_check_finish and @add_segment is
 %
@@ -8563,11 +8574,11 @@
 % #3 - NEXT_TOKEN
 % #4 used to look ahead
 %
-% If the next token is not a backslash, process the rest of the argument; 
+% If the next token is not a backslash, process the rest of the argument;
 % otherwise, remove the next token.
 @gdef at look_ahead#1!#2#3#4{%
   @ifx#4\%
-   @expandafter at gobble_and_check_finish 
+   @expandafter at gobble_and_check_finish
   @else
    @expandafter at add_segment
   @fi#1!{#2}#4#4%
@@ -8591,9 +8602,9 @@
 % #3 - NEXT_TOKEN
 % #4 is input stream until next backslash
 %
-% Input stream is either at the start of the argument, or just after a 
-% backslash sequence, either a lone backslash, or a doubled backslash.  
-% NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
+% Input stream is either at the start of the argument, or just after a
+% backslash sequence, either a lone backslash, or a doubled backslash.
+% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
 % a backslash just before the start of the input stream that has not been
@@ -8605,13 +8616,13 @@
   % append the pending backslash to the result, followed by the next segment
   @expandafter at is_fi@look_ahead#1#2#4!{\}@fi
   % this @fi is discarded by @look_ahead.
-  % we can't get rid of it with \expandafter because we don't know how 
+  % we can't get rid of it with \expandafter because we don't know how
   % long #4 is.
 }
 
 % #1 - THE_MACRO
 % #2 - ARG_RESULT
-% #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
+% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
 % conditional.
 @gdef at call_the_macro#1#2!#3 at fi{@is_fi #1{#2}}
 
@@ -8623,7 +8634,7 @@
 % for reading the argument (slightly different in the two cases).  Then,
 % to read the argument, in the whole-line case, it then calls the regular
 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
-% 
+%
 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
 \def\braceorlinexxx{%
   \ifx\nchar\bgroup
@@ -8677,7 +8688,7 @@
 
 % Used so that the @top node doesn't have to be wrapped in an @ifnottex
 % conditional.
-% \doignore goes to more effort to skip nested conditionals but we don't need 
+% \doignore goes to more effort to skip nested conditionals but we don't need
 % that here.
 \def\omittopnode{%
    \ifx\lastnode\wordTop
@@ -8685,7 +8696,7 @@
 }
 \def\wordTop{Top}
 
-% Until the next @node or @bye command, divert output to a box that is not 
+% Until the next @node or @bye command, divert output to a box that is not
 % output.
 \def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
 \ignorenodebye
@@ -8752,7 +8763,7 @@
 % automatically in xrefs, if the third arg is not explicitly specified.
 % This was provided as a "secret" @set xref-automatic-section-title
 % variable, now it's official.
-% 
+%
 \parseargdef\xrefautomaticsectiontitle{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -8768,7 +8779,7 @@
   \fi\fi
 }
 
-% 

+%
 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
 % the node name, #2 the name of the Info cross-reference, #3 the printed
 % node name, #4 the name of the Info file, #5 the name of the printed
@@ -8921,7 +8932,7 @@
     \fi
   \else
     % node/anchor (non-float) references.
-    % 
+    %
     % If we use \unhbox to print the node names, TeX does not insert
     % empty discretionaries after hyphens, which means that it will not
     % find a line break at a hyphen in a node names.  Since some manuals
@@ -8928,10 +8939,10 @@
     % are best written with fairly long node names, containing hyphens,
     % this is a loss.  Therefore, we give the text of the node name
     % again, so it is as if TeX is seeing it for the first time.
-    % 
+    %
     \ifdim \wd\printedmanualbox > 0pt
       % Cross-manual reference with a printed manual name.
-      % 
+      %
       \crossmanualxref{\cite{\printedmanual\unskip}}%
     %
     \else\ifdim \wd\infofilenamebox > 0pt
@@ -8938,7 +8949,7 @@
       % Cross-manual reference with only an info filename (arg 4), no
       % printed manual name (arg 5).  This is essentially the same as
       % the case above; we output the filename, since we have nothing else.
-      % 
+      %
       \crossmanualxref{\code{\infofilename\unskip}}%
     %
     \else
@@ -8978,20 +8989,20 @@
 \endgroup}
 
 % Output a cross-manual xref to #1.  Used just above (twice).
-% 
+%
 % Only include the text "Section ``foo'' in" if the foo is neither
 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
 % "see The Foo Manual", the idea being to refer to the whole manual.
-% 
+%
 % But, this being TeX, we can't easily compare our node name against the
 % string "Top" while ignoring the possible spaces before and after in
 % the input.  By adding the arbitrary 7sp below, we make it much less
 % likely that a real node name would have the same width as "Top" (e.g.,
 % in a monospaced font).  Hopefully it will never happen in practice.
-% 
+%
 % For the same basic reason, we retypeset the "Top" at every
 % reference, since the current font is indeterminate.
-% 
+%
 \def\crossmanualxref#1{%
   \setbox\toprefbox = \hbox{Top\kern7sp}%
   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
@@ -9038,7 +9049,7 @@
   \fi\fi\fi
 }
 
-% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
+% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX
 % is output afterwards if non-empty.
 \def\refx#1#2{%
   \requireauxfile
@@ -9070,9 +9081,9 @@
   #2% Output the suffix in any case.
 }
 
-% This is the macro invoked by entries in the aux file.  Define a control 
-% sequence for a cross-reference target (we prepend XR to the control sequence 
-% name to avoid collisions).  The value is the page number.  If this is a float 
+% This is the macro invoked by entries in the aux file.  Define a control
+% sequence for a cross-reference target (we prepend XR to the control sequence
+% name to avoid collisions).  The value is the page number.  If this is a float
 % type, we have more work to do.
 %
 \def\xrdef#1#2{%
@@ -9088,10 +9099,10 @@
   \bgroup
     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
   \egroup
-  % We put the \gdef inside a group to avoid the definitions building up on 
-  % TeX's save stack, which can cause it to run out of space for aux files with 
+  % We put the \gdef inside a group to avoid the definitions building up on
+  % TeX's save stack, which can cause it to run out of space for aux files with
   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
-  % when it defines an unknown control sequence as \relax. 
+  % when it defines an unknown control sequence as \relax.
   %
   % Was that xref control sequence that we just defined for a float?
   \expandafter\iffloat\csname XR\safexrefname\endcsname
@@ -9450,7 +9461,7 @@
   %
   \ifimagevmode
     \medskip  % space after a standalone image
-  \fi  
+  \fi
   \ifx\centersub\centerV \egroup \fi
 \endgroup}
 
@@ -10281,7 +10292,7 @@
         \uppercase{.}
       \endgroup
     \else
-      \errhelp = \EMsimple	
+      \errhelp = \EMsimple
       \errmessage{Unicode character U+#1 not supported, sorry}%
     \fi
   \else
@@ -10314,7 +10325,7 @@
     \countUTFz = "#1\relax
     \begingroup
       \parseXMLCharref
-    
+
       % Give \u8:... its definition.  The sequence of seven \expandafter's
       % expands after the \gdef three times, e.g.
       %
@@ -10326,7 +10337,7 @@
       \expandafter\expandafter
       \expandafter\expandafter
       \expandafter\gdef       \UTFviiiTmp{#2}%
-      % 
+      %
       \expandafter\ifx\csname uni:#1\endcsname \relax \else
        \message{Internal error, already defined: #1}%
       \fi
@@ -10365,7 +10376,7 @@
     \divide\countUTFz by 64
     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
     \multiply\countUTFz by 64
-    
+
     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
     % in order to get the last five bits.
     \advance\countUTFx by -\countUTFz
@@ -10400,7 +10411,7 @@
 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
-% 
+%
 % Many of our renditions are less than wonderful, and all the missing
 % characters are available somewhere.  Loading the necessary fonts
 % awaits user request.  We can't truly support Unicode without
@@ -11438,9 +11449,9 @@
 \def\texinfochars{%
   \let< = \activeless
   \let> = \activegtr
-  \let~ = \activetilde 
+  \let~ = \activetilde
   \let^ = \activehat
-  \markupsetuplqdefault \markupsetuprqdefault 
+  \markupsetuplqdefault \markupsetuprqdefault
   \let\b = \strong
   \let\i = \smartitalic
   % in principle, all other definitions in \tex have to be undone too.

Modified: branches/stable/source/src/doc/ChangeLog
===================================================================
--- branches/stable/source/src/doc/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/doc/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,7 @@
+2019-08-11  Karl Berry  <karl at freefriends.org>
+
+	* tlbuild.texi (Build one package): rm sources to build without C++11.
+
 2018-04-10  Karl Berry  <karl at tug.org>
 
 	* tlbuild.texi (Cross compilation): move to under Building.
@@ -5,7 +9,6 @@
 	
 	* Makefile.am (*_node_{good,bad}): update for current pod doc.
 	($(mydoc)-incl.texi): hint to symlink scripts for pod2texi.
-	
 
 2018-02-20  Karl Berry  <karl at freefriends.org>
 

Modified: branches/stable/source/src/doc/build-tools.txt
===================================================================
--- branches/stable/source/src/doc/build-tools.txt	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/doc/build-tools.txt	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
 autoconf (GNU Autoconf) 2.69
 automake (GNU automake) 1.16.1
-bison (GNU Bison) 3.3.1
+bison (GNU Bison) 3.4.2
 flex 2.6.0
 ltmain.sh (GNU libtool) 2.4.6
 m4 (GNU M4) 1.4.18
-makeinfo (GNU texinfo) 6.6
+makeinfo (GNU texinfo) 6.7

Added: branches/stable/source/src/doc/buildinfo.sh
===================================================================
--- branches/stable/source/src/doc/buildinfo.sh	                        (rev 0)
+++ branches/stable/source/src/doc/buildinfo.sh	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,60 @@
+#!/bin/sh
+# $Id: buildinfo.sh 51449 2019-06-24 22:12:32Z karl $
+# Public domain. Report basics of current system; run from top-level
+# Makefile so any make overrides will be taken into account. (And from
+# Build.) buildenv.log with full environment dump is also created.
+
+do_config_status=true
+if test "x$1" = x--no-config-status; then
+  shift
+  do_config_status=false
+fi
+
+printf 'UNAME\t"%s"\n'    "`uname -a`"
+
+# /etc/issue often contains only placeholders, so don't bother with it.
+
+# Return version identification for $1, by calling it with --version.
+# gcc on Macs, when linked to cc, has a useless "Configured with:" as
+# the first line. Likely we'll need to generalize for other compilers.
+# We intentionally don't quote $1 in case CC was set to something like
+# "cc --someopt".
+compiler_version () {
+  $1 --version 2>&1 | grep -v '^Configured' | sed 1q
+}
+
+printf 'MAKE\t"%s"\n'     "${MAKE-make}"
+printf 'MAKE-v\t"%s"\n'   "`${MAKE-make} -v 2>&1 | sed 1q`"
+# BSD make does not give version info with -v, but the
+# first line of the usage message is sort of an identifier.
+
+# our configure defaults to using gcc and g++, so we will too.
+printf 'CC\t"%s"\n'       "${CC-gcc}"
+printf 'CFLAGS\t"%s"\n'   "${CFLAGS}"
+printf 'CC-v\t"%s"\n'     "`compiler_version ${CC-gcc}`"
+# 
+printf 'CXX\t"%s"\n'      "${CXX-g++}"
+printf 'CXXFLAGS\t"%s"\n' "${CXXFLAGS}"
+printf 'CXX-v\t"%s"\n'    "`compiler_version ${CXX-g++}`"
+#
+printf 'OBJCXX\t"%s"\n'      "${OBJCXX-cc}"
+printf 'OBJCXXFLAGS\t"%s"\n' "${OBJCXXFLAGS}"
+#
+printf 'LDFLAGS\t"%s"\n'  "${LDFLAGS}"
+
+# Some Linux-based systems provide this, but don't worry if not there.
+# Let's hope that other systems are sufficiently identified by uname,
+# don't feel like doing a big system-information hunt. But if we do:
+#   http://www.datadisk.co.uk/html_docs/misc/unix_commands.htm
+if test -n "`lsb_release -a 2>/dev/null`"; then
+  printf '\nLSB_RELEASE\n'
+  lsb_release -a 2>&1
+fi
+
+# the whole configure line and more, if requested.
+# (We want this from make, but not from Build.)
+$do_config_status \
+&& test -s config.status \
+&& (printf '\nCONFIG_STATUS\n'; ./config.status --version | sed -n '1,/^$/p')
+
+exit 0


Property changes on: branches/stable/source/src/doc/buildinfo.sh
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: branches/stable/source/src/doc/tlbuild.cp
===================================================================
--- branches/stable/source/src/doc/tlbuild.cp	                        (rev 0)
+++ branches/stable/source/src/doc/tlbuild.cp	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,372 @@
+\entry{introduction}{1}{introduction}
+\entry{build system, design of}{2}{build system, design of}
+\entry{Autoconf}{2}{Autoconf}
+\entry{Automake}{2}{Automake}
+\entry{Libtool}{2}{Libtool}
+\entry{tests, running}{2}{tests, running}
+\entry{kpse-pkgs.m4}{2}{\code {kpse-pkgs.m4}}
+\entry{prerequisites for building}{3}{prerequisites for building}
+\entry{requirements for building}{3}{requirements for building}
+\entry{compilers, C and C++11}{3}{compilers, C and C++11}
+\entry{GNU make, required}{3}{GNU \code {make}, required}
+\entry{gmake, required}{3}{\code {gmake}, required}
+\entry{FreeType}{3}{FreeType}
+\entry{C++11, required}{3}{C++11, required}
+\entry{perl, required by web2c, etc.}{3}{\code {perl}, required by \code {web2c}, etc.}
+\entry{X11 development, required by X clients}{3}{X11 development, required by X clients}
+\entry{fontconfig library, required by xetex}{3}{\code {fontconfig} library, required by \code {xetex}}
+\entry{ApplicationServices Mac framework, required by xetex}{3}{\code {ApplicationServices} Mac framework, required by \code {xetex}}
+\entry{Cocoa Mac framework, required by xetex}{3}{\code {Cocoa} Mac framework, required by \code {xetex}}
+\entry{clisp, required by xindy}{3}{\code {clisp}, required by \code {xindy}}
+\entry{libsigsegv, required by xindy}{3}{\code {libsigsegv}, required by \code {xindy}}
+\entry{building}{4}{building}
+\entry{overall build process}{4}{overall build process}
+\entry{Build script}{4}{\code {Build \r {script}}}
+\entry{source directory building, not supported}{4}{source directory building, not supported}
+\entry{build directory, required}{4}{build directory, required}
+\entry{build iteration}{4}{build iteration}
+\entry{iteration through sources, by configure and make}{4}{iteration through sources, by \code {configure} and \code {make}}
+\entry{build problems}{4}{build problems}
+\entry{problems with build}{4}{problems with build}
+\entry{failure to build}{4}{failure to build}
+\entry{--no-clean Build option}{4}{\code {--no-clean Build \r {option}}}
+\entry{building in parallel}{4}{building in parallel}
+\entry{parallel build}{4}{parallel build}
+\entry{cache for configure}{4}{cache for \code {configure}}
+\entry{dependencies, with several output files}{4}{dependencies, with several output files}
+\entry{-j make option}{4}{\code {-j make \r {option}}}
+\entry{cache file, for configure}{4}{cache file, for \code {configure}}
+\entry{-C configure option}{4}{\code {-C configure \r {option}}}
+\entry{building a distribution}{4}{building a distribution}
+\entry{distribution tarball, making}{4}{distribution tarball, making}
+\entry{dist and distcheck targets for make}{4}{\code {dist} and \code {distcheck} targets for \code {make}}
+\entry{build one package}{5}{build one package}
+\entry{one package, building}{5}{one package, building}
+\entry{--disable-all-packages}{5}{\code {--disable-all-packages}}
+\entry{build on demand}{5}{build on demand}
+\entry{size of source tree}{6}{size of source tree}
+\entry{--enable-missing to ignore dependencies}{6}{\code {--enable-missing \r {to ignore dependencies}}}
+\entry{CC=c-compiler}{6}{\code {CC=\var {c-compiler}}}
+\entry{CXX=c++-compiler}{6}{\code {CXX=\var {c++-compiler}}}
+\entry{OBJCXX=objc-compiler}{6}{\code {OBJCXX=\var {objc-compiler}}}
+\entry{gcc, default compilers}{6}{\code {gcc\r {, default compilers}}}
+\entry{build one engine}{6}{build one engine}
+\entry{one engine, building}{6}{one engine, building}
+\entry{engine, building one}{6}{engine, building one}
+\entry{cross compilation}{6}{cross compilation}
+\entry{native cross compilation}{6}{native cross compilation}
+\entry{cross compilation configuring}{7}{cross compilation configuring}
+\entry{configuring, for cross compilation}{7}{configuring, for cross compilation}
+\entry{--host=host}{7}{\code {--host=\var {host}}}
+\entry{--build=host}{7}{\code {--build=\var {host}}}
+\entry{mingw32}{7}{\code {mingw32}}
+\entry{BUILDCC, BUILDCFLAGS, ...}{7}{\code {BUILDCC\r {,} BUILDCFLAGS\r {, \dots {}}}}
+\entry{cross compilation problems}{7}{cross compilation problems}
+\entry{squeeze}{8}{\code {squeeze}}
+\entry{web2c program}{8}{\code {web2c \r {program}}}
+\entry{freetype cross compiling}{8}{\code {freetype} cross compiling}
+\entry{CC_BUILD}{8}{\code {CC_BUILD}}
+\entry{ICU cross compiling}{8}{ICU cross compiling}
+\entry{tangle}{8}{\code {tangle}}
+\entry{ctangle}{8}{\code {ctangle}}
+\entry{otangle}{8}{\code {otangle}}
+\entry{tie}{8}{\code {tie}}
+\entry{xindy cross compiling impossible}{8}{\code {xindy} cross compiling impossible}
+\entry{installing}{9}{installing}
+\entry{support files, separate from build}{9}{support files, separate from build}
+\entry{texlive.tlpdb,  database}{9}{\code {texlive.tlpdb\r {, \TL {} database}}}
+\entry{install-tl,  installer}{9}{\code {install-tl\r {, \TL {} installer}}}
+\entry{plain.tex, not in source tree}{9}{\code {plain.tex\r {, not in source tree}}}
+\entry{installation directories}{9}{installation directories}
+\entry{directories, for installation}{9}{directories, for installation}
+\entry{paths, for installation}{9}{paths, for installation}
+\entry{linked scripts}{9}{linked scripts}
+\entry{scripts, linked and not maintained}{9}{scripts, linked and not maintained}
+\entry{symlinks, used for scripts}{9}{symlinks, used for scripts}
+\entry{wrapper binary for scripts on Windows}{9}{wrapper binary for scripts on Windows}
+\entry{Windows, invoking scripts on}{9}{Windows, invoking scripts on}
+\entry{asymptote}{10}{\code {asymptote}}
+\entry{biber}{10}{\code {biber}}
+\entry{xindy}{10}{\code {xindy}}
+\entry{xz}{10}{\code {xz}}
+\entry{wget}{10}{\code {wget}}
+\entry{distro, building for}{10}{distro, building for}
+\entry{operating system distribution, building for}{10}{operating system distribution, building for}
+\entry{system distribution, building for}{10}{system distribution, building for}
+\entry{GNU/Linux distro}{10}{GNU/Linux distro}
+\entry{BSD distro}{10}{BSD distro}
+\entry{shared libraries, using vs. avoiding}{10}{shared libraries, using vs.\: avoiding}
+\entry{Preining, Norbert}{11}{Preining, Norbert}
+\entry{adapting  for distros}{11}{adapting \TL {} for distros}
+\entry{layout of sources}{12}{layout of sources}
+\entry{source tree}{12}{source tree}
+\entry{tools, for building}{12}{tools, for building}
+\entry{GNU tools, needed for building}{12}{GNU tools, needed for building}
+\entry{infrastructure, tools needed for}{12}{infrastructure, tools needed for}
+\entry{reautoconf}{12}{\code {reautoconf}}
+\entry{--enable-maintainer-mode}{12}{\code {--enable-maintainer-mode}}
+\entry{Subversion repository}{12}{Subversion repository}
+\entry{timestamps, in repository}{12}{timestamps, in repository}
+\entry{use-commit-times, Subversion}{12}{\code {use-commit-times\r {, Subversion}}}
+\entry{touching files to avoid rerunning}{12}{touching files to avoid rerunning}
+\entry{make -t}{12}{\code {make -t}}
+\entry{directories, top-level}{12}{directories, top-level}
+\entry{top-level directories}{12}{top-level directories}
+\entry{am/ top-level directory}{12}{\file {am/} top-level directory}
+\entry{m4/ top-level directory}{12}{\file {m4/} top-level directory}
+\entry{build-aux/ top-level directory}{13}{\file {build-aux/} top-level directory}
+\entry{config.guess, config.sub, ...}{13}{\code {config.guess\r {,} config.sub, \dots {}}}
+\entry{Gnulib, used for common files}{13}{Gnulib, used for common files}
+\entry{Work/ top-level directory}{13}{\file {Work/} top-level directory}
+\entry{inst/ top-level directory}{13}{\file {inst/} top-level directory}
+\entry{autoconf macros}{13}{autoconf macros}
+\entry{general setup macros}{13}{general setup macros}
+\entry{setup macros, general}{13}{setup macros, general}
+\entry{macros, general setup}{13}{macros, general setup}
+\entry{KPSE_BASIC}{13}{\code {KPSE_BASIC}}
+\entry{KPSE_COMMON}{13}{\code {KPSE_COMMON}}
+\entry{macros, for programs}{14}{macros, for programs}
+\entry{KPSE_CHECK_LATEX}{14}{\code {KPSE_CHECK_LATEX}}
+\entry{KPSE_CHECK_PDFLATEX}{14}{\code {KPSE_CHECK_PDFLATEX}}
+\entry{KPSE_CHECK_PERL}{14}{\code {KPSE_CHECK_PERL}}
+\entry{KPSE_PROG_LEX}{14}{\code {KPSE_PROG_LEX}}
+\entry{macros, for compilers}{14}{macros, for compilers}
+\entry{KPSE_COMPILER_WARNINGS}{14}{\code {KPSE_COMPILER_WARNINGS}}
+\entry{WARNING_C[XX]FLAGS}{14}{\code {WARNING_C[XX]FLAGS}}
+\entry{kpse_cv_warning_cflags}{14}{\code {kpse_cv_warning_cflags}}
+\entry{KPSE_COMPILER_VISIBILITY}{14}{\code {KPSE_COMPILER_VISIBILITY}}
+\entry{kpse_cv_visibility_c[xx]flags}{14}{\code {kpse_cv_visibility_c[xx]flags}}
+\entry{KPSE_CXX_HACK}{14}{\code {KPSE_CXX_HACK}}
+\entry{static linking for C++}{14}{static linking for C++}
+\entry{linking C++ libraries statically}{14}{linking C++ libraries statically}
+\entry{--enable-cxx-runtime-hack}{14}{\code {--enable-cxx-runtime-hack}}
+\entry{libstc++, statically linking}{14}{\code {libstc++\r {, statically linking}}}
+\entry{kpse_cv_cxx_hack}{14}{\code {kpse_cv_cxx_hack}}
+\entry{macros, for libraries}{14}{macros, for libraries}
+\entry{KPSE_LARGEFILE}{14}{\code {KPSE_LARGEFILE}}
+\entry{macros, for library and header flags}{15}{macros, for library and header flags}
+\entry{flags, macros for library and header}{15}{flags, macros for library and header}
+\entry{KPSE_LIB_FLAGS}{15}{\code {KPSE_\var {LIB}_FLAGS}}
+\entry{KPSE_LIBPNG_FLAGS}{15}{\code {KPSE_LIBPNG_FLAGS}}
+\entry{KPSE_ADD_FLAGS}{15}{\code {KPSE_ADD_FLAGS}}
+\entry{KPSE_RESTORE_FLAGS}{15}{\code {KPSE_RESTORE_FLAGS}}
+\entry{macros, for Windows}{15}{macros, for Windows}
+\entry{Windows, macros for}{15}{Windows, macros for}
+\entry{KPSE_CHECK_WIN32}{16}{\code {KPSE_CHECK_WIN32}}
+\entry{kpse_cv_have_win32}{16}{\code {kpse_cv_have_win32}}
+\entry{KPSE_COND_WIN32}{16}{\code {KPSE_COND_WIN32}}
+\entry{WIN32, Automake conditional}{16}{\code {WIN32\r {, Automake conditional}}}
+\entry{KPSE_COND_MINGW32}{16}{\code {KPSE_COND_MINGW32}}
+\entry{MINGW32, Automake conditional}{16}{\code {MINGW32\r {, Automake conditional}}}
+\entry{KPSE_COND_WIN32_WRAP}{16}{\code {KPSE_COND_WIN32_WRAP}}
+\entry{WIN32_WRAP, Automake conditional}{16}{\code {WIN32_WRAP\r {, Automake conditional}}}
+\entry{runscript.exe}{16}{\code {runscript.exe}}
+\entry{KPSE_WIN32_CALL}{16}{\code {KPSE_WIN32_CALL}}
+\entry{callexe.c}{16}{\code {callexe.c}}
+\entry{library modules}{16}{library modules}
+\entry{modules, for libraries}{16}{modules, for libraries}
+\entry{png library}{16}{\code {png \r {library}}}
+\entry{libpng library}{16}{\code {libpng \r {library}}}
+\entry{KPSE_TRY_LIB}{16}{\code {KPSE_TRY_LIB}}
+\entry{KPSE_TRY_LIBXX}{17}{\code {KPSE_TRY_LIBXX}}
+\entry{proxy build system}{17}{proxy build system}
+\entry{kpse-libpng-flags.m4}{17}{\code {kpse-libpng-flags.m4}}
+\entry{KPSE_LIBPNG_FLAGS}{17}{\code {KPSE_LIBPNG_FLAGS}}
+\entry{zlib library}{17}{\code {zlib \r {library}}}
+\entry{kpse-zlib-flags.m4}{17}{\code {kpse-zlib-flags.m4}}
+\entry{freetype library}{17}{\code {freetype \r {library}}}
+\entry{wrapper build system}{17}{wrapper build system}
+\entry{freetype-config}{17}{\code {freetype-config}}
+\entry{kpathsea library}{17}{\code {kpathsea \r {library}}}
+\entry{--with-system-kpathsea}{17}{\code {--with-system-kpathsea}}
+\entry{kpathsea.ac}{17}{\code {kpathsea.ac}}
+\entry{mktex.ac}{17}{\code {mktex.ac}}
+\entry{--enable-mktextfm-default}{17}{\code {--enable-mktextfm-default}}
+\entry{mktextfm}{17}{\code {mktextfm}}
+\entry{program modules}{18}{program modules}
+\entry{modules, for programs}{18}{modules, for programs}
+\entry{t1utils package}{18}{\code {t1utils \r {package}}}
+\entry{xindy}{18}{\code {xindy}}
+\entry{xdvik}{18}{\code {xdvik}}
+\entry{squeeze/configure.ac}{18}{\code {squeeze/configure.ac}}
+\entry{cross compilation, with host binary}{18}{cross compilation, with host binary}
+\entry{--with-xdvi-x-toolkit}{18}{\code {--with-xdvi-x-toolkit}}
+\entry{asymptote}{19}{\code {asymptote}}
+\entry{xasy}{19}{\code {xasy}}
+\entry{OpenGL, required for Asymptote}{19}{OpenGL, required for Asymptote}
+\entry{extending }{19}{extending \TL {}}
+\entry{adding to }{19}{adding to \TL {}}
+\entry{adding a new program}{19}{adding a new program}
+\entry{program module, adding}{19}{program module, adding}
+\entry{kpse_texk_pkgs}{19}{\code {kpse_texk_pkgs}}
+\entry{kpse_utils_pkgs}{19}{\code {kpse_utils_pkgs}}
+\entry{withenable.ac, for new modules}{19}{\code {withenable.ac\r {, for new modules}}}
+\entry{KPSE_ENABLE_PROG}{19}{\code {KPSE_ENABLE_PROG}}
+\entry{adding a new generic library}{20}{adding a new generic library}
+\entry{generic library module, adding}{20}{generic library module, adding}
+\entry{library module, generic, adding}{20}{library module, generic, adding}
+\entry{kpse_libs_pkgs}{20}{\code {kpse_libs_pkgs}}
+\entry{KPSE_WITH_LIB}{20}{\code {KPSE_WITH_LIB}}
+\entry{KPSE_TRY_LIB}{20}{\code {KPSE_TRY_LIB}}
+\entry{KPSE_TRY_LIBXX}{20}{\code {KPSE_TRY_LIBXX}}
+\entry{KPSE_LIB_FLAGS}{20}{\code {KPSE_\var {LIB}_FLAGS}}
+\entry{--with-system-lib}{21}{\code {--with-system-\var {lib}}}
+\entry{KPSE_LIB_SYSTEM_FLAGS}{21}{\code {KPSE_\var {LIB}_SYSTEM_FLAGS}}
+\entry{KPSE_ALL_SYSTEM_FLAGS}{21}{\code {KPSE_ALL_SYSTEM_FLAGS}}
+\entry{adding a new TeX{}-specific library}{21}{adding a new \TeX {}-specific library}
+\entry{TeX{}-specific library module, adding}{21}{\TeX {}-specific library module, adding}
+\entry{library module, TeX{}-specific, adding}{21}{library module, \TeX {}-specific, adding}
+\entry{kpse_texlibs_pkgs}{21}{\code {kpse_texlibs_pkgs}}
+\entry{KPSE_WITH_TEXLIB}{21}{\code {KPSE_WITH_TEXLIB}}
+\entry{configure options}{22}{\code {configure} options}
+\entry{environment variables, for configure}{22}{environment variables, for \code {configure}}
+\entry{global configure options}{22}{global \code {configure} options}
+\entry{configure options, global}{22}{\code {configure} options, global}
+\entry{--disable-native-texlive-build}{22}{\code {--disable-native-texlive-build}}
+\entry{--enable-texlive-build}{22}{\code {--enable-texlive-build}}
+\entry{--prefix configure option}{22}{\code {--prefix configure \r {option}}}
+\entry{--bindir configure option}{22}{\code {--bindir configure \r {option}}}
+\entry{DESTDIR}{22}{\code {DESTDIR}}
+\entry{--disable-largefile}{22}{\code {--disable-largefile}}
+\entry{large file support}{22}{large file support}
+\entry{LFS (large file support)}{22}{LFS (large file support)}
+\entry{size of PDF and PS files}{22}{size of PDF and PS files}
+\entry{PDF files, size of}{22}{PDF files, size of}
+\entry{PostScript files, size of}{22}{PostScript files, size of}
+\entry{--disable-missing}{23}{\code {--disable-missing}}
+\entry{--enable-compiler-warnings=level}{23}{\code {--enable-compiler-warnings=\var {level}}}
+\entry{--enable-maintainer-mode}{23}{\code {--enable-maintainer-mode}}
+\entry{--enable-multiplatform}{23}{\code {--enable-multiplatform}}
+\entry{exec_prefix}{23}{\code {exec_prefix}}
+\entry{--bindir configure option}{23}{\code {--bindir configure \r {option}}}
+\entry{--libdir configure option}{23}{\code {--libdir configure \r {option}}}
+\entry{--enable-shared}{23}{\code {--enable-shared}}
+\entry{--enable-silent-rules}{23}{\code {--enable-silent-rules}}
+\entry{make rules, verbose vs. silent}{23}{\code {make} rules, verbose vs.\: silent}
+\entry{--without-ln-s}{23}{\code {--without-ln-s}}
+\entry{--without-x}{24}{\code {--without-x}}
+\entry{program-specific configure options}{24}{program-specific \code {configure} options}
+\entry{configure options, program-specific}{24}{\code {configure} options, program-specific}
+\entry{--enable-prog}{24}{\code {--enable-\var {prog}}}
+\entry{--disable-prog}{24}{\code {--disable-\var {prog}}}
+\entry{--disable-all-pkgs}{24}{\code {--disable-all-pkgs}}
+\entry{configure options, for web2c}{24}{\code {configure} options, for \code {web2c}}
+\entry{--with-banner-add=str}{24}{\code {--with-banner-add=\var {str}}}
+\entry{--with-editor=cmd}{24}{\code {--with-editor=\var {cmd}}}
+\entry{--with-fontconfig-includes=dir}{24}{\code {--with-fontconfig-includes=\var {dir}}}
+\entry{--with-fontconfig-libdir=dir}{24}{\code {--with-fontconfig-libdir=\var {dir}}}
+\entry{X toolkit}{24}{X toolkit}
+\entry{libXt}{24}{\code {libXt}}
+\entry{Xlib}{24}{\code {Xlib}}
+\entry{--disable-dump-share}{24}{\code {--disable-dump-share}}
+\entry{LittleEndian architectures}{24}{LittleEndian architectures}
+\entry{--disable-ipc}{24}{\code {--disable-ipc}}
+\entry{interprocess communication}{24}{interprocess communication}
+\entry{--disable-mf-nowin}{24}{\code {--disable-mf-nowin}}
+\entry{mf-nowin}{24}{\code {mf-nowin}}
+\entry{--disable-tex}{24}{\code {--disable-tex}}
+\entry{--enable-etex}{24}{\code {--enable-etex}}
+\entry{web2c.ac}{24}{\code {web2c.ac}}
+\entry{--disable-web-progs}{24}{\code {--disable-web-progs}}
+\entry{--enable-auto-core}{25}{\code {--enable-auto-core}}
+\entry{preloaded binaries}{25}{preloaded binaries}
+\entry{--enable-libtool-hack}{25}{\code {--enable-libtool-hack}}
+\entry{libtool, hack for avoiding excessive linking}{25}{\code {libtool\r {, hack for avoiding excessive linking}}}
+\entry{libfontconfig, hack for avoiding linking dependencies}{25}{\code {libfontconfig\r {, hack for avoiding linking dependencies}}}
+\entry{libexpat, dependency of libfontconfig}{25}{\code {libexpat\r {, dependency of \code {libfontconfig}}}}
+\entry{--enable-*win for Metafont window support}{25}{\code {--enable-*win \r {for Metafont window support}}}
+\entry{--enable-tex-synctex}{25}{\code {--enable-tex-synctex}}
+\entry{--disable-etex-synctex}{25}{\code {--disable-etex-synctex}}
+\entry{synctex}{25}{synctex}
+\entry{--disable-synctex}{25}{\code {--disable-synctex}}
+\entry{synctex}{25}{synctex}
+\entry{configure options, for bibtex-x}{25}{\code {configure} options, for \code {bibtex-x}}
+\entry{bibtex8}{25}{\code {bibtex8}}
+\entry{bibtexu}{25}{\code {bibtexu}}
+\entry{bibtex-x}{25}{\code {bibtex-x}}
+\entry{--disable-bibtex8}{25}{\code {--disable-bibtex8}}
+\entry{--disable-bibtexu}{25}{\code {--disable-bibtexu}}
+\entry{configure options, for dvipdfm-x}{25}{\code {configure} options, for \code {dvipdfm-x}}
+\entry{dvipdfm-x}{25}{\code {dvipdfm-x}}
+\entry{dvipdfmx}{25}{\code {dvipdfmx}}
+\entry{xdvipdfmx}{25}{\code {xdvipdfmx}}
+\entry{--disable-dvipdfmx}{25}{\code {--disable-dvipdfmx}}
+\entry{--disable-xdvipdfmx}{25}{\code {--disable-xdvipdfmx}}
+\entry{configure options, for dvisvgm}{25}{\code {configure} options, for \file {dvisvgm}}
+\entry{dvisvgm}{25}{\code {dvisvgm}}
+\entry{--with-system-libgs}{25}{\code {--with-system-libgs}}
+\entry{--without-libgs}{25}{\code {--without-libgs}}
+\entry{--with-libgs-includes, -libdir}{25}{\code {--with-libgs-includes\r {,} -libdir}}
+\entry{configure options, for texk/texlive}{26}{\code {configure} options, for \file {texk/texlive}}
+\entry{--disable-linked-scripts}{26}{\code {--disable-linked-scripts}}
+\entry{configure options, for xdvik}{26}{\code {configure} options, for \file {xdvik}}
+\entry{xdvik}{26}{\code {xdvik}}
+\entry{--with-gs=filename}{26}{\code {--with-gs=\var {filename}}}
+\entry{Ghostscript location for Xdvik}{26}{Ghostscript location for Xdvik}
+\entry{--with-xdvi-x-toolkit=kit}{26}{\code {--with-xdvi-x-toolkit=\var {kit}}}
+\entry{motif}{26}{\code {motif}}
+\entry{xaw}{26}{\code {xaw}}
+\entry{--enable-xi2-scrolling}{26}{\code {--enable-xi2-scrolling}}
+\entry{XInput}{26}{\code {XInput}}
+\entry{scrolling, smooth}{26}{\code {scrolling, smooth}}
+\entry{configure options, for xindy}{26}{\code {configure} options, for \file {xindy}}
+\entry{xindy}{26}{\code {xindy}}
+\entry{--enable-xindy-rules}{26}{\code {--enable-xindy-rules}}
+\entry{--enable-xindy-docs}{26}{\code {--enable-xindy-docs}}
+\entry{--with-clisp-runtime=filename}{26}{\code {--with-clisp-runtime=\var {filename}}}
+\entry{lisp.run, lisp.exe}{26}{\code {lisp.run\r {,} lisp.exe}}
+\entry{CLISP}{26}{CLISP}
+\entry{library-specific configure options}{26}{library-specific \code {configure} options}
+\entry{configure options, library-specific}{26}{\code {configure} options, library-specific}
+\entry{--with-system-lib}{26}{\code {--with-system-\var {lib}}}
+\entry{--with-lib-includes=dir, -libdir}{26}{\code {--with-\var {lib}-includes=\var {dir}\r {,} -libdir}}
+\entry{configure options, for kpathsea}{26}{\code {configure} options, for \code {kpathsea}}
+\entry{configure options, for system poppler}{27}{\code {configure} options, for system \code {poppler}}
+\entry{poppler}{27}{\code {poppler}}
+\entry{xpdf as library}{27}{\code {xpdf \r {as library}}}
+\entry{--with-system-poppler}{27}{\code {--with-system-poppler}}
+\entry{--with-system-xpdf}{27}{\code {--with-system-xpdf}}
+\entry{variables for configure}{27}{variables for \code {configure}}
+\entry{configure variables}{27}{\code {configure} variables}
+\entry{CC}{27}{\code {CC}}
+\entry{CXX}{27}{\code {CXX}}
+\entry{CPPFLAGS}{27}{\code {CPPFLAGS}}
+\entry{CLISP}{27}{\code {CLISP}}
+\entry{clisp}{27}{\code {clisp}}
+\entry{FT2_CONFIG}{27}{\code {FT2_CONFIG}}
+\entry{ICU_CONFIG}{27}{\code {ICU_CONFIG}}
+\entry{PKG_CONFIG}{27}{\code {PKG_CONFIG}}
+\entry{freetype-config}{27}{\code {freetype-config}}
+\entry{icu-config}{27}{\code {icu-config}}
+\entry{libfreetype}{27}{\code {libfreetype}}
+\entry{ICU libraries}{27}{ICU libraries}
+\entry{KPSEWHICH}{27}{\code {KPSEWHICH}}
+\entry{kpsewhich}{27}{\code {kpsewhich}}
+\entry{MAKE}{28}{\code {MAKE}}
+\entry{SED}{28}{\code {SED}}
+\entry{PERL}{28}{\code {PERL}}
+\entry{LATEX}{28}{\code {LATEX}}
+\entry{PDFLATEX}{28}{\code {PDFLATEX}}
+\entry{coding conventions}{29}{coding conventions}
+\entry{conventions, coding}{29}{conventions, coding}
+\entry{declarations and definitions, in source code}{29}{declarations and definitions, in source code}
+\entry{source code declarations}{29}{source code declarations}
+\entry{ANSI C}{29}{ANSI C}
+\entry{declarations before statements, avoiding}{29}{declarations before statements, avoiding}
+\entry{C, ANSI, required}{29}{C, ANSI, required}
+\entry{C99, avoided}{29}{C99, avoided}
+\entry{chktex}{29}{\code {chktex}}
+\entry{stpcpy}{29}{\code {stpcpy}}
+\entry{static functions}{29}{\code {static} functions}
+\entry{extern functions}{29}{\code {extern} functions}
+\entry{variable declarations, in source code}{29}{variable declarations, in source code}
+\entry{const}{30}{\code {const}}
+\entry{X11 headers, and const}{30}{X11 headers, and \code {const}}
+\entry{libfreetype, and const}{30}{\code {libfreetype}, and \code {const}}
+\entry{warning, discards qualifiers}{30}{warning, discards qualifiers}
+\entry{discards qualifiers warning}{30}{discards qualifiers warning}
+\entry{type cast from const, avoiding}{30}{type cast from const, avoiding}
+\entry{continuous integration}{31}{continuous integration}
+\entry{Travis-CI}{31}{Travis-CI}
+\entry{git-svn}{31}{\code {git-svn}}
+\entry{travis.yml}{32}{\code {travis.yml}}


Property changes on: branches/stable/source/src/doc/tlbuild.cp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/stable/source/src/doc/tlbuild.cps
===================================================================
--- branches/stable/source/src/doc/tlbuild.cps	                        (rev 0)
+++ branches/stable/source/src/doc/tlbuild.cps	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,381 @@
+\initial {-}
+\entry {\code {--bindir configure \r {option}}}{22, 23}
+\entry {\code {--build=\var {host}}}{7}
+\entry {\code {--disable-all-packages}}{5}
+\entry {\code {--disable-all-pkgs}}{24}
+\entry {\code {--disable-bibtex8}}{25}
+\entry {\code {--disable-bibtexu}}{25}
+\entry {\code {--disable-dump-share}}{24}
+\entry {\code {--disable-dvipdfmx}}{25}
+\entry {\code {--disable-etex-synctex}}{25}
+\entry {\code {--disable-ipc}}{24}
+\entry {\code {--disable-largefile}}{22}
+\entry {\code {--disable-linked-scripts}}{26}
+\entry {\code {--disable-mf-nowin}}{24}
+\entry {\code {--disable-missing}}{23}
+\entry {\code {--disable-native-texlive-build}}{22}
+\entry {\code {--disable-\var {prog}}}{24}
+\entry {\code {--disable-synctex}}{25}
+\entry {\code {--disable-tex}}{24}
+\entry {\code {--disable-web-progs}}{24}
+\entry {\code {--disable-xdvipdfmx}}{25}
+\entry {\code {--enable-*win \r {for Metafont window support}}}{25}
+\entry {\code {--enable-auto-core}}{25}
+\entry {\code {--enable-compiler-warnings=\var {level}}}{23}
+\entry {\code {--enable-cxx-runtime-hack}}{14}
+\entry {\code {--enable-etex}}{24}
+\entry {\code {--enable-libtool-hack}}{25}
+\entry {\code {--enable-maintainer-mode}}{12, 23}
+\entry {\code {--enable-missing \r {to ignore dependencies}}}{6}
+\entry {\code {--enable-mktextfm-default}}{17}
+\entry {\code {--enable-multiplatform}}{23}
+\entry {\code {--enable-\var {prog}}}{24}
+\entry {\code {--enable-shared}}{23}
+\entry {\code {--enable-silent-rules}}{23}
+\entry {\code {--enable-tex-synctex}}{25}
+\entry {\code {--enable-texlive-build}}{22}
+\entry {\code {--enable-xi2-scrolling}}{26}
+\entry {\code {--enable-xindy-docs}}{26}
+\entry {\code {--enable-xindy-rules}}{26}
+\entry {\code {--host=\var {host}}}{7}
+\entry {\code {--libdir configure \r {option}}}{23}
+\entry {\code {--no-clean Build \r {option}}}{4}
+\entry {\code {--prefix configure \r {option}}}{22}
+\entry {\code {--with-banner-add=\var {str}}}{24}
+\entry {\code {--with-clisp-runtime=\var {filename}}}{26}
+\entry {\code {--with-editor=\var {cmd}}}{24}
+\entry {\code {--with-fontconfig-includes=\var {dir}}}{24}
+\entry {\code {--with-fontconfig-libdir=\var {dir}}}{24}
+\entry {\code {--with-gs=\var {filename}}}{26}
+\entry {\code {--with-\var {lib}-includes=\var {dir}\r {,} -libdir}}{26}
+\entry {\code {--with-libgs-includes\r {,} -libdir}}{25}
+\entry {\code {--with-system-kpathsea}}{17}
+\entry {\code {--with-system-\var {lib}}}{21, 26}
+\entry {\code {--with-system-libgs}}{25}
+\entry {\code {--with-system-poppler}}{27}
+\entry {\code {--with-system-xpdf}}{27}
+\entry {\code {--with-xdvi-x-toolkit}}{18}
+\entry {\code {--with-xdvi-x-toolkit=\var {kit}}}{26}
+\entry {\code {--without-libgs}}{25}
+\entry {\code {--without-ln-s}}{23}
+\entry {\code {--without-x}}{24}
+\entry {\code {-C configure \r {option}}}{4}
+\entry {\code {-j make \r {option}}}{4}
+\initial {A}
+\entry {adapting \TL {} for distros}{11}
+\entry {adding a new generic library}{20}
+\entry {adding a new program}{19}
+\entry {adding a new \TeX {}-specific library}{21}
+\entry {adding to \TL {}}{19}
+\entry {\file {am/} top-level directory}{12}
+\entry {ANSI C}{29}
+\entry {\code {ApplicationServices} Mac framework, required by \code {xetex}}{3}
+\entry {\code {asymptote}}{10, 19}
+\entry {Autoconf}{2}
+\entry {autoconf macros}{13}
+\entry {Automake}{2}
+\initial {B}
+\entry {\code {biber}}{10}
+\entry {\code {bibtex-x}}{25}
+\entry {\code {bibtex8}}{25}
+\entry {\code {bibtexu}}{25}
+\entry {BSD distro}{10}
+\entry {build directory, required}{4}
+\entry {build iteration}{4}
+\entry {build on demand}{5}
+\entry {build one engine}{6}
+\entry {build one package}{5}
+\entry {build problems}{4}
+\entry {\code {Build \r {script}}}{4}
+\entry {build system, design of}{2}
+\entry {\file {build-aux/} top-level directory}{13}
+\entry {\code {BUILDCC\r {,} BUILDCFLAGS\r {, \dots {}}}}{7}
+\entry {building}{4}
+\entry {building a distribution}{4}
+\entry {building in parallel}{4}
+\initial {C}
+\entry {C++11, required}{3}
+\entry {C, ANSI, required}{29}
+\entry {C99, avoided}{29}
+\entry {cache file, for \code {configure}}{4}
+\entry {cache for \code {configure}}{4}
+\entry {\code {callexe.c}}{16}
+\entry {\code {CC}}{27}
+\entry {\code {CC=\var {c-compiler}}}{6}
+\entry {\code {CC_BUILD}}{8}
+\entry {\code {chktex}}{29}
+\entry {\code {clisp}}{27}
+\entry {\code {clisp}, required by \code {xindy}}{3}
+\entry {CLISP}{26, 27}
+\entry {\code {Cocoa} Mac framework, required by \code {xetex}}{3}
+\entry {coding conventions}{29}
+\entry {compilers, C and C++11}{3}
+\entry {\code {config.guess\r {,} config.sub, \dots {}}}{13}
+\entry {\code {configure} options}{22}
+\entry {\code {configure} options, for \code {bibtex-x}}{25}
+\entry {\code {configure} options, for \code {dvipdfm-x}}{25}
+\entry {\code {configure} options, for \file {dvisvgm}}{25}
+\entry {\code {configure} options, for \code {kpathsea}}{26}
+\entry {\code {configure} options, for system \code {poppler}}{27}
+\entry {\code {configure} options, for \file {texk/texlive}}{26}
+\entry {\code {configure} options, for \code {web2c}}{24}
+\entry {\code {configure} options, for \file {xdvik}}{26}
+\entry {\code {configure} options, for \file {xindy}}{26}
+\entry {\code {configure} options, global}{22}
+\entry {\code {configure} options, library-specific}{26}
+\entry {\code {configure} options, program-specific}{24}
+\entry {\code {configure} variables}{27}
+\entry {configuring, for cross compilation}{7}
+\entry {\code {const}}{30}
+\entry {continuous integration}{31}
+\entry {conventions, coding}{29}
+\entry {\code {CPPFLAGS}}{27}
+\entry {cross compilation}{6}
+\entry {cross compilation configuring}{7}
+\entry {cross compilation problems}{7}
+\entry {cross compilation, with host binary}{18}
+\entry {\code {ctangle}}{8}
+\entry {\code {CXX}}{27}
+\entry {\code {CXX=\var {c++-compiler}}}{6}
+\initial {D}
+\entry {declarations and definitions, in source code}{29}
+\entry {declarations before statements, avoiding}{29}
+\entry {dependencies, with several output files}{4}
+\entry {\code {DESTDIR}}{22}
+\entry {directories, for installation}{9}
+\entry {directories, top-level}{12}
+\entry {discards qualifiers warning}{30}
+\entry {\code {dist} and \code {distcheck} targets for \code {make}}{4}
+\entry {distribution tarball, making}{4}
+\entry {distro, building for}{10}
+\entry {\code {dvipdfm-x}}{25}
+\entry {\code {dvipdfmx}}{25}
+\entry {\code {dvisvgm}}{25}
+\initial {E}
+\entry {engine, building one}{6}
+\entry {environment variables, for \code {configure}}{22}
+\entry {\code {exec_prefix}}{23}
+\entry {extending \TL {}}{19}
+\entry {\code {extern} functions}{29}
+\initial {F}
+\entry {failure to build}{4}
+\entry {flags, macros for library and header}{15}
+\entry {\code {fontconfig} library, required by \code {xetex}}{3}
+\entry {FreeType}{3}
+\entry {\code {freetype} cross compiling}{8}
+\entry {\code {freetype \r {library}}}{17}
+\entry {\code {freetype-config}}{17, 27}
+\entry {\code {FT2_CONFIG}}{27}
+\initial {G}
+\entry {\code {gcc\r {, default compilers}}}{6}
+\entry {general setup macros}{13}
+\entry {generic library module, adding}{20}
+\entry {Ghostscript location for Xdvik}{26}
+\entry {\code {git-svn}}{31}
+\entry {global \code {configure} options}{22}
+\entry {\code {gmake}, required}{3}
+\entry {GNU \code {make}, required}{3}
+\entry {GNU tools, needed for building}{12}
+\entry {GNU/Linux distro}{10}
+\entry {Gnulib, used for common files}{13}
+\initial {I}
+\entry {\code {icu-config}}{27}
+\entry {ICU cross compiling}{8}
+\entry {ICU libraries}{27}
+\entry {\code {ICU_CONFIG}}{27}
+\entry {infrastructure, tools needed for}{12}
+\entry {\file {inst/} top-level directory}{13}
+\entry {\code {install-tl\r {, \TL {} installer}}}{9}
+\entry {installation directories}{9}
+\entry {installing}{9}
+\entry {interprocess communication}{24}
+\entry {introduction}{1}
+\entry {iteration through sources, by \code {configure} and \code {make}}{4}
+\initial {K}
+\entry {\code {kpathsea \r {library}}}{17}
+\entry {\code {kpathsea.ac}}{17}
+\entry {\code {kpse-libpng-flags.m4}}{17}
+\entry {\code {kpse-pkgs.m4}}{2}
+\entry {\code {kpse-zlib-flags.m4}}{17}
+\entry {\code {kpse_cv_cxx_hack}}{14}
+\entry {\code {kpse_cv_have_win32}}{16}
+\entry {\code {kpse_cv_visibility_c[xx]flags}}{14}
+\entry {\code {kpse_cv_warning_cflags}}{14}
+\entry {\code {kpse_libs_pkgs}}{20}
+\entry {\code {kpse_texk_pkgs}}{19}
+\entry {\code {kpse_texlibs_pkgs}}{21}
+\entry {\code {kpse_utils_pkgs}}{19}
+\entry {\code {KPSE_ADD_FLAGS}}{15}
+\entry {\code {KPSE_ALL_SYSTEM_FLAGS}}{21}
+\entry {\code {KPSE_BASIC}}{13}
+\entry {\code {KPSE_CHECK_LATEX}}{14}
+\entry {\code {KPSE_CHECK_PDFLATEX}}{14}
+\entry {\code {KPSE_CHECK_PERL}}{14}
+\entry {\code {KPSE_CHECK_WIN32}}{16}
+\entry {\code {KPSE_COMMON}}{13}
+\entry {\code {KPSE_COMPILER_VISIBILITY}}{14}
+\entry {\code {KPSE_COMPILER_WARNINGS}}{14}
+\entry {\code {KPSE_COND_MINGW32}}{16}
+\entry {\code {KPSE_COND_WIN32}}{16}
+\entry {\code {KPSE_COND_WIN32_WRAP}}{16}
+\entry {\code {KPSE_CXX_HACK}}{14}
+\entry {\code {KPSE_ENABLE_PROG}}{19}
+\entry {\code {KPSE_LARGEFILE}}{14}
+\entry {\code {KPSE_\var {LIB}_FLAGS}}{15, 20}
+\entry {\code {KPSE_\var {LIB}_SYSTEM_FLAGS}}{21}
+\entry {\code {KPSE_LIBPNG_FLAGS}}{15, 17}
+\entry {\code {KPSE_PROG_LEX}}{14}
+\entry {\code {KPSE_RESTORE_FLAGS}}{15}
+\entry {\code {KPSE_TRY_LIB}}{16, 20}
+\entry {\code {KPSE_TRY_LIBXX}}{17, 20}
+\entry {\code {KPSE_WIN32_CALL}}{16}
+\entry {\code {KPSE_WITH_LIB}}{20}
+\entry {\code {KPSE_WITH_TEXLIB}}{21}
+\entry {\code {kpsewhich}}{27}
+\entry {\code {KPSEWHICH}}{27}
+\initial {L}
+\entry {large file support}{22}
+\entry {\code {LATEX}}{28}
+\entry {layout of sources}{12}
+\entry {LFS (large file support)}{22}
+\entry {\code {libexpat\r {, dependency of \code {libfontconfig}}}}{25}
+\entry {\code {libfontconfig\r {, hack for avoiding linking dependencies}}}{25}
+\entry {\code {libfreetype}}{27}
+\entry {\code {libfreetype}, and \code {const}}{30}
+\entry {\code {libpng \r {library}}}{16}
+\entry {library module, generic, adding}{20}
+\entry {library module, \TeX {}-specific, adding}{21}
+\entry {library modules}{16}
+\entry {library-specific \code {configure} options}{26}
+\entry {\code {libsigsegv}, required by \code {xindy}}{3}
+\entry {\code {libstc++\r {, statically linking}}}{14}
+\entry {Libtool}{2}
+\entry {\code {libtool\r {, hack for avoiding excessive linking}}}{25}
+\entry {\code {libXt}}{24}
+\entry {linked scripts}{9}
+\entry {linking C++ libraries statically}{14}
+\entry {\code {lisp.run\r {,} lisp.exe}}{26}
+\entry {LittleEndian architectures}{24}
+\initial {M}
+\entry {\file {m4/} top-level directory}{12}
+\entry {macros, for compilers}{14}
+\entry {macros, for libraries}{14}
+\entry {macros, for library and header flags}{15}
+\entry {macros, for programs}{14}
+\entry {macros, for Windows}{15}
+\entry {macros, general setup}{13}
+\entry {\code {make -t}}{12}
+\entry {\code {make} rules, verbose vs.\: silent}{23}
+\entry {\code {MAKE}}{28}
+\entry {\code {mf-nowin}}{24}
+\entry {\code {mingw32}}{7}
+\entry {\code {MINGW32\r {, Automake conditional}}}{16}
+\entry {\code {mktex.ac}}{17}
+\entry {\code {mktextfm}}{17}
+\entry {modules, for libraries}{16}
+\entry {modules, for programs}{18}
+\entry {\code {motif}}{26}
+\initial {N}
+\entry {native cross compilation}{6}
+\initial {O}
+\entry {\code {OBJCXX=\var {objc-compiler}}}{6}
+\entry {one engine, building}{6}
+\entry {one package, building}{5}
+\entry {OpenGL, required for Asymptote}{19}
+\entry {operating system distribution, building for}{10}
+\entry {\code {otangle}}{8}
+\entry {overall build process}{4}
+\initial {P}
+\entry {parallel build}{4}
+\entry {paths, for installation}{9}
+\entry {PDF files, size of}{22}
+\entry {\code {PDFLATEX}}{28}
+\entry {\code {perl}, required by \code {web2c}, etc.}{3}
+\entry {\code {PERL}}{28}
+\entry {\code {PKG_CONFIG}}{27}
+\entry {\code {plain.tex\r {, not in source tree}}}{9}
+\entry {\code {png \r {library}}}{16}
+\entry {\code {poppler}}{27}
+\entry {PostScript files, size of}{22}
+\entry {Preining, Norbert}{11}
+\entry {preloaded binaries}{25}
+\entry {prerequisites for building}{3}
+\entry {problems with build}{4}
+\entry {program module, adding}{19}
+\entry {program modules}{18}
+\entry {program-specific \code {configure} options}{24}
+\entry {proxy build system}{17}
+\initial {R}
+\entry {\code {reautoconf}}{12}
+\entry {requirements for building}{3}
+\entry {\code {runscript.exe}}{16}
+\initial {S}
+\entry {scripts, linked and not maintained}{9}
+\entry {\code {scrolling, smooth}}{26}
+\entry {\code {SED}}{28}
+\entry {setup macros, general}{13}
+\entry {shared libraries, using vs.\: avoiding}{10}
+\entry {size of PDF and PS files}{22}
+\entry {size of source tree}{6}
+\entry {source code declarations}{29}
+\entry {source directory building, not supported}{4}
+\entry {source tree}{12}
+\entry {\code {squeeze}}{8}
+\entry {\code {squeeze/configure.ac}}{18}
+\entry {\code {static} functions}{29}
+\entry {static linking for C++}{14}
+\entry {\code {stpcpy}}{29}
+\entry {Subversion repository}{12}
+\entry {support files, separate from build}{9}
+\entry {symlinks, used for scripts}{9}
+\entry {synctex}{25}
+\entry {system distribution, building for}{10}
+\initial {T}
+\entry {\code {t1utils \r {package}}}{18}
+\entry {\code {tangle}}{8}
+\entry {tests, running}{2}
+\entry {\TeX {}-specific library module, adding}{21}
+\entry {\code {texlive.tlpdb\r {, \TL {} database}}}{9}
+\entry {\code {tie}}{8}
+\entry {timestamps, in repository}{12}
+\entry {tools, for building}{12}
+\entry {top-level directories}{12}
+\entry {touching files to avoid rerunning}{12}
+\entry {Travis-CI}{31}
+\entry {\code {travis.yml}}{32}
+\entry {type cast from const, avoiding}{30}
+\initial {U}
+\entry {\code {use-commit-times\r {, Subversion}}}{12}
+\initial {V}
+\entry {variable declarations, in source code}{29}
+\entry {variables for \code {configure}}{27}
+\initial {W}
+\entry {warning, discards qualifiers}{30}
+\entry {\code {WARNING_C[XX]FLAGS}}{14}
+\entry {\code {web2c \r {program}}}{8}
+\entry {\code {web2c.ac}}{24}
+\entry {\code {wget}}{10}
+\entry {\code {WIN32\r {, Automake conditional}}}{16}
+\entry {\code {WIN32_WRAP\r {, Automake conditional}}}{16}
+\entry {Windows, invoking scripts on}{9}
+\entry {Windows, macros for}{15}
+\entry {\code {withenable.ac\r {, for new modules}}}{19}
+\entry {\file {Work/} top-level directory}{13}
+\entry {wrapper binary for scripts on Windows}{9}
+\entry {wrapper build system}{17}
+\initial {X}
+\entry {X toolkit}{24}
+\entry {X11 development, required by X clients}{3}
+\entry {X11 headers, and \code {const}}{30}
+\entry {\code {xasy}}{19}
+\entry {\code {xaw}}{26}
+\entry {\code {xdvik}}{18, 26}
+\entry {\code {xdvipdfmx}}{25}
+\entry {\code {xindy}}{10, 18, 26}
+\entry {\code {xindy} cross compiling impossible}{8}
+\entry {\code {XInput}}{26}
+\entry {\code {Xlib}}{24}
+\entry {\code {xpdf \r {as library}}}{27}
+\entry {\code {xz}}{10}
+\initial {Z}
+\entry {\code {zlib \r {library}}}{17}


Property changes on: branches/stable/source/src/doc/tlbuild.cps
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: branches/stable/source/src/doc/tlbuild.info
===================================================================
--- branches/stable/source/src/doc/tlbuild.info	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/doc/tlbuild.info	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,4 +1,4 @@
-This is tlbuild.info, produced by makeinfo version 6.6 from
+This is tlbuild.info, produced by makeinfo version 6.7 from
 tlbuild.texi.
 
 This file documents the TeX Live build system and more.
@@ -169,11 +169,10 @@
 
    A C++11 compiler is similarly required because of the third-party
 libraries ICU and Poppler; the program 'dvisvgm' also requires C++11.
-It is possible to build everything else with older compilers;
-<https://tug.org/texlive/custom-bin.html> links to a build script for
-doing this.
+It is possible to build everything else with older compilers, but you
+have to remove the C++11-dependent sources.  *Note Build one package::.
 
-   However, a few programs in the tree have additional requirements:
+   A few programs in the tree have additional requirements:
 
 'web2c'
      requires 'perl' for some tests run by 'make check'.
@@ -180,8 +179,8 @@
 
 'xdvik'
 'xpdfopen'
-     require X11 headers and libraries, often in "development" packages
-     that are not installed by default.
+     require X11 headers and libraries, typically in "development"
+     packages that are not installed by default.
 
 'xetex'
      requires 'fontconfig' (again both headers and library), or, for
@@ -189,8 +188,8 @@
 
 'xindy'
      requires GNU 'clisp', 'libsigsegv', and 'libiconv'; additionally,
-     to build the rules and/or documentation: 'perl', 'latex', and
-     'pdflatex'
+     to build the rules and/or documentation: 'perl', 'latex',
+     'pdflatex'.
 
 Lacking the required tools, building these programs must avoided, e.g.,
 'configure --without-x --disable-xetex --disable-xindy'
@@ -329,17 +328,10 @@
 invoked to build an individual program or library, first building any
 required libraries.
 
-   This "build-on-demand" procedure is used, e.g., in the upstream
-LuaTeX repository to build LuaTeX, from a subset of the complete
-TeX Live source tree.  As another example, when building the original
-e-TeX has been disabled (as it is by default), one can run 'make etex'
-(or 'make etex.exe') in 'texk/web2c/' to build e-TeX (although there is
-no comparably simple way to _install_ e-TeX).
+   Here is an example from start to finish for working on 'dvipdfm-x'.
+(Unfortunately, this does not suffice for building one, or a subset, of
+the TeX engines; see the next section.)
 
-   If you want to work on a single program within the TL sources, this
-is the recommended way to do it.  Here is an example from start to
-finish for working on 'dvipdfm-x'.
-
      mkdir mydir && cd mydir  # new working directory
 
      # Get sources (<https://tug.org/texlive/svn>), e.g.:
@@ -387,11 +379,20 @@
 development source (details at <http://pdftex.org>), which is indeed
 such a cut-down TL source tree.
 
-   Even with '--disable-all-pkgs', dependencies will be checked.  For
-instance, if a (non-MacOSX) system does not have 'fontconfig', XeTeX
-cannot be built (*note Prerequisites::) and 'configure' will terminate.
-To proceed without such dependencies, specify '--enable-missing' also.
+   Some libraries and programs require C++11.  If you want to build with
+an older compiler lacking such support, you need to (re)move those
+source directories; specifying '--disable' for them does not suffice,
+unfortunately.  Specifically, before running 'configure':
 
+     rm -rf libs/icu libs/poppler libs/graphite2 texk/dvisvgm
+
+   Also, even with '--disable-all-pkgs', dependencies are (currently)
+checked.  For instance, if a (non-MacOSX) system does not have
+'fontconfig', XeTeX cannot be built (*note Prerequisites::), and
+'configure' will terminate even with '--disable-xetex'.  To proceed
+without such dependencies, specify '--enable-missing' also.  (Patches to
+improve this would be most welcome.)
+
    By default, the 'gcc' compilers will be used if present; otherwise,
 individual packages may use something different.  You can explicitly
 specify the compilers to be used with the environment variables 'CC',
@@ -417,8 +418,9 @@
 
    This works because the 'make' automatically runs 'configure' as
 necessary for the dependencies and target.  Furthermore, the source tree
-can be cut down to just what is needed for the given engine (as the
-separate pdfTeX and LuaTeX source repositories do).
+can be cut down to just what is needed for the given engine (the
+separate pdfTeX and LuaTeX source repositories do this, if you want to
+peruse examples).
 
    We hope to improve the situation in the future.  Patches are welcome.
 
@@ -745,11 +747,11 @@
 
      autoconf (GNU Autoconf) 2.69
      automake (GNU automake) 1.16.1
-     bison (GNU Bison) 3.3.1
+     bison (GNU Bison) 3.4.2
      flex 2.6.0
      ltmain.sh (GNU libtool) 2.4.6
      m4 (GNU M4) 1.4.18
-     makeinfo (GNU texinfo) 6.6
+     makeinfo (GNU texinfo) 6.7
 
    These versions should be used to update the generated files (e.g.,
 'configure' or 'Makefile.in') in all or parts of the TL tree after their
@@ -771,7 +773,6 @@
 ('.c', '.h', or '.info') files.  With '--enable-maintainer-mode' it may
 also be necessary to 'touch' first 'aclocal.m4', then 'configure' and
 'config.h.in' (or 'c-auto.in'), and finally all 'Makefile.in' files.
-Perhaps 'make -t' will help.
 
 
 File: tlbuild.info,  Node: Top-level directories,  Next: Autoconf macros,  Prev: Build system tools,  Up: Layout and infrastructure
@@ -2086,6 +2087,7 @@
 * Transfer from Subversion to Github::
 * Automatic update of the Git mirror::
 * CI testing on Travis-CI::
+* Releases on Github::
 
 
 File: tlbuild.info,  Node: Transfer from Subversion to Github,  Next: Automatic update of the Git mirror,  Up: Continuous integration
@@ -2146,7 +2148,7 @@
 them, and the second pushes changes (if any) to Github.
 
 
-File: tlbuild.info,  Node: CI testing on Travis-CI,  Prev: Automatic update of the Git mirror,  Up: Continuous integration
+File: tlbuild.info,  Node: CI testing on Travis-CI,  Next: Releases on Github,  Prev: Automatic update of the Git mirror,  Up: Continuous integration
 
 9.3 CI testing on Travis-CI
 ===========================
@@ -2162,6 +2164,23 @@
 automatically checkout the last pushed commit and try building it.
 
 
+File: tlbuild.info,  Node: Releases on Github,  Prev: CI testing on Travis-CI,  Up: Continuous integration
+
+9.4 Releases on Github
+======================
+
+Given a git checkout of 'texlive-source':
+
+     git pull
+     git tag build-svnNNNN
+     git push --tags
+
+and the result will appear at
+<https://github.com/TeX-Live/texlive-source/releases>.  Releases can
+also be made manually from that web page (see 'tl-update-bindir' for
+hints).
+
+
 File: tlbuild.info,  Node: install-tl,  Next: tlmgr,  Prev: Continuous integration,  Up: Top
 
 Appendix A install-tl
@@ -5157,7 +5176,7 @@
 * ANSI C:                                Declarations and definitions.
                                                                (line  6)
 * ApplicationServices Mac framework, required by xetex: Prerequisites.
-                                                               (line 32)
+                                                               (line 31)
 * asymptote:                             Linked scripts.       (line 23)
 * asymptote <1>:                         asymptote.            (line  6)
 * Autoconf:                              Overview of build system.
@@ -5188,6 +5207,7 @@
 * building:                              Building.             (line  6)
 * building a distribution:               Build distribution.   (line  6)
 * building in parallel:                  Build in parallel.    (line  6)
+* C++11, removing dependent sources:     Build one package.    (line 64)
 * C++11, required:                       Prerequisites.        (line 15)
 * C, ANSI, required:                     Declarations and definitions.
                                                                (line  6)
@@ -5198,7 +5218,7 @@
 * callexe.c:                             Macros for Windows.   (line 32)
 * CC:                                    Variables for configure.
                                                                (line 10)
-* CC=C-COMPILER:                         Build one package.    (line 76)
+* CC=C-COMPILER:                         Build one package.    (line 78)
 * CC_BUILD:                              Cross problems.       (line 13)
 * chktex:                                Declarations and definitions.
                                                                (line 18)
@@ -5208,8 +5228,8 @@
                                                                (line 17)
 * CLISP <1>:                             Configure options for utils/xindy.
                                                                (line 14)
-* clisp, required by xindy:              Prerequisites.        (line 36)
-* Cocoa Mac framework, required by xetex: Prerequisites.       (line 32)
+* clisp, required by xindy:              Prerequisites.        (line 35)
+* Cocoa Mac framework, required by xetex: Prerequisites.       (line 31)
 * coding conventions:                    Coding conventions.   (line  6)
 * compilers, C and C++11:                Prerequisites.        (line  6)
 * config.guess, config.sub, ...:         Top-level directories.
@@ -5255,7 +5275,7 @@
 * ctangle:                               Cross problems.       (line 26)
 * CXX:                                   Variables for configure.
                                                                (line 11)
-* CXX=C++-COMPILER:                      Build one package.    (line 76)
+* CXX=C++-COMPILER:                      Build one package.    (line 78)
 * declarations and definitions, in source code: Declarations and definitions.
                                                                (line  6)
 * declarations before statements, avoiding: Declarations and definitions.
@@ -5287,7 +5307,7 @@
 * failure to build:                      Build problems.       (line  6)
 * flags, macros for library and header:  Macros for library and header flags.
                                                                (line  6)
-* fontconfig library, required by xetex: Prerequisites.        (line 32)
+* fontconfig library, required by xetex: Prerequisites.        (line 31)
 * FreeType:                              Prerequisites.        (line 11)
 * freetype cross compiling:              Cross problems.       (line 13)
 * freetype library:                      freetype library.     (line  6)
@@ -5296,7 +5316,7 @@
                                                                (line 24)
 * FT2_CONFIG:                            Variables for configure.
                                                                (line 21)
-* gcc, default compilers:                Build one package.    (line 76)
+* gcc, default compilers:                Build one package.    (line 78)
 * general setup macros:                  General setup macros. (line  6)
 * generic library module, adding:        Adding a new generic library module.
                                                                (line  6)
@@ -5416,7 +5436,7 @@
 * library modules:                       Library modules.      (line  6)
 * library-specific configure options:    Library-specific configure options.
                                                                (line  6)
-* libsigsegv, required by xindy:         Prerequisites.        (line 36)
+* libsigsegv, required by xindy:         Prerequisites.        (line 35)
 * libstc++, statically linking:          Macros for compilers. (line 29)
 * Libtool:                               Overview of build system.
                                                                (line  6)
@@ -5455,7 +5475,7 @@
 * motif:                                 Configure options for texk/xdvik.
                                                                (line  9)
 * native cross compilation:              Cross compilation.    (line 10)
-* OBJCXX=OBJC-COMPILER:                  Build one package.    (line 76)
+* OBJCXX=OBJC-COMPILER:                  Build one package.    (line 78)
 * one engine, building:                  Build one engine.     (line  6)
 * one package, building:                 Build one package.    (line  6)
 * OpenGL, required for Asymptote:        asymptote.            (line  6)
@@ -5470,7 +5490,7 @@
                                                                (line 41)
 * PERL:                                  Variables for configure.
                                                                (line 39)
-* perl, required by web2c, etc.:         Prerequisites.        (line 24)
+* perl, required by web2c, etc.:         Prerequisites.        (line 23)
 * PKG_CONFIG:                            Variables for configure.
                                                                (line 23)
 * plain.tex, not in source tree:         Installing.           (line  8)
@@ -5500,7 +5520,7 @@
 * setup macros, general:                 General setup macros. (line  6)
 * shared libraries, using vs. avoiding:  Distro builds.        (line 11)
 * size of PDF and PS files:              --disable-largefile.  (line 11)
-* size of source tree:                   Build one package.    (line 60)
+* size of source tree:                   Build one package.    (line 53)
 * source code declarations:              Declarations and definitions.
                                                                (line  6)
 * source directory building, not supported: Building.          (line 17)
@@ -5562,7 +5582,7 @@
 * wrapper build system:                  freetype library.     (line  6)
 * X toolkit:                             Configure options for texk/web2c.
                                                                (line 22)
-* X11 development, required by X clients: Prerequisites.       (line 28)
+* X11 development, required by X clients: Prerequisites.       (line 27)
 * X11 headers, and const:                Const.                (line 21)
 * xasy:                                  asymptote.            (line  6)
 * xaw:                                   Configure options for texk/xdvik.
@@ -5593,367 +5613,373 @@
 Node: Introduction2118
 Node: Overview of build system3946
 Node: Prerequisites5997
-Node: Building8616
-Node: Build iteration10002
-Node: Build problems11043
-Node: Build in parallel11497
-Node: Build distribution12101
-Node: Build one package12749
-Node: Build one engine16384
-Node: Cross compilation17399
-Node: Cross configuring18679
-Node: Cross problems20356
-Node: Installing22018
-Node: Installation directories23038
-Node: Linked scripts24856
-Node: Distro builds26347
-Node: Layout and infrastructure28723
-Node: Build system tools29554
-Node: Top-level directories31800
-Node: Autoconf macros34036
-Node: General setup macros34798
-Node: Macros for programs35673
-Node: Macros for compilers36474
-Node: Macros for libraries37882
-Node: Macros for library and header flags38308
-Node: Macros for Windows40219
-Node: Library modules41806
-Node: png library42295
-Node: zlib library44643
-Node: freetype library45158
-Node: kpathsea library45854
-Node: Program modules47233
-Node: t1utils package47661
-Node: xindy package48206
-Node: xdvik package49320
-Node: asymptote50379
-Node: Extending TeX Live50875
-Node: Adding a new program module51658
-Node: Adding a new generic library module54997
-Node: Adding a new TeX-specific library module57226
-Node: Configure options57924
-Node: Global configure options59305
-Node: --disable-native-texlive-build59847
-Node: --prefix --bindir ...60809
-Node: --disable-largefile61349
-Node: --disable-missing62050
-Node: --enable-compiler-warnings=LEVEL62451
-Node: --enable-cxx-runtime-hack63107
-Node: --enable-maintainer-mode63527
-Node: --enable-multiplatform64056
-Node: --enable-shared64629
-Node: --enable-silent-rules65000
-Node: --without-ln-s65452
-Node: --without-x65799
-Node: Program-specific configure options65987
-Node: --enable-PROG --disable-PROG66630
-Node: --disable-all-pkgs66903
-Node: Configure options for texk/web2c67686
-Node: Configure options for texk/bibtex-x70224
-Node: Configure options for texk/dvipdfm-x70767
-Node: Configure options for texk/dvisvgm71543
-Node: Configure options for texk/texlive72424
-Node: Configure options for texk/xdvik72845
-Node: Configure options for utils/xindy73466
-Node: Library-specific configure options74356
-Node: Configure options for kpathsea75358
-Node: Configure options for system poppler76107
-Node: Variables for configure76871
-Node: Coding conventions78297
-Node: Declarations and definitions79012
-Node: Const81186
-Node: Continuous integration83050
-Node: Transfer from Subversion to Github83691
-Node: Automatic update of the Git mirror85853
-Node: CI testing on Travis-CI86435
-Node: install-tl87117
-Node: install-tl NAME87486
-Node: install-tl SYNOPSIS87644
-Node: install-tl DESCRIPTION87902
-Node: install-tl REFERENCES88969
-Node: install-tl OPTIONS89495
-Ref: install-tl *-gui* [[=]_module_]89836
-Ref: install-tl text90046
-Ref: install-tl wizard90169
-Ref: install-tl perltk90323
-Ref: install-tl *-no-gui*90754
-Ref: install-tl *-lang* _llcode_90835
-Ref: install-tl *-repository* _url|path_91522
-Ref: install-tl *-select-repository*93402
-Ref: install-tl *-all-options*93838
-Ref: install-tl *-custom-bin* _path_94093
-Ref: install-tl *-debug-translation*94925
-Ref: install-tl *-force-platform* _platform_95144
-Ref: install-tl *-help*, *--help*, *-?*95388
-Ref: install-tl *-in-place*95795
-Ref: install-tl *-init-from-profile* _profile_file_96340
-Ref: install-tl *-logfile* _file_96560
-Ref: install-tl *-no-cls*96911
-Ref: install-tl *-non-admin*97045
-Ref: install-tl *-persistent-downloads*97150
-Ref: install-tl *-no-persistent-downloads*97178
-Ref: install-tl *-no-verify-downloads*97796
-Ref: install-tl *-portable*98157
-Ref: install-tl *-print-platform*98296
-Ref: install-tl *-profile* _profile_file_98494
-Ref: install-tl *-q*98674
-Ref: install-tl *-scheme* _scheme_98736
-Ref: install-tl *-v*99210
-Ref: install-tl *-version*, *--version*99365
-Node: install-tl PROFILES99496
-Ref: install-tl instopt_adjustpath (default 0 on Unix, 1 on Windows)102146
-Ref: install-tl instopt_adjustrepo (default 1)102222
-Ref: install-tl instopt_letter (default 0)102359
-Ref: install-tl instopt_portable (default 0)102450
-Ref: install-tl instopt_write18_restricted (default 1)102546
-Node: install-tl ENVIRONMENT VARIABLES103865
-Ref: install-tl TEXLIVE_INSTALL_ENV_NOCHECK104256
-Ref: install-tl TEXLIVE_INSTALL_NO_CONTEXT_CACHE104458
-Ref: install-tl TEXLIVE_INSTALL_NO_WELCOME104568
-Ref: install-tl TEXLIVE_INSTALL_PREFIX104689
-Ref: install-tl TEXLIVE_INSTALL_TEXDIR104715
-Ref: install-tl TEXLIVE_INSTALL_TEXMFCONFIG104746
-Ref: install-tl TEXLIVE_INSTALL_TEXMFVAR104774
-Ref: install-tl TEXLIVE_INSTALL_TEXMFHOME104803
-Ref: install-tl TEXLIVE_INSTALL_TEXMFLOCAL104833
-Ref: install-tl TEXLIVE_INSTALL_TEXMFSYSCONFIG104867
-Ref: install-tl TEXLIVE_INSTALL_TEXMFSYSVAR104898
-Ref: install-tl NOPERLDOC105269
-Node: install-tl AUTHORS AND COPYRIGHT105333
-Node: tlmgr105749
-Node: tlmgr NAME106202
-Node: tlmgr SYNOPSIS106334
-Node: tlmgr DESCRIPTION106524
-Node: tlmgr EXAMPLES107620
-Ref: tlmgr tlmgr option repository ctan107871
-Ref: tlmgr tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet107943
-Ref: tlmgr tlmgr update --list108395
-Ref: tlmgr tlmgr update --all108488
-Ref: tlmgr tlmgr info _what_108645
-Node: tlmgr OPTIONS108907
-Ref: tlmgr *--repository* _url|path_109427
-Ref: tlmgr *--gui* [_action_]110152
-Ref: tlmgr *--gui-lang* _llcode_110559
-Ref: tlmgr *--debug-translation*111242
-Ref: tlmgr *--machine-readable*111445
-Ref: tlmgr *--no-execute-actions*111713
-Ref: tlmgr *--package-logfile* _file_111906
-Ref: tlmgr *--pause*112160
-Ref: tlmgr *--persistent-downloads*112315
-Ref: tlmgr *--no-persistent-downloads*112343
-Ref: tlmgr *--pin-file*112837
-Ref: tlmgr *--usermode*113055
-Ref: tlmgr *--usertree* _dir_113175
-Ref: tlmgr *--verify-repo=[none|main|all]*113301
-Node: tlmgr ACTIONS114200
-Node: tlmgr help115052
-Node: tlmgr version115528
-Node: tlmgr backup115791
-Ref: tlmgr *backup [_option_...] --all*115962
-Ref: tlmgr *backup [_option_...] _pkg_...*115995
-Ref: tlmgr *--backupdir* _directory_116850
-Ref: tlmgr *--all*117067
-Ref: tlmgr *--clean*[=_N_]117319
-Ref: tlmgr *--dry-run*117646
-Node: tlmgr candidates _pkg_117776
-Node: tlmgr check [_option_...] [files|depends|executes|runfiles|all]118122
-Ref: tlmgr *files*118495
-Ref: tlmgr *depends*118630
-Ref: tlmgr *executes*118972
-Ref: tlmgr *runfiles*119090
-Ref: tlmgr *--use-svn*119211
-Node: tlmgr conf119328
-Ref: tlmgr *conf [texmf|tlmgr|updmap [--conffile _file_] [--delete] [_key_ [_value_]]]*119607
-Ref: tlmgr *conf auxtrees [--conffile _file_] [show|add|delete] [_value_]*119671
-Node: tlmgr dump-tlpdb [_option_...] [--json]122016
-Ref: tlmgr *--local*122449
-Ref: tlmgr *--remote*122488
-Ref: tlmgr *--json*122526
-Node: tlmgr generate123097
-Ref: tlmgr *generate [_option_...] language*123293
-Ref: tlmgr *generate [_option_...] language.dat*123332
-Ref: tlmgr *generate [_option_...] language.def*123371
-Ref: tlmgr *generate [_option_...] language.dat.lua*123414
-Ref: tlmgr *--dest* _output_file_125740
-Ref: tlmgr *--localcfg* _local_conf_file_126316
-Ref: tlmgr *--rebuild-sys*126439
-Node: tlmgr gui127254
-Node: tlmgr info127432
-Ref: tlmgr *info [_option_...] _pkg_...*127594
-Ref: tlmgr *info [_option_...] collections*127628
-Ref: tlmgr *info [_option_...] schemes*127658
-Ref: tlmgr *--list*129188
-Ref: tlmgr *--only-installed*129502
-Ref: tlmgr *--data item1,item2,...*129701
-Ref: tlmgr *--json* 1130282
-Node: tlmgr init-usertree130665
-Node: tlmgr install [_option_...] _pkg_...131046
-Ref: tlmgr *--dry-run* 1131556
-Ref: tlmgr *--file*131673
-Ref: tlmgr *--force*131895
-Ref: tlmgr *--no-depends*132115
-Ref: tlmgr *--no-depends-at-all*132274
-Ref: tlmgr *--reinstall*132674
-Ref: tlmgr *--with-doc*133052
-Ref: tlmgr *--with-src*133065
-Node: tlmgr key133587
-Ref: tlmgr *key list*133745
-Ref: tlmgr *key add _file_*133763
-Ref: tlmgr *key remove _keyid_*133785
-Node: tlmgr list134380
-Node: tlmgr option134542
-Ref: tlmgr *option [--json] [show]*134697
-Ref: tlmgr *option [--json] showall*134723
-Ref: tlmgr *option _key_ [_value_]*134749
-Node: tlmgr paper139146
-Ref: tlmgr *paper [a4|letter]*139295
-Ref: tlmgr *[xdvi|pdftex|dvips|dvipdfmx|context|psutils] paper [_papersize_|--list]*139369
-Ref: tlmgr *paper --json*139384
-Node: tlmgr path140599
-Ref: tlmgr *path [--w32mode=user|admin] add*140760
-Ref: tlmgr *path [--w32mode=user|admin] remove*140797
-Node: tlmgr pinning142137
-Ref: tlmgr pinning show142378
-Ref: tlmgr pinning add _repo_ _pkgglob_...142451
-Ref: tlmgr pinning remove _repo_ _pkgglob_...142570
-Ref: tlmgr pinning remove _repo_ --all142723
-Node: tlmgr platform142777
-Ref: tlmgr *platform list|add|remove _platform_...*142963
-Ref: tlmgr *platform set _platform_*142990
-Ref: tlmgr *platform set auto*143011
-Ref: tlmgr *--dry-run* 2143897
-Node: tlmgr postaction144016
-Ref: tlmgr *postaction [_option_...] install [shortcut|fileassoc|script] [_pkg_...]*144246
-Ref: tlmgr *postaction [_option_...] remove [shortcut|fileassoc|script] [_pkg_...]*144320
-Ref: tlmgr *--w32mode=[user|admin]*144635
-Ref: tlmgr *--fileassocmode=[1|2]*145051
-Ref: tlmgr *--all* 1145336
-Node: tlmgr print-platform145391
-Node: tlmgr print-platform-info145722
-Node: tlmgr remove [_option_...] _pkg_...146022
-Ref: tlmgr *--all* 2146506
-Ref: tlmgr *--backup*146616
-Ref: tlmgr *--backupdir* _directory_ 1146642
-Ref: tlmgr *--no-depends* 1147047
-Ref: tlmgr *--no-depends-at-all* 1147109
-Ref: tlmgr *--force* 1147212
-Ref: tlmgr *--dry-run* 3147685
-Node: tlmgr repository147792
-Ref: tlmgr *repository list*147980
-Ref: tlmgr *repository list _path|tag_*148010
-Ref: tlmgr *repository add _path_ [_tag_]*148043
-Ref: tlmgr *repository remove _path|tag_*148075
-Ref: tlmgr *repository set _path_[#_tag_] [_path_[#_tag_] ...]*148129
-Node: tlmgr restore149182
-Ref: tlmgr *restore [_option_...] _pkg_ [_rev_]*149361
-Ref: tlmgr *restore [_option_...] --all*149391
-Ref: tlmgr *--all* 3150091
-Ref: tlmgr *--backupdir* _directory_ 2150305
-Ref: tlmgr *--dry-run* 4150486
-Ref: tlmgr *--force* 2150618
-Ref: tlmgr *--json* 2150664
-Node: tlmgr search150991
-Ref: tlmgr *search [_option_...] _what_*151155
-Ref: tlmgr *search [_option_...] --file _what_*151192
-Ref: tlmgr *search [_option_...] --all _what_*151228
-Ref: tlmgr *--file* 1151448
-Ref: tlmgr *--all* 4151510
-Ref: tlmgr *--global*151599
-Ref: tlmgr *--word*151726
-Node: tlmgr shell152041
-Ref: tlmgr protocol152776
-Ref: tlmgr help 1152840
-Ref: tlmgr version 1152893
-Ref: tlmgr quit, end, bye, byebye, EOF152961
-Ref: tlmgr restart152982
-Ref: tlmgr load [local|remote]153105
-Ref: tlmgr save153175
-Ref: tlmgr get [_var_] =item set [_var_ [_val_]]153298
-Node: tlmgr show153899
-Node: tlmgr uninstall154066
-Node: tlmgr update [_option_...] [_pkg_...]154296
-Ref: tlmgr *--all* 5154667
-Ref: tlmgr *--self*156408
-Ref: tlmgr *--dry-run* 5157172
-Ref: tlmgr *--list* [_pkg_]157349
-Ref: tlmgr *--exclude* _pkg_158038
-Ref: tlmgr *--no-auto-remove* [_pkg_...]158838
-Ref: tlmgr *--no-auto-install* [_pkg_...]159289
-Ref: tlmgr *--reinstall-forcibly-removed*159945
-Ref: tlmgr *--backup* 1160480
-Ref: tlmgr *--backupdir* _directory_ 3160506
-Ref: tlmgr *--no-depends* 2161672
-Ref: tlmgr *--no-depends-at-all* 2161875
-Ref: tlmgr *--force* 3161978
-Node: tlmgr CONFIGURATION FILE FOR TLMGR162793
-Ref: tlmgr auto-remove, value 0 or 1 (default 1), same as command-line option.163806
-Ref: tlmgr gui-expertmode, value 0 or 1 (default 1). This switches between the full GUI and a simplified GUI with only the most common settings.163943
-Ref: tlmgr gui-lang _llcode_, with a language code value as with the command-line option.164025
-Ref: tlmgr no-checksums, value 0 or 1 (default 0, see below).164079
-Ref: tlmgr persistent-downloads, value 0 or 1 (default 1), same as command-line option.164159
-Ref: tlmgr require-verification, value 0 or 1 (default 0), same as command-line option.164239
-Ref: tlmgr update-exclude, value: comma-separated list of packages (no space allowed). Same as the command line option --exclude for the action update.164387
-Ref: tlmgr verify-downloads, value 0 or 1 (default 1), same as command-line option.164463
-Ref: tlmgr allowed-actions _action1_ [,_action_,...] The value is a comma-separated list of tlmgr actions which are allowed to be executed when tlmgr is invoked in system mode (that is, without --usermode).164732
-Node: tlmgr CRYPTOGRAPHIC VERIFICATION165818
-Node: tlmgr Configuration of GnuPG invocation167967
-Node: tlmgr USER MODE168605
-Node: tlmgr User mode install171451
-Node: tlmgr User mode backup, restore, remove, update172595
-Node: tlmgr User mode generate, option, paper173037
-Node: tlmgr MULTIPLE REPOSITORIES173413
-Node: tlmgr Pinning175142
-Node: tlmgr GUI FOR TLMGR177117
-Node: tlmgr Main display178457
-Node: tlmgr Display configuration area178709
-Ref: tlmgr Status179070
-Ref: tlmgr Category179234
-Ref: tlmgr Match179420
-Ref: tlmgr Selection179601
-Ref: tlmgr Display configuration buttons179805
-Node: tlmgr Package list area179988
-Ref: tlmgr a checkbox180572
-Ref: tlmgr package name180708
-Ref: tlmgr local revision (and version)180807
-Ref: tlmgr remote revision (and version)181182
-Ref: tlmgr short description181479
-Node: tlmgr Main display action buttons181524
-Ref: tlmgr Update all installed181790
-Ref: tlmgr Update182162
-Ref: tlmgr Install182212
-Ref: tlmgr Remove182398
-Ref: tlmgr Backup182576
-Node: tlmgr Menu bar182733
-Ref: tlmgr tlmgr menu182956
-Ref: tlmgr Options menu183264
-Ref: tlmgr Actions menu184347
-Ref: tlmgr Help menu184775
-Node: tlmgr GUI options184908
-Ref: tlmgr -background _color_185154
-Ref: tlmgr -font " _fontname_ _fontsize_ "185219
-Ref: tlmgr -foreground _color_185377
-Ref: tlmgr -geometry _geomspec_185429
-Ref: tlmgr -xrm _xresource_185621
-Node: tlmgr MACHINE-READABLE OUTPUT185889
-Node: tlmgr Machine-readable update and install output186699
-Ref: tlmgr location-url _location_187975
-Ref: tlmgr total-bytes _count_188191
-Ref: tlmgr _pkgname_188601
-Ref: tlmgr _status_188811
-Ref: tlmgr d188889
-Ref: tlmgr f188949
-Ref: tlmgr u189128
-Ref: tlmgr r189174
-Ref: tlmgr a189297
-Ref: tlmgr i189475
-Ref: tlmgr I189594
-Ref: tlmgr _localrev_189696
-Ref: tlmgr _serverrev_189803
-Ref: tlmgr _size_189915
-Ref: tlmgr _runtime_190084
-Ref: tlmgr _esttot_190154
-Node: tlmgr Machine-readable option output190187
-Node: tlmgr AUTHORS AND COPYRIGHT190699
-Node: Index191098
+Node: Building8606
+Node: Build iteration9992
+Node: Build problems11033
+Node: Build in parallel11487
+Node: Build distribution12091
+Node: Build one package12739
+Node: Build one engine16418
+Node: Cross compilation17467
+Node: Cross configuring18747
+Node: Cross problems20424
+Node: Installing22086
+Node: Installation directories23106
+Node: Linked scripts24924
+Node: Distro builds26415
+Node: Layout and infrastructure28791
+Node: Build system tools29622
+Node: Top-level directories31839
+Node: Autoconf macros34075
+Node: General setup macros34837
+Node: Macros for programs35712
+Node: Macros for compilers36513
+Node: Macros for libraries37921
+Node: Macros for library and header flags38347
+Node: Macros for Windows40258
+Node: Library modules41845
+Node: png library42334
+Node: zlib library44682
+Node: freetype library45197
+Node: kpathsea library45893
+Node: Program modules47272
+Node: t1utils package47700
+Node: xindy package48245
+Node: xdvik package49359
+Node: asymptote50418
+Node: Extending TeX Live50914
+Node: Adding a new program module51697
+Node: Adding a new generic library module55036
+Node: Adding a new TeX-specific library module57265
+Node: Configure options57963
+Node: Global configure options59344
+Node: --disable-native-texlive-build59886
+Node: --prefix --bindir ...60848
+Node: --disable-largefile61388
+Node: --disable-missing62089
+Node: --enable-compiler-warnings=LEVEL62490
+Node: --enable-cxx-runtime-hack63146
+Node: --enable-maintainer-mode63566
+Node: --enable-multiplatform64095
+Node: --enable-shared64668
+Node: --enable-silent-rules65039
+Node: --without-ln-s65491
+Node: --without-x65838
+Node: Program-specific configure options66026
+Node: --enable-PROG --disable-PROG66669
+Node: --disable-all-pkgs66942
+Node: Configure options for texk/web2c67725
+Node: Configure options for texk/bibtex-x70263
+Node: Configure options for texk/dvipdfm-x70806
+Node: Configure options for texk/dvisvgm71582
+Node: Configure options for texk/texlive72463
+Node: Configure options for texk/xdvik72884
+Node: Configure options for utils/xindy73505
+Node: Library-specific configure options74395
+Node: Configure options for kpathsea75397
+Node: Configure options for system poppler76146
+Node: Variables for configure76910
+Node: Coding conventions78336
+Node: Declarations and definitions79051
+Node: Const81225
+Node: Continuous integration83089
+Node: Transfer from Subversion to Github83753
+Node: Automatic update of the Git mirror85915
+Node: CI testing on Travis-CI86497
+Node: Releases on Github87206
+Node: install-tl87646
+Node: install-tl NAME88015
+Node: install-tl SYNOPSIS88173
+Node: install-tl DESCRIPTION88431
+Node: install-tl REFERENCES89498
+Node: install-tl OPTIONS90024
+Ref: install-tl *-gui* [[=]_module_]90365
+Ref: install-tl text90575
+Ref: install-tl wizard90698
+Ref: install-tl perltk90852
+Ref: install-tl *-no-gui*91283
+Ref: install-tl *-lang* _llcode_91364
+Ref: install-tl *-repository* _url|path_92051
+Ref: install-tl *-select-repository*93931
+Ref: install-tl *-all-options*94367
+Ref: install-tl *-custom-bin* _path_94622
+Ref: install-tl *-debug-translation*95454
+Ref: install-tl *-force-platform* _platform_95673
+Ref: install-tl *-help*, *--help*, *-?*95917
+Ref: install-tl *-in-place*96324
+Ref: install-tl *-init-from-profile* _profile_file_96869
+Ref: install-tl *-logfile* _file_97089
+Ref: install-tl *-no-cls*97440
+Ref: install-tl *-non-admin*97574
+Ref: install-tl *-persistent-downloads*97679
+Ref: install-tl *-no-persistent-downloads*97707
+Ref: install-tl *-no-verify-downloads*98325
+Ref: install-tl *-portable*98686
+Ref: install-tl *-print-platform*98825
+Ref: install-tl *-profile* _profile_file_99023
+Ref: install-tl *-q*99203
+Ref: install-tl *-scheme* _scheme_99265
+Ref: install-tl *-v*99739
+Ref: install-tl *-version*, *--version*99894
+Node: install-tl PROFILES100025
+Ref: install-tl instopt_adjustpath (default 0 on Unix, 1 on Windows)102675
+Ref: install-tl instopt_adjustrepo (default 1)102751
+Ref: install-tl instopt_letter (default 0)102888
+Ref: install-tl instopt_portable (default 0)102979
+Ref: install-tl instopt_write18_restricted (default 1)103075
+Node: install-tl ENVIRONMENT VARIABLES104394
+Ref: install-tl TEXLIVE_INSTALL_ENV_NOCHECK104785
+Ref: install-tl TEXLIVE_INSTALL_NO_CONTEXT_CACHE104987
+Ref: install-tl TEXLIVE_INSTALL_NO_WELCOME105097
+Ref: install-tl TEXLIVE_INSTALL_PREFIX105218
+Ref: install-tl TEXLIVE_INSTALL_TEXDIR105244
+Ref: install-tl TEXLIVE_INSTALL_TEXMFCONFIG105275
+Ref: install-tl TEXLIVE_INSTALL_TEXMFVAR105303
+Ref: install-tl TEXLIVE_INSTALL_TEXMFHOME105332
+Ref: install-tl TEXLIVE_INSTALL_TEXMFLOCAL105362
+Ref: install-tl TEXLIVE_INSTALL_TEXMFSYSCONFIG105396
+Ref: install-tl TEXLIVE_INSTALL_TEXMFSYSVAR105427
+Ref: install-tl NOPERLDOC105798
+Node: install-tl AUTHORS AND COPYRIGHT105862
+Node: tlmgr106278
+Node: tlmgr NAME106731
+Node: tlmgr SYNOPSIS106863
+Node: tlmgr DESCRIPTION107053
+Node: tlmgr EXAMPLES108149
+Ref: tlmgr tlmgr option repository ctan108400
+Ref: tlmgr tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet108472
+Ref: tlmgr tlmgr update --list108924
+Ref: tlmgr tlmgr update --all109017
+Ref: tlmgr tlmgr info _what_109174
+Node: tlmgr OPTIONS109436
+Ref: tlmgr *--repository* _url|path_109956
+Ref: tlmgr *--gui* [_action_]110681
+Ref: tlmgr *--gui-lang* _llcode_111088
+Ref: tlmgr *--debug-translation*111771
+Ref: tlmgr *--machine-readable*111974
+Ref: tlmgr *--no-execute-actions*112242
+Ref: tlmgr *--package-logfile* _file_112435
+Ref: tlmgr *--pause*112689
+Ref: tlmgr *--persistent-downloads*112844
+Ref: tlmgr *--no-persistent-downloads*112872
+Ref: tlmgr *--pin-file*113366
+Ref: tlmgr *--usermode*113584
+Ref: tlmgr *--usertree* _dir_113704
+Ref: tlmgr *--verify-repo=[none|main|all]*113830
+Node: tlmgr ACTIONS114729
+Node: tlmgr help115581
+Node: tlmgr version116057
+Node: tlmgr backup116320
+Ref: tlmgr *backup [_option_...] --all*116491
+Ref: tlmgr *backup [_option_...] _pkg_...*116524
+Ref: tlmgr *--backupdir* _directory_117379
+Ref: tlmgr *--all*117596
+Ref: tlmgr *--clean*[=_N_]117848
+Ref: tlmgr *--dry-run*118175
+Node: tlmgr candidates _pkg_118305
+Node: tlmgr check [_option_...] [files|depends|executes|runfiles|all]118651
+Ref: tlmgr *files*119024
+Ref: tlmgr *depends*119159
+Ref: tlmgr *executes*119501
+Ref: tlmgr *runfiles*119619
+Ref: tlmgr *--use-svn*119740
+Node: tlmgr conf119857
+Ref: tlmgr *conf [texmf|tlmgr|updmap [--conffile _file_] [--delete] [_key_ [_value_]]]*120136
+Ref: tlmgr *conf auxtrees [--conffile _file_] [show|add|delete] [_value_]*120200
+Node: tlmgr dump-tlpdb [_option_...] [--json]122545
+Ref: tlmgr *--local*122978
+Ref: tlmgr *--remote*123017
+Ref: tlmgr *--json*123055
+Node: tlmgr generate123626
+Ref: tlmgr *generate [_option_...] language*123822
+Ref: tlmgr *generate [_option_...] language.dat*123861
+Ref: tlmgr *generate [_option_...] language.def*123900
+Ref: tlmgr *generate [_option_...] language.dat.lua*123943
+Ref: tlmgr *--dest* _output_file_126269
+Ref: tlmgr *--localcfg* _local_conf_file_126845
+Ref: tlmgr *--rebuild-sys*126968
+Node: tlmgr gui127783
+Node: tlmgr info127961
+Ref: tlmgr *info [_option_...] _pkg_...*128123
+Ref: tlmgr *info [_option_...] collections*128157
+Ref: tlmgr *info [_option_...] schemes*128187
+Ref: tlmgr *--list*129717
+Ref: tlmgr *--only-installed*130031
+Ref: tlmgr *--data item1,item2,...*130230
+Ref: tlmgr *--json* 1130811
+Node: tlmgr init-usertree131194
+Node: tlmgr install [_option_...] _pkg_...131575
+Ref: tlmgr *--dry-run* 1132085
+Ref: tlmgr *--file*132202
+Ref: tlmgr *--force*132424
+Ref: tlmgr *--no-depends*132644
+Ref: tlmgr *--no-depends-at-all*132803
+Ref: tlmgr *--reinstall*133203
+Ref: tlmgr *--with-doc*133581
+Ref: tlmgr *--with-src*133594
+Node: tlmgr key134116
+Ref: tlmgr *key list*134274
+Ref: tlmgr *key add _file_*134292
+Ref: tlmgr *key remove _keyid_*134314
+Node: tlmgr list134909
+Node: tlmgr option135071
+Ref: tlmgr *option [--json] [show]*135226
+Ref: tlmgr *option [--json] showall*135252
+Ref: tlmgr *option _key_ [_value_]*135278
+Node: tlmgr paper139675
+Ref: tlmgr *paper [a4|letter]*139824
+Ref: tlmgr *[xdvi|pdftex|dvips|dvipdfmx|context|psutils] paper [_papersize_|--list]*139898
+Ref: tlmgr *paper --json*139913
+Node: tlmgr path141128
+Ref: tlmgr *path [--w32mode=user|admin] add*141289
+Ref: tlmgr *path [--w32mode=user|admin] remove*141326
+Node: tlmgr pinning142666
+Ref: tlmgr pinning show142907
+Ref: tlmgr pinning add _repo_ _pkgglob_...142980
+Ref: tlmgr pinning remove _repo_ _pkgglob_...143099
+Ref: tlmgr pinning remove _repo_ --all143252
+Node: tlmgr platform143306
+Ref: tlmgr *platform list|add|remove _platform_...*143492
+Ref: tlmgr *platform set _platform_*143519
+Ref: tlmgr *platform set auto*143540
+Ref: tlmgr *--dry-run* 2144426
+Node: tlmgr postaction144545
+Ref: tlmgr *postaction [_option_...] install [shortcut|fileassoc|script] [_pkg_...]*144775
+Ref: tlmgr *postaction [_option_...] remove [shortcut|fileassoc|script] [_pkg_...]*144849
+Ref: tlmgr *--w32mode=[user|admin]*145164
+Ref: tlmgr *--fileassocmode=[1|2]*145580
+Ref: tlmgr *--all* 1145865
+Node: tlmgr print-platform145920
+Node: tlmgr print-platform-info146251
+Node: tlmgr remove [_option_...] _pkg_...146551
+Ref: tlmgr *--all* 2147035
+Ref: tlmgr *--backup*147145
+Ref: tlmgr *--backupdir* _directory_ 1147171
+Ref: tlmgr *--no-depends* 1147576
+Ref: tlmgr *--no-depends-at-all* 1147638
+Ref: tlmgr *--force* 1147741
+Ref: tlmgr *--dry-run* 3148214
+Node: tlmgr repository148321
+Ref: tlmgr *repository list*148509
+Ref: tlmgr *repository list _path|tag_*148539
+Ref: tlmgr *repository add _path_ [_tag_]*148572
+Ref: tlmgr *repository remove _path|tag_*148604
+Ref: tlmgr *repository set _path_[#_tag_] [_path_[#_tag_] ...]*148658
+Node: tlmgr restore149711
+Ref: tlmgr *restore [_option_...] _pkg_ [_rev_]*149890
+Ref: tlmgr *restore [_option_...] --all*149920
+Ref: tlmgr *--all* 3150620
+Ref: tlmgr *--backupdir* _directory_ 2150834
+Ref: tlmgr *--dry-run* 4151015
+Ref: tlmgr *--force* 2151147
+Ref: tlmgr *--json* 2151193
+Node: tlmgr search151520
+Ref: tlmgr *search [_option_...] _what_*151684
+Ref: tlmgr *search [_option_...] --file _what_*151721
+Ref: tlmgr *search [_option_...] --all _what_*151757
+Ref: tlmgr *--file* 1151977
+Ref: tlmgr *--all* 4152039
+Ref: tlmgr *--global*152128
+Ref: tlmgr *--word*152255
+Node: tlmgr shell152570
+Ref: tlmgr protocol153305
+Ref: tlmgr help 1153369
+Ref: tlmgr version 1153422
+Ref: tlmgr quit, end, bye, byebye, EOF153490
+Ref: tlmgr restart153511
+Ref: tlmgr load [local|remote]153634
+Ref: tlmgr save153704
+Ref: tlmgr get [_var_] =item set [_var_ [_val_]]153827
+Node: tlmgr show154428
+Node: tlmgr uninstall154595
+Node: tlmgr update [_option_...] [_pkg_...]154825
+Ref: tlmgr *--all* 5155196
+Ref: tlmgr *--self*156937
+Ref: tlmgr *--dry-run* 5157701
+Ref: tlmgr *--list* [_pkg_]157878
+Ref: tlmgr *--exclude* _pkg_158567
+Ref: tlmgr *--no-auto-remove* [_pkg_...]159367
+Ref: tlmgr *--no-auto-install* [_pkg_...]159818
+Ref: tlmgr *--reinstall-forcibly-removed*160474
+Ref: tlmgr *--backup* 1161009
+Ref: tlmgr *--backupdir* _directory_ 3161035
+Ref: tlmgr *--no-depends* 2162201
+Ref: tlmgr *--no-depends-at-all* 2162404
+Ref: tlmgr *--force* 3162507
+Node: tlmgr CONFIGURATION FILE FOR TLMGR163322
+Ref: tlmgr auto-remove, value 0 or 1 (default 1), same as command-line option.164335
+Ref: tlmgr gui-expertmode, value 0 or 1 (default 1). This switches between the full GUI and a simplified GUI with only the most common settings.164472
+Ref: tlmgr gui-lang _llcode_, with a language code value as with the command-line option.164554
+Ref: tlmgr no-checksums, value 0 or 1 (default 0, see below).164608
+Ref: tlmgr persistent-downloads, value 0 or 1 (default 1), same as command-line option.164688
+Ref: tlmgr require-verification, value 0 or 1 (default 0), same as command-line option.164768
+Ref: tlmgr update-exclude, value: comma-separated list of packages (no space allowed). Same as the command line option --exclude for the action update.164916
+Ref: tlmgr verify-downloads, value 0 or 1 (default 1), same as command-line option.164992
+Ref: tlmgr allowed-actions _action1_ [,_action_,...] The value is a comma-separated list of tlmgr actions which are allowed to be executed when tlmgr is invoked in system mode (that is, without --usermode).165261
+Node: tlmgr CRYPTOGRAPHIC VERIFICATION166347
+Node: tlmgr Configuration of GnuPG invocation168496
+Node: tlmgr USER MODE169134
+Node: tlmgr User mode install171980
+Node: tlmgr User mode backup, restore, remove, update173124
+Node: tlmgr User mode generate, option, paper173566
+Node: tlmgr MULTIPLE REPOSITORIES173942
+Node: tlmgr Pinning175671
+Node: tlmgr GUI FOR TLMGR177646
+Node: tlmgr Main display178986
+Node: tlmgr Display configuration area179238
+Ref: tlmgr Status179599
+Ref: tlmgr Category179763
+Ref: tlmgr Match179949
+Ref: tlmgr Selection180130
+Ref: tlmgr Display configuration buttons180334
+Node: tlmgr Package list area180517
+Ref: tlmgr a checkbox181101
+Ref: tlmgr package name181237
+Ref: tlmgr local revision (and version)181336
+Ref: tlmgr remote revision (and version)181711
+Ref: tlmgr short description182008
+Node: tlmgr Main display action buttons182053
+Ref: tlmgr Update all installed182319
+Ref: tlmgr Update182691
+Ref: tlmgr Install182741
+Ref: tlmgr Remove182927
+Ref: tlmgr Backup183105
+Node: tlmgr Menu bar183262
+Ref: tlmgr tlmgr menu183485
+Ref: tlmgr Options menu183793
+Ref: tlmgr Actions menu184876
+Ref: tlmgr Help menu185304
+Node: tlmgr GUI options185437
+Ref: tlmgr -background _color_185683
+Ref: tlmgr -font " _fontname_ _fontsize_ "185748
+Ref: tlmgr -foreground _color_185906
+Ref: tlmgr -geometry _geomspec_185958
+Ref: tlmgr -xrm _xresource_186150
+Node: tlmgr MACHINE-READABLE OUTPUT186418
+Node: tlmgr Machine-readable update and install output187228
+Ref: tlmgr location-url _location_188504
+Ref: tlmgr total-bytes _count_188720
+Ref: tlmgr _pkgname_189130
+Ref: tlmgr _status_189340
+Ref: tlmgr d189418
+Ref: tlmgr f189478
+Ref: tlmgr u189657
+Ref: tlmgr r189703
+Ref: tlmgr a189826
+Ref: tlmgr i190004
+Ref: tlmgr I190123
+Ref: tlmgr _localrev_190225
+Ref: tlmgr _serverrev_190332
+Ref: tlmgr _size_190444
+Ref: tlmgr _runtime_190613
+Ref: tlmgr _esttot_190683
+Node: tlmgr Machine-readable option output190716
+Node: tlmgr AUTHORS AND COPYRIGHT191228
+Node: Index191627
 
 End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:

Added: branches/stable/source/src/doc/tlbuild.pdf
===================================================================
(Binary files differ)

Index: branches/stable/source/src/doc/tlbuild.pdf
===================================================================
--- branches/stable/source/src/doc/tlbuild.pdf	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/doc/tlbuild.pdf	2019-11-23 23:34:02 UTC (rev 816)

Property changes on: branches/stable/source/src/doc/tlbuild.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Modified: branches/stable/source/src/doc/tlbuild.texi
===================================================================
--- branches/stable/source/src/doc/tlbuild.texi	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/doc/tlbuild.texi	2019-11-23 23:34:02 UTC (rev 816)
@@ -234,11 +234,11 @@
 @cindex C++11, required
 A C++11 compiler is similarly required because of the third-party
 libraries ICU and Poppler; the program @code{dvisvgm} also requires
-C++11. It is possible to build everything else with older compilers;
- at url{https://tug.org/texlive/custom-bin.html} links to a build script
-for doing this.
+C++11.  It is possible to build everything else with older compilers,
+but you have to remove the C++11-dependent sources.  @xref{Build one
+package}.
 
-However, a few programs in the tree have additional requirements:
+A few programs in the tree have additional requirements:
 
 @table @file
 @item web2c
@@ -248,7 +248,7 @@
 @item xdvik
 @itemx xpdfopen
 @cindex X11 development, required by X clients
-require X11 headers and libraries, often in ``development'' packages
+require X11 headers and libraries, typically in ``development'' packages
 that are not installed by default.
 
 @item xetex
@@ -264,7 +264,7 @@
 @cindex @code{libsigsegv}, required by @code{xindy}
 requires GNU @code{clisp}, @code{libsigsegv}, and @code{libiconv};
 additionally, to build the rules and/or documentation: @code{perl},
- at code{latex}, and @code{pdflatex}
+ at code{latex}, @code{pdflatex}.
 
 @end table
 
@@ -440,18 +440,10 @@
 dependencies and can be invoked to build an individual program or
 library, first building any required libraries.
 
-This ``build-on-demand'' procedure is used, e.g., in the upstream
-Lua at TeX{} repository to build Lua at TeX{}, from a subset of the complete
- at TL{} source tree.  As another example, when building the original
-e- at TeX{} has been disabled (as it is by default), one can run
- at code{make etex} (or @code{make etex.exe}) in @file{texk/web2c/} to
-build e- at TeX{} (although there is no comparably simple way to
- at emph{install} e- at TeX{}).
+Here is an example from start to finish for working on
+ at code{dvipdfm-x}.  (Unfortunately, this does not suffice for building
+one, or a subset, of the @TeX{} engines; see the next section.)
 
-If you want to work on a single program within the TL sources, this is
-the recommended way to do it.  Here is an example from start to
-finish for working on @code{dvipdfm-x}.
-
 @example
 mkdir mydir && cd mydir  # new working directory
 
@@ -492,7 +484,6 @@
 is also a good idea to run @code{make check} after making any changes,
 to ensure that whatever tests have been written still pass.
 
-
 @cindex size of source tree
 Finally, the above retrieves the entire TL source tree (several
 hundred megabytes). It is natural to ask if this is really necessary.
@@ -506,12 +497,23 @@
 @url{http://pdftex.org}), which is indeed such a cut-down TL source
 tree.
 
+ at cindex C++11, removing dependent sources
+Some libraries and programs require C++11.  If you want to build with
+an older compiler lacking such support, you need to (re)move those
+source directories; specifying @code{--disable} for them does not
+suffice, unfortunately.  Specifically, before running @code{configure}:
+
+ at example
+rm -rf libs/icu libs/poppler libs/graphite2 texk/dvisvgm
+ at end example
+
 @vindex --enable-missing @r{to ignore dependencies}
-Even with @code{--disable-all-pkgs}, dependencies will be checked.
-For instance, if a (non-MacOSX) system does not have
- at code{fontconfig}, Xe at TeX{} cannot be built (@pxref{Prerequisites})
-and @code{configure} will terminate.  To proceed without such
-dependencies, specify @code{--enable-missing} also.
+Also, even with @code{--disable-all-pkgs}, dependencies are (currently)
+checked.  For instance, if a (non-MacOSX) system does not have
+ at code{fontconfig}, Xe at TeX{} cannot be built (@pxref{Prerequisites}),
+and @code{configure} will terminate even with @code{--disable-xetex}.
+To proceed without such dependencies, specify @code{--enable-missing}
+also.  (Patches to improve this would be most welcome.)
 
 @vindex CC=@var{c-compiler}
 @vindex CXX=@var{c++-compiler}
@@ -546,8 +548,9 @@
 
 This works because the @code{make} automatically runs @code{configure}
 as necessary for the dependencies and target.  Furthermore, the source
-tree can be cut down to just what is needed for the given engine (as
-the separate pdf at TeX{} and Lua at TeX{} source repositories do).
+tree can be cut down to just what is needed for the given engine
+(the separate pdf at TeX{} and Lua at TeX{} source repositories do this, if
+you want to peruse examples).
 
 We hope to improve the situation in the future.  Patches are welcome.
 
@@ -974,7 +977,6 @@
 be sure to set @file{use-commit-times=yes} in
 @file{~/.subversion/config} or the equivalent.
 
-
 @cindex touching files to avoid rerunning
 @pindex make -t
 If timestamps are wrong, you may also be able to avoid unnecessary
@@ -983,7 +985,7 @@
 files.  With @code{--enable-maintainer-mode} it may also be necessary
 to @code{touch} first @file{aclocal.m4}, then @file{configure} and
 @file{config.h.in} (or @file{c-auto.in}), and finally all
- at file{Makefile.in} files.  Perhaps @code{make -t} will help.
+ at file{Makefile.in} files.
 
 
 @node Top-level directories
@@ -2031,7 +2033,7 @@
 program, which is specified with an additional @code{--enable} option,
 e.g., @code{--enable-dvipdfm-x}.  It's still simplest to check out and
 configure the whole source tree, but at least only the program you are
-interested in, and its dependencies, are built. @xref{Build one package}.
+interested in, and its dependencies, are built.  @xref{Build one package}.
 
 Without this option, all modules are built except those that are
 explicitly disabled or specify @code{disable} in their
@@ -2552,6 +2554,7 @@
 * Transfer from Subversion to Github::
 * Automatic update of the Git mirror::
 * CI testing on Travis-CI::
+* Releases on Github::
 @end menu
 
 
@@ -2634,6 +2637,22 @@
 If changes have been pushed via the cron job above, Travis-CI will
 automatically checkout the last pushed commit and try building it.
 
+ at node Releases on Github
+ at section Releases on Github
+
+Given a git checkout of @code{texlive-source}:
+
+ at example
+git pull
+git tag build-svnNNNN
+git push --tags
+ at end example
+
+ at noindent and the result will appear at
+ at url{https://github.com/TeX-Live/texlive-source/releases}.
+Releases can also be made manually from that web page (see
+ at code{tl-update-bindir} for hints).
+
 @c made from pod doc.
 @include tlbuild-incl/install-tl.texi
 @include tlbuild-incl/tlmgr.texi

Modified: branches/stable/source/src/libs/README
===================================================================
--- branches/stable/source/src/libs/README	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/README	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,4 +1,4 @@
-$Id: README 51529 2019-07-02 04:44:43Z kakuto $
+$Id: README 52576 2019-10-29 21:32:18Z kakuto $
 Public domain.  Originally created by Karl Berry, 2005.
 
 Libraries we compile for TeX Live.
@@ -25,7 +25,7 @@
   http://sourceforge.net/projects/silgraphite/files/graphite2/
   (requires C++11)
 
-harfbuzz 2.5.3 - checked 27jun19
+harfbuzz 2.6.4 - checked 30oct19
   http://www.freedesktop.org/software/harfbuzz/release/
 
 icu 63.1 - checked 8jan19
@@ -59,7 +59,7 @@
 teckit 2.5.9 - checked 03may19
   https://github.com/silnrsi/teckit/archive/2.5.9.tar.gz
 
-xpdf 4.01.01 - checked 03may19
+xpdf 4.02 - checked 29sep19
   http://www.xpdfreader.com/download.html
   with modifications for pdftex
 

Modified: branches/stable/source/src/libs/xpdf/ChangeLog
===================================================================
--- branches/stable/source/src/libs/xpdf/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,8 @@
+2019-09-29  Akira Kakuto  <kakuto at w32tex.org>
+
+	* Import xpdf-4.02.
+	* version.ac: Adjust.
+
 2019-05-03  Akira Kakuto  <kakuto at w32tex.org>
 
 	* Import xpdf-4.01.01.

Modified: branches/stable/source/src/libs/xpdf/TLpatches/ChangeLog
===================================================================
--- branches/stable/source/src/libs/xpdf/TLpatches/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/TLpatches/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,7 @@
+2019-09-29  Akira Kakuto  <kakuto at w32tex.org>
+
+	* patch-bunched: Adjust.
+
 2019-05-03  Akira Kakuto  <kakuto at w32tex.org>
 
 	* patch-bunched: Adjust.

Modified: branches/stable/source/src/libs/xpdf/TLpatches/TL-Changes
===================================================================
--- branches/stable/source/src/libs/xpdf/TLpatches/TL-Changes	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/TLpatches/TL-Changes	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,4 +1,4 @@
-Changes applied to the xpdf-4.01.01/ tree as obtained from:
+Changes applied to the xpdf-4.02/ tree as obtained from:
 	http://www.xpdfreader.com/download.html
 
 Removed:

Modified: branches/stable/source/src/libs/xpdf/TLpatches/patch-bunched
===================================================================
--- branches/stable/source/src/libs/xpdf/TLpatches/patch-bunched	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/TLpatches/patch-bunched	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
-diff -ur xpdf-4.01.01/goo/gfile.cc xpdf-src/goo/gfile.cc
---- xpdf-4.01.01/goo/gfile.cc	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/goo/gfile.cc	Mon Feb 25 11:09:32 2019
+diff -ur xpdf-4.02/goo/gfile.cc xpdf-src/goo/gfile.cc
+--- xpdf-4.02/goo/gfile.cc	Thu Sep 26 04:54:33 2019
++++ xpdf-src/goo/gfile.cc	Sun Sep 29 11:23:53 2019
 @@ -7,6 +7,9 @@
  // Copyright 1996-2003 Glyph & Cog, LLC
  //
@@ -11,7 +11,7 @@
  
  #include <aconf.h>
  
-@@ -52,7 +55,11 @@
+@@ -54,7 +57,11 @@
    char *s;
    GString *ret;
  
@@ -23,7 +23,7 @@
      ret = new GString(s);
    else
      ret = new GString(".");
-@@ -401,6 +408,7 @@
+@@ -403,6 +410,7 @@
  #endif
  }
  
@@ -31,7 +31,7 @@
  GBool openTempFile(GString **name, FILE **f,
  		   const char *mode, const char *ext) {
  #if defined(_WIN32)
-@@ -515,10 +523,11 @@
+@@ -517,10 +525,11 @@
    return gTrue;
  #endif
  }
@@ -44,7 +44,7 @@
  #else
    return !mkdir(path, mode);
  #endif
-@@ -572,6 +581,8 @@
+@@ -574,6 +583,8 @@
  
  FILE *openFile(const char *path, const char *mode) {
  #if defined(_WIN32)
@@ -53,7 +53,7 @@
    OSVERSIONINFO version;
    wchar_t wPath[_MAX_PATH + 1];
    char nPath[_MAX_PATH + 1];
-@@ -628,6 +639,7 @@
+@@ -630,6 +641,7 @@
      nPath[i] = '\0';
      return fopen(nPath, mode);
    }
@@ -61,7 +61,7 @@
  #elif defined(VMS)
    return fopen(path, mode, "ctx=stm");
  #else
-@@ -688,6 +700,7 @@
+@@ -690,6 +702,7 @@
  #endif
  }
  
@@ -69,15 +69,15 @@
  void fixCommandLine(int *argc, char **argv[]) {
  #ifdef _WIN32
    int argcw;
-@@ -713,3 +726,4 @@
+@@ -715,3 +728,4 @@
    LocalFree(argvw);
  #endif
  }
 +#endif /* !PDF_PARSER_ONLY */
-diff -ur xpdf-4.01.01/goo/gfile.h xpdf-src/goo/gfile.h
---- xpdf-4.01.01/goo/gfile.h	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/goo/gfile.h	Mon Feb 25 11:07:26 2019
-@@ -114,6 +114,8 @@
+diff -ur xpdf-4.02/goo/gfile.h xpdf-src/goo/gfile.h
+--- xpdf-4.02/goo/gfile.h	Thu Sep 26 04:54:33 2019
++++ xpdf-src/goo/gfile.h	Sun Sep 29 11:25:19 2019
+@@ -115,6 +115,8 @@
  
  // On Windows, this gets the Unicode command line and converts it to
  // UTF-8.  On other systems, this is a nop.
@@ -86,9 +86,9 @@
 +#endif /* !PDF_PARSER_ONLY */
  
  #endif
-diff -ur xpdf-4.01.01/xpdf/GlobalParams.cc xpdf-src/xpdf/GlobalParams.cc
---- xpdf-4.01.01/xpdf/GlobalParams.cc	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/GlobalParams.cc	Mon Feb 25 08:01:11 2019
+diff -ur xpdf-4.02/xpdf/GlobalParams.cc xpdf-src/xpdf/GlobalParams.cc
+--- xpdf-4.02/xpdf/GlobalParams.cc	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/GlobalParams.cc	Sun Sep 29 11:32:58 2019
 @@ -5,6 +5,9 @@
  // Copyright 2001-2003 Glyph & Cog, LLC
  //
@@ -99,7 +99,7 @@
  
  #include <aconf.h>
  
-@@ -39,8 +42,12 @@
+@@ -44,8 +47,12 @@
  #include "GlobalParams.h"
  
  #ifdef _WIN32
@@ -114,7 +114,7 @@
  #endif
  
  #if MULTITHREADED
-@@ -684,6 +691,7 @@
+@@ -803,6 +810,7 @@
    f = NULL;
    fileName = NULL;
    if (cfgFileName && cfgFileName[0]) {
@@ -122,7 +122,7 @@
      fileName = new GString(cfgFileName);
      if (!(f = fopen(fileName->getCString(), "r"))) {
        delete fileName;
-@@ -716,6 +724,7 @@
+@@ -835,6 +843,7 @@
      parseFile(fileName, f);
      delete fileName;
      fclose(f);
@@ -130,7 +130,7 @@
    }
  }
  
-@@ -2092,8 +2101,11 @@
+@@ -2265,8 +2274,11 @@
  				   base14->fontNum,
  				   displayFontTab[i].obliqueFactor));
        } else {
@@ -142,9 +142,9 @@
        }
      }
    }
-diff -ur xpdf-4.01.01/xpdf/GlobalParams.h xpdf-src/xpdf/GlobalParams.h
---- xpdf-4.01.01/xpdf/GlobalParams.h	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/GlobalParams.h	Mon Feb 25 08:02:36 2019
+diff -ur xpdf-4.02/xpdf/GlobalParams.h xpdf-src/xpdf/GlobalParams.h
+--- xpdf-4.02/xpdf/GlobalParams.h	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/GlobalParams.h	Sun Sep 29 11:34:12 2019
 @@ -5,6 +5,9 @@
  // Copyright 2001-2003 Glyph & Cog, LLC
  //
@@ -155,7 +155,7 @@
  
  #ifndef GLOBALPARAMS_H
  #define GLOBALPARAMS_H
-@@ -218,7 +221,7 @@
+@@ -219,7 +222,7 @@
  
    // Initialize the global parameters by attempting to read a config
    // file.
@@ -164,10 +164,10 @@
  
    ~GlobalParams();
  
-diff -ur xpdf-4.01.01/xpdf/PDFDoc.cc xpdf-src/xpdf/PDFDoc.cc
---- xpdf-4.01.01/xpdf/PDFDoc.cc	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/PDFDoc.cc	Sun Mar 17 08:59:43 2019
-@@ -147,20 +147,25 @@
+diff -ur xpdf-4.02/xpdf/PDFDoc.cc xpdf-src/xpdf/PDFDoc.cc
+--- xpdf-4.02/xpdf/PDFDoc.cc	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/PDFDoc.cc	Sun Sep 29 11:41:09 2019
+@@ -156,20 +156,25 @@
  
  PDFDoc::PDFDoc(char *fileNameA, GString *ownerPassword,
  	       GString *userPassword, PDFCore *coreA) {
@@ -193,20 +193,19 @@
    n = 0;
    i = 0;
    while (getUTF8(fileName, &i, &u)) {
-@@ -178,8 +183,12 @@
+@@ -187,8 +192,11 @@
    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-     file = _wfopen(fileNameU, L"rb");
+     file = _wfopen(fileNameU, wfopenReadMode);
    } else {
 +#endif /* 0 */
-     file = fopen(fileName->getCString(), "rb");
+     file = fopen(fileName->getCString(), fopenReadMode);
 +#if 0
    }
 +#endif /* 0 */
-+
  #elif defined(VMS)
-   file = fopen(fileName->getCString(), "rb", "ctx=stm");
+   file = fopen(fileName->getCString(), fopenReadMode, "ctx=stm");
  #else
-@@ -572,6 +581,7 @@
+@@ -581,6 +589,7 @@
    GBool ret;
  
    // NB: _wfopen is only available in NT
@@ -214,7 +213,7 @@
    version.dwOSVersionInfoSize = sizeof(version);
    GetVersionEx(&version);
    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-@@ -581,12 +591,15 @@
+@@ -590,12 +599,15 @@
      path2w[i] = 0;
      f = _wfopen(path2w, L"wb");
    } else {
@@ -230,9 +229,9 @@
    if (!f) {
      return gFalse;
    }
-diff -ur xpdf-4.01.01/xpdf/Page.cc xpdf-src/xpdf/Page.cc
---- xpdf-4.01.01/xpdf/Page.cc	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/Page.cc	Mon Feb 25 08:19:00 2019
+diff -ur xpdf-4.02/xpdf/Page.cc xpdf-src/xpdf/Page.cc
+--- xpdf-4.02/xpdf/Page.cc	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/Page.cc	Sun Sep 29 11:43:12 2019
 @@ -480,9 +480,9 @@
    delete links;
  }
@@ -251,10 +250,10 @@
 -}
  #endif
 +}
-diff -ur xpdf-4.01.01/xpdf/XFAForm.cc xpdf-src/xpdf/XFAForm.cc
---- xpdf-4.01.01/xpdf/XFAForm.cc	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/XFAForm.cc	Mon Feb 25 08:20:00 2019
-@@ -28,8 +28,10 @@
+diff -ur xpdf-4.02/xpdf/XFAForm.cc xpdf-src/xpdf/XFAForm.cc
+--- xpdf-4.02/xpdf/XFAForm.cc	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/XFAForm.cc	Sun Sep 29 11:44:10 2019
+@@ -29,8 +29,10 @@
  #include "XFAForm.h"
  
  #ifdef _WIN32
@@ -267,9 +266,9 @@
  #endif
  
  //------------------------------------------------------------------------
-diff -ur xpdf-4.01.01/xpdf/config.h xpdf-src/xpdf/config.h
---- xpdf-4.01.01/xpdf/config.h	Fri Mar 15 06:01:02 2019
-+++ xpdf-src/xpdf/config.h	Sun Mar 17 16:09:03 2019
+diff -ur xpdf-4.02/xpdf/config.h xpdf-src/xpdf/config.h
+--- xpdf-4.02/xpdf/config.h	Thu Sep 26 04:54:33 2019
++++ xpdf-src/xpdf/config.h	Sun Sep 29 11:45:39 2019
 @@ -78,11 +78,6 @@
  // popen
  //------------------------------------------------------------------------

Modified: branches/stable/source/src/libs/xpdf/configure
===================================================================
--- branches/stable/source/src/libs/xpdf/configure	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/configure	2019-11-23 23:34:02 UTC (rev 816)
@@ -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) 4.01.01.
+# Generated by GNU Autoconf 2.69 for xpdf (TeX Live) 4.02.
 #
 # 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='4.01.01'
-PACKAGE_STRING='xpdf (TeX Live) 4.01.01'
+PACKAGE_VERSION='4.02'
+PACKAGE_STRING='xpdf (TeX Live) 4.02'
 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) 4.01.01 to adapt to many kinds of systems.
+\`configure' configures xpdf (TeX Live) 4.02 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) 4.01.01:";;
+     short | recursive ) echo "Configuration of xpdf (TeX Live) 4.02:";;
    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 4.01.01
+xpdf (TeX Live) configure 4.02
 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 4.01.01, which was
+It was created by xpdf (TeX Live) $as_me 4.02, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3791,7 +3791,7 @@
 
 # Define the identity of the package.
  PACKAGE='xpdf--tex-live-'
- VERSION='4.01.01'
+ VERSION='4.02'
 
 
 # Some tools Automake needs.
@@ -6704,7 +6704,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 4.01.01, which was
+This file was extended by xpdf (TeX Live) $as_me 4.02, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6774,7 +6774,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 4.01.01
+xpdf (TeX Live) config.status 4.02
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: branches/stable/source/src/libs/xpdf/version.ac
===================================================================
--- branches/stable/source/src/libs/xpdf/version.ac	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/version.ac	2019-11-23 23:34:02 UTC (rev 816)
@@ -8,4 +8,4 @@
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current xpdf version
-m4_define([xpdf_version], [4.01.01])
+m4_define([xpdf_version], [4.02])

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/ANNOUNCE
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/ANNOUNCE	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/ANNOUNCE	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,4 +1,4 @@
-Subject: ANNOUNCE: Xpdf 4.01 - a PDF viewer and related tools
+Subject: ANNOUNCE: Xpdf 4.02 - 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.  The Xpdf project
@@ -5,22 +5,24 @@
 also includes a PDF text extractor, PDF-to-PostScript converter, and
 various other utilities.
 
-*** 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.
 
-4.01 is primarily a bug fix release.  There are some new features:
-* Added remote server mode back into xpdf.
-* Added support for Unicode file names for the command line tools on
-  Windows.
-* Added the tabStateFile setting, the saveTabState/loadTabState
-  commands, and the "-tabstate" switch to xpdf.  [Thanks to Christian
-  Barthel for the suggestion.]
-* Added the defaultPrinter xpdfrc setting.
+4.02 is primarily a bug fix release.  There are some new features:
 
+* Pdftohtml now extracts embedded fonts.
+
+* Various user interface tweaks in XpdfReader: added a button to
+  toggle sidebar visibilty, added menu items to toggle the sidebar and
+  toolbar, added the 'initialDisplayMode', 'initialToolbarState', and
+  'initialSelectMode' xpdfrc settings.
+
+* If XpdfReader is already running, double-clicking on a PDF file (or
+  dragging-and-dropping it on the XpdfReader icon) opens the file in a
+  new tab (via the new '-open' command line switch).
+
 See the `CHANGES' file for a complete list of changes.
 
 Source (C++ and C) is available, and it should be fairly easy to

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/CHANGES
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/CHANGES	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/CHANGES	2019-11-23 23:34:02 UTC (rev 816)
@@ -2550,3 +2550,99 @@
 Pdffonts now checks more carefully for loops between objects.
 Fixed a problem parsing large real numbers.  [Thanks to Loginsoft for
   the bug report.]
+
+4.02 (2019-sep-25)
+------------------
+Pdftohtml now extracts embedded fonts (TrueType and CFF only).
+Added the margin settings (-marginl -marginr -margint -marginb) to
+  pdftotext.
+Various user interface tweaks:
+  - added a toolbar button to toggle (show/hide) the sidebar
+  - added view menu items to toggle (show/hide) the sidebar and
+    toolbar
+  - added the 'showToolbar', 'hideToolbar', 'toggleToolbar',
+    'expandSidebar', and 'shrinkSidebar' commands
+  - added the 'initialDisplayMode', 'initialToolbarState', and
+    'initialSelectMode' xpdfrc settings
+  - rearranged the xpdf toolbar
+Implemented drag-and-drop, so that PDF files can be drag-and-dropped
+  onto an already-open xpdf window.
+Added the option to display page labels, rather than page numbers.
+Implemented the missing 'openInNewWin' command.
+Added the 'openFileIn', 'openFileAtDestIn', 'openFileAtPageIn', and
+  'openIn' commands; removed the 'openInNewWin' command.
+Added the '-open' switch to xpdf.
+Added the reverseVideoInvertImages setting.
+Page-up and page-down now "snap" to the nearest page, if it's within a
+  few pixels.  This avoids annoying behavior when the window is a tiny
+  bit too short or too tall for a page.
+Properly handle overprint in non-isolated transparency groups.
+Missing null check in Gfx::opSetExtGState().  [Thanks to
+  pwd at 360TeamSeri0us for the bug report.]
+The DCT decoder doesn't handle a sampling factor of 3 -- check for
+  this and report an error.  [Thanks for Agostino Sarubbo of Gentoo
+  for the bug report.]
+Check for images with a Pattern color space, and report an error.
+  [Thanks to TeamSeri0us for the bug report.]
+Check that the Width, Height, and BitsPerComponent are valid in image
+  soft masks.  [Thanks to TeamSeri0us for the bug report.]
+Check for zero page width/height in PSOutputDev.  [Thanks to
+  TeamSeri0us for the bug report.]
+Check for divide-by-zero in PostScript functions.  [Thanks to
+  TeamSeri0us for the bug report.]
+Properly handle overprint in shading pattern strokes.
+The "save image" feature in Xpdf wasn't getting the user-specified
+  page number correctly.
+PostScript doesn't support progressive or non-interleaved DCT (JPEG)
+  streams, so check for those and re-encode them in PS output.
+Splash now caches the most recent scaled image, in case it is
+  immediately reused -- this results in a significant speedup in
+  certain cases.
+Fixed a problem with parsing the TrueType loca table.  [Thanks to
+  Pangu Lab for the bug report.]
+Fixed a problem with int overflow on image bounds.  [Thanks to
+  Pangu Lab for the bug report.]
+Fixed a problem with TrueType font parsing where there is gibberish in
+  the TrueType table directory.  [Thanks to Pangu Lab for the bug
+  report.]
+Fixed a problem with JPX image resolution reduction.  [Thanks to Pangu
+  Lab for the bug report.]
+Fixed a problem with non-isolated transparency groups in 1-bit
+  monochrome mode.  [Thanks to Pangu Lab for the bug report.]
+Fixed various bugs in FoFi.  [Thanks to Pangu Lab for the bug
+  reports.]
+Added a missing bounds check to Annot::setFillColor().  [Thanks to
+  Pangu Lab for the bug report.]
+Added a check on the DCT quant table selector.  [Thanks to Pangu Lab
+  for the bug report.]
+Fixed a problem with the Type 3 font cache running out of entries.
+  [Thanks to Pangu Lab for the bug report.]
+Fixed an integer overflow bug in SampledFunction.  [Thanks to Pangu
+  Lab for the bug report.]
+Fixed an integer overflow bug in the tiling pattern size.  [Thanks to
+  Martin Muskens at Ergosoft for the bug report.]
+Fixed a read-past-end-of-buffer in the Type 1 font parser.  [Thanks to
+  Pangu Lab for the bug report.]
+Fixed an int overflow bug in the JBIG2 decoder.  [Thanks to
+  TeamSeri0us for the bug report.]
+Added a missing bounds check to GfxPatchMeshShading::parse().  [Thanks
+  to TeamSeri0us for the bug report.]
+JPEG 2000 tile indexes were being computed incorrectly.  [Thanks to
+  TeamSeri0us for the bug report.]
+Large sample separation values in a JPX stream were resulting in
+  zero-width/height tiles, which caused problems.  [Thanks to Pangu
+  Lab for the bug report.]
+The XFA parser now looks for "ancestor matches" when searching for
+  data to fill a form field.
+Fixed an uninitialized variable in BuiltinFontWidths::getWidth().
+  [Thanks to Martin Muskens at Ergosoft for the bug report.]
+If there are no popupMenuCmd instances, construct a popup menu with
+  basic instructions pointing to 'popupMenuCmd'.
+Ignore color operators in uncolored tiling patterns.  [Thanks to
+  Martin Muskens at Ergosoft for the bug report.]
+Pdftotext raw mode output looks for space characters.
+Increased the width of the font name column in the pdffonts output.
+Function objects weren't checking their input/output counts properly.
+  [Thanks to Pangu Lab for the bug report.]
+TextPage::findGaps() wasn't checking the x/y min/max values for int
+  overflow.  [Thanks to Taolaw for the bugf report.]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/INSTALL
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/INSTALL	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/INSTALL	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 Xpdf
 ====
 
-version 4.01.01
-2019-mar-14
+version 4.02
+2019-sep-25
 
 The Xpdf software and documentation are
 copyright 1996-2019 Glyph & Cog, LLC.
@@ -97,6 +97,11 @@
         Enables support for generation of OPI (Open Prepress
         Interface) comments with pdftops.
 
+    -DNO_FONTCONFIG=ON
+        Disables use of libfontconfig, which is used to locate system
+        fonts on Linux/Unix systems.  The default is to search for the
+        library, and to use it if found.
+
     -DMULTITHREADED=0
         Disables multithreading, which also disables building the GUI
         viewer (xpdf).  This does not affect the command line tools.
@@ -104,6 +109,9 @@
         building with a compiler other than gcc, clang, or Microsoft
         Visual Studio.
 
+    -DXPDFWIDGET_PRINTING=OFF
+        Disable printing support.
+
     -DSYSTEM_XPDFRC="/etc/xpdfrc"
         Look for a system-wide xpdfrc config file in this directory.
 
@@ -110,7 +118,9 @@
      -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).
+        building the GUI viewer (xpdf).  Cmake will look for a "qmake"
+        binary -- make sure the first qmake binary on your executable
+        search path matches the desired version of Qt.
 
      -DCMAKE_C_FLAGS="..."
      -DCMAKE_CXX_FLAGS="..."

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/README
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/README	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/README	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 Xpdf
 ====
 
-version 4.01.01
-2019-mar-14
+version 4.02
+2019-sep-25
 
 The Xpdf software and documentation are
 copyright 1996-2019 Glyph & Cog, LLC.

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/aconf2.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/aconf2.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/aconf2.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -28,4 +28,14 @@
 #  endif
 #endif
 
+/*
+ * Speed up Windows compilation.  This will only work for the command
+ * line tools.
+ */
+/*
+ *#ifdef _WIN32
+ *#  define WIN32_LEAN_AND_MEAN
+ *#endif
+ */
+
 #endif

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/cmake-config.txt
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/cmake-config.txt	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/cmake-config.txt	2019-11-23 23:34:02 UTC (rev 816)
@@ -81,6 +81,7 @@
 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(NO_FONTCONFIG "disable support for libfontconfig" OFF)
 option(SYSTEM_XPDFRC "full path for system-wide xpdfrc file" "")
 if (SYSTEM_XPDFRC)
   set(SYSTEM_XPDFRC_DEFINE "#define SYSTEM_XPDFRC \"${SYSTEM_XPDFRC}\"")
@@ -193,7 +194,7 @@
   find_package(Qt5Network)
   find_package(Qt5PrintSupport)
 else ()
-  find_package(Qt4)
+  find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
 endif ()
 if(Qt5Widgets_FOUND)
   message(STATUS "Qt5 found")
@@ -200,13 +201,7 @@
   if (XPDFWIDGET_PRINTING)
     set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}")
     set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS}")
-    if (APPLE)
-      set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport "-framework ApplicationServices")
-    elseif (UNIX)
-      set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport cups)
-    else ()
-      set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport)
-    endif ()
+    set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport)
   else ()
     set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}")
     set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}")
@@ -216,7 +211,12 @@
     if (APPLE)
       set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
     elseif (UNIX)
-      set(EXTRA_QT_LIBRARIES cups)
+      find_package(Cups)
+      if (CUPS_FOUND)
+        set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
+      else ()
+        set (XPDFWIDGET_PRINTING OFF)
+      endif ()
     else ()
       set(EXTRA_QT_LIBRARIES "")
     endif ()
@@ -229,7 +229,12 @@
     if (APPLE)
       set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
     elseif (UNIX)
-      set(EXTRA_QT_LIBRARIES cups)
+      find_package(Cups)
+      if (CUPS_FOUND)
+        set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
+      else ()
+        set (XPDFWIDGET_PRINTING OFF)
+      endif ()
     else ()
       set(EXTRA_QT_LIBRARIES "")
     endif ()
@@ -250,8 +255,30 @@
   set(PAPER_LIBRARY "")
 endif ()
 
+#--- look for fontconfig
+if (NOT NO_FONTCONFIG)
+  find_library(FONTCONFIG_LIBRARY
+               NAMES fontconfig libfontconfig
+               PATH_SUFFIXES lib64 lib
+  )
+  if (FONTCONFIG_LIBRARY)
+    set(HAVE_FONTCONFIG TRUE)
+    message(STATUS "Found fontconfig")
+  else ()
+    set(HAVE_FONTCONFIG FALSE)
+    set(FONTCONFIG_LIBRARY "")
+  endif ()
+else ()
+  set(HAVE_FONTCONFIG FALSE)
+  set(FONTCONFIG_LIBRARY "")
+endif ()
+
 #--- look for pthreads
-find_package(Threads)
+if (MULTITHREADED)
+  find_package(Threads)
+else ()
+  set(CMAKE_THREAD_LIBS_INIT "")
+endif ()
 
 #--- create aconf.h
 configure_file("aconf.h.in" "aconf.h")

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 2013-2019 Glyph & Cog, LLC
-.TH pdfdetach 1 "18 Feb 2019"
+.TH pdfdetach 1 "25 Sep 2019"
 .SH NAME
 pdfdetach \- Portable Document Format (PDF) document embedded file
-extractor (version 4.01)
+extractor (version 4.02)
 .SH SYNOPSIS
 .B pdfdetach
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfdetach.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdfdetach  -  Portable  Document  Format  (PDF)  document embedded file
-       extractor (version 4.01)
+       extractor (version 4.02)
 
 SYNOPSIS
        pdfdetach [options] [PDF-file]
@@ -89,4 +89,4 @@
 
 
 
-                                  18 Feb 2019                     pdfdetach(1)
+                                  25 Sep 2019                     pdfdetach(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1999-2019 Glyph & Cog, LLC
-.TH pdffonts 1 "18 Feb 2019"
+.TH pdffonts 1 "25 Sep 2019"
 .SH NAME
 pdffonts \- Portable Document Format (PDF) font analyzer (version
-4.01)
+4.02)
 .SH SYNOPSIS
 .B pdffonts
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdffonts.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -3,7 +3,7 @@
 
 
 NAME
-       pdffonts - Portable Document Format (PDF) font analyzer (version 4.01)
+       pdffonts - Portable Document Format (PDF) font analyzer (version 4.02)
 
 SYNOPSIS
        pdffonts [options] [PDF-file]
@@ -115,4 +115,4 @@
 
 
 
-                                  18 Feb 2019                      pdffonts(1)
+                                  25 Sep 2019                      pdffonts(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1998-2019 Glyph & Cog, LLC
-.TH pdfimages 1 "18 Feb 2019"
+.TH pdfimages 1 "25 Sep 2019"
 .SH NAME
 pdfimages \- Portable Document Format (PDF) image extractor
-(version 4.01)
+(version 4.02)
 .SH SYNOPSIS
 .B pdfimages
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfimages.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdfimages  -  Portable  Document  Format (PDF) image extractor (version
-       4.01)
+       4.02)
 
 SYNOPSIS
        pdfimages [options] PDF-file image-root
@@ -95,4 +95,4 @@
 
 
 
-                                  18 Feb 2019                     pdfimages(1)
+                                  25 Sep 2019                     pdfimages(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1999-2019 Glyph & Cog, LLC
-.TH pdfinfo 1 "18 Feb 2019"
+.TH pdfinfo 1 "25 Sep 2019"
 .SH NAME
 pdfinfo \- Portable Document Format (PDF) document information
-extractor (version 4.01)
+extractor (version 4.02)
 .SH SYNOPSIS
 .B pdfinfo
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdfinfo.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdfinfo - Portable Document Format (PDF) document information extractor
-       (version 4.01)
+       (version 4.02)
 
 SYNOPSIS
        pdfinfo [options] [PDF-file]
@@ -114,4 +114,4 @@
 
 
 
-                                  18 Feb 2019                       pdfinfo(1)
+                                  25 Sep 2019                       pdfinfo(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1997-2019 Glyph & Cog, LLC
-.TH pdftohtml 1 "18 Feb 2019"
+.TH pdftohtml 1 "25 Sep 2019"
 .SH NAME
 pdftohtml \- Portable Document Format (PDF) to HTML converter
-(version 4.01)
+(version 4.02)
 .SH SYNOPSIS
 .B pdftohtml
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftohtml.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdftohtml  -  Portable Document Format (PDF) to HTML converter (version
-       4.01)
+       4.02)
 
 SYNOPSIS
        pdftohtml [options] PDF-file HTML-dir
@@ -107,4 +107,4 @@
 
 
 
-                                  18 Feb 2019                     pdftohtml(1)
+                                  25 Sep 2019                     pdftohtml(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 2017-2019 Glyph & Cog, LLC
-.TH pdftopng 1 "18 Feb 2019"
+.TH pdftopng 1 "25 Sep 2019"
 .SH NAME
 pdftopng \- Portable Document Format (PDF) to Portable Network Graphics
-(PNG) converter (version 4.01)
+(PNG) converter (version 4.02)
 .SH SYNOPSIS
 .B pdftopng
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftopng.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdftopng  - Portable Document Format (PDF) to Portable Network Graphics
-       (PNG) converter (version 4.01)
+       (PNG) converter (version 4.02)
 
 SYNOPSIS
        pdftopng [options] PDF-file PNG-root
@@ -97,4 +97,4 @@
 
 
 
-                                  18 Feb 2019                      pdftopng(1)
+                                  25 Sep 2019                      pdftopng(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 2005-2019 Glyph & Cog, LLC
-.TH pdftoppm 1 "18 Feb 2019"
+.TH pdftoppm 1 "25 Sep 2019"
 .SH NAME
 pdftoppm \- Portable Document Format (PDF) to Portable Pixmap (PPM)
-converter (version 4.01)
+converter (version 4.02)
 .SH SYNOPSIS
 .B pdftoppm
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftoppm.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdftoppm - Portable Document Format (PDF) to Portable Pixmap (PPM) con-
-       verter (version 4.01)
+       verter (version 4.02)
 
 SYNOPSIS
        pdftoppm [options] PDF-file PPM-root
@@ -96,4 +96,4 @@
 
 
 
-                                  18 Feb 2019                      pdftoppm(1)
+                                  25 Sep 2019                      pdftoppm(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1996-2019 Glyph & Cog, LLC
-.TH pdftops 1 "18 Feb 2019"
+.TH pdftops 1 "25 Sep 2019"
 .SH NAME
 pdftops \- Portable Document Format (PDF) to PostScript converter
-(version 4.01)
+(version 4.02)
 .SH SYNOPSIS
 .B pdftops
 [options]

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftops.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdftops  - Portable Document Format (PDF) to PostScript converter (ver-
-       sion 4.01)
+       sion 4.02)
 
 SYNOPSIS
        pdftops [options] [PDF-file [PS-file]]
@@ -211,4 +211,4 @@
 
 
 
-                                  18 Feb 2019                       pdftops(1)
+                                  25 Sep 2019                       pdftops(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,8 +1,8 @@
 .\" Copyright 1997-2019 Glyph & Cog, LLC
-.TH pdftotext 1 "18 Feb 2019"
+.TH pdftotext 1 "25 Sep 2019"
 .SH NAME
 pdftotext \- Portable Document Format (PDF) to text converter
-(version 4.01)
+(version 4.02)
 .SH SYNOPSIS
 .B pdftotext
 [options]
@@ -125,6 +125,26 @@
 Insert a Unicode byte order marker (BOM) at the start of the text
 output.
 .TP
+.BI \-marginl " number"
+Specifies the left margin, in points.  Text in the left margin (i.e.,
+within that many points of the left edge of the page) is discarded.
+The default value is zero.
+.TP
+.BI \-marginr " number"
+Specifies the right margin, in points.  Text in the right margin
+(i.e., within that many points of the right edge of the page) is
+discarded.  The default value is zero.
+.TP
+.BI \-margint " number"
+Specifies the top margin, in points.  Text in the top margin (i.e.,
+within that many points of the top edge of the page) is discarded.
+The default value is zero.
+.TP
+.BI \-marginb " number"
+Specifies the bottom margin, in points.  Text in the bottom margin
+(i.e., within that many points of the bottom edge of the page) is
+discarded.  The default value is zero.
+.TP
 .BI \-opw " password"
 Specify the owner password for the PDF file.  Providing this will
 bypass all security restrictions.

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/pdftotext.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -4,7 +4,7 @@
 
 NAME
        pdftotext  -  Portable Document Format (PDF) to text converter (version
-       4.01)
+       4.02)
 
 SYNOPSIS
        pdftotext [options] [PDF-file [text-file]]
@@ -102,6 +102,26 @@
        -bom   Insert a Unicode byte order marker (BOM) at  the  start  of  the
               text output.
 
+       -marginl number
+              Specifies  the  left margin, in points.  Text in the left margin
+              (i.e., within that many points of the left edge of the page)  is
+              discarded.  The default value is zero.
+
+       -marginr number
+              Specifies the right margin, in points.  Text in the right margin
+              (i.e., within that many points of the right edge of the page) is
+              discarded.  The default value is zero.
+
+       -margint number
+              Specifies  the  top  margin,  in points.  Text in the top margin
+              (i.e., within that many points of the top edge of the  page)  is
+              discarded.  The default value is zero.
+
+       -marginb number
+              Specifies the bottom margin, in points.  Text in the bottom mar-
+              gin (i.e., within that many points of the  bottom  edge  of  the
+              page) is discarded.  The default value is zero.
+
        -opw password
               Specify  the  owner  password  for the PDF file.  Providing this
               will bypass all security restrictions.
@@ -148,4 +168,4 @@
 
 
 
-                                  18 Feb 2019                     pdftotext(1)
+                                  25 Sep 2019                     pdftotext(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.1
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.1	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.1	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
 .\" Copyright 1996-2019 Glyph & Cog, LLC
-.TH xpdf 1 "18 Feb 2019"
+.TH xpdf 1 "25 Sep 2019"
 .SH NAME
-xpdf \- Portable Document Format (PDF) file viewer (version 4.01)
+xpdf \- Portable Document Format (PDF) file viewer (version 4.02)
 .SH SYNOPSIS
 .B xpdf
 [options]
@@ -12,6 +12,11 @@
 [options]
 .B -remote
 .IR remote-name " [" command " ...]"
+.PP
+.B xpdf
+[options]
+.B -open
+.RI "[" PDF-file "]"
 .SH DESCRIPTION
 .B Xpdf
 is a viewer for Portable Document Format (PDF) files.  (These are also
@@ -74,6 +79,14 @@
 .BI \-title " title"
 Set the window title.  By default, the title will be "xpdf: foo.pdf".
 .TP
+.BI \-open " \fR[\fPPDF-file\fR]\fP"
+This option sets up a default remote server.  If Xpdf is already
+running (with the "-open" switch), the PDF file (if any) is opened in
+a new tab.  If Xpdf (with the "-open" switch) is not already running,
+starts Xpdf and opens the PDF file (if any).  This is useful for GUI
+desktop environments, e.g., the typical double-click on a PDF file
+case.
+.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
@@ -155,11 +168,25 @@
 are equivalent.)
 .PP
 .SH CONTROLS
-.SS Tool bar
+.SS Toolbar
 .TP
-.B "\'page' entry box"
+.B "toggle sidebar button"
+Toggles (i.e., shows or hides) the sidebar.
+.TP
+.B "status 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 "selection mode"
+This icon is an "I-beam" in linear selection mode, and an arrow in
+block selection mode.  Clicking on it toggles between the two
+selection modes.
+.TP
+.B "page number entry box"
 Move to a specific page number.  Click in the box to activate it, type
-the page number, then hit return.
+the page number, then hit return.  This will instead display and
+accept page labels, if the "view - page labels" menu item is checked.
 .TP
 .B "left/right arrow buttons"
 Go backward or forward along the history path.
@@ -176,12 +203,7 @@
 .B "fit page button"
 Change the zoom factor to fit the page to the window size.
 .TP
-.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 "\'find' box"
+.B "find entry box"
 Find a text string.  Click in the box to activate it, type a search
 string, then hit return.
 .TP
@@ -196,11 +218,11 @@
 words (on/off).
 .PP
 .SS Menu bar
-The menu bar is above the tool bar.  The menu items should be
+The menu bar is above the toolbar.  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
+The tab list is on the left, just below the toolbar.  It lists all
 open tabs.
 .PP
 .SS Outline/layers/attachments pane
@@ -291,6 +313,9 @@
 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-l
+Toggle between full-screen and window modes.
+.TP
 .B control-q
 Quit.
 .TP
@@ -433,6 +458,11 @@
 .B endSelection
 End a selection.
 .TP
+.BI expandSidebar( n )
+Expand the sidebar by
+.I n
+pixels.  Opens the sidebar if it is currently closed.
+.TP
 .B find
 Set keyboard focus to the \'find' box.
 .TP
@@ -497,6 +527,9 @@
 .BI help
 Open the help URL.
 .TP
+.B hideToolbar
+Hide the toolbar.
+.TP
 .B horizontalContinuousMode
 Switch to horizontal continuous view mode.
 .TP
@@ -526,7 +559,7 @@
 Switch to the next tab.
 .TP
 .B open
-Open a PDF file in this tab, using the open dialog.
+Open a PDF file in the current tab, using the open dialog.
 .TP
 .B openErrorWindow
 Open the error window.
@@ -538,9 +571,25 @@
 Open the specified file in the current tab at the specified named
 destination.
 .TP
+.BI openFileAtDestIn( file, dest, location )
+Open the specified file at the specified named destination.  Location
+must be "win" for a new window or "tab" for a new tab.
+.TP
 .BI openFileAtPage( file, page )
 Open the specified file in the current tab at the specified page.
 .TP
+.BI openFileAtPageIn( file, page, location )
+Open the specified file at the specified page.  Location must be "win"
+for a new window or "tab" for a new tab.
+.TP
+.BI openFileIn( file, location )
+Open the specified file.  Location must be "win" for a new window or
+"tab" for a new tab.
+.TP
+.BI openIn( location )
+Open a PDF file, using the open dialog.  Location must be "win" for a
+new window or "tab" for a new tab.
+.TP
 .B openSidebar
 Open the sidebar.
 .TP
@@ -705,6 +754,15 @@
 .BI setSelection( pg , ulx , uly , lrx , lry )
 Set the selection to the specified coordinates on the specified page.
 .TP
+.B showToolbar
+Show the toolbar.
+.TP
+.BI shrinkSidebar( n )
+Shrink the sidebar by
+.I n
+pixels.  Closes the sidebar if shrinking it would go below the minimum
+allowed side.
+.TP
 .B sideBySideContinuousMode
 Switch to side-by-side continuous view mode.
 .TP
@@ -743,6 +801,15 @@
 Toggle the sidebar between open and closed, resizing the window so
 that the document size doesn't change.
 .TP
+.B toggleToolbar
+Toggle the toolbar between shown and hidden.
+.TP
+.B viewPageLabels
+Show page labels (if the PDF file has them), rather than page numbers.
+.TP
+.B viewPageNumbers
+Show page numbers, rather than page labels.
+.TP
 .B windowMode
 Go to window (non-full-screen) mode.
 .TP

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdf.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -3,7 +3,7 @@
 
 
 NAME
-       xpdf - Portable Document Format (PDF) file viewer (version 4.01)
+       xpdf - Portable Document Format (PDF) file viewer (version 4.02)
 
 SYNOPSIS
        xpdf [options] [PDF-file [:page | +dest]] ...
@@ -10,6 +10,8 @@
 
        xpdf [options] -remote remote-name [command ...]
 
+       xpdf [options] -open [PDF-file]
+
 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
@@ -61,15 +63,23 @@
               Set the window title.  By default,  the  title  will  be  "xpdf:
               foo.pdf".
 
-       -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
+       -open [PDF-file]
+              This option sets up a default remote server.  If Xpdf is already
+              running (with the "-open" switch), the  PDF  file  (if  any)  is
+              opened  in  a new tab.  If Xpdf (with the "-open" switch) is not
+              already running, starts Xpdf and opens the PDF  file  (if  any).
+              This  is  useful for GUI desktop environments, e.g., the typical
+              double-click on a PDF file case.
+
+       -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.
 
        -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
+              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
@@ -78,18 +88,18 @@
               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:
+              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
+              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]
 
        -aa yes | no
-              Enable or disable font anti-aliasing.  This defaults  to  "yes".
+              Enable  or  disable font anti-aliasing.  This defaults to "yes".
               [config file: antialias]
 
        -aaVector yes | no
@@ -97,14 +107,14 @@
               [config file: vectorAntialias]
 
        -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]
 
        -pw password
-              Specify  the  password for the PDF file.  This can be either the
-              owner password (which will bypass all security restrictions)  or
+              Specify the password for the PDF file.  This can be  either  the
+              owner  password (which will bypass all security restrictions) or
               the user password.
 
        -fullscreen
@@ -111,13 +121,13 @@
               Open xpdf in full-screen mode, useful for presentations.
 
        -remote remote-name
-              Start  Xpdf  in  remote server mode.  See the REMOVE SERVER MODE
+              Start Xpdf in remote server mode.  See the  REMOVE  SERVER  MODE
               section.
 
        -display display
               Set the X display (only available with X11).
 
-       -cmd   Print commands  as  they're  executed  (useful  for  debugging).
+       -cmd   Print  commands  as  they're  executed  (useful  for debugging).
               [config file: printCommands]
 
        -cfg config-file
@@ -129,11 +139,26 @@
        -h     Print usage information.  (-help and --help are equivalent.)
 
 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.
+   Toolbar
+       toggle sidebar button
+              Toggles (i.e., shows or hides) the sidebar.
 
+       status 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.
+
+       selection mode
+              This  icon is an "I-beam" in linear selection mode, and an arrow
+              in block selection mode.  Clicking on it toggles between the two
+              selection modes.
+
+       page number entry box
+              Move  to  a  specific page number.  Click in the box to activate
+              it, type the page number, then hit return.   This  will  instead
+              display and accept page labels, if the "view - page labels" menu
+              item is checked.
+
        left/right arrow buttons
               Go backward or forward along the history path.
 
@@ -141,23 +166,18 @@
               Zoom out or in (i.e., change magnification) incrementally.
 
        zoom popup menu
-              Change  the  zoom  factor  (see the description of the -z option
+              Change the zoom factor (see the description  of  the  -z  option
               above).
 
        fit width button
-              Change the zoom factor to fit  the  page  width  to  the  window
+              Change  the  zoom  factor  to  fit  the page width to the window
               width.
 
        fit page button
               Change the zoom factor to fit the page to the window size.
 
-       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.
-
-       'find' box
-              Find  a  text  string.   Click in the box to activate it, type a
+       find entry box
+              Find a text string.  Click in the box to  activate  it,  type  a
               search string, then hit return.
 
        find next button
@@ -171,41 +191,41 @@
               whole words (on/off).
 
    Menu bar
-       The  menu  bar  is  above the tool bar.  The menu items should be self-
+       The menu bar is above the toolbar.  The  menu  items  should  be  self-
        explanatory.
 
    Tab list
-       The tab list is on the left, just below the tool  bar.   It  lists  all
-       open tabs.
+       The tab list is on the left, just below the toolbar.  It lists all open
+       tabs.
 
    Outline/layers/attachments pane
-       This  pane is on the left, below the tab list.  The popup allows you to
+       This pane is on the left, below the tab list.  The popup allows you  to
        select from outline, layers, or attachments.
 
-       The outline is a tree-like structure of bookmarks  that  allows  moving
+       The  outline  is  a tree-like structure of bookmarks that allows moving
        within the PDF file.  Not all PDF files have outlines.
 
-       Layers  (a.k.a.  optional content) allow parts of the PDF content to be
+       Layers (a.k.a. optional content) allow parts of the PDF content  to  be
        shown or hidden.  Not all PDF files have layers.
 
-       Attachments are other files embedded within the PDF file.  There  is  a
-       'save'  button  for each attached file.  Not all PDF files have attach-
+       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.
 
    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-
+       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.
 
    Links
-       When  the mouse is over a hyperlink, the link target will be shown in a
+       When the mouse is over a hyperlink, the link target will be shown in  a
        popup near the bottom of the window.
 
        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
+       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.)
 
    Mouse bindings
@@ -215,11 +235,11 @@
 
        Dragging the mouse with the middle button held down pans the window.
 
-       The right  mouse  button  opens  a  popup  menu  (see  popupMenuCmd  in
+       The  right  mouse  button  opens  a  popup  menu  (see  popupMenuCmd in
        xpdfrc(5)).
 
    Key bindings
-       This  section  lists the default key bindings.  Bindings can be changed
+       This section lists the default key bindings.  Bindings can  be  changed
        using the config file (see xpdfrc(5)).
 
        control-o
@@ -226,8 +246,8 @@
               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
+              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-f
@@ -261,10 +281,13 @@
               Open a new window.
 
        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-
+              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.
 
+       control-l
+              Toggle between full-screen and window modes.
+
        control-q
               Quit.
 
@@ -294,11 +317,11 @@
               Go to the last page.
 
        <space> or <PageDown>
-              Scroll down on the current page; if already at bottom,  move  to
+              Scroll  down  on the current page; if already at bottom, move to
               next page.
 
        control-<PageDown> or control-<down-arrow>
-              Go  to the next page.  If <ScrollLock> is active, this maintains
+              Go to the next page.  If <ScrollLock> is active, this  maintains
               the relative position on the page.
 
        <PageUp>
@@ -306,7 +329,7 @@
               ous page.
 
        control-<PageUp> or control-<up-arrow>
-              Go  to the previous page.  If <ScrollLock> is active, this main-
+              Go to the previous page.  If <ScrollLock> is active, this  main-
               tains the relative position on the page.
 
        <esc>  Exit full-screen mode.
@@ -320,20 +343,20 @@
        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
+       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 toggleFullScreenMode command.
 
-       Entering full-screen mode automatically switches  to  single-page  view
+       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
+       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  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
+       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.
 
        The following commands are supported:
@@ -349,11 +372,11 @@
               Check that file is open in the current tab, and open it if not.
 
        checkOpenFileAtDest(file,dest)
-              Check  that file is open in the current tab, and open it if not.
+              Check that file is open in the current tab, and open it if  not.
               In either case go to the specified named destination.
 
        checkOpenFileAtPage(file,page)
-              Check that file is open in the current tab, and open it if  not.
+              Check  that file is open in the current tab, and open it if not.
               In either case go to the specified page.
 
        closeSidebar
@@ -385,6 +408,10 @@
        endSelection
               End a selection.
 
+       expandSidebar(n)
+              Expand the sidebar by n pixels.  Opens the sidebar if it is cur-
+              rently closed.
+
        find   Set keyboard focus to the 'find' box.
 
        findFirst
@@ -448,6 +475,9 @@
 
        help   Open the help URL.
 
+       hideToolbar
+              Hide the toolbar.
+
        horizontalContinuousMode
               Switch to horizontal continuous view mode.
 
@@ -475,7 +505,7 @@
        nextTab
               Switch to the next tab.
 
-       open   Open a PDF file in this tab, using the open dialog.
+       open   Open a PDF file in the current tab, using the open dialog.
 
        openErrorWindow
               Open the error window.
@@ -487,10 +517,26 @@
               Open  the  specified  file  in  the current tab at the specified
               named destination.
 
+       openFileAtDestIn(file,dest,location)
+              Open the specified file  at  the  specified  named  destination.
+              Location must be "win" for a new window or "tab" for a new tab.
+
        openFileAtPage(file,page)
-              Open the specified file in the  current  tab  at  the  specified
+              Open  the  specified  file  in  the current tab at the specified
               page.
 
+       openFileAtPageIn(file,page,location)
+              Open the specified file at the specified page.  Location must be
+              "win" for a new window or "tab" for a new tab.
+
+       openFileIn(file,location)
+              Open  the specified file.  Location must be "win" for a new win-
+              dow or "tab" for a new tab.
+
+       openIn(location)
+              Open a PDF file, using the open dialog.  Location must be  "win"
+              for a new window or "tab" for a new tab.
+
        openSidebar
               Open the sidebar.
 
@@ -632,6 +678,13 @@
               Set  the selection to the specified coordinates on the specified
               page.
 
+       showToolbar
+              Show the toolbar.
+
+       shrinkSidebar(n)
+              Shrink the sidebar by n pixels.  Closes the sidebar if shrinking
+              it would go below the minimum allowed side.
+
        sideBySideContinuousMode
               Switch to side-by-side continuous view mode.
 
@@ -642,11 +695,11 @@
               Switch to single-page view mode.
 
        startPan
-              Start a pan operation at the current mouse position, which  will
+              Start  a pan operation at the current mouse position, which will
               scroll the document as the mouse moves.
 
        startSelection
-              Start  a  selection at the current mouse position, which will be
+              Start a selection at the current mouse position, which  will  be
               extended as the mouse moves.
 
        toggleContinuousMode
@@ -662,14 +715,24 @@
               Toggle the sidebar between open and closed.
 
        toggleSidebarMoveResizeWin
-              Toggle the sidebar between open and closed, resizing the  window
-              so  that the document size doesn't change, and moving the window
+              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.
 
        toggleSidebarResizeWin
-              Toggle the sidebar between open and closed, resizing the  window
+              Toggle  the sidebar between open and closed, resizing the window
               so that the document size doesn't change.
 
+       toggleToolbar
+              Toggle the toolbar between shown and hidden.
+
+       viewPageLabels
+              Show page labels (if the PDF file has them),  rather  than  page
+              numbers.
+
+       viewPageNumbers
+              Show page numbers, rather than page labels.
+
        windowMode
               Go to window (non-full-screen) mode.
 
@@ -732,4 +795,4 @@
 
 
 
-                                  18 Feb 2019                          xpdf(1)
+                                  25 Sep 2019                          xpdf(1)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.5
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.5	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.5	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
 .\" Copyright 2002-2019 Glyph & Cog, LLC
-.TH xpdfrc 5 "18 Feb 2019"
+.TH xpdfrc 5 "25 Sep 2019"
 .SH NAME
-xpdfrc \- configuration file for Xpdf tools (version 4.01)
+xpdfrc \- configuration file for Xpdf tools (version 4.02)
 .SH DESCRIPTION
 All of the Xpdf tools read a single configuration file.  If you have a
 .I .xpdfrc
@@ -537,11 +537,21 @@
 zoom factor (which must be a percentage).  The default value is
 based on the screen resolution.
 .TP
+.BR initialDisplayMode " single | continuous | sideBySideSingle | sideBySideContinuous | horizontalContinuous"
+Sets the initial display mode.  The default setting is "continuous".
+.TP
+.BI initialToolbarState " yes | no"
+If set to "yes", xpdf opens with the toolbar visible.  If set to "no",
+xpdf opens with the toolbar hidden.  The default is "yes".
+.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 "yes".
 .TP
+.BR initialSelectMode " block | linear"
+Sets the initial selection mode.  The default setting is "linear".
+.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
@@ -557,6 +567,11 @@
 Set the matte color for full-screen mode.  The color can be #RRGGBB
 (hexadecimal) or a named color.
 .TP
+.BI reverseVideoInvertImages " yes | no"
+If set to "no", xpdf's reverse-video mode inverts text and vector
+graphic content, but not images.  If set to "yes", xpdf inverts images
+as well.  The default is "no".
+.TP
 .BI popupMenuCmd " title command ..."
 Add a command to the popup menu.
 .I Title

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.cat
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.cat	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/doc/xpdfrc.cat	2019-11-23 23:34:02 UTC (rev 816)
@@ -3,7 +3,7 @@
 
 
 NAME
-       xpdfrc - configuration file for Xpdf tools (version 4.01)
+       xpdfrc - configuration file for Xpdf tools (version 4.02)
 
 DESCRIPTION
        All  of the Xpdf tools read a single configuration file.  If you have a
@@ -493,11 +493,24 @@
               window  at  this  zoom factor (which must be a percentage).  The
               default value is based on the screen resolution.
 
+       initialDisplayMode single | continuous | sideBySideSingle | sideBySide-
+       Continuous | horizontalContinuous
+              Sets the initial display mode.  The default setting is "continu-
+              ous".
+
+       initialToolbarState yes | no
+              If set to "yes", xpdf opens with the toolbar visible.  If set to
+              "no", xpdf opens with the toolbar hidden.  The default is "yes".
+
        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
+              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 "yes".
 
+       initialSelectMode block | linear
+              Sets  the  initial selection mode.  The default setting is "lin-
+              ear".
+
        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
@@ -513,6 +526,11 @@
               Set  the  matte  color  for  full-screen mode.  The color can be
               #RRGGBB (hexadecimal) or a named color.
 
+       reverseVideoInvertImages yes | no
+              If set to "no", xpdf's reverse-video mode inverts text and  vec-
+              tor  graphic  content,  but  not  images.  If set to "yes", xpdf
+              inverts images as well.  The default is "no".
+
        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-
@@ -716,4 +734,4 @@
 
 
 
-                                  18 Feb 2019                        xpdfrc(5)
+                                  25 Sep 2019                        xpdfrc(5)

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiBase.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiBase.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiBase.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -171,6 +171,7 @@
 
 GBool FoFiBase::checkRegion(int pos, int size) {
   return pos >= 0 &&
-         pos + size >= pos &&
+         size >= 0 &&
+         size <= INT_MAX - pos &&
          pos + size <= len;
 }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -320,6 +320,7 @@
   nCmaps = 0;
   nameToGID = NULL;
   isDfont = isDfontA;
+  isTTC = gFalse;
   parsedOk = gFalse;
 
   parse(fontNum, allowHeadlessCFF);
@@ -985,7 +986,8 @@
 
 GBool FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc,
 			     void *outputStream, char *name,
-			     int *codeToGID) {
+			     int *codeToGID, Guchar *replacementCmapTable,
+			     int replacementCmapTableLen) {
   // this substitute cmap table maps char code ffff to glyph 0,
   // with tables for MacRoman and MS Unicode
   static char cmapTab[44] = {
@@ -1188,7 +1190,7 @@
   if (!missingCmap && !missingName && !missingPost && !missingOS2 &&
       !unsortedLoca && !emptyCmap && !badCmapLen && !abbrevHMTX &&
       nZeroLengthTables == 0 && nBogusTables == 0 &&
-      !name && !codeToGID && !isDfont) {
+      !name && !codeToGID && !replacementCmapTable && !isDfont && !isTTC) {
     (*outputFunc)(outputStream, (char *)file, len);
     gfree(locaTable);
     return gFalse;
@@ -1306,7 +1308,7 @@
   }
 
   // construct the new cmap table
-  if (codeToGID) {
+  if (codeToGID && !replacementCmapTable) {
     newCmapLen = 44 + 256 * 2;
     newCmapTab = (char *)gmalloc(newCmapLen);
     newCmapTab[0] = 0;		// table version number = 0
@@ -1435,8 +1437,15 @@
 	  // don't include the file checksum
 	  newTables[j].checksum -= getU32BE(tables[i].offset + 8, &ok);
 	}
+      } else {
+	// we'll write four zero bytes for this table
+	newTables[j].len = 4;
       }
-      if (newTables[j].tag == cmapTag && codeToGID) {
+      if (newTables[j].tag == cmapTag && replacementCmapTable) {
+	newTables[j].len = replacementCmapTableLen;
+	newTables[j].checksum = computeTableChecksum(replacementCmapTable,
+						     replacementCmapTableLen);
+      } else if (newTables[j].tag == cmapTag && codeToGID) {
 	newTables[j].len = newCmapLen;
 	newTables[j].checksum = computeTableChecksum((Guchar *)newCmapTab,
 						     newCmapLen);
@@ -1470,7 +1479,11 @@
   }
   if (missingCmap) {
     newTables[j].tag = cmapTag;
-    if (codeToGID) {
+    if (replacementCmapTable) {
+      newTables[j].checksum = computeTableChecksum(replacementCmapTable,
+						   replacementCmapTableLen);
+      newTables[j].len = replacementCmapTableLen;
+    } else if (codeToGID) {
       newTables[j].checksum = computeTableChecksum((Guchar *)newCmapTab,
 						   newCmapLen);
       newTables[j].len = newCmapLen;
@@ -1588,6 +1601,9 @@
 	  (*outputFunc)(outputStream, "\0", 1);
 	}
       }
+    } else if (newTables[i].tag == cmapTag && replacementCmapTable) {
+      (*outputFunc)(outputStream, (char *)replacementCmapTable,
+		    newTables[i].len);
     } else if (newTables[i].tag == cmapTag && codeToGID) {
       (*outputFunc)(outputStream, newCmapTab, newTables[i].len);
     } else if (newTables[i].tag == cmapTag && missingCmap) {
@@ -1816,7 +1832,8 @@
     } else {
       locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok);
     }
-    if (locaTable[i].origOffset > glyfTableLen) {
+    if (locaTable[i].origOffset < 0 ||
+	locaTable[i].origOffset > glyfTableLen) {
       locaTable[i].origOffset = glyfTableLen;
     }
   }
@@ -2172,7 +2189,9 @@
     tables[j].checksum = getU32BE(offset + pos + 4, &parsedOk);
     tables[j].offset = offset + (int)getU32BE(offset + pos + 8, &parsedOk);
     tables[j].len = (int)getU32BE(offset + pos + 12, &parsedOk);
-    if (tables[j].offset + tables[j].len >= tables[j].offset &&
+    if (tables[j].offset >= 0 &&
+	tables[j].len >= 0 &&
+	tables[j].offset + tables[j].len >= tables[j].offset &&
 	tables[j].offset + tables[j].len <= len) {
       // ignore any bogus entries in the table directory
       ++j;
@@ -2274,6 +2293,7 @@
 void FoFiTrueType::parseTTC(int fontNum, int *pos) {
   int nFonts;
 
+  isTTC = gTrue;
   nFonts = getU32BE(8, &parsedOk);
   if (!parsedOk) {
     return;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiTrueType.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -95,6 +95,9 @@
   // for OpenType CFF fonts.)
   void getFontMatrix(double *mat);
 
+  // Return the number of glyphs in the font.
+  int getNumGlyphs() { return nGlyphs; }
+
   // Returns true if this looks like a CJK font that uses bytecode
   // instructions to assemble glyphs.
   GBool checkForTrickyCJK();
@@ -154,10 +157,15 @@
   // various other errors.  If <name> is non-NULL, the font is renamed
   // to <name>.  If <codeToGID> is non-NULL, the font is re-encoded,
   // using a Windows Unicode cmap.  If <name> is NULL and the font is
-  // complete and correct, it will be written unmodified.  (Not useful
-  // for OpenType CFF fonts.)  Returns true if the font was modified.
+  // complete and correct, it will be written unmodified.  If
+  // <replacementCmapTable> is non-NULL it will be used as the cmap
+  // table in the written font (overriding any existing cmap table
+  // and/or the codeToGID arg).  (Not useful for OpenType CFF fonts.)
+  // Returns true if the font was modified.
   GBool writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
-		 char *name = NULL, int *codeToGID = NULL);
+		 char *name = NULL, int *codeToGID = NULL,
+		 Guchar *replacementCmapTable = NULL,
+		 int replacementCmapTableLen = 0);
 
   // Returns a pointer to the CFF font embedded in this OpenType font.
   // If successful, sets *<start> and *<length>, and returns true.
@@ -200,6 +208,7 @@
   GBool openTypeCFF;
   GBool headlessCFF;
   GBool isDfont;
+  GBool isTTC;
 
   GBool parsedOk;
 };

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -99,7 +99,7 @@
 
   // copy everything up to the encoding
   for (line = (char *)file;
-       line && strncmp(line, "/Encoding", 9);
+       line && line + 9 <= (char *)file + len && strncmp(line, "/Encoding", 9);
        line = getNextLine(line)) ;
   if (!line) {
     // no encoding - just copy the whole font file
@@ -122,7 +122,8 @@
   
   // find the end of the encoding data
   //~ this ought to parse PostScript tokens
-  if (!strncmp(line, "/Encoding StandardEncoding def", 30)) {
+  if (line + 30 <= (char *)file + len && 
+      !strncmp(line, "/Encoding StandardEncoding def", 30)) {
     line = getNextLine(line);
   } else {
     // skip "/Encoding" + one whitespace char,
@@ -144,16 +145,18 @@
   // check for a second one here
   if (line) {
     for (line2 = line, i = 0;
-	 i < 20 && line2 && strncmp(line2, "/Encoding", 9);
+	 i < 20 && line2 && line2 + 9 <= (char *)file + len &&
+	   strncmp(line2, "/Encoding", 9);
 	 line2 = getNextLine(line2), ++i) ;
     if (i < 20 && line2) {
       (*outputFunc)(outputStream, line, (int)(line2 - line));
-      if (!strncmp(line2, "/Encoding StandardEncoding def", 30)) {
+      if (line2 + 30 <= (char *)file + len && 
+	  !strncmp(line2, "/Encoding StandardEncoding def", 30)) {
 	line = getNextLine(line2);
       } else {
-	// skip "/Encoding" + one whitespace char,
+	// skip "/Encoding",
 	// then look for 'def' preceded by PostScript whitespace
-	p = line2 + 10;
+	p = line2 + 9;
 	line = NULL;
 	for (; p < (char *)file + len; ++p) {
 	  if ((*p == ' ' || *p == '\t' || *p == '\x0a' ||
@@ -203,9 +206,14 @@
        ++i) {
 
     // get font name
-    if (!name && !strncmp(line, "/FontName", 9)) {
-      strncpy(buf, line, 255);
-      buf[255] = '\0';
+    if (!name && line + 9 <= (char *)file + len &&
+	!strncmp(line, "/FontName", 9)) {
+      n = 255;
+      if (line + n > (char *)file + len) {
+	n = (int)(((char *)file + len) - line);
+      }
+      strncpy(buf, line, n);
+      buf[n] = '\0';
       if ((p = strchr(buf+9, '/')) &&
 	  (p = strtok(p+1, " \t\n\r"))) {
 	name = copyString(p);
@@ -213,10 +221,10 @@
       line = getNextLine(line);
 
     // get encoding
-    } else if (!encoding &&
+    } else if (!encoding && line + 30 <= (char *)file + len &&
 	       !strncmp(line, "/Encoding StandardEncoding def", 30)) {
       encoding = (char **)fofiType1StandardEncoding;
-    } else if (!encoding &&
+    } else if (!encoding && line + 19 <= (char *)file + len &&
 	       !strncmp(line, "/Encoding 256 array", 19)) {
       encoding = (char **)gmallocn(256, sizeof(char *));
       for (j = 0; j < 256; ++j) {
@@ -284,9 +292,14 @@
       }
       //~ check for getinterval/putinterval junk
 
-    } else if (!gotMatrix && !strncmp(line, "/FontMatrix", 11)) {
-      strncpy(buf, line + 11, 255);
-      buf[255] = '\0';
+    } else if (!gotMatrix && line + 11 <= (char *)file + len &&
+	       !strncmp(line, "/FontMatrix", 11)) {
+      n = 255;
+      if (line + 11 + n > (char *)file + len) {
+	n = (int)(((char *)file + len) - (line + 11));
+      }
+      strncpy(buf, line + 11, n);
+      buf[n] = '\0';
       if ((p = strchr(buf, '['))) {
 	++p;
 	if ((p2 = strchr(p, ']'))) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -18,6 +18,7 @@
 #include "gmem.h"
 #include "gmempp.h"
 #include "GString.h"
+#include "GHash.h"
 #include "FoFiEncodings.h"
 #include "FoFiType1C.h"
 
@@ -152,6 +153,23 @@
   return new GString(buf);
 }
 
+GHash *FoFiType1C::getNameToGIDMap() {
+  GHash *map;
+  char name[256];
+  GBool ok;
+  int gid;
+
+  map = new GHash(gTrue);
+  for (gid = 0; gid < nGlyphs; ++gid) {
+    ok = gTrue;
+    getString(charset[gid], name, &ok);
+    if (ok) {
+      map->add(new GString(name), gid);
+    }
+  }
+  return map;
+}
+
 int *FoFiType1C::getCIDToGIDMap(int *nCIDs) {
   int *map;
   int n, i;
@@ -2183,6 +2201,371 @@
   (*outputFunc)(outputStream, buf, i);
 }
 
+void FoFiType1C::convertToOpenType(FoFiOutputFunc outputFunc,
+				   void *outputStream,
+				   int nWidths, Gushort *widths,
+				   Guchar *cmapTable, int cmapTableLen) {
+  // dummy OS/2 table (taken from FoFiTrueType::writeTTF)
+  static Guchar os2Tab[86] = {
+    0, 1,			// version
+    0, 1,			// xAvgCharWidth
+    0x01, 0x90,			// usWeightClass
+    0, 5,			// usWidthClass
+    0, 0,			// fsType
+    0, 0,			// ySubscriptXSize
+    0, 0,			// ySubscriptYSize
+    0, 0,			// ySubscriptXOffset
+    0, 0,			// ySubscriptYOffset
+    0, 0,			// ySuperscriptXSize
+    0, 0,			// ySuperscriptYSize
+    0, 0,			// ySuperscriptXOffset
+    0, 0,			// ySuperscriptYOffset
+    0, 0,			// yStrikeoutSize
+    0, 0,			// yStrikeoutPosition
+    0, 0,			// sFamilyClass
+    0, 0, 0, 0, 0,		// panose
+    0, 0, 0, 0, 0,
+    0, 0, 0, 0,			// ulUnicodeRange1
+    0, 0, 0, 0,			// ulUnicodeRange2
+    0, 0, 0, 0,			// ulUnicodeRange3
+    0, 0, 0, 0,			// ulUnicodeRange4
+    0, 0, 0, 0,			// achVendID
+    0, 0,			// fsSelection
+    0, 0,			// usFirstCharIndex
+    0, 0,			// usLastCharIndex
+    0, 0,			// sTypoAscender
+    0, 0,			// sTypoDescender
+    0, 0,			// sTypoLineGap
+    0x20, 0x00,			// usWinAscent
+    0x20, 0x00,			// usWinDescent
+    0, 0, 0, 1,			// ulCodePageRange1
+    0, 0, 0, 0			// ulCodePageRange2
+  };
+  Guchar headTable[54], hheaTable[36], maxpTable[6];
+  Guchar nameTable[26], postTable[32];
+  Guchar *hmtxTable;
+  static const char *tableTag[9] = {
+    "CFF ",
+    "OS/2",
+    "cmap",
+    "head",
+    "hhea",
+    "hmtx",
+    "maxp",
+    "name",
+    "post"
+  };
+  Guchar *tableData[9];
+  int tableLength[9];
+  Guchar header[12 + 9*16];
+  double mat[6];
+  Gushort maxWidth;
+  Guint checksum, fileChecksum;
+  int unitsPerEm, xMin, yMin, xMax, yMax, offset, i;
+
+  //--- CFF_ table
+  tableData[0] = file;
+  tableLength[0] = len;
+
+  //--- OS/2 table
+  tableData[1] = os2Tab;
+  tableLength[1] = 86;
+
+  //--- cmap table
+  tableData[2] = cmapTable;
+  tableLength[2] = cmapTableLen;
+
+  //--- head table
+  getFontMatrix(mat);
+  if (mat[0] == 0) {
+    unitsPerEm = 1000;
+  } else {
+    unitsPerEm = (int)(1 / mat[0] + 0.5);
+  }
+  xMin = (int)(topDict.fontBBox[0] + 0.5);
+  yMin = (int)(topDict.fontBBox[1] + 0.5);
+  xMax = (int)(topDict.fontBBox[2] + 0.5);
+  yMax = (int)(topDict.fontBBox[3] + 0.5);
+  headTable[ 0] = 0x00;				// version
+  headTable[ 1] = 0x01;
+  headTable[ 2] = 0x00;
+  headTable[ 3] = 0x00;
+  headTable[ 4] = 0x00;				// revision
+  headTable[ 5] = 0x00;
+  headTable[ 6] = 0x00;
+  headTable[ 7] = 0x00;
+  headTable[ 8] = 0x00;				// checksumAdjustment
+  headTable[ 9] = 0x00;				//   (set later)
+  headTable[10] = 0x00;
+  headTable[11] = 0x00;
+  headTable[12] = 0x5f;				// magicNumber
+  headTable[13] = 0x0f;
+  headTable[14] = 0x3c;
+  headTable[15] = 0xf5;
+  headTable[16] = 0x00;				// flags
+  headTable[17] = 0x03;
+  headTable[18] = (Guchar)(unitsPerEm >> 8);	// unitsPerEm
+  headTable[19] = (Guchar)unitsPerEm;
+  headTable[20] = 0x00;				// created
+  headTable[21] = 0x00;
+  headTable[22] = 0x00;
+  headTable[23] = 0x00;
+  headTable[24] = 0x00;
+  headTable[25] = 0x00;
+  headTable[26] = 0x00;
+  headTable[27] = 0x00;
+  headTable[28] = 0x00;				// modified
+  headTable[29] = 0x00;
+  headTable[30] = 0x00;
+  headTable[31] = 0x00;
+  headTable[32] = 0x00;
+  headTable[33] = 0x00;
+  headTable[34] = 0x00;
+  headTable[35] = 0x00;
+  headTable[36] = (Guchar)(xMin >> 8);		// xMin
+  headTable[37] = (Guchar)xMin;
+  headTable[38] = (Guchar)(yMin >> 8);		// yMin
+  headTable[39] = (Guchar)yMin;
+  headTable[40] = (Guchar)(xMax >> 8);		// xMax
+  headTable[41] = (Guchar)xMax;
+  headTable[42] = (Guchar)(yMax >> 8);		// yMax
+  headTable[43] = (Guchar)yMax;
+  headTable[44] = 0;				// macStyle
+  headTable[45] = 0;
+  headTable[46] = 0;				// lowestRecPPEM
+  headTable[47] = 3;
+  headTable[48] = 0;				// fontDirectionHint
+  headTable[49] = 2;				//   (deprecated)
+  headTable[50] = 0;				// indexToLocFormat
+  headTable[51] = 0;				//   (n/a to CFF fonts)
+  headTable[52] = 0;				// glyphDataFormat
+  headTable[53] = 0;				//   (n/a to CFF fonts)
+  tableData[3] = headTable;
+  tableLength[3] = 54;
+
+  //--- hhea table
+  maxWidth = widths[0];
+  for (i = 1; i < nWidths; ++i) {
+    if (widths[i] > maxWidth) {
+      maxWidth = widths[i];
+    }
+  }
+  hheaTable[ 0] = 0x00;				// version
+  hheaTable[ 1] = 0x01;
+  hheaTable[ 2] = 0x00;
+  hheaTable[ 3] = 0x00;
+  hheaTable[ 4] = (Guchar)(yMax >> 8);		// ascender
+  hheaTable[ 5] = (Guchar)yMax;
+  hheaTable[ 6] = (Guchar)(yMin >> 8);		// descender
+  hheaTable[ 7] = (Guchar)yMin;
+  hheaTable[ 8] = 0;				// lineGap
+  hheaTable[ 9] = 0;
+  hheaTable[10] = (Guchar)(maxWidth >> 8);	// advanceWidthMax
+  hheaTable[11] = (Guchar)maxWidth;
+  hheaTable[12] = 0;				// minLeftSideBearing
+  hheaTable[13] = 0;
+  hheaTable[14] = 0;				// minRightSideBearing
+  hheaTable[15] = 0;
+  hheaTable[16] = (Guchar)(maxWidth >> 8);	// xMaxExtent
+  hheaTable[17] = (Guchar)maxWidth;
+  hheaTable[18] = 0;				// caretSlopeRise
+  hheaTable[19] = 1;
+  hheaTable[20] = 0;				// caretSlopeRun
+  hheaTable[21] = 0;
+  hheaTable[22] = 0;				// caretOffset
+  hheaTable[23] = 0;
+  hheaTable[24] = 0;				// reserved
+  hheaTable[25] = 0;
+  hheaTable[26] = 0;				// reserved
+  hheaTable[27] = 0;
+  hheaTable[28] = 0;				// reserved
+  hheaTable[29] = 0;
+  hheaTable[30] = 0;				// reserved
+  hheaTable[31] = 0;
+  hheaTable[32] = 0;				// metricDataFormat
+  hheaTable[33] = 0;
+  hheaTable[34] = (Guchar)(nWidths >> 8);	// numberOfHMetrics
+  hheaTable[35] = (Guchar)nWidths;
+  tableData[4] = hheaTable;
+  tableLength[4] = 36;
+
+  //--- hmtx table
+  //~ this currently sets LSB to 0 for all glyphs
+  hmtxTable = (Guchar *)gmallocn(nWidths, 4);
+  for (i = 0; i < nWidths; ++i) {
+    hmtxTable[4*i  ] = (Guchar)(widths[i] >> 8);
+    hmtxTable[4*i+1] = (Guchar)widths[i];
+    hmtxTable[4*i+2] = 0;
+    hmtxTable[4*i+3] = 0;
+  }
+  tableData[5] = hmtxTable;
+  tableLength[5] = 4 * nWidths;
+
+  //--- maxp table
+  maxpTable[0] = 0x00;				// version = 0.5
+  maxpTable[1] = 0x00;
+  maxpTable[2] = 0x50;
+  maxpTable[3] = 0x00;
+  maxpTable[4] = (Guchar)(nGlyphs >> 8);	// numGlyphs
+  maxpTable[5] = (Guchar)nGlyphs;
+  tableData[6] = maxpTable;
+  tableLength[6] = 6;
+
+  //--- name table
+  nameTable[ 0] = 0x00;				// format
+  nameTable[ 1] = 0x00;
+  nameTable[ 2] = 0x00;				// count
+  nameTable[ 3] = 0x01;
+  nameTable[ 4] = 0x00;				// stringOffset
+  nameTable[ 5] = 0x12;
+  nameTable[ 6] = 0x00;				// platformID
+  nameTable[ 7] = 0x00;
+  nameTable[ 8] = 0x00;				// encodingID
+  nameTable[ 9] = 0x03;
+  nameTable[10] = 0x00;				// languageID
+  nameTable[11] = 0x00;
+  nameTable[12] = 0x00;				// nameID
+  nameTable[13] = 0x00;
+  nameTable[14] = 0x00;				// length
+  nameTable[15] = 0x08;
+  nameTable[16] = 0x00;				// offset
+  nameTable[17] = 0x00;
+  nameTable[18] = 0x00;				// string data
+  nameTable[19] = (Guchar)'n';
+  nameTable[20] = 0x00;
+  nameTable[21] = (Guchar)'o';
+  nameTable[22] = 0x00;
+  nameTable[23] = (Guchar)'n';
+  nameTable[24] = 0x00;
+  nameTable[25] = (Guchar)'e';
+  tableData[7] = nameTable;
+  tableLength[7] = 26;
+
+  //--- post table
+  postTable[ 0] = 0x00;				// version = 3.0
+  postTable[ 1] = 0x03;
+  postTable[ 2] = 0x00;
+  postTable[ 3] = 0x00;
+  postTable[ 4] = 0x00;				// italicAngle
+  postTable[ 5] = 0x00;
+  postTable[ 6] = 0x00;
+  postTable[ 7] = 0x00;
+  postTable[ 8] = 0x00;				// underlinePosition
+  postTable[ 9] = 0x00;
+  postTable[10] = 0x00;				// underlineThickness
+  postTable[11] = 0x00;
+  postTable[12] = 0x00;				// isFixedPitch
+  postTable[13] = 0x00;
+  postTable[14] = 0x00;
+  postTable[15] = 0x00;
+  postTable[16] = 0x00;				// minMemType42
+  postTable[17] = 0x00;
+  postTable[18] = 0x00;
+  postTable[19] = 0x00;
+  postTable[20] = 0x00;				// maxMemType42
+  postTable[21] = 0x00;
+  postTable[22] = 0x00;
+  postTable[23] = 0x00;
+  postTable[24] = 0x00;				// minMemType1
+  postTable[25] = 0x00;
+  postTable[26] = 0x00;
+  postTable[27] = 0x00;
+  postTable[28] = 0x00;				// maxMemType1
+  postTable[29] = 0x00;
+  postTable[30] = 0x00;
+  postTable[31] = 0x00;
+  tableData[8] = postTable;
+  tableLength[8] = 32;
+
+  //--- header and table directory
+  header[ 0] = 'O';				// sfnt version
+  header[ 1] = 'T';
+  header[ 2] = 'T';
+  header[ 3] = 'O';
+  header[ 4] = 0x00;				// numTables
+  header[ 5] = 0x09;
+  header[ 6] = 0x00;				// searchRange
+  header[ 7] = 0x80;
+  header[ 8] = 0x00;				// entrySelector
+  header[ 9] = 0x03;
+  header[10] = 0x00;				// rangeShift
+  header[11] = 0x10;
+  offset = 12 + 9*16;
+  fileChecksum = 0;
+  for (i = 0; i < 9; ++i) {
+    header[12 + i*16 +  0] = tableTag[i][0];
+    header[12 + i*16 +  1] = tableTag[i][1];
+    header[12 + i*16 +  2] = tableTag[i][2];
+    header[12 + i*16 +  3] = tableTag[i][3];
+    checksum = computeOpenTypeTableChecksum(tableData[i], tableLength[i]);
+    fileChecksum += checksum;
+    header[12 + i*16 +  4] = (Guchar)(checksum >> 24);
+    header[12 + i*16 +  5] = (Guchar)(checksum >> 16);
+    header[12 + i*16 +  6] = (Guchar)(checksum >> 8);
+    header[12 + i*16 +  7] = (Guchar)checksum;
+    header[12 + i*16 +  8] = (Guchar)(offset >> 24);
+    header[12 + i*16 +  9] = (Guchar)(offset >> 16);
+    header[12 + i*16 + 10] = (Guchar)(offset >> 8);
+    header[12 + i*16 + 11] = (Guchar)offset;
+    header[12 + i*16 + 12] = (Guchar)(tableLength[i] >> 24);
+    header[12 + i*16 + 13] = (Guchar)(tableLength[i] >> 16);
+    header[12 + i*16 + 14] = (Guchar)(tableLength[i] >> 8);
+    header[12 + i*16 + 15] = (Guchar)tableLength[i];
+    offset += tableLength[i];
+    if (tableLength[i] & 3) {
+      offset += 4 - (tableLength[i] & 3);
+    }
+  }
+
+  //--- file checksum
+  fileChecksum += computeOpenTypeTableChecksum(header, 12 + 9*16);
+  fileChecksum = 0xb1b0afba - fileChecksum;
+  headTable[ 8] = (Guchar)(fileChecksum >> 24);
+  headTable[ 9] = (Guchar)(fileChecksum >> 16);
+  headTable[10] = (Guchar)(fileChecksum >>  8);
+  headTable[11] = (Guchar)fileChecksum;
+
+  //--- write the OpenType font
+  (*outputFunc)(outputStream, (char *)header, 12 + 9*16);
+  for (i = 0; i < 9; ++i) {
+    (*outputFunc)(outputStream, (char *)tableData[i], tableLength[i]);
+    if (tableLength[i] & 3) {
+      (*outputFunc)(outputStream, "\0\0\0", 4 - (tableLength[i] & 3));
+    }
+  }
+
+  gfree(hmtxTable);
+}
+
+Guint FoFiType1C::computeOpenTypeTableChecksum(Guchar *data, int length) {
+  Guint checksum, word;
+  int i;
+
+  checksum = 0;
+  for (i = 0; i+3 < length; i += 4) {
+    word = ((data[i  ] & 0xff) << 24) +
+           ((data[i+1] & 0xff) << 16) +
+           ((data[i+2] & 0xff) <<  8) +
+            (data[i+3] & 0xff);
+    checksum += word;
+  }
+  if (length & 3) {
+    word = 0;
+    i = length & ~3;
+    switch (length & 3) {
+    case 3:
+      word |= (data[i+2] & 0xff) <<  8;
+    case 2:
+      word |= (data[i+1] & 0xff) << 16;
+    case 1:
+      word |= (data[i  ] & 0xff) << 24;
+      break;
+    }
+    checksum += word;
+  }
+  return checksum;
+}
+
 GBool FoFiType1C::parse() {
   Type1CIndex fdIdx;
   Type1CIndexVal val;
@@ -2577,7 +2960,14 @@
 	parsedOk = gFalse;
 	return;
       }
-      memcpy(fdSelect, file + pos, nGlyphs);
+      for (gid0 = 0; gid0 < nGlyphs; ++gid0) {
+	if (file[pos + gid0] >= nFDs) {
+	  //~ error(-1, "Bad FDSelect table in CID font");
+	  parsedOk = gFalse;
+	  return;
+	}
+	fdSelect[gid0] = file[pos + gid0];
+      }
     } else if (fdSelectFmt == 3) {
       nRanges = getU16BE(pos, &parsedOk);
       pos += 2;
@@ -2590,7 +2980,7 @@
 	  return;
 	}
 	pos += 2;
-	if (gid0 > gid1 || gid1 > nGlyphs) {
+	if (gid0 > gid1 || gid1 > nGlyphs || fd >= nFDs) {
 	  //~ error(-1, "Bad FDSelect table in CID font");
 	  parsedOk = gFalse;
 	  return;
@@ -2703,10 +3093,19 @@
 
   if (topDict.charsetOffset == 0) {
     charset = fofiType1CISOAdobeCharset;
+    if (nGlyphs > 229) {
+      nGlyphs = 229;
+    }
   } else if (topDict.charsetOffset == 1) {
     charset = fofiType1CExpertCharset;
+    if (nGlyphs > 166) {
+      nGlyphs = 166;
+    }
   } else if (topDict.charsetOffset == 2) {
     charset = fofiType1CExpertSubsetCharset;
+    if (nGlyphs > 87) {
+      nGlyphs = 87;
+    }
   } else {
     charset = (Gushort *)gmallocn(nGlyphs, sizeof(Gushort));
     for (i = 0; i < nGlyphs; ++i) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/fofi/FoFiType1C.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -18,6 +18,7 @@
 #include "gtypes.h"
 #include "FoFiBase.h"
 
+class GHash;
 class GString;
 
 //------------------------------------------------------------------------
@@ -169,6 +170,10 @@
   int getNumGlyphs() { return nGlyphs; }
   GString *getGlyphName(int gid);
 
+  // Returns a hash mapping glyph names to GIDs.  This is only useful
+  // with 8-bit fonts.
+  GHash *getNameToGIDMap();
+
   // Return the mapping from CIDs to GIDs, and return the number of
   // CIDs in *<nCIDs>.  This is only useful for CID fonts.
   int *getCIDToGIDMap(int *nCIDs);
@@ -208,6 +213,13 @@
   void convertToType0(char *psName, int *codeMap, int nCodes,
 		      FoFiOutputFunc outputFunc, void *outputStream);
 
+  // Write an OpenType file, encapsulating the CFF font.  <widths>
+  // provides the glyph widths (in design units) for <nWidths> glyphs.
+  // The cmap table must be supplied by the caller.
+  void convertToOpenType(FoFiOutputFunc outputFunc, void *outputStream,
+			 int nWidths, Gushort *widths,
+			 Guchar *cmapTable, int cmapTableLen);
+
 private:
 
   FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
@@ -224,6 +236,7 @@
   void eexecWrite(Type1CEexecBuf *eb, const char *s);
   void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
   void writePSString(char *s, FoFiOutputFunc outputFunc, void *outputStream);
+  Guint computeOpenTypeTableChecksum(Guchar *data, int length);
   GBool parse();
   void readTopDict();
   void readFD(int offset, int length, Type1CPrivateDict *pDict);

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/FixedPoint.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/FixedPoint.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/FixedPoint.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -36,7 +36,7 @@
   FixedPoint(const FixedPoint &x) { val = x.val; }
   FixedPoint(double x) { val = (int)(x * (1 << fixptShift) + 0.5); }
   FixedPoint(int x) { val = x << fixptShift; }
-  FixedPoint(long x) { val = x << fixptShift; }
+  FixedPoint(long x) { val = (int)x << fixptShift; }
 
   operator float()
     { return (float) val * ((float)1 / (float)(1 << fixptShift)); }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/GMutex.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/GMutex.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/GMutex.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -12,6 +12,7 @@
 #ifndef GMUTEX_H
 #define GMUTEX_H
 
+#include <aconf.h>
 #ifdef _WIN32
 #  include <windows.h>
 #  include <intrin.h>

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -14,6 +14,8 @@
 #include <aconf.h>
 
 #ifdef _WIN32
+#  undef WIN32_LEAN_AND_MEAN
+#  include <windows.h>
 #  include <time.h>
 #  include <direct.h>
 #else
@@ -613,7 +615,7 @@
       }
     }
     wPath[i] = (wchar_t)0;
-    for (i = 0; mode[i] && i < sizeof(wMode) - 1; ++i) {
+    for (i = 0; mode[i] && i < sizeof(wMode)/sizeof(wchar_t) - 1; ++i) {
       wMode[i] = (wchar_t)(mode[i] & 0xff);
     }
     wMode[i] = (wchar_t)0;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/gfile.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -11,6 +11,7 @@
 #ifndef GFILE_H
 #define GFILE_H
 
+#include <aconf.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -11,7 +11,9 @@
 #include <stdlib.h>
 #include <stddef.h>
 // older compilers won't define SIZE_MAX in stdint.h without this
-#define __STDC_LIMIT_MACROS 1
+#ifndef __STDC_LIMIT_MACROS
+#  define __STDC_LIMIT_MACROS 1
+#endif
 #include <stdint.h>
 #include <string.h>
 #include <limits.h>
@@ -107,12 +109,12 @@
   trl = (unsigned long *)(mem + gMemHdrSize + size1);
   hdr->magic = gMemMagic;
   hdr->size = size;
+  gMemLock;
   if (ignore) {
     hdr->index = -1;
   } else {
     hdr->index = gMemIndex++;
   }
-  gMemLock;
   if (gMemTail) {
     gMemTail->next = hdr;
     hdr->prev = gMemTail;
@@ -233,12 +235,12 @@
   trl = (unsigned long *)(mem + gMemHdrSize + size1);
   hdr->magic = gMemMagic;
   hdr->size = size;
+  gMemLock;
   if (ignore) {
     hdr->index = -1;
   } else {
     hdr->index = gMemIndex++;
   }
-  gMemLock;
   if (gMemTail) {
     gMemTail->next = hdr;
     hdr->prev = gMemTail;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/goo/gmem.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -20,7 +20,11 @@
   ~GMemException() {}
 };
 
-#define GMEM_EXCEP throw(GMemException)
+// This used to be:
+//   #define GMEM_EXCEP throw(GMemException)
+// but the throw decl was never really very useful, and is deprecated
+// as of C++11 and illegal as of C++17.
+#define GMEM_EXCEP
 
 #else // USE_EXCEPTIONS
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -18,6 +18,7 @@
 #include <math.h>
 #include "gmem.h"
 #include "gmempp.h"
+#include "GString.h"
 #include "SplashErrorCodes.h"
 #include "SplashMath.h"
 #include "SplashBitmap.h"
@@ -257,6 +258,22 @@
       pipe->run = &Splash::pipeRunAACMYK8;
 #endif
     }
+  } else if (!pipe->pattern && !pipe->noTransparency && !state->softMask &&
+	     usesShape &&
+	     state->inNonIsolatedGroup && groupBackBitmap->alpha &&
+	     !state->inKnockoutGroup &&
+	     !state->blendFunc && !pipe->nonIsolatedGroup) {
+    if (mode == splashModeMono8 && bitmap->alpha) {
+      pipe->run = &Splash::pipeRunNonIsoMono8;
+    } else if (mode == splashModeRGB8 && bitmap->alpha) {
+      pipe->run = &Splash::pipeRunNonIsoRGB8;
+    } else if (mode == splashModeBGR8 && bitmap->alpha) {
+      pipe->run = &Splash::pipeRunNonIsoBGR8;
+#if SPLASH_CMYK
+    } else if (mode == splashModeCMYK8 && bitmap->alpha) {
+      pipe->run = &Splash::pipeRunNonIsoCMYK8;
+#endif
+    }
   }
 }
 
@@ -276,6 +293,7 @@
   Guchar *alpha0Ptr;
   SplashColorPtr softMaskPtr;
 #if SPLASH_CMYK
+  Guchar aPrev;
   SplashColor cSrc2, cDest2;
 #endif
 
@@ -514,25 +532,38 @@
 	break;
 #if SPLASH_CMYK
       case splashModeCMYK8:
+	if (alpha0Ptr) {   // non-isolated group
+	  if (color0Ptr) { //   non-isolated, knockout group
+	    aPrev = *alpha0Ptr;
+	  } else {         //   non-isolated, non-knockout group
+	    aPrev = (Guchar)(*alpha0Ptr + aDest - div255(*alpha0Ptr * aDest));
+	  }
+	} else {           // isolated group
+	  if (color0Ptr) { //   isolated, knockout group
+	    aPrev = 0;
+	  } else {         //   isolated, non-knockout group
+	    aPrev = aDest;
+	  }
+	}
 	if (state->overprintMask & 0x01) {
 	  cSrc[0] = state->cmykTransferC[cSrcPtr[0]];
 	} else {
-	  cSrc[0] = div255(aDest * cDest[0]);
+	  cSrc[0] = div255(aPrev * cDest[0]);
 	}
 	if (state->overprintMask & 0x02) {
 	  cSrc[1] = state->cmykTransferM[cSrcPtr[1]];
 	} else {
-	  cSrc[1] = div255(aDest * cDest[1]);
+	  cSrc[1] = div255(aPrev * cDest[1]);
 	}
 	if (state->overprintMask & 0x04) {
 	  cSrc[2] = state->cmykTransferY[cSrcPtr[2]];
 	} else {
-	  cSrc[2] = div255(aDest * cDest[2]);
+	  cSrc[2] = div255(aPrev * cDest[2]);
 	}
 	if (state->overprintMask & 0x08) {
 	  cSrc[3] = state->cmykTransferK[cSrcPtr[3]];
 	} else {
-	  cSrc[3] = div255(aDest * cDest[3]);
+	  cSrc[3] = div255(aPrev * cDest[3]);
 	}
 	break;
 #endif
@@ -1986,6 +2017,398 @@
 #endif
 
 
+void Splash::pipeRunNonIsoMono8(SplashPipe *pipe, int x0, int x1, int y,
+				Guchar *shapePtr, SplashColorPtr cSrcPtr) {
+  Guchar shape, aSrc, aDest, alphaI, alpha0, aResult;
+  Guchar cSrc0, cDest0, cResult0;
+  SplashColorPtr destColorPtr;
+  Guchar *destAlphaPtr;
+  Guchar *alpha0Ptr;
+  int cSrcStride, x, lastX;
+
+  if (cSrcPtr) {
+    cSrcStride = 1;
+  } else {
+    cSrcPtr = pipe->cSrcVal;
+    cSrcStride = 0;
+  }
+  for (; x0 <= x1; ++x0) {
+    if (*shapePtr) {
+      break;
+    }
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  }
+  if (x0 > x1) {
+    return;
+  }
+  updateModX(x0);
+  updateModY(y);
+  lastX = x0;
+
+  destColorPtr = &bitmap->data[y * bitmap->rowSize + x0];
+  destAlphaPtr = &bitmap->alpha[y * bitmap->alphaRowSize + x0];
+  alpha0Ptr = &groupBackBitmap->alpha[(groupBackY + y)
+				        * groupBackBitmap->alphaRowSize +
+				      (groupBackX + x0)];
+
+  for (x = x0; x <= x1; ++x) {
+
+    //----- shape
+    shape = *shapePtr;
+    if (!shape) {
+      destColorPtr += 1;
+      ++destAlphaPtr;
+      ++alpha0Ptr;
+      cSrcPtr += cSrcStride;
+      ++shapePtr;
+      continue;
+    }
+    lastX = x;
+
+    //----- read destination pixel
+    cDest0 = destColorPtr[0];
+    aDest = *destAlphaPtr;
+
+    //----- source color
+    cSrc0 = state->grayTransfer[cSrcPtr[0]];
+
+    //----- source alpha
+    aSrc = div255(pipe->aInput * shape);
+
+    //----- result alpha and non-isolated group element correction
+    aResult = (Guchar)(aSrc + aDest - div255(aSrc * aDest));
+    alpha0 = *alpha0Ptr++;
+    alphaI = (Guchar)(aResult + alpha0 - div255(aResult * alpha0));
+
+    //----- result color
+    if (alphaI == 0) {
+      cResult0 = 0;
+    } else {
+      cResult0 = (Guchar)(((alphaI - aSrc) * cDest0 + aSrc * cSrc0) / alphaI);
+    }
+
+    //----- write destination pixel
+    *destColorPtr++ = cResult0;
+    *destAlphaPtr++ = aResult;
+
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  } // for (x ...)
+
+  updateModX(lastX);
+}
+
+void Splash::pipeRunNonIsoRGB8(SplashPipe *pipe, int x0, int x1, int y,
+			       Guchar *shapePtr, SplashColorPtr cSrcPtr) {
+  Guchar shape, aSrc, aDest, alphaI, alpha0, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
+  Guchar cDest0, cDest1, cDest2;
+  Guchar cResult0, cResult1, cResult2;
+  SplashColorPtr destColorPtr;
+  Guchar *destAlphaPtr;
+  Guchar *alpha0Ptr;
+  int cSrcStride, x, lastX;
+
+  if (cSrcPtr) {
+    cSrcStride = 3;
+  } else {
+    cSrcPtr = pipe->cSrcVal;
+    cSrcStride = 0;
+  }
+  for (; x0 <= x1; ++x0) {
+    if (*shapePtr) {
+      break;
+    }
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  }
+  if (x0 > x1) {
+    return;
+  }
+  updateModX(x0);
+  updateModY(y);
+  lastX = x0;
+
+  destColorPtr = &bitmap->data[y * bitmap->rowSize + x0 * 3];
+  destAlphaPtr = &bitmap->alpha[y * bitmap->alphaRowSize + x0];
+  alpha0Ptr = &groupBackBitmap->alpha[(groupBackY + y)
+				        * groupBackBitmap->alphaRowSize +
+				      (groupBackX + x0)];
+
+  for (x = x0; x <= x1; ++x) {
+
+    //----- shape
+    shape = *shapePtr;
+    if (!shape) {
+      destColorPtr += 3;
+      ++destAlphaPtr;
+      ++alpha0Ptr;
+      cSrcPtr += cSrcStride;
+      ++shapePtr;
+      continue;
+    }
+    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 = div255(pipe->aInput * shape);
+
+    //----- result alpha and non-isolated group element correction
+    aResult = (Guchar)(aSrc + aDest - div255(aSrc * aDest));
+    alpha0 = *alpha0Ptr++;
+    alphaI = (Guchar)(aResult + alpha0 - div255(aResult * alpha0));
+
+    //----- result color
+    if (alphaI == 0) {
+      cResult0 = 0;
+      cResult1 = 0;
+      cResult2 = 0;
+    } else {
+      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
+    destColorPtr[0] = cResult0;
+    destColorPtr[1] = cResult1;
+    destColorPtr[2] = cResult2;
+    destColorPtr += 3;
+    *destAlphaPtr++ = aResult;
+
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  } // for (x ...)
+
+  updateModX(lastX);
+}
+
+void Splash::pipeRunNonIsoBGR8(SplashPipe *pipe, int x0, int x1, int y,
+			       Guchar *shapePtr, SplashColorPtr cSrcPtr) {
+  Guchar shape, aSrc, aDest, alphaI, alpha0, aResult;
+  Guchar cSrc0, cSrc1, cSrc2;
+  Guchar cDest0, cDest1, cDest2;
+  Guchar cResult0, cResult1, cResult2;
+  SplashColorPtr destColorPtr;
+  Guchar *destAlphaPtr;
+  Guchar *alpha0Ptr;
+  int cSrcStride, x, lastX;
+
+  if (cSrcPtr) {
+    cSrcStride = 3;
+  } else {
+    cSrcPtr = pipe->cSrcVal;
+    cSrcStride = 0;
+  }
+  for (; x0 <= x1; ++x0) {
+    if (*shapePtr) {
+      break;
+    }
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  }
+  if (x0 > x1) {
+    return;
+  }
+  updateModX(x0);
+  updateModY(y);
+  lastX = x0;
+
+  destColorPtr = &bitmap->data[y * bitmap->rowSize + x0 * 3];
+  destAlphaPtr = &bitmap->alpha[y * bitmap->alphaRowSize + x0];
+  alpha0Ptr = &groupBackBitmap->alpha[(groupBackY + y)
+				        * groupBackBitmap->alphaRowSize +
+				      (groupBackX + x0)];
+
+  for (x = x0; x <= x1; ++x) {
+
+    //----- shape
+    shape = *shapePtr;
+    if (!shape) {
+      destColorPtr += 3;
+      ++destAlphaPtr;
+      ++alpha0Ptr;
+      cSrcPtr += cSrcStride;
+      ++shapePtr;
+      continue;
+    }
+    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 = div255(pipe->aInput * shape);
+
+    //----- result alpha and non-isolated group element correction
+    aResult = (Guchar)(aSrc + aDest - div255(aSrc * aDest));
+    alpha0 = *alpha0Ptr++;
+    alphaI = (Guchar)(aResult + alpha0 - div255(aResult * alpha0));
+
+    //----- result color
+    if (alphaI == 0) {
+      cResult0 = 0;
+      cResult1 = 0;
+      cResult2 = 0;
+    } else {
+      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
+    destColorPtr[0] = cResult2;
+    destColorPtr[1] = cResult1;
+    destColorPtr[2] = cResult0;
+    destColorPtr += 3;
+    *destAlphaPtr++ = aResult;
+
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  } // for (x ...)
+
+  updateModX(lastX);
+}
+
+#if SPLASH_CMYK
+void Splash::pipeRunNonIsoCMYK8(SplashPipe *pipe, int x0, int x1, int y,
+				Guchar *shapePtr, SplashColorPtr cSrcPtr) {
+  Guchar shape, aSrc, aDest, alphaI, alpha0, aResult, aPrev;
+  Guchar cSrc0, cSrc1, cSrc2, cSrc3;
+  Guchar cDest0, cDest1, cDest2, cDest3;
+  Guchar cResult0, cResult1, cResult2, cResult3;
+  SplashColorPtr destColorPtr;
+  Guchar *destAlphaPtr;
+  Guchar *alpha0Ptr;
+  int cSrcStride, x, lastX;
+
+  if (cSrcPtr) {
+    cSrcStride = 4;
+  } else {
+    cSrcPtr = pipe->cSrcVal;
+    cSrcStride = 0;
+  }
+  for (; x0 <= x1; ++x0) {
+    if (*shapePtr) {
+      break;
+    }
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  }
+  if (x0 > x1) {
+    return;
+  }
+  updateModX(x0);
+  updateModY(y);
+  lastX = x0;
+
+  destColorPtr = &bitmap->data[y * bitmap->rowSize + x0 * 4];
+  destAlphaPtr = &bitmap->alpha[y * bitmap->alphaRowSize + x0];
+  alpha0Ptr = &groupBackBitmap->alpha[(groupBackY + y)
+				        * groupBackBitmap->alphaRowSize +
+				      (groupBackX + x0)];
+
+  for (x = x0; x <= x1; ++x) {
+
+    //----- shape
+    shape = *shapePtr;
+    if (!shape) {
+      destColorPtr += 4;
+      ++destAlphaPtr;
+      ++alpha0Ptr;
+      cSrcPtr += cSrcStride;
+      ++shapePtr;
+      continue;
+    }
+    lastX = x;
+
+    //----- read destination pixel
+    cDest0 = destColorPtr[0];
+    cDest1 = destColorPtr[1];
+    cDest2 = destColorPtr[2];
+    cDest3 = destColorPtr[3];
+    aDest = *destAlphaPtr;
+
+    //----- overprint
+    aPrev = (Guchar)(*alpha0Ptr + aDest - div255(*alpha0Ptr * aDest));
+    if (state->overprintMask & 0x01) {
+      cSrc0 = state->cmykTransferC[cSrcPtr[0]];
+    } else {
+      cSrc0 = div255(aPrev * cDest0);
+    }
+    if (state->overprintMask & 0x02) {
+      cSrc1 = state->cmykTransferM[cSrcPtr[1]];
+    } else {
+      cSrc1 = div255(aPrev * cDest1);
+    }
+    if (state->overprintMask & 0x04) {
+      cSrc2 = state->cmykTransferY[cSrcPtr[2]];
+    } else {
+      cSrc2 = div255(aPrev * cDest2);
+    }
+    if (state->overprintMask & 0x08) {
+      cSrc3 = state->cmykTransferK[cSrcPtr[3]];
+    } else {
+      cSrc3 = div255(aPrev * cDest3);
+    }
+
+    //----- source alpha
+    aSrc = div255(pipe->aInput * shape);
+
+    //----- result alpha and non-isolated group element correction
+    aResult = (Guchar)(aSrc + aDest - div255(aSrc * aDest));
+    alpha0 = *alpha0Ptr++;
+    alphaI = (Guchar)(aResult + alpha0 - div255(aResult * alpha0));
+
+    //----- result color
+    if (alphaI == 0) {
+      cResult0 = 0;
+      cResult1 = 0;
+      cResult2 = 0;
+      cResult3 = 0;
+    } else {
+      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
+    destColorPtr[0] = cResult0;
+    destColorPtr[1] = cResult1;
+    destColorPtr[2] = cResult2;
+    destColorPtr[3] = cResult3;
+    destColorPtr += 4;
+    *destAlphaPtr++ = aResult;
+
+    cSrcPtr += cSrcStride;
+    ++shapePtr;
+  } // for (x ...)
+
+  updateModX(lastX);
+}
+#endif
+
+
 //------------------------------------------------------------------------
 
 // Transform a point from user space to device space.
@@ -2000,10 +2423,41 @@
 }
 
 //------------------------------------------------------------------------
+// SplashImageCache
+//------------------------------------------------------------------------
+
+SplashImageCache::SplashImageCache() {
+  tag = NULL;
+  image = NULL;
+  refCount = 1;
+}
+
+SplashImageCache::~SplashImageCache() {
+  if (tag) {
+    delete tag;
+  }
+  if (image) {
+    delete image;
+  }
+}
+
+void SplashImageCache::incRefCount() {
+  ++refCount;
+}
+
+void SplashImageCache::decRefCount() {
+  --refCount;
+  if (refCount == 0) {
+    delete this;
+  }
+}
+
+//------------------------------------------------------------------------
 // Splash
 //------------------------------------------------------------------------
 
 Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
+	       SplashImageCache *imageCacheA,
 	       SplashScreenParams *screenParams) {
   bitmap = bitmapA;
   bitmapComps = splashColorModeNComps[bitmap->mode];
@@ -2021,10 +2475,17 @@
   minLineWidth = 0;
   clearModRegion();
   debugMode = gFalse;
+
+  if (imageCacheA) {
+    imageCache = imageCacheA;
+    imageCache->incRefCount();
+  } else {
+    imageCache = new SplashImageCache();
+  }
 }
 
 Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
-	       SplashScreen *screenA) {
+	       SplashImageCache *imageCacheA, SplashScreen *screenA) {
   bitmap = bitmapA;
   bitmapComps = splashColorModeNComps[bitmap->mode];
   vectorAntialias = vectorAntialiasA;
@@ -2041,9 +2502,18 @@
   minLineWidth = 0;
   clearModRegion();
   debugMode = gFalse;
+
+  if (imageCacheA) {
+    imageCache = imageCacheA;
+    imageCache->incRefCount();
+  } else {
+    imageCache = new SplashImageCache();
+  }
 }
 
 Splash::~Splash() {
+  imageCache->decRefCount();
+
   while (state->next) {
     restoreState();
   }
@@ -3335,6 +3805,30 @@
 void Splash::getImageBounds(SplashCoord xyMin, SplashCoord xyMax,
 			    int *xyMinI, int *xyMaxI) {
   if (state->strokeAdjust == splashStrokeAdjustOff) {
+    // make sure the coords fit in 32-bit ints
+#if USE_FIXEDPOINT
+    if (xyMin < -32767) {
+      xyMin = -32767;
+    } else if (xyMin > 32767) {
+      xyMin = 32767;
+    }
+    if (xyMax < -32767) {
+      xyMax = -32767;
+    } else if (xyMax > 32767) {
+      xyMax = 32767;
+    }
+#else
+    if (xyMin < -1e9) {
+      xyMin = -1e9;
+    } else if (xyMin > 1e9) {
+      xyMin = 1e9;
+    }
+    if (xyMax < -1e9) {
+      xyMax = -1e9;
+    } else if (xyMax > 1e9) {
+      xyMax = 1e9;
+    }
+#endif
     *xyMinI = splashFloor(xyMin);
     *xyMaxI = splashFloor(xyMax);
     if (*xyMaxI <= *xyMinI) {
@@ -3347,7 +3841,8 @@
 
 // The glyphMode flag is not currently used, but may be useful if the
 // stroke adjustment behavior is changed.
-SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData,
+SplashError Splash::fillImageMask(GString *imageTag,
+				  SplashImageMaskSource src, void *srcData,
 				  int w, int h, SplashCoord *mat,
 				  GBool glyphMode, GBool interpolate) {
   SplashBitmap *scaledMask;
@@ -3401,10 +3896,17 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight,
-			     interpolate);
+      scaledMask = scaleMask(imageTag, src, srcData, w, h,
+			     scaledWidth, scaledHeight, interpolate);
+      if (imageCache->vertFlip) {
+	vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->vertFlip = gFalse;
+      }
+      if (imageCache->horizFlip) {
+	horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->horizFlip = gFalse;
+      }
       blitMask(scaledMask, x0, y0, clipRes);
-      delete scaledMask;
     }
     
   // scaling plus vertical flip
@@ -3417,11 +3919,17 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight,
-			     interpolate);
-      vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+      scaledMask = scaleMask(imageTag, src, srcData, w, h,
+			     scaledWidth, scaledHeight, interpolate);
+      if (!imageCache->vertFlip) {
+	vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->vertFlip = gTrue;
+      }
+      if (imageCache->horizFlip) {
+	horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->horizFlip = gFalse;
+      }
       blitMask(scaledMask, x0, y0, clipRes);
-      delete scaledMask;
     }
 
   // scaling plus horizontal flip
@@ -3434,11 +3942,17 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight,
-			     interpolate);
-      horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+      scaledMask = scaleMask(imageTag, src, srcData, w, h,
+			     scaledWidth, scaledHeight, interpolate);
+      if (imageCache->vertFlip) {
+	vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->vertFlip = gFalse;
+      }
+      if (!imageCache->horizFlip) {
+	horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->horizFlip = gTrue;
+      }
       blitMask(scaledMask, x0, y0, clipRes);
-      delete scaledMask;
     }
 
   // scaling plus horizontal and vertical flips
@@ -3451,17 +3965,23 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight,
-			     interpolate);
-      vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
-      horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+      scaledMask = scaleMask(imageTag, src, srcData, w, h,
+			     scaledWidth, scaledHeight, interpolate);
+      if (!imageCache->vertFlip) {
+	vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->vertFlip = gTrue;
+      }
+      if (!imageCache->horizFlip) {
+	horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+	imageCache->horizFlip = gTrue;
+      }
       blitMask(scaledMask, x0, y0, clipRes);
-      delete scaledMask;
     }
 
   // all other cases
   } else {
-    arbitraryTransformMask(src, srcData, w, h, mat, glyphMode, interpolate);
+    arbitraryTransformMask(imageTag, src, srcData, w, h,
+			   mat, glyphMode, interpolate);
   }
 
   return splashOk;
@@ -3634,7 +4154,8 @@
 
 // The glyphMode flag is not currently used, but may be useful if the
 // stroke adjustment behavior is changed.
-void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData,
+void Splash::arbitraryTransformMask(GString *imageTag,
+				    SplashImageMaskSource src, void *srcData,
 				    int srcWidth, int srcHeight,
 				    SplashCoord *mat, GBool glyphMode,
 				    GBool interpolate) {
@@ -3727,8 +4248,16 @@
   ir11 = r00 / det;
 
   // scale the input image
-  scaledMask = scaleMask(src, srcData, srcWidth, srcHeight,
+  scaledMask = scaleMask(imageTag, src, srcData, srcWidth, srcHeight,
 			 scaledWidth, scaledHeight, interpolate);
+  if (imageCache->vertFlip) {
+    vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+    imageCache->vertFlip = gFalse;
+  }
+  if (imageCache->horizFlip) {
+    horizFlipImage(scaledMask, scaledWidth, scaledHeight, 1);
+    imageCache->horizFlip = gFalse;
+  }
 
   // construct the three sections
   i = 0;
@@ -3901,42 +4430,61 @@
       (this->*pipe.run)(&pipe, xa, xb - 1, y, scanBuf + xa, NULL);
     }
   }
-
-  delete scaledMask;
 }
 
 // Scale an image mask into a SplashBitmap.
-SplashBitmap *Splash::scaleMask(SplashImageMaskSource src, void *srcData,
+SplashBitmap *Splash::scaleMask(GString *imageTag,
+				SplashImageMaskSource src, void *srcData,
 				int srcWidth, int srcHeight,
 				int scaledWidth, int scaledHeight,
 				GBool interpolate) {
-  SplashBitmap *dest;
-
-  dest = new SplashBitmap(scaledWidth, scaledHeight, 1, splashModeMono8,
-			  gFalse);
+  if (imageCache->tag && imageTag &&
+      !imageCache->tag->cmp(imageTag) &&
+      imageCache->isMask &&
+      imageCache->width == scaledWidth &&
+      imageCache->height == scaledHeight &&
+      imageCache->interpolate == interpolate) {
+    return imageCache->image;
+  }
+  if (imageCache->tag) {
+    delete imageCache->tag;
+  }
+  if (imageCache->image) {
+    delete imageCache->image;
+  }
+  imageCache->tag = imageTag ? imageTag->copy() : (GString *)NULL;
+  imageCache->isMask = gTrue;
+  imageCache->width = scaledWidth;
+  imageCache->height = scaledHeight;
+  imageCache->interpolate = interpolate;
+  imageCache->vertFlip = gFalse;
+  imageCache->horizFlip = gFalse;
+  imageCache->image = new SplashBitmap(scaledWidth, scaledHeight,
+				       1, splashModeMono8, gFalse,
+				       gTrue, NULL);
   if (scaledHeight < srcHeight) {
     if (scaledWidth < srcWidth) {
       scaleMaskYdXd(src, srcData, srcWidth, srcHeight,
-		    scaledWidth, scaledHeight, dest);
+		    scaledWidth, scaledHeight, imageCache->image);
     } else {
       scaleMaskYdXu(src, srcData, srcWidth, srcHeight,
-		    scaledWidth, scaledHeight, dest);
+		    scaledWidth, scaledHeight, imageCache->image);
     }
   } else {
     if (scaledWidth < srcWidth) {
       scaleMaskYuXd(src, srcData, srcWidth, srcHeight,
-		    scaledWidth, scaledHeight, dest);
+		    scaledWidth, scaledHeight, imageCache->image);
     } else {
       if (interpolate) {
 	scaleMaskYuXuI(src, srcData, srcWidth, srcHeight,
-		       scaledWidth, scaledHeight, dest);
+		       scaledWidth, scaledHeight, imageCache->image);
       } else {
 	scaleMaskYuXu(src, srcData, srcWidth, srcHeight,
-		      scaledWidth, scaledHeight, dest);
+		      scaledWidth, scaledHeight, imageCache->image);
       }
     }
   }
-  return dest;
+  return imageCache->image;
 }
 
 void Splash::scaleMaskYdXd(SplashImageMaskSource src, void *srcData,
@@ -4009,7 +4557,7 @@
 	pix += pixBuf[xx++];
       }
       // (255 * pix) / xStep * yStep
-      pix = (pix * d) >> 23;
+      pix = (pix * d + (1 << 22)) >> 23;
 
       // store the pixel
       *destPtr++ = (Guchar)pix;
@@ -4083,7 +4631,7 @@
       // compute the final pixel
       pix = pixBuf[x];
       // (255 * pix) / yStep
-      pix = (pix * d) >> 23;
+      pix = (pix * d + (1 << 22)) >> 23;
 
       // store the pixel
       for (i = 0; i < xStep; ++i) {
@@ -4158,7 +4706,7 @@
 	pix += lineBuf[xx++];
       }
       // (255 * pix) / xStep
-      pix = (pix * d) >> 23;
+      pix = (pix * d + (1 << 22)) >> 23;
 
       // store the pixel
       for (i = 0; i < yStep; ++i) {
@@ -4403,7 +4951,8 @@
   }
 }
 
-SplashError Splash::drawImage(SplashImageSource src, void *srcData,
+SplashError Splash::drawImage(GString *imageTag,
+			      SplashImageSource src, void *srcData,
 			      SplashColorMode srcMode, GBool srcAlpha,
 			      int w, int h, SplashCoord *mat,
 			      GBool interpolate) {
@@ -4489,10 +5038,18 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h,
+      scaledImg = scaleImage(imageTag,
+			     src, srcData, srcMode, nComps, srcAlpha, w, h,
 			     scaledWidth, scaledHeight, interpolate);
+      if (imageCache->vertFlip) {
+	vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->vertFlip = gFalse;
+      }
+      if (imageCache->horizFlip) {
+	horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->horizFlip = gFalse;
+      }
       blitImage(scaledImg, srcAlpha, x0, y0, clipRes);
-      delete scaledImg;
     }
     
   // scaling plus vertical flip
@@ -4505,11 +5062,18 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h,
+      scaledImg = scaleImage(imageTag,
+			     src, srcData, srcMode, nComps, srcAlpha, w, h,
 			     scaledWidth, scaledHeight, interpolate);
-      vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+      if (!imageCache->vertFlip) {
+	vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->vertFlip = gTrue;
+      }
+      if (imageCache->horizFlip) {
+	horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->horizFlip = gFalse;
+      }
       blitImage(scaledImg, srcAlpha, x0, y0, clipRes);
-      delete scaledImg;
     }
 
   // scaling plus horizontal flip
@@ -4522,11 +5086,18 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h,
+      scaledImg = scaleImage(imageTag,
+			     src, srcData, srcMode, nComps, srcAlpha, w, h,
 			     scaledWidth, scaledHeight, interpolate);
-      horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+      if (imageCache->vertFlip) {
+	vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->vertFlip = gFalse;
+      }
+      if (!imageCache->horizFlip) {
+	horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->horizFlip = gTrue;
+      }
       blitImage(scaledImg, srcAlpha, x0, y0, clipRes);
-      delete scaledImg;
     }
     
   // scaling plus horizontal and vertical flips
@@ -4539,17 +5110,23 @@
     if (clipRes != splashClipAllOutside) {
       scaledWidth = x1 - x0;
       scaledHeight = y1 - y0;
-      scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h,
+      scaledImg = scaleImage(imageTag,
+			     src, srcData, srcMode, nComps, srcAlpha, w, h,
 			     scaledWidth, scaledHeight, interpolate);
-      vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
-      horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+      if (!imageCache->vertFlip) {
+	vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->vertFlip = gTrue;
+      }
+      if (!imageCache->horizFlip) {
+	horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+	imageCache->horizFlip = gTrue;
+      }
       blitImage(scaledImg, srcAlpha, x0, y0, clipRes);
-      delete scaledImg;
     }
 
   // all other cases
   } else {
-    arbitraryTransformImage(src, srcData, srcMode, nComps, srcAlpha,
+    arbitraryTransformImage(imageTag, src, srcData, srcMode, nComps, srcAlpha,
 			    w, h, mat, interpolate);
   }
 
@@ -4765,7 +5342,8 @@
   gfree(unscaledAlpha);
 }
 
-void Splash::arbitraryTransformImage(SplashImageSource src, void *srcData,
+void Splash::arbitraryTransformImage(GString *imageTag,
+				     SplashImageSource src, void *srcData,
 				     SplashColorMode srcMode, int nComps,
 				     GBool srcAlpha,
 				     int srcWidth, int srcHeight,
@@ -4860,9 +5438,17 @@
   ir11 = r00 / det;
 
   // scale the input image
-  scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha,
+  scaledImg = scaleImage(imageTag, src, srcData, srcMode, nComps, srcAlpha,
 			 srcWidth, srcHeight, scaledWidth, scaledHeight,
 			 interpolate);
+  if (imageCache->vertFlip) {
+    vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+    imageCache->vertFlip = gFalse;
+  }
+  if (imageCache->horizFlip) {
+    horizFlipImage(scaledImg, scaledWidth, scaledHeight, nComps);
+    imageCache->horizFlip = gFalse;
+  }
 
   // construct the three sections
   i = 0;
@@ -5045,41 +5631,70 @@
   }
 
   gfree(pixelBuf);
-  delete scaledImg;
 }
 
 // Scale an image into a SplashBitmap.
-SplashBitmap *Splash::scaleImage(SplashImageSource src, void *srcData,
+SplashBitmap *Splash::scaleImage(GString *imageTag,
+				 SplashImageSource src, void *srcData,
 				 SplashColorMode srcMode, int nComps,
 				 GBool srcAlpha, int srcWidth, int srcHeight,
 				 int scaledWidth, int scaledHeight,
 				 GBool interpolate) {
-  SplashBitmap *dest;
-
-  dest = new SplashBitmap(scaledWidth, scaledHeight, 1, srcMode, srcAlpha);
+  if (imageCache->tag && imageTag &&
+      !imageCache->tag->cmp(imageTag) &&
+      !imageCache->isMask &&
+      imageCache->width == scaledWidth &&
+      imageCache->height == scaledHeight &&
+      imageCache->mode == srcMode &&
+      imageCache->alpha == srcAlpha &&
+      imageCache->interpolate == interpolate) {
+    return imageCache->image;
+  }
+  if (imageCache->tag) {
+    delete imageCache->tag;
+  }
+  if (imageCache->image) {
+    delete imageCache->image;
+  }
+  imageCache->tag = imageTag ? imageTag->copy() : (GString *)NULL;
+  imageCache->isMask = gFalse;
+  imageCache->width = scaledWidth;
+  imageCache->height = scaledHeight;
+  imageCache->mode = srcMode;
+  imageCache->alpha = srcAlpha;
+  imageCache->interpolate = interpolate;
+  imageCache->vertFlip = gFalse;
+  imageCache->horizFlip = gFalse;
+  imageCache->image = new SplashBitmap(scaledWidth, scaledHeight, 1,
+				       srcMode, srcAlpha, gTrue, NULL);
   if (scaledHeight < srcHeight) {
     if (scaledWidth < srcWidth) {
       scaleImageYdXd(src, srcData, srcMode, nComps, srcAlpha,
-		     srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
+		     srcWidth, srcHeight, scaledWidth, scaledHeight,
+		     imageCache->image);
     } else {
       scaleImageYdXu(src, srcData, srcMode, nComps, srcAlpha,
-		     srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
+		     srcWidth, srcHeight, scaledWidth, scaledHeight,
+		     imageCache->image);
     }
   } else {
     if (scaledWidth < srcWidth) {
       scaleImageYuXd(src, srcData, srcMode, nComps, srcAlpha,
-		     srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
+		     srcWidth, srcHeight, scaledWidth, scaledHeight,
+		     imageCache->image);
     } else {
       if (interpolate) {
 	scaleImageYuXuI(src, srcData, srcMode, nComps, srcAlpha,
-			srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
+			srcWidth, srcHeight, scaledWidth, scaledHeight,
+			imageCache->image);
       } else {
 	scaleImageYuXu(src, srcData, srcMode, nComps, srcAlpha,
-		       srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
+		       srcWidth, srcHeight, scaledWidth, scaledHeight,
+		       imageCache->image);
       }
     }
   }
-  return dest;
+  return imageCache->image;
 }
 
 void Splash::scaleImageYdXd(SplashImageSource src, void *srcData,
@@ -5177,7 +5792,7 @@
 	  pix0 += pixBuf[xx++];
 	}
 	// pix / xStep * yStep
-	pix0 = (pix0 * d) >> 23;
+	pix0 = (pix0 * d + (1 << 22)) >> 23;
 
 	// store the pixel
 	*destPtr++ = (Guchar)pix0;
@@ -5194,9 +5809,9 @@
 	  xx += 3;
 	}
 	// pix / xStep * yStep
-	pix0 = (pix0 * d) >> 23;
-	pix1 = (pix1 * d) >> 23;
-	pix2 = (pix2 * d) >> 23;
+	pix0 = (pix0 * d + (1 << 22)) >> 23;
+	pix1 = (pix1 * d + (1 << 22)) >> 23;
+	pix2 = (pix2 * d + (1 << 22)) >> 23;
 
 	// store the pixel
 	*destPtr++ = (Guchar)pix0;
@@ -5217,10 +5832,10 @@
 	  xx += 4;
 	}
 	// pix / xStep * yStep
-	pix0 = (pix0 * d) >> 23;
-	pix1 = (pix1 * d) >> 23;
-	pix2 = (pix2 * d) >> 23;
-	pix3 = (pix3 * d) >> 23;
+	pix0 = (pix0 * d + (1 << 22)) >> 23;
+	pix1 = (pix1 * d + (1 << 22)) >> 23;
+	pix2 = (pix2 * d + (1 << 22)) >> 23;
+	pix3 = (pix3 * d + (1 << 22)) >> 23;
 
 	// store the pixel
 	*destPtr++ = (Guchar)pix0;
@@ -5244,7 +5859,7 @@
 	  alpha += alphaPixBuf[xxa];
 	}
 	// alpha / xStep * yStep
-	alpha = (alpha * d) >> 23;
+	alpha = (alpha * d + (1 << 22)) >> 23;
 	*destAlphaPtr++ = (Guchar)alpha;
       }
     }
@@ -5343,7 +5958,7 @@
       // compute the final pixel
       for (i = 0; i < nComps; ++i) {
 	// pixBuf[] / yStep
-	pix[i] = (pixBuf[x * nComps + i] * d) >> 23;
+	pix[i] = (pixBuf[x * nComps + i] * d + (1 << 22)) >> 23;
       }
 
       // store the pixel
@@ -5379,7 +5994,7 @@
       // process alpha
       if (srcAlpha) {
 	// alphaPixBuf[] / yStep
-	alpha = (alphaPixBuf[x] * d) >> 23;
+	alpha = (alphaPixBuf[x] * d + (1 << 22)) >> 23;
 	for (i = 0; i < xStep; ++i) {
 	  *destAlphaPtr++ = (Guchar)alpha;
 	}
@@ -5474,7 +6089,7 @@
       }
       for (i = 0; i < nComps; ++i) {
 	// pix[] / xStep
-	pix[i] = (pix[i] * d) >> 23;
+	pix[i] = (pix[i] * d + (1 << 22)) >> 23;
       }
 
       // store the pixel
@@ -5517,7 +6132,7 @@
 	  alpha += alphaLineBuf[xxa];
 	}
 	// alpha / xStep
-	alpha = (alpha * d) >> 23;
+	alpha = (alpha * d + (1 << 22)) >> 23;
 	for (i = 0; i < yStep; ++i) {
 	  destAlphaPtr = destAlphaPtr0 + i * scaledWidth + x;
 	  *destAlphaPtr = (Guchar)alpha;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/Splash.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -18,6 +18,7 @@
 #include "SplashTypes.h"
 #include "SplashClip.h"
 
+class GString;
 class Splash;
 class SplashBitmap;
 struct SplashGlyphBitmap;
@@ -65,6 +66,34 @@
 };
 
 //------------------------------------------------------------------------
+// SplashImageCache
+//------------------------------------------------------------------------
+
+// This holds a cached image, and is shared by multiple Splash objects
+// in the same thread.
+class SplashImageCache {
+public:
+
+  SplashImageCache();
+  ~SplashImageCache();
+  void incRefCount();
+  void decRefCount();
+
+  GString *tag;
+  GBool isMask;
+  int width;
+  int height;
+  SplashColorMode mode;
+  GBool alpha;
+  GBool interpolate;
+  GBool vertFlip;
+  GBool horizFlip;
+  SplashBitmap *image;
+
+  int refCount;
+};
+
+//------------------------------------------------------------------------
 // Splash
 //------------------------------------------------------------------------
 
@@ -73,9 +102,10 @@
 
   // Create a new rasterizer object.
   Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
+	 SplashImageCache *imageCacheA,
 	 SplashScreenParams *screenParams = NULL);
   Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA,
-	 SplashScreen *screenA);
+	 SplashImageCache *imageCacheA, SplashScreen *screenA);
 
   ~Splash();
 
@@ -173,7 +203,8 @@
   // Note that the Splash y axis points downward, and the image source
   // is assumed to produce pixels in raster order, starting from the
   // top line.
-  SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
+  SplashError fillImageMask(GString *imageTag,
+			    SplashImageMaskSource src, void *srcData,
 			    int w, int h, SplashCoord *mat,
 			    GBool glyphMode, GBool interpolate);
 
@@ -191,7 +222,8 @@
   //    BGR8         RGB8
   //    CMYK8        CMYK8
   // The matrix behaves as for fillImageMask.
-  SplashError drawImage(SplashImageSource src, void *srcData,
+  SplashError drawImage(GString *imageTag,
+			SplashImageSource src, void *srcData,
 			SplashColorMode srcMode, GBool srcAlpha,
 			int w, int h, SplashCoord *mat,
 			GBool interpolate);
@@ -255,6 +287,8 @@
   // Toggle debug mode on or off.
   void setDebugMode(GBool debugModeA) { debugMode = debugModeA; }
 
+  SplashImageCache *getImageCache() { return imageCache; }
+
 #if 1 //~tmp: turn off anti-aliasing temporarily
   void setInShading(GBool sh) { inShading = sh; }
 #endif
@@ -303,6 +337,16 @@
   void pipeRunAACMYK8(SplashPipe *pipe, int x0, int x1, int y,
 		      Guchar *shapePtr, SplashColorPtr cSrcPtr);
 #endif
+  void pipeRunNonIsoMono8(SplashPipe *pipe, int x0, int x1, int y,
+			  Guchar *shapePtr, SplashColorPtr cSrcPtr);
+  void pipeRunNonIsoRGB8(SplashPipe *pipe, int x0, int x1, int y,
+			 Guchar *shapePtr, SplashColorPtr cSrcPtr);
+  void pipeRunNonIsoBGR8(SplashPipe *pipe, int x0, int x1, int y,
+			 Guchar *shapePtr, SplashColorPtr cSrcPtr);
+#if SPLASH_CMYK
+  void pipeRunNonIsoCMYK8(SplashPipe *pipe, int x0, int x1, int y,
+			  Guchar *shapePtr, SplashColorPtr cSrcPtr);
+#endif
   void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi,
 		 SplashCoord *xo, SplashCoord *yo);
   void updateModX(int x);
@@ -331,11 +375,13 @@
 		   int srcWidth, int srcHeight,
 		   SplashCoord *mat, GBool glyphMode,
 		   GBool interpolate);
-  void arbitraryTransformMask(SplashImageMaskSource src, void *srcData,
+  void arbitraryTransformMask(GString *imageTag,
+			      SplashImageMaskSource src, void *srcData,
 			      int srcWidth, int srcHeight,
 			      SplashCoord *mat, GBool glyphMode,
 			      GBool interpolate);
-  SplashBitmap *scaleMask(SplashImageMaskSource src, void *srcData,
+  SplashBitmap *scaleMask(GString *imageTag,
+			  SplashImageMaskSource src, void *srcData,
 			  int srcWidth, int srcHeight,
 			  int scaledWidth, int scaledHeight,
 			  GBool interpolate);
@@ -365,12 +411,14 @@
 		    SplashColorMode srcMode, int nComps,
 		    GBool srcAlpha, int srcWidth, int srcHeight,
 		    SplashCoord *mat, GBool interpolate);
-  void arbitraryTransformImage(SplashImageSource src, void *srcData,
+  void arbitraryTransformImage(GString *imageTag,
+			       SplashImageSource src, void *srcData,
 			       SplashColorMode srcMode, int nComps,
 			       GBool srcAlpha,
 			       int srcWidth, int srcHeight,
 			       SplashCoord *mat, GBool interpolate);
-  SplashBitmap *scaleImage(SplashImageSource src, void *srcData,
+  SplashBitmap *scaleImage(GString *imageTag,
+			   SplashImageSource src, void *srcData,
 			   SplashColorMode srcMode, int nComps,
 			   GBool srcAlpha, int srcWidth, int srcHeight,
 			   int scaledWidth, int scaledHeight,
@@ -432,6 +480,8 @@
   GBool vectorAntialias;
   GBool inShading;
   GBool debugMode;
+
+  SplashImageCache *imageCache;
 };
 
 #endif

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -25,7 +25,7 @@
 
 SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
 			   SplashColorMode modeA, GBool alphaA,
-			   GBool topDown) {
+			   GBool topDown, SplashBitmap *parentA) {
   // NB: this code checks that rowSize fits in a signed 32-bit
   // integer, because some code (outside this class) makes that
   // assumption
@@ -63,7 +63,21 @@
   }
   rowSize += rowPad - 1;
   rowSize -= rowSize % rowPad;
-  data = (SplashColorPtr)gmallocn64(height, rowSize);
+
+  parent = parentA;
+  oldData = NULL;
+  oldAlpha = NULL;
+  oldRowSize = 0;
+  oldAlphaRowSize = 0;
+  oldHeight = 0;
+  if (parent && parent->oldData &&
+      parent->oldRowSize == rowSize &&
+      parent->oldHeight == height) {
+    data = parent->oldData;
+    parent->oldData = NULL;
+  } else {
+    data = (SplashColorPtr)gmallocn64(height, rowSize);
+  }
   if (!topDown) {
     data += (height - 1) * rowSize;
     rowSize = -rowSize;
@@ -70,7 +84,14 @@
   }
   if (alphaA) {
     alphaRowSize = width;
-    alpha = (Guchar *)gmallocn64(height, alphaRowSize);
+    if (parent && parent->oldAlpha &&
+	parent->oldAlphaRowSize == alphaRowSize &&
+	parent->oldHeight == height) {
+      alpha = parent->oldAlpha;
+      parent->oldAlpha = NULL;
+    } else {
+      alpha = (Guchar *)gmallocn64(height, alphaRowSize);
+    }
   } else {
     alphaRowSize = 0;
     alpha = NULL;
@@ -78,14 +99,24 @@
 }
 
 SplashBitmap::~SplashBitmap() {
-  if (data) {
-    if (rowSize < 0) {
-      gfree(data + (height - 1) * rowSize);
-    } else {
-      gfree(data);
-    }
+  if (data && rowSize < 0) {
+    rowSize = -rowSize;
+    data -= (height - 1) * rowSize;
   }
-  gfree(alpha);
+  if (parent && rowSize > 10000000 / height) {
+    gfree(parent->oldData);
+    gfree(parent->oldAlpha);
+    parent->oldData = data;
+    parent->oldAlpha = alpha;
+    parent->oldRowSize = rowSize;
+    parent->oldAlphaRowSize = alphaRowSize;
+    parent->oldHeight = height;
+  } else {
+    gfree(data);
+    gfree(alpha);
+  }
+  gfree(oldData);
+  gfree(oldAlpha);
 }
 
 SplashError SplashBitmap::writePNMFile(char *fileName) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashBitmap.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -44,7 +44,7 @@
   // upside-down, i.e., with the last row first in memory.
   SplashBitmap(int widthA, int heightA, int rowPad,
 	       SplashColorMode modeA, GBool alphaA,
-	       GBool topDown = gTrue);
+	       GBool topDown, SplashBitmap *parentA);
 
   ~SplashBitmap();
 
@@ -79,6 +79,14 @@
   Guchar *alpha;		// pointer to row zero of the alpha data
 				//   (always top-down)
 
+  // save the last-allocated (large) bitmap data and reuse if possible
+  SplashBitmap *parent;
+  SplashColorPtr oldData;
+  Guchar *oldAlpha;
+  SplashBitmapRowSize oldRowSize;
+  size_t oldAlphaRowSize;
+  int oldHeight;
+
   friend class Splash;
 };
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -132,10 +132,14 @@
 						 char *fileName,
 						 GBool deleteFile,
 #endif
+						 int *codeToGID,
 						 const char **enc) {
   SplashFontFile *fontFile;
 
   fontFile = NULL;
+  if (!fontFile) {
+    gfree(codeToGID);
+  }
 #if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadType1CFont(idA,
@@ -168,10 +172,14 @@
 						      char *fileName,
 						      GBool deleteFile,
 #endif
+						      int *codeToGID,
 						      const char **enc) {
   SplashFontFile *fontFile;
 
   fontFile = NULL;
+  if (!fontFile) {
+    gfree(codeToGID);
+  }
 #if HAVE_FREETYPE_H
   if (!fontFile && ftEngine) {
     fontFile = ftEngine->loadOpenTypeT1CFont(idA,
@@ -221,6 +229,10 @@
   }
 #endif
 
+  if (!fontFile) {
+    gfree(codeToGID);
+  }
+
 #if !LOAD_FONTS_FROM_MEM && !defined(_WIN32) && !defined(__ANDROID__)
   // delete the (temporary) font file -- with Unix hard link
   // semantics, this will remove the last link; otherwise it will
@@ -258,6 +270,10 @@
   }
 #endif
 
+  if (!fontFile) {
+    gfree(codeToGID);
+  }
+
 #if !LOAD_FONTS_FROM_MEM && !defined(_WIN32) && !defined(__ANDROID__)
   // delete the (temporary) font file -- with Unix hard link
   // semantics, this will remove the last link; otherwise it will

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashFontEngine.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -68,7 +68,7 @@
 #else
 				 char *fileName, GBool deleteFile,
 #endif
-				 const char **enc);
+				 int *codeToGID, const char **enc);
   SplashFontFile *loadOpenTypeT1CFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
 				      GString *fontBuf,
@@ -75,7 +75,7 @@
 #else
 				      char *fileName, GBool deleteFile,
 #endif
-				      const char **enc);
+				      int *codeToGID, const char **enc);
   SplashFontFile *loadCIDFont(SplashFontFileID *idA,
 #if LOAD_FONTS_FROM_MEM
 			      GString *fontBuf,

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashMath.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashMath.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashMath.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -47,17 +47,13 @@
   // NB: 64-bit x86 guarantees availability of SSE2.
 
   __m128d m1, m2;
-  __m128i m3;
-  int s, i;
+  int i, s;
 
-  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
+  m1 = _mm_set_sd(x);
+  i = _mm_cvttsd_si32(m1);
+  m2 = _mm_cvtsi32_sd(m1, i);
+  s = _mm_ucomigt_sd(m2, m1);
+  return i - s;
 
 #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__)
 
@@ -123,17 +119,13 @@
   // NB: 64-bit x86 guarantees availability of SSE2.
 
   __m128d m1, m2;
-  __m128i m3;
-  int s, i;
+  int i, s;
 
-  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
+  m1 = _mm_set_sd(x);
+  i = _mm_cvttsd_si32(m1);
+  m2 = _mm_cvtsi32_sd(m1, i);
+  s = _mm_ucomilt_sd(m2, m1);
+  return i + s;
 
 #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__)
 
@@ -315,6 +307,31 @@
 				      SplashCoord w = -1) {
   int x0, x1;
 
+  // make sure the coords fit in 32-bit ints
+#if USE_FIXEDPOINT
+  if (xMin < -32767) {
+    xMin = -32767;
+  } else if (xMin > 32767) {
+    xMin = 32767;
+  }
+  if (xMax < -32767) {
+    xMax = -32767;
+  } else if (xMax > 32767) {
+    xMax = 32767;
+  }
+#else
+  if (xMin < -1e9) {
+    xMin = -1e9;
+  } else if (xMin > 1e9) {
+    xMin = 1e9;
+  }
+  if (xMax < -1e9) {
+    xMax = -1e9;
+  } else if (xMax > 1e9) {
+    xMax = 1e9;
+  }
+#endif
+
   // this will never be called with strokeAdjMode == splashStrokeAdjustOff
   if (strokeAdjMode == splashStrokeAdjustCAD) {
     x0 = splashRound(xMin);

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashXPath.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashXPath.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/splash/SplashXPath.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -247,7 +247,7 @@
     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) {
+    if (splashAbs(x0 - x1) < 0.01 && splashAbs(x2 - x3) < 0.01) {
       adjusts[i].vert = gTrue;
       adj0 = x0;
       adj1 = x2;
@@ -254,7 +254,7 @@
       if (hint->projectingCap) {
 	w = splashAbs(y1 - y0);
       }
-    } else if (y0 == y1 && y2 == y3) {
+    } else if (splashAbs(y0 - y1) < 0.01 && splashAbs(y2 - y3) < 0.01) {
       adjusts[i].vert = gFalse;
       adj0 = y0;
       adj1 = y2;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/AcroForm.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/AcroForm.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/AcroForm.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -1542,10 +1542,11 @@
     fontSize = atof(tok->getCString());
   } else {
     error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string");
-    fontSize = 10;
+    fontSize = 0;
     if (!daToks) {
       daToks = new GList();
     }
+    tfPos = daToks->getLength();
     daToks->append(new GString("/xpdf_default_font"));
     daToks->append(new GString("10"));
     daToks->append(new GString("Tf"));
@@ -1583,7 +1584,7 @@
 
     // compute font autosize
     if (fontSize == 0) {
-      for (fontSize = 20; fontSize > 1; --fontSize) {
+      for (fontSize = 10; fontSize > 1; --fontSize) {
 	y = dy - 3;
 	w2 = 0;
 	i = 0;
@@ -1596,7 +1597,7 @@
 	  y -= fontSize;
 	}
 	// approximate the descender for the last line
-	if (y >= 0.33 * fontSize) {
+	if (y >= 0.33 * fontSize && w <= wMax) {
 	  break;
 	}
       }
@@ -1697,6 +1698,9 @@
 	  fontSize = w;
 	}
 	fontSize = floor(fontSize);
+	if (fontSize > 10) {
+	  fontSize = 10;
+	}
 	if (tfPos >= 0) {
 	  tok = (GString *)daToks->get(tfPos + 1);
 	  tok->clear();
@@ -1783,6 +1787,9 @@
 	  fontSize = fontSize2;
 	}
 	fontSize = floor(fontSize);
+	if (fontSize > 10) {
+	  fontSize = 10;
+	}
 	if (tfPos >= 0) {
 	  tok = (GString *)daToks->get(tfPos + 1);
 	  tok->clear();
@@ -1936,6 +1943,9 @@
       fontSize = fontSize2;
     }
     fontSize = floor(fontSize);
+    if (fontSize > 10) {
+      fontSize = 10;
+    }
     if (tfPos >= 0) {
       tok = (GString *)daToks->get(tfPos + 1);
       tok->clear();

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Annot.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Annot.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Annot.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -845,7 +845,7 @@
   if (!colorObj->isArray()) {
     return gFalse;
   }
-  for (i = 0; i < colorObj->arrayGetLength(); ++i) {
+  for (i = 0; i < colorObj->arrayGetLength() && i < 4; ++i) {
     if (colorObj->arrayGet(i, &obj)->isNum()) {
       color[i] = obj.getNum();
     } else {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/BuiltinFont.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -51,6 +51,7 @@
       return gTrue;
     }
   }
+  *width = 0;
   return gFalse;
 }
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/CMakeLists.txt	2019-11-23 23:34:02 UTC (rev 816)
@@ -111,7 +111,9 @@
                         ${PAPER_LIBRARY}
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
                         ${DTYPE_LIBRARY}
-                        ${LCMS_LIBRARY})
+                        ${LCMS_LIBRARY}
+                        ${FONTCONFIG_LIBRARY}
+                        ${CMAKE_THREAD_LIBS_INIT})
 else ()
   add_executable(pdftops
     $<TARGET_OBJECTS:xpdf_objs>
@@ -119,7 +121,11 @@
     PSOutputDev.cc
     pdftops.cc
   )
-  target_link_libraries(pdftops goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+  target_link_libraries(pdftops goo fofi
+                        ${PAPER_LIBRARY}
+                        ${LCMS_LIBRARY}
+                        ${FONTCONFIG_LIBRARY}
+                        ${CMAKE_THREAD_LIBS_INIT})
 endif ()
 install(TARGETS pdftops RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
@@ -131,7 +137,11 @@
   TextOutputDev.cc
   pdftotext.cc
 )
-target_link_libraries(pdftotext goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+target_link_libraries(pdftotext goo fofi
+                      ${PAPER_LIBRARY}
+                      ${LCMS_LIBRARY}
+                      ${FONTCONFIG_LIBRARY}
+                      ${CMAKE_THREAD_LIBS_INIT})
 install(TARGETS pdftotext RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 
@@ -143,6 +153,7 @@
     HTMLGen.cc
     SplashOutputDev.cc
     TextOutputDev.cc
+    WebFont.cc
     pdftohtml.cc
   )
   target_link_libraries(pdftohtml goo fofi splash
@@ -149,7 +160,10 @@
                         ${PAPER_LIBRARY}
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
                         ${DTYPE_LIBRARY}
-                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+                        ${LCMS_LIBRARY}
+                        ${PNG_LIBRARIES}
+                        ${FONTCONFIG_LIBRARY}
+                        ${CMAKE_THREAD_LIBS_INIT})
   install(TARGETS pdftohtml RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
   install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 endif ()
@@ -160,7 +174,11 @@
   $<TARGET_OBJECTS:xpdf_objs>
   pdfinfo.cc
 )
-target_link_libraries(pdfinfo goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+target_link_libraries(pdfinfo goo fofi
+                      ${PAPER_LIBRARY}
+                      ${LCMS_LIBRARY}
+                      ${FONTCONFIG_LIBRARY}
+                      ${CMAKE_THREAD_LIBS_INIT})
 install(TARGETS pdfinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 
@@ -170,7 +188,11 @@
   $<TARGET_OBJECTS:xpdf_objs>
   pdffonts.cc
 )
-target_link_libraries(pdffonts goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+target_link_libraries(pdffonts goo fofi
+                      ${PAPER_LIBRARY}
+                      ${LCMS_LIBRARY}
+                      ${FONTCONFIG_LIBRARY}
+                      ${CMAKE_THREAD_LIBS_INIT})
 install(TARGETS pdffonts RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 
@@ -180,7 +202,11 @@
   $<TARGET_OBJECTS:xpdf_objs>
   pdfdetach.cc
 )
-target_link_libraries(pdfdetach goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+target_link_libraries(pdfdetach goo fofi
+                      ${PAPER_LIBRARY}
+                      ${LCMS_LIBRARY}
+                      ${FONTCONFIG_LIBRARY}
+                      ${CMAKE_THREAD_LIBS_INIT})
 install(TARGETS pdfdetach RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 
@@ -196,7 +222,9 @@
                         ${PAPER_LIBRARY}
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
                         ${DTYPE_LIBRARY}
-                        ${LCMS_LIBRARY})
+                        ${LCMS_LIBRARY}
+                        ${FONTCONFIG_LIBRARY}
+                        ${CMAKE_THREAD_LIBS_INIT})
   install(TARGETS pdftoppm RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
   install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 endif ()
@@ -213,7 +241,10 @@
                         ${PAPER_LIBRARY}
                         ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
                         ${DTYPE_LIBRARY}
-                        ${LCMS_LIBRARY} ${PNG_LIBRARIES})
+                        ${LCMS_LIBRARY}
+                        ${PNG_LIBRARIES}
+                        ${FONTCONFIG_LIBRARY}
+                        ${CMAKE_THREAD_LIBS_INIT})
   install(TARGETS pdftopng RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
   install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 endif ()
@@ -225,7 +256,11 @@
   ImageOutputDev.cc
   pdfimages.cc
 )
-target_link_libraries(pdfimages goo fofi ${PAPER_LIBRARY} ${LCMS_LIBRARY})
+target_link_libraries(pdfimages goo fofi
+                      ${PAPER_LIBRARY}
+                      ${LCMS_LIBRARY}
+                      ${FONTCONFIG_LIBRARY}
+                      ${CMAKE_THREAD_LIBS_INIT})
 install(TARGETS pdfimages RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -89,6 +89,59 @@
 }
 
 //------------------------------------------------------------------------
+// PageLabelNode
+//------------------------------------------------------------------------
+
+class PageLabelNode {
+public:
+
+  PageLabelNode(int firstPageA, Dict *dict);
+  ~PageLabelNode();
+
+  int firstPage;		// first page number covered by this node
+  int lastPage;			// last page number covered by this node
+  TextString *prefix;		// label prefix (may be empty)
+  int start;			// value of the numeric portion of this
+				//   label for the first page in the range
+  char style;			// page label style
+};
+
+PageLabelNode::PageLabelNode(int firstPageA, Dict *dict) {
+  Object prefixObj, styleObj, startObj;
+
+  // convert page index to page number
+  firstPage = firstPageA + 1;
+
+  // lastPage will be filled in later
+  lastPage = -1;
+
+  if (dict->lookup("P", &prefixObj)->isString()) {
+    prefix = new TextString(prefixObj.getString());
+  } else {
+    prefix = new TextString();
+  }
+  prefixObj.free();
+
+  style = '\0';
+  if (dict->lookup("S", &styleObj)->isName()) {
+    if (strlen(styleObj.getName()) == 1) {
+      style = styleObj.getName()[0];
+    }
+  }
+  styleObj.free();
+
+  start = 1;
+  if (dict->lookup("St", &startObj)->isInt()) {
+    start = startObj.getInt();
+  }
+  startObj.free();
+}
+
+PageLabelNode::~PageLabelNode() {
+  delete prefix;
+}
+
+//------------------------------------------------------------------------
 // Catalog
 //------------------------------------------------------------------------
 
@@ -185,6 +238,15 @@
   // get the list of embedded files
   readEmbeddedFileList(catDict.getDict());
 
+  // get the ViewerPreferences object
+  catDict.dictLookupNF("ViewerPreferences", &viewerPrefs);
+
+  pageLabels = NULL;
+  if (catDict.dictLookup("PageLabels", &obj)->isDict()) {
+    readPageLabelTree(&obj);
+  }
+  obj.free();
+
   catDict.free();
   return;
 
@@ -229,6 +291,10 @@
   if (embeddedFiles) {
     deleteGList(embeddedFiles, EmbeddedFile);
   }
+  if (pageLabels) {
+    deleteGList(pageLabels, PageLabelNode);
+  }
+  viewerPrefs.free();
 }
 
 Page *Catalog::getPage(int i) {
@@ -833,107 +899,45 @@
   return strObj;
 }
 
-TextString *Catalog::getPageLabel(int pageNum) {
-  Object catDict, node, pageLabelObj, start, prefix, style;
-  GString *label, *s;
-  TextString *ts;
-  int firstPageIndex, pageRangeNum;
+void Catalog::readPageLabelTree(Object *root) {
+  PageLabelNode *label0, *label1;
+  int i;
 
-  if (!xref->getCatalog(&catDict)->isDict()) {
-    catDict.free();
-    return NULL;
+  pageLabels = new GList();
+  readPageLabelTree2(root);
+
+  if (pageLabels->getLength() == 0) {
+    deleteGList(pageLabels, PageLabelNode);
+    pageLabels = NULL;
+    return;
   }
 
-  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();
+  // set lastPage in each node
+  label0 = (PageLabelNode *)pageLabels->get(0);
+  for (i = 1; i < pageLabels->getLength(); ++i) {
+    label1 = (PageLabelNode *)pageLabels->get(i);
+    label0->lastPage = label1->firstPage - 1;
+    label0 = label1;
   }
-  node.free();
-  catDict.free();
-
-  ts = new TextString(label);
-  delete label;
-  return ts;
+  label0->lastPage = numPages;
 }
 
-GBool Catalog::findPageLabel(Object *node, int pageIndex,
-			     Object *pageLabelObj, int *firstPageIndex) {
-  Object limits, limit, nums, num, kids, kid;
+void Catalog::readPageLabelTree2(Object *node) {
+  Object nums, num, labelObj, kids, kid;
   int i;
 
   if (!node->isDict()) {
-    return gFalse;
+    return;
   }
 
-  // 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;
+    for (i = 0; i < nums.arrayGetLength() - 1; i += 2) {
+      if (nums.arrayGet(i, &num)->isInt()) {
+	if (nums.arrayGet(i+1, &labelObj)->isDict()) {
+	  pageLabels->append(new PageLabelNode(num.getInt(),
+					       labelObj.getDict()));
 	}
-      } else {
-	error(errSyntaxError, -1, "Invalid key in page label number tree");
-	num.free();
-	nums.free();
-	return gFalse;
+	labelObj.free();
       }
       num.free();
     }
@@ -941,22 +945,63 @@
   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;
-	}
-      }
+    for (i = 0; i < kids.arrayGetLength(); ++i) {
+      kids.arrayGet(i, &kid);
+      readPageLabelTree2(&kid);
       kid.free();
     }
   }
   kids.free();
+}
 
-  return gFalse;
+TextString *Catalog::getPageLabel(int pageNum) {
+  PageLabelNode *label;
+  TextString *ts;
+  int pageRangeNum;
+  GString *suffix;
+
+  if (!pageLabels || !(label = findPageLabel(pageNum))) {
+    return NULL;
+  }
+
+  ts = new TextString(label->prefix);
+
+  pageRangeNum = label->start + (pageNum - label->firstPage);
+
+  suffix = NULL;
+  if (label->style == 'D') {
+    suffix = GString::format("{0:d}", pageRangeNum);
+  } else if (label->style == 'R') {
+    suffix = makeRomanNumeral(pageRangeNum, gTrue);
+  } else if (label->style == 'r') {
+    suffix = makeRomanNumeral(pageRangeNum, gFalse);
+  } else if (label->style == 'A') {
+    suffix = makeLetterLabel(pageRangeNum, gTrue);
+  } else if (label->style == 'a') {
+    suffix = makeLetterLabel(pageRangeNum, gFalse);
+  }
+  if (suffix) {
+    ts->append(suffix);
+    delete suffix;
+  }
+
+  return ts;
 }
 
+PageLabelNode *Catalog::findPageLabel(int pageNum) {
+  PageLabelNode *label;
+  int i;
+
+  //~ this could use a binary search
+  for (i = 0; i < pageLabels->getLength(); ++i) {
+    label = (PageLabelNode *)pageLabels->get(i);
+    if (pageNum >= label->firstPage && pageNum <= label->lastPage) {
+      return label;
+    }
+  }
+  return NULL;
+}
+
 GString *Catalog::makeRomanNumeral(int num, GBool uppercase) {
   GString *s;
 
@@ -1022,3 +1067,131 @@
   }
   return s;
 }
+
+int Catalog::getPageNumFromPageLabel(TextString *pageLabel) {
+  PageLabelNode *label;
+  int pageNum, prefixLength, i, n;
+
+  if (!pageLabels) {
+    return -1;
+  }
+  for (i = 0; i < pageLabels->getLength(); ++i) {
+    label = (PageLabelNode *)pageLabels->get(i);
+    prefixLength = label->prefix->getLength();
+    if (pageLabel->getLength() < prefixLength ||
+	memcmp(pageLabel->getUnicode(), label->prefix->getUnicode(),
+	       prefixLength * sizeof(Unicode))) {
+      continue;
+    }
+    if (label->style == '\0' && pageLabel->getLength() == prefixLength) {
+      return label->firstPage;
+    }
+    if (!convertPageLabelToInt(pageLabel, prefixLength, label->style, &n)) {
+      continue;
+    }
+    if (n < label->start) {
+      continue;
+    }
+    pageNum = label->firstPage + n - label->start;
+    if (pageNum <= label->lastPage) {
+      return pageNum;
+    }
+  }
+  return -1;
+}
+
+// Attempts to convert pageLabel[prefixLength .. end] to an integer,
+// following the specified page label style.  If successful, sets *n
+// and returns true; else returns false.
+GBool Catalog::convertPageLabelToInt(TextString *pageLabel, int prefixLength,
+				     char style, int *n) {
+  Unicode *u;
+  Unicode delta;
+  int len, i;
+
+  len = pageLabel->getLength();
+  if (len <= prefixLength) {
+    return gFalse;
+  }
+  u = pageLabel->getUnicode();
+  if (style == 'D') {
+    *n = 0;
+    for (i = prefixLength; i < len; ++i) {
+      if (u[i] < (Unicode)'0' || u[i] > (Unicode)'9') {
+	return gFalse;
+      }
+      *n = *n * 10 + (u[i] - (Unicode)'0');
+    }
+    return gTrue;
+  } else if (style == 'R' || style == 'r') {
+    delta = style - 'R';
+    *n = 0;
+    i = prefixLength;
+    while (i < len && u[i] == (Unicode)'M' + delta) {
+      *n += 1000;
+      ++i;
+    }
+    if (i+1 < len && u[i] == (Unicode)'C' + delta &&
+	u[i+1] == (Unicode)'M' + delta) {
+      *n += 900;
+      i += 2;
+    } else if (i < len && u[i] == (Unicode)'D' + delta) {
+      *n += 500;
+      ++i;
+    } else if (i+1 < len && u[i] == (Unicode)'C' + delta &&
+	       u[i+1] == (Unicode)'D' + delta) {
+      *n += 400;
+      i += 2;
+    }
+    while (i < len && u[i] == (Unicode)'C' + delta) {
+      *n += 100;
+      ++i;
+    }
+    if (i+1 < len && u[i] == (Unicode)'X' + delta &&
+	u[i+1] == (Unicode)'C' + delta) {
+      *n += 90;
+      i += 2;
+    } else if (i < len && u[i] == (Unicode)'L' + delta) {
+      *n += 50;
+      ++i;
+    } else if (i+1 < len && u[i] == (Unicode)'X' + delta &&
+	       u[i+1] == (Unicode)'L' + delta) {
+      *n += 40;
+      i += 2;
+    }
+    while (i < len && u[i] == (Unicode)'X' + delta) {
+      *n += 10;
+      ++i;
+    }
+    if (i+1 < len && u[i] == (Unicode)'I' + delta &&
+	u[i+1] == (Unicode)'X' + delta) {
+      *n += 9;
+      i += 2;
+    } else if (i < len && u[i] == (Unicode)'V' + delta) {
+      *n += 5;
+      ++i;
+    } else if (i+1 < len && u[i] == (Unicode)'I' + delta &&
+	       u[i+1] == (Unicode)'V' + delta) {
+      *n += 4;
+      i += 2;
+    }
+    while (i < len && u[i] == (Unicode)'I' + delta) {
+      *n += 1;
+      ++i;
+    }
+    return i == len;
+  } else if (style == 'A' || style == 'a') {
+    if (u[prefixLength] < (Unicode)style ||
+	u[prefixLength] > (Unicode)style + 25) {
+      return gFalse;
+    }
+    for (i = prefixLength + 1; i < len; ++i) {
+      if (u[i] != u[prefixLength]) {
+	return gFalse;
+      }
+    }
+    *n = (len - prefixLength - 1) * 26 + (u[i] - (Unicode)style) + 1;
+    return gTrue;
+  }
+  return gFalse;
+}

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Catalog.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -29,6 +29,7 @@
 struct Ref;
 class LinkDest;
 class PageTreeNode;
+class PageLabelNode;
 class Form;
 class TextString;
 
@@ -103,10 +104,20 @@
   Object *getEmbeddedFileStreamRef(int idx);
   Object *getEmbeddedFileStreamObj(int idx, Object *strObj);
 
+  // Return true if the document has page labels.
+  GBool hasPageLabels() { return pageLabels != NULL; }
+
   // Get the page label for page number [pageNum].  Returns NULL if
   // the PDF file doesn't have page labels.
   TextString *getPageLabel(int pageNum);
 
+  // Returns the page number corresponding to [pageLabel].  Returns -1
+  // if there is no matching page label, or if the document doesn't
+  // have page labels.
+  int getPageNumFromPageLabel(TextString *pageLabel);
+
+  Object *getViewerPreferences() { return &viewerPrefs; }
+
 private:
 
   PDFDoc *doc;
@@ -129,6 +140,8 @@
   Form *form;			// parsed form
   Object ocProperties;		// OCProperties dictionary
   GList *embeddedFiles;		// embedded file list [EmbeddedFile]
+  GList *pageLabels;		// page labels [PageLabelNode]
+  Object viewerPrefs;		// ViewerPreferences object
   GBool ok;			// true if catalog is valid
 
   Object *findDestInTree(Object *tree, GString *name, Object *obj);
@@ -141,10 +154,13 @@
   void readFileAttachmentAnnots(Object *pageNodeRef,
 				char *touchedObjs);
   void readEmbeddedFile(Object *fileSpec, Object *name1);
-  GBool findPageLabel(Object *node, int pageIndex,
-		      Object *pageLabelObj, int *firstPageIndex);
+  void readPageLabelTree(Object *root);
+  void readPageLabelTree2(Object *node);
+  PageLabelNode *findPageLabel(int pageNum);
   GString *makeRomanNumeral(int num, GBool uppercase);
   GString *makeLetterLabel(int num, GBool uppercase);
+  GBool convertPageLabelToInt(TextString *pageLabel, int prefixLength,
+			      char style, int *n);
 };
 
 #endif

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -41,7 +41,8 @@
 Function::~Function() {
 }
 
-Function *Function::parse(Object *funcObj, int recursion) {
+Function *Function::parse(Object *funcObj, int expectedInputs,
+			  int expectedOutputs, int recursion) {
   Function *func;
   Dict *dict;
   int funcType;
@@ -57,7 +58,11 @@
   } else if (funcObj->isDict()) {
     dict = funcObj->getDict();
   } else if (funcObj->isName("Identity")) {
-    return new IdentityFunction();
+    if (expectedInputs != expectedOutputs) {
+      error(errSyntaxError, -1, "Invalid use of identity function");
+      return NULL;
+    }
+    return new IdentityFunction(expectedInputs);
   } else {
     error(errSyntaxError, -1, "Expected function dictionary or stream");
     return NULL;
@@ -76,7 +81,8 @@
   } else if (funcType == 2) {
     func = new ExponentialFunction(funcObj, dict);
   } else if (funcType == 3) {
-    func = new StitchingFunction(funcObj, dict, recursion);
+    func = new StitchingFunction(funcObj, dict, expectedInputs,
+				 expectedOutputs, recursion);
   } else if (funcType == 4) {
     func = new PostScriptFunction(funcObj, dict);
   } else {
@@ -88,6 +94,14 @@
     return NULL;
   }
 
+  if (func->getInputSize() != expectedInputs ||
+      (expectedOutputs >= 0 && func->getOutputSize() != expectedOutputs)) {
+    error(errSyntaxError, -1,
+	  "Incorrect number of function inputs or outputs");
+    delete func;
+    return NULL;
+  }
+
   return func;
 }
 
@@ -169,14 +183,12 @@
 // IdentityFunction
 //------------------------------------------------------------------------
 
-IdentityFunction::IdentityFunction() {
+IdentityFunction::IdentityFunction(int nInputs) {
   int i;
 
-  // fill these in with arbitrary values just in case they get used
-  // somewhere
-  m = funcMaxInputs;
-  n = funcMaxOutputs;
-  for (i = 0; i < funcMaxInputs; ++i) {
+  m = n = nInputs;
+  // domain info shouldn't be used anywhere
+  for (i = 0; i < nInputs; ++i) {
     domain[i][0] = 0;
     domain[i][1] = 1;
   }
@@ -189,7 +201,7 @@
 void IdentityFunction::transform(double *in, double *out) {
   int i;
 
-  for (i = 0; i < funcMaxOutputs; ++i) {
+  for (i = 0; i < m; ++i) {
     out[i] = in[i];
   }
 }
@@ -347,8 +359,13 @@
 
   //----- samples
   nSamples = n;
-  for (i = 0; i < m; ++i)
+  for (i = 0; i < m; ++i) {
+    if (nSamples > INT_MAX / sampleSize[i]) {
+      error(errSyntaxError, -1, "Integer overflow in sampled function setup");
+      goto err1;
+    }
     nSamples *= sampleSize[i];
+  }
   samples = (double *)gmallocn(nSamples, sizeof(double));
   buf = 0;
   bits = 0;
@@ -623,6 +640,7 @@
 //------------------------------------------------------------------------
 
 StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict,
+				     int expectedInputs, int expectedOutputs,
 				     int recursion) {
   Object obj1, obj2;
   int i;
@@ -643,7 +661,8 @@
   }
 
   //----- Functions
-  if (!dict->lookup("Functions", &obj1)->isArray()) {
+  if (!dict->lookup("Functions", &obj1)->isArray() ||
+      obj1.arrayGetLength() < 1) {
     error(errSyntaxError, -1,
 	  "Missing 'Functions' entry in stitching function");
     goto err1;
@@ -658,11 +677,14 @@
   }
   for (i = 0; i < k; ++i) {
     if (!(funcs[i] = Function::parse(obj1.arrayGet(i, &obj2),
+				     expectedInputs, expectedOutputs,
 				     recursion + 1))) {
       goto err2;
     }
-    if (funcs[i]->getInputSize() != 1 ||
-	(i > 0 && funcs[i]->getOutputSize() != funcs[0]->getOutputSize())) {
+    if (i == 0) {
+      n = funcs[0]->getOutputSize();
+    }
+    if (funcs[i]->getInputSize() != 1 || funcs[i]->getOutputSize() != n) {
       error(errSyntaxError, -1,
 	    "Incompatible subfunctions in stitching function");
       goto err2;
@@ -1305,6 +1327,9 @@
       if (sp + 1 >= psStackSize) {
 	goto underflow;
       }
+      if (stack[sp] == 0) {
+	goto invalidArg;
+      }
       stack[sp + 1] = stack[sp + 1] / stack[sp];
       ++sp;
       break;
@@ -1371,7 +1396,11 @@
       if (sp + 1 >= psStackSize) {
 	goto underflow;
       }
-      stack[sp + 1] = (int)stack[sp + 1] / (int)stack[sp];
+      k = (int)stack[sp];
+      if (k == 0) {
+	goto invalidArg;
+      }
+      stack[sp + 1] = (int)stack[sp + 1] / k;
       ++sp;
       break;
     case psOpIndex:
@@ -1417,7 +1446,11 @@
       if (sp + 1 >= psStackSize) {
 	goto underflow;
       }
-      stack[sp + 1] = (int)stack[sp + 1] % (int)stack[sp];
+      k = (int)stack[sp];
+      if (k == 0) {
+	goto invalidArg;
+      }
+      stack[sp + 1] = (int)stack[sp + 1] % k;
       ++sp;
       break;
     case psOpMul:
@@ -1468,23 +1501,25 @@
       if (nn < 0) {
 	goto invalidArg;
       }
-      if (sp + nn > psStackSize) {
-	goto underflow;
-      }
-      if (k >= 0) {
-	k %= nn;
-      } else {
-	k = -k % nn;
-	if (k) {
-	  k = nn - k;
+      if (nn > 0) {
+	if (sp + nn > psStackSize) {
+	  goto underflow;
 	}
+	if (k >= 0) {
+	  k %= nn;
+	} else {
+	  k = -k % nn;
+	  if (k) {
+	    k = nn - k;
+	  }
+	}
+	for (i = 0; i < nn; ++i) {
+	  tmp[i] = stack[sp + i];
+	}
+	for (i = 0; i < nn; ++i) {
+	  stack[sp + i] = tmp[(i + k) % nn];
+	}
       }
-      for (i = 0; i < nn; ++i) {
-	tmp[i] = stack[sp + i];
-      }
-      for (i = 0; i < nn; ++i) {
-	stack[sp + i] = tmp[(i + k) % nn];
-      }
       break;
     case psOpRound:
       if (sp >= psStackSize) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Function.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -38,8 +38,11 @@
 
   virtual ~Function();
 
-  // Construct a function.  Returns NULL if unsuccessful.
-  static Function *parse(Object *funcObj, int recursion = 0);
+  // Construct a function, with [expectedInputs] inputs and
+  // [expectedOutputs] outputs.  [expectedOutputs] can be -1 to
+  // indicate unknown.  Returns NULL if unsuccessful.
+  static Function *parse(Object *funcObj, int expectedInputs,
+			 int expectedOutputs, int recursion = 0);
 
   // Initialize the entries common to all function types.
   GBool init(Dict *dict);
@@ -86,9 +89,9 @@
 class IdentityFunction: public Function {
 public:
 
-  IdentityFunction();
+  IdentityFunction(int nInputs);
   virtual ~IdentityFunction();
-  virtual Function *copy() { return new IdentityFunction(); }
+  virtual Function *copy() { return new IdentityFunction(m); }
   virtual int getType() { return -1; }
   virtual void transform(double *in, double *out);
   virtual GBool isOk() { return gTrue; }
@@ -173,7 +176,8 @@
 class StitchingFunction: public Function {
 public:
 
-  StitchingFunction(Object *funcObj, Dict *dict, int recursion);
+  StitchingFunction(Object *funcObj, Dict *dict, int expectedInputs,
+		    int expectedOutputs, int recursion);
   virtual ~StitchingFunction();
   virtual Function *copy() { return new StitchingFunction(this); }
   virtual int getType() { return 3; }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -919,12 +919,24 @@
 }
 
 void Gfx::opSetLineJoin(Object args[], int numArgs) {
-  state->setLineJoin(args[0].getInt());
+  int lineJoin;
+
+  lineJoin = args[0].getInt();
+  if (lineJoin < 0 || lineJoin > 2) {
+    lineJoin = 0;
+  }
+  state->setLineJoin(lineJoin);
   out->updateLineJoin(state);
 }
 
 void Gfx::opSetLineCap(Object args[], int numArgs) {
-  state->setLineCap(args[0].getInt());
+  int lineCap;
+
+  lineCap = args[0].getInt();
+  if (lineCap < 0 || lineCap > 2) {
+    lineCap = 0;
+  }
+  state->setLineCap(lineCap);
   out->updateLineCap(state);
 }
 
@@ -1041,17 +1053,17 @@
 
   // fill/stroke overprint, overprint mode
   if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) {
-    if (!state->getInCachedT3Char()) {
+    if (!state->getIgnoreColorOps()) {
       state->setFillOverprint(obj2.getBool());
       out->updateFillOverprint(state);
     } else {
-      error(errSyntaxWarning, getPos(),
-	    "Ignoring overprint setting in cached Type 3 character");
+      error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
+	    " in uncolored Type 3 char or tiling pattern");
     }
   }
   obj2.free();
   if (obj1.dictLookup("OP", &obj2)->isBool()) {
-    if (!state->getInCachedT3Char()) {
+    if (!state->getIgnoreColorOps()) {
       state->setStrokeOverprint(obj2.getBool());
       out->updateStrokeOverprint(state);
       if (!haveFillOP) {
@@ -1059,18 +1071,18 @@
 	out->updateFillOverprint(state);
       }
     } else {
-      error(errSyntaxWarning, getPos(),
-	    "Ignoring overprint setting in cached Type 3 character");
+      error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
+	    " in uncolored Type 3 char or tiling pattern");
     }
   }
   obj2.free();
   if (obj1.dictLookup("OPM", &obj2)->isInt()) {
-    if (!state->getInCachedT3Char()) {
+    if (!state->getIgnoreColorOps()) {
       state->setOverprintMode(obj2.getInt());
       out->updateOverprintMode(state);
     } else {
-      error(errSyntaxWarning, getPos(),
-	    "Ignoring overprint setting in cached Type 3 character");
+      error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
+	    " in uncolored Type 3 char or tiling pattern");
     }
   }
   obj2.free();
@@ -1088,7 +1100,7 @@
     obj1.dictLookup("TR", &obj2);
   }
   if (!obj2.isNull()) {
-    if (!state->getInCachedT3Char()) {
+    if (!state->getIgnoreColorOps()) {
       if (obj2.isName("Default") ||
 	  obj2.isName("Identity")) {
 	funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL;
@@ -1097,7 +1109,7 @@
       } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
 	for (i = 0; i < 4; ++i) {
 	  obj2.arrayGet(i, &obj3);
-	  funcs[i] = Function::parse(&obj3);
+	  funcs[i] = Function::parse(&obj3, 1, 1);
 	  obj3.free();
 	  if (!funcs[i]) {
 	    break;
@@ -1108,7 +1120,7 @@
 	  out->updateTransfer(state);
 	}
       } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) {
-	if ((funcs[0] = Function::parse(&obj2))) {
+	if ((funcs[0] = Function::parse(&obj2, 1, 1))) {
 	  funcs[1] = funcs[2] = funcs[3] = NULL;
 	  state->setTransfer(funcs);
 	  out->updateTransfer(state);
@@ -1118,8 +1130,8 @@
 	      "Invalid transfer function in ExtGState");
       }
     } else {
-      error(errSyntaxWarning, getPos(),
-	    "Ignoring transfer function setting in cached Type 3 character");
+      error(errSyntaxWarning, getPos(), "Ignoring transfer function setting"
+	    " in uncolored Type 3 char or tiling pattern");
     }
   }
   obj2.free();
@@ -1129,10 +1141,15 @@
     if (obj2.isName("None")) {
       out->clearSoftMask(state);
     } else if (obj2.isDict()) {
-      if (obj2.dictLookup("S", &obj3)->isName("Alpha")) {
+      obj2.dictLookup("S", &obj3);
+      if (obj3.isName("Alpha")) {
 	alpha = gTrue;
-      } else { // "Luminosity"
+      } else if (obj3.isName("Luminosity")) {
 	alpha = gFalse;
+      } else {
+	error(errSyntaxError, getPos(),
+	      "Missing S (subtype) entry in soft mask");
+	alpha = gFalse;
       }
       obj3.free();
       funcs[0] = NULL;
@@ -1141,9 +1158,7 @@
 	    obj3.isName("Identity")) {
 	  funcs[0] = NULL;
 	} else {
-	  funcs[0] = Function::parse(&obj3);
-	  if (funcs[0]->getInputSize() != 1 ||
-	      funcs[0]->getOutputSize() != 1) {
+	  if (!(funcs[0] = Function::parse(&obj3, 1, 1))) {
 	    error(errSyntaxError, getPos(),
 		  "Invalid transfer function in soft mask in ExtGState");
 	    delete funcs[0];
@@ -1290,9 +1305,9 @@
 void Gfx::opSetRenderingIntent(Object args[], int numArgs) {
   GfxRenderingIntent ri;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring rendering intent setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring rendering intent setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   ri = parseRenderingIntent(args[0].getName());
@@ -1320,9 +1335,9 @@
 void Gfx::opSetFillGray(Object args[], int numArgs) {
   GfxColor color;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setFillPattern(NULL);
@@ -1336,9 +1351,9 @@
 void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   GfxColor color;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setStrokePattern(NULL);
@@ -1353,9 +1368,9 @@
   GfxColor color;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setFillPattern(NULL);
@@ -1372,9 +1387,9 @@
   GfxColor color;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setStrokePattern(NULL);
@@ -1391,9 +1406,9 @@
   GfxColor color;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setFillPattern(NULL);
@@ -1410,9 +1425,9 @@
   GfxColor color;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setStrokePattern(NULL);
@@ -1430,9 +1445,9 @@
   GfxColorSpace *colorSpace;
   GfxColor color;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color space setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color space setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setFillPattern(NULL);
@@ -1461,9 +1476,9 @@
   GfxColorSpace *colorSpace;
   GfxColor color;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color space setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color space setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   state->setStrokePattern(NULL);
@@ -1491,9 +1506,9 @@
   GfxColor color;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   if (numArgs != state->getFillColorSpace()->getNComps()) {
@@ -1531,9 +1546,9 @@
   GfxPattern *pattern;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   if (state->getFillColorSpace()->getMode() == csPattern) {
@@ -1585,9 +1600,9 @@
   GfxPattern *pattern;
   int i;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring color setting in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring color setting"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
   if (state->getStrokeColorSpace()->getMode() == csPattern) {
@@ -2068,6 +2083,7 @@
     state->setStrokeColor(state->getFillColor());
     out->updateFillColor(state);
     out->updateStrokeColor(state);
+    state->setIgnoreColorOps(gTrue);
   } else {
     state->setFillColorSpace(GfxColorSpace::create(csDeviceGray));
     out->updateFillColorSpace(state);
@@ -2223,6 +2239,7 @@
   if (stroke) {
     state->clipToStrokePath();
     out->clipToStrokePath(state);
+    state->setFillOverprint(state->getStrokeOverprint());
   } else if (!text) {
     state->clip();
     if (eoFill) {
@@ -2241,6 +2258,7 @@
   det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
   if (fabs(det) <= 1e-10) {
     error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill");
+    restoreStateStack(savedState);
     return;
   }
   det = 1 / det;
@@ -2338,9 +2356,9 @@
   GfxState *savedState;
   double xMin, yMin, xMax, yMax;
 
-  if (state->getInCachedT3Char()) {
-    error(errSyntaxWarning, getPos(),
-	  "Ignoring shaded fill in cached Type 3 character");
+  if (state->getIgnoreColorOps()) {
+    error(errSyntaxWarning, getPos(), "Ignoring shaded fill"
+	  " in uncolored Type 3 char or tiling pattern");
     return;
   }
 
@@ -4123,7 +4141,7 @@
   ocState = ocSaved;
 }
 
-void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
+GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
   Dict *dict, *maskDict;
   int width, height;
   int bits, maskBits;
@@ -4145,7 +4163,7 @@
 
   // check for optional content
   if (!ocState && !inlineImg) {
-    return;
+    return gTrue;
   }
 
   // get info from the stream
@@ -4309,6 +4327,11 @@
     if (!colorSpace) {
       goto err1;
     }
+    if (colorSpace->getMode() == csPattern) {
+      error(errSyntaxError, getPos(), "Image with a Pattern color space");
+      delete colorSpace;
+      goto err1;
+    }
     dict->lookup("Decode", &obj1);
     if (obj1.isNull()) {
       obj1.free();
@@ -4365,6 +4388,12 @@
       }
       maskHeight = obj1.getInt();
       obj1.free();
+      if (maskWidth <= 0 || maskHeight <= 0) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
+	goto err1;
+      }
       maskDict->lookup("BitsPerComponent", &obj1);
       if (obj1.isNull()) {
 	obj1.free();
@@ -4378,6 +4407,12 @@
       }
       maskBits = obj1.getInt();
       obj1.free();
+      if (maskBits < 1 || maskBits > 16) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
+	goto err1;
+      }
       maskDict->lookup("ColorSpace", &obj1);
       if (obj1.isNull()) {
 	obj1.free();
@@ -4501,6 +4536,12 @@
       }
       maskHeight = obj1.getInt();
       obj1.free();
+      if (maskWidth <= 0 || maskHeight <= 0) {
+	delete colorMap;
+	maskObj.free();
+	smaskObj.free();
+	goto err2;
+      }
       maskDict->lookup("ImageMask", &obj1);
       if (obj1.isNull()) {
 	obj1.free();
@@ -4534,10 +4575,10 @@
     }
 
     // if drawing is disabled, skip over inline image data
-    if (state->getInCachedT3Char() || !ocState) {
-      if (state->getInCachedT3Char()) {
-	error(errSyntaxWarning, getPos(),
-	      "Ignoring image in cached Type 3 character");
+    if (state->getIgnoreColorOps() || !ocState) {
+      if (state->getIgnoreColorOps()) {
+	error(errSyntaxWarning, getPos(), "Ignoring image"
+	      " in uncolored Type 3 char or tiling pattern");
       }
       if (inlineImg) {
 	str->reset();
@@ -4582,7 +4623,7 @@
   }
   opCounter += i;
 
-  return;
+  return gTrue;
 
  err2:
   obj1.free();
@@ -4594,6 +4635,8 @@
     state->setRenderingIntent(riSaved);
     out->updateRenderingIntent(state);
   }
+
+  return gFalse;
 }
 
 void Gfx::doForm(Object *strRef, Object *str) {
@@ -4826,11 +4869,12 @@
 
   // display the image
   if (str) {
-    doImage(NULL, str, gTrue);
+    if (!doImage(NULL, str, gTrue)) {
+      delete str;
   
     // if we have the stream length, skip to end-of-stream and then
     // skip 'EI' in the original stream
-    if (haveLength) {
+    } else if (haveLength) {
       while ((c1 = str->getChar()) != EOF) ;
       delete str;
       str = parser->getStream();
@@ -4935,7 +4979,7 @@
 }
 
 void Gfx::opSetCacheDevice(Object args[], int numArgs) {
-  state->setInCachedT3Char(gTrue);
+  state->setIgnoreColorOps(gTrue);
   out->type3D1(state, args[0].getNum(), args[1].getNum(),
 	       args[2].getNum(), args[3].getNum(),
 	       args[4].getNum(), args[5].getNum());

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Gfx.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -330,7 +330,7 @@
 
   // XObject operators
   void opXObject(Object args[], int numArgs);
-  void doImage(Object *ref, Stream *str, GBool inlineImg);
+  GBool doImage(Object *ref, Stream *str, GBool inlineImg);
   void doForm(Object *strRef, Object *str);
 
   // in-line image operators

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -164,7 +164,8 @@
 // GfxFont
 //------------------------------------------------------------------------
 
-GfxFont *GfxFont::makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict) {
+GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA,
+			   Ref idA, Dict *fontDict) {
   GString *nameA;
   Ref embFontIDA;
   GfxFontType typeA;
@@ -197,7 +198,7 @@
   return font;
 }
 
-GfxFont::GfxFont(char *tagA, Ref idA, GString *nameA,
+GfxFont::GfxFont(const char *tagA, Ref idA, GString *nameA,
 		 GfxFontType typeA, Ref embFontIDA) {
   ok = gFalse;
   tag = new GString(tagA);
@@ -541,6 +542,7 @@
 GfxFontLoc *GfxFont::locateFont(XRef *xref, GBool ps) {
   GfxFontLoc *fontLoc;
   SysFontType sysFontType;
+  FoFiIdentifierType fft;
   GString *path, *base14Name, *substName;
   PSFontParam16 *psFont16;
   Object refObj, embFontObj;
@@ -635,32 +637,43 @@
   //----- system font
   if (name && (path = globalParams->findSystemFontFile(name, &sysFontType,
 						       &fontNum))) {
+    fontLoc = new GfxFontLoc();
+    fontLoc->locType = gfxFontLocExternal;
+    fontLoc->path = path;
+    fontLoc->fontNum = fontNum;
     if (isCIDFont()) {
       if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) {
-	fontLoc = new GfxFontLoc();
-	fontLoc->locType = gfxFontLocExternal;
 	fontLoc->fontType = fontCIDType2;
-	fontLoc->path = path;
-	fontLoc->fontNum = fontNum;
 	return fontLoc;
+      } else if (sysFontType == sysFontOTF) {
+	fft = FoFiIdentifier::identifyFile(fontLoc->path->getCString());
+	if (fft == fofiIdOpenTypeCFFCID) {
+	  fontLoc->fontType = fontCIDType0COT;
+	  return fontLoc;
+	} else if (fft == fofiIdTrueType) {
+	  fontLoc->fontType = fontCIDType2;
+	  return fontLoc;
+	}
       }
     } else {
       if (sysFontType == sysFontTTF || sysFontType == sysFontTTC) {
-	fontLoc = new GfxFontLoc();
-	fontLoc->locType = gfxFontLocExternal;
 	fontLoc->fontType = fontTrueType;
-	fontLoc->path = path;
-	fontLoc->fontNum = fontNum;
 	return fontLoc;
       } else if (sysFontType == sysFontPFA || sysFontType == sysFontPFB) {
-	fontLoc = new GfxFontLoc();
-	fontLoc->locType = gfxFontLocExternal;
 	fontLoc->fontType = fontType1;
-	fontLoc->path = path;
 	return fontLoc;
+      } else if (sysFontType == sysFontOTF) {
+	fft = FoFiIdentifier::identifyFile(fontLoc->path->getCString());
+	if (fft == fofiIdOpenTypeCFF8Bit) {
+	  fontLoc->fontType = fontType1COT;
+	  return fontLoc;
+	} else if (fft == fofiIdTrueType) {
+	  fontLoc->fontType = fontTrueTypeOT;
+	  return fontLoc;
+	}
       }
     }
-    delete path;
+    delete fontLoc;
   }
 
   if (!isCIDFont()) {
@@ -863,7 +876,7 @@
 // Gfx8BitFont
 //------------------------------------------------------------------------
 
-Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
+Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GString *nameA,
 			 GfxFontType typeA, Ref embFontIDA, Dict *fontDict):
   GfxFont(tagA, idA, nameA, typeA, embFontIDA)
 {
@@ -1490,6 +1503,33 @@
   return map;
 }
 
+int *Gfx8BitFont::getCodeToGIDMap(FoFiType1C *ff) {
+  int *map;
+  GHash *nameToGID;
+  int i, gid;
+
+  map = (int *)gmallocn(256, sizeof(int));
+  for (i = 0; i < 256; ++i) {
+    map[i] = 0;
+  }
+
+  nameToGID = ff->getNameToGIDMap();
+  for (i = 0; i < 256; ++i) {
+    if (!enc[i]) {
+      continue;
+    }
+    gid = nameToGID->lookupInt(enc[i]);
+    if (gid < 0 || gid >= 65536) {
+      continue;
+    }
+    map[i] = gid;
+  }
+
+  delete nameToGID;
+
+  return map;
+}
+
 Dict *Gfx8BitFont::getCharProcs() {
   return charProcs.isDict() ? charProcs.getDict() : (Dict *)NULL;
 }
@@ -1575,7 +1615,7 @@
 // GfxCIDFont
 //------------------------------------------------------------------------
 
-GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
+GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GString *nameA,
 		       GfxFontType typeA, Ref embFontIDA, Dict *fontDict):
   GfxFont(tagA, idA, nameA, typeA, embFontIDA)
 {
@@ -2001,6 +2041,13 @@
   return cMap ? cMap->getCollection() : (GString *)NULL;
 }
 
+double GfxCIDFont::getWidth(CID cid) {
+  double w;
+
+  getHorizontalMetrics(cid, &w);
+  return w;
+}
+
 GBool GfxCIDFont::problematicForUnicode() {
   GString *nameLC;
   GBool symbolic;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxFont.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -26,6 +26,7 @@
 class CMap;
 class CharCodeToUnicode;
 class FoFiTrueType;
+class FoFiType1C;
 struct GfxFontCIDWidths;
 struct Base14FontMapEntry;
 class FNVHash;
@@ -131,9 +132,10 @@
 public:
 
   // Build a GfxFont object.
-  static GfxFont *makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict);
+  static GfxFont *makeFont(XRef *xref, const char *tagA,
+			   Ref idA, Dict *fontDict);
 
-  GfxFont(char *tagA, Ref idA, GString *nameA,
+  GfxFont(const char *tagA, Ref idA, GString *nameA,
 	  GfxFontType typeA, Ref embFontIDA);
 
   virtual ~GfxFont();
@@ -243,7 +245,7 @@
 class Gfx8BitFont: public GfxFont {
 public:
 
-  Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
+  Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GString *nameA,
 	      GfxFontType typeA, Ref embFontIDA, Dict *fontDict);
 
   virtual ~Gfx8BitFont();
@@ -274,6 +276,10 @@
   // (This is only useful for TrueType fonts.)
   int *getCodeToGIDMap(FoFiTrueType *ff);
 
+  // Return a char code-to-GID mapping for the provided font file.
+  // (This is only useful for Type1C fonts.)
+  int *getCodeToGIDMap(FoFiType1C *ff);
+
   // Return the Type 3 CharProc dictionary, or NULL if none.
   Dict *getCharProcs();
 
@@ -311,7 +317,7 @@
 class GfxCIDFont: public GfxFont {
 public:
 
-  GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA,
+  GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GString *nameA,
 	     GfxFontType typeA, Ref embFontIDA, Dict *fontDict);
 
   virtual ~GfxCIDFont();
@@ -331,6 +337,9 @@
   // Get the collection name (<registry>-<ordering>).
   GString *getCollection();
 
+  // Return the horizontal width for <cid>.
+  double getWidth(CID cid);
+
   // Return the CID-to-GID mapping table.  These should only be called
   // if type is fontCIDType2.
   int *getCIDToGID() { return cidToGID; }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -1281,7 +1281,7 @@
   }
   obj1.free();
   arr->get(3, &obj1);
-  if (!(funcA = Function::parse(&obj1))) {
+  if (!(funcA = Function::parse(&obj1, 1, altA->getNComps()))) {
     goto err4;
   }
   obj1.free();
@@ -1476,7 +1476,7 @@
   }
   obj1.free();
   arr->get(3, &obj1);
-  if (!(funcA = Function::parse(&obj1))) {
+  if (!(funcA = Function::parse(&obj1, nCompsA, altA->getNComps()))) {
     goto err4;
   }
   obj1.free();
@@ -2117,7 +2117,7 @@
     }
     for (i = 0; i < nFuncsA; ++i) {
       obj1.arrayGet(i, &obj2);
-      if (!(funcsA[i] = Function::parse(&obj2))) {
+      if (!(funcsA[i] = Function::parse(&obj2, 2, 1))) {
 	goto err2;
       }
       obj2.free();
@@ -2124,7 +2124,7 @@
     }
   } else {
     nFuncsA = 1;
-    if (!(funcsA[0] = Function::parse(&obj1))) {
+    if (!(funcsA[0] = Function::parse(&obj1, 2, -1))) {
       goto err1;
     }
   }
@@ -2137,6 +2137,16 @@
     delete shading;
     return NULL;
   }
+
+  for (i = 0; i < shading->nFuncs; ++i) {
+    if (shading->funcs[i]->getOutputSize()
+	!= shading->getColorSpace()->getNComps()) {
+      error(errSyntaxError, -1, "Invalid function in shading dictionary");
+      delete shading;
+      return NULL;
+    }
+  }
+
   return shading;
 
  err2:
@@ -2274,7 +2284,7 @@
     }
     for (i = 0; i < nFuncsA; ++i) {
       obj1.arrayGet(i, &obj2);
-      if (!(funcsA[i] = Function::parse(&obj2))) {
+      if (!(funcsA[i] = Function::parse(&obj2, 1, 1))) {
 	obj1.free();
 	obj2.free();
 	goto err1;
@@ -2283,7 +2293,7 @@
     }
   } else {
     nFuncsA = 1;
-    if (!(funcsA[0] = Function::parse(&obj1))) {
+    if (!(funcsA[0] = Function::parse(&obj1, 1, -1))) {
       obj1.free();
       goto err1;
     }
@@ -2307,6 +2317,16 @@
     delete shading;
     return NULL;
   }
+
+  for (i = 0; i < shading->nFuncs; ++i) {
+    if (shading->funcs[i]->getOutputSize()
+	!= shading->getColorSpace()->getNComps()) {
+      error(errSyntaxError, -1, "Invalid function in shading dictionary");
+      delete shading;
+      return NULL;
+    }
+  }
+
   return shading;
 
  err1:
@@ -2446,7 +2466,7 @@
     }
     for (i = 0; i < nFuncsA; ++i) {
       obj1.arrayGet(i, &obj2);
-      if (!(funcsA[i] = Function::parse(&obj2))) {
+      if (!(funcsA[i] = Function::parse(&obj2, 1, 1))) {
 	obj1.free();
 	obj2.free();
 	goto err1;
@@ -2455,7 +2475,7 @@
     }
   } else {
     nFuncsA = 1;
-    if (!(funcsA[0] = Function::parse(&obj1))) {
+    if (!(funcsA[0] = Function::parse(&obj1, 1, -1))) {
       obj1.free();
       goto err1;
     }
@@ -2479,6 +2499,16 @@
     delete shading;
     return NULL;
   }
+
+  for (i = 0; i < shading->nFuncs; ++i) {
+    if (shading->funcs[i]->getOutputSize()
+	!= shading->getColorSpace()->getNComps()) {
+      error(errSyntaxError, -1, "Invalid function in shading dictionary");
+      delete shading;
+      return NULL;
+    }
+  }
+
   return shading;
 
  err1:
@@ -2719,7 +2749,7 @@
       }
       for (i = 0; i < nFuncsA; ++i) {
 	obj1.arrayGet(i, &obj2);
-	if (!(funcsA[i] = Function::parse(&obj2))) {
+	if (!(funcsA[i] = Function::parse(&obj2, 1, 1))) {
 	  obj1.free();
 	  obj2.free();
 	  goto err1;
@@ -2728,7 +2758,7 @@
       }
     } else {
       nFuncsA = 1;
-      if (!(funcsA[0] = Function::parse(&obj1))) {
+      if (!(funcsA[0] = Function::parse(&obj1, 1, -1))) {
 	obj1.free();
 	goto err1;
       }
@@ -2832,6 +2862,16 @@
     delete shading;
     return NULL;
   }
+
+  for (i = 0; i < shading->nFuncs; ++i) {
+    if (shading->funcs[i]->getOutputSize()
+	!= shading->getColorSpace()->getNComps()) {
+      error(errSyntaxError, -1, "Invalid function in shading dictionary");
+      delete shading;
+      return NULL;
+    }
+  }
+
   return shading;
 
  err2:
@@ -3017,7 +3057,7 @@
       }
       for (i = 0; i < nFuncsA; ++i) {
 	obj1.arrayGet(i, &obj2);
-	if (!(funcsA[i] = Function::parse(&obj2))) {
+	if (!(funcsA[i] = Function::parse(&obj2, 1, 1))) {
 	  obj1.free();
 	  obj2.free();
 	  goto err1;
@@ -3026,7 +3066,7 @@
       }
     } else {
       nFuncsA = 1;
-      if (!(funcsA[0] = Function::parse(&obj1))) {
+      if (!(funcsA[0] = Function::parse(&obj1, 1, -1))) {
 	obj1.free();
 	goto err1;
       }
@@ -3044,6 +3084,12 @@
     if (!bitBuf->getBits(flagBits, &flag)) {
       break;
     }
+    flag &= 3;
+    if (flag != 0 && nPatchesA == 0) {
+      error(errSyntaxError, -1, "Invalid patch in patch mesh shading");
+      delete bitBuf;
+      goto err1;
+    }
     if (typeA == 6) {
       switch (flag) {
       case 0: nPts = 12; nColors = 4; break;
@@ -3445,6 +3491,16 @@
     delete shading;
     return NULL;
   }
+
+  for (i = 0; i < shading->nFuncs; ++i) {
+    if (shading->funcs[i]->getOutputSize()
+	!= shading->getColorSpace()->getNComps()) {
+      error(errSyntaxError, -1, "Invalid function in shading dictionary");
+      delete shading;
+      return NULL;
+    }
+  }
+
   return shading;
 
  err2:
@@ -4122,7 +4178,7 @@
   clipXMax = pageWidth;
   clipYMax = pageHeight;
 
-  inCachedT3Char = gFalse;
+  ignoreColorOps = gFalse;
 
   saved = NULL;
 }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GfxState.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -1183,7 +1183,7 @@
   void getUserClipBBox(double *xMin, double *yMin, double *xMax, double *yMax);
   double getLineX() { return lineX; }
   double getLineY() { return lineY; }
-  GBool getInCachedT3Char() { return inCachedT3Char; }
+  GBool getIgnoreColorOps() { return ignoreColorOps; }
 
   // Is there a current point/path?
   GBool isCurPt() { return path->isCurPt(); }
@@ -1280,8 +1280,9 @@
   void textShift(double tx, double ty);
   void shift(double dx, double dy);
   
-  // Cached Type 3 char status.
-  void setInCachedT3Char(GBool in) { inCachedT3Char = in; }
+  // Ignore color operators (in cached/uncolored Type 3 chars, and
+  // uncolored tiling patterns).  Cached Type 3 char status.
+  void setIgnoreColorOps(GBool ignore) { ignoreColorOps = ignore; }
 
   // Push/pop GfxState on/off stack.
   GfxState *save();
@@ -1344,7 +1345,9 @@
   double clipXMin, clipYMin,	// bounding box for clip region
          clipXMax, clipYMax;
 
-  GBool inCachedT3Char;		// in a cached (uncolored) Type 3 char
+  GBool ignoreColorOps;		// ignore color ops (in cached/uncolored
+				//   Type 3 chars, and uncolored tiling
+				//   patterns)
 
   GfxState *saved;		// next GfxState on stack
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -17,7 +17,9 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stdarg.h>
 #include <ctype.h>
+#include <time.h>
 #ifdef _WIN32
 #  include <shlobj.h>
 #endif
@@ -24,6 +26,9 @@
 #if HAVE_PAPER_H
 #include <paper.h>
 #endif
+#if HAVE_FONTCONFIG
+#  include <fontconfig/fontconfig.h>
+#endif
 #include "gmem.h"
 #include "gmempp.h"
 #include "GString.h"
@@ -91,14 +96,14 @@
   {"Courier-BoldOblique",   "n022024l.pfb", "courbi.ttf",  "Courier",      "Courier Bold Oblique",   "Courier-Bold",   0.212557},
   {"Courier-Oblique",       "n022023l.pfb", "couri.ttf",   "Courier",      "Courier Oblique",        "Courier",        0.212557},
   {"Helvetica",             "n019003l.pfb", "arial.ttf",   "Helvetica",    "Helvetica",              NULL,             0},
-  {"Helvetica-Bold",        "n019004l.pfb", "arialbd.ttf", "Helvetica",    "Helvetica-Bold",         NULL,             0},
+  {"Helvetica-Bold",        "n019004l.pfb", "arialbd.ttf", "Helvetica",    "Helvetica Bold",         NULL,             0},
   {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf", "Helvetica",    "Helvetica Bold Oblique", "Helvetica-Bold", 0.212557},
   {"Helvetica-Oblique",     "n019023l.pfb", "ariali.ttf",  "Helvetica",    "Helvetica Oblique",      "Helvetica",      0.212557},
   {"Symbol",                "s050000l.pfb", NULL,          "Symbol",       "Symbol",                 NULL,             0},
-  {"Times-Bold",            "n021004l.pfb", "timesbd.ttf", "Times",        "Times-Bold",             NULL,             0},
-  {"Times-BoldItalic",      "n021024l.pfb", "timesbi.ttf", "Times",        "Times-BoldItalic",       NULL,             0},
-  {"Times-Italic",          "n021023l.pfb", "timesi.ttf",  "Times",        "Times-Italic",           NULL,             0},
-  {"Times-Roman",           "n021003l.pfb", "times.ttf",   "Times",        "Times-Roman",            NULL,             0},
+  {"Times-Bold",            "n021004l.pfb", "timesbd.ttf", "Times",        "Times Bold",             NULL,             0},
+  {"Times-BoldItalic",      "n021024l.pfb", "timesbi.ttf", "Times",        "Times Bold Italic",       NULL,             0},
+  {"Times-Italic",          "n021023l.pfb", "timesi.ttf",  "Times",        "Times Italic",           NULL,             0},
+  {"Times-Roman",           "n021003l.pfb", "times.ttf",   "Times",        "Times Roman",            NULL,             0},
   {"ZapfDingbats",          "d050000l.pfb", NULL,          "ZapfDingbats", "Zapf Dingbats",          NULL,             0},
   {NULL}
 };
@@ -226,6 +231,10 @@
   void scanWindowsFonts(char *winFontDir);
 #endif
 
+#if HAVE_FONTCONFIG
+  void scanFontconfigFonts();
+#endif
+
 private:
 
 #ifdef _WIN32
@@ -458,6 +467,8 @@
 
   if (!strcasecmp(path + strlen(path) - 4, ".ttc")) {
     type = sysFontTTC;
+  } else if (!strcasecmp(path + strlen(path) - 4, ".otf")) {
+    type = sysFontOTF;
   } else {
     type = sysFontTTF;
   }
@@ -465,6 +476,109 @@
 }
 #endif
 
+#if HAVE_FONTCONFIG
+void SysFontList::scanFontconfigFonts() {
+  FcPattern *pattern;
+  FcObjectSet *objSet;
+  FcFontSet *fontSet;
+  char *family, *file, *styleLang, *style;
+  GString *family2;
+  SysFontType type;
+  GBool bold, italic;
+  char c;
+  int fontNum, i, j, n;
+
+  FcInit();
+
+  pattern = FcPatternBuild(NULL,
+			   FC_OUTLINE, FcTypeBool, FcTrue,
+			   FC_SCALABLE, FcTypeBool, FcTrue,
+			   NULL);
+  objSet = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_STYLELANG,
+			    FC_FILE, FC_INDEX, NULL);
+  fontSet = FcFontList(NULL, pattern, objSet);
+  FcPatternDestroy(pattern);
+  FcObjectSetDestroy(objSet);
+
+  if (fontSet) {
+    for (i = 0; i < fontSet->nfont; ++i) {
+
+      //--- font file, font type
+      if (FcPatternGetString(fontSet->fonts[i], FC_FILE, 0,
+			     (FcChar8 **)&file)
+	  != FcResultMatch) {
+	continue;
+      }
+      n = (int)strlen(file);
+      if (n > 4 && !strcasecmp(file + n - 4, ".pfa")) {
+	type = sysFontPFA;
+      } else if (n > 4 && !strcasecmp(file + n - 4, ".pfb")) {
+	type = sysFontPFB;
+      } else if (n > 4 && !strcasecmp(file + n - 4, ".ttf")) {
+	type = sysFontTTF;
+      } else if (n > 4 && !strcasecmp(file + n - 4, ".otf")) {
+	type = sysFontOTF;
+      } else {
+	continue;
+      }
+
+      //--- font number
+      if (FcPatternGetInteger(fontSet->fonts[i], FC_INDEX, 0, &fontNum)
+	  != FcResultMatch) {
+	fontNum = 0;
+      }
+
+      //--- font family
+      if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0,
+			     (FcChar8 **)&family)
+	  != FcResultMatch) {
+	continue;
+      }
+
+      //----- normalize the font name
+      family2 = new GString(family);
+      j = 0;
+      while (j < family2->getLength()) {
+	c = family2->getChar(j);
+	if (c == ' ' || c == ',' || c == '-') {
+	  family2->del(j);
+	} else {
+	  ++j;
+	}
+      }
+
+      //--- font style
+      style = NULL;
+      for (j = 0;
+	   FcPatternGetString(fontSet->fonts[i], FC_STYLELANG, j,
+			      (FcChar8 **)&styleLang)
+	     == FcResultMatch;
+	   ++j) {
+	if (!strcmp(styleLang, "en")) {
+	  if (FcPatternGetString(fontSet->fonts[i], FC_STYLE, j,
+				 (FcChar8 **)&style)
+	      != FcResultMatch) {
+	    style = NULL;
+	  }
+	  break;
+	}
+	++j;
+      }
+      bold = style && strstr(style, "Bold") != NULL;
+      italic = style && (strstr(style, "Italic") != NULL ||
+			 strstr(style, "Oblique") != NULL);
+
+      fonts->append(new SysFontInfo(family2, bold, italic,
+				    new GString(file), type, fontNum));
+    }
+
+    FcFontSetDestroy(fontSet);
+  }
+
+  FcFini();
+}
+#endif // HAVE_FONTCONFIG
+
 //------------------------------------------------------------------------
 // KeyBinding
 //------------------------------------------------------------------------
@@ -619,7 +733,10 @@
   textKeepTinyChars = gTrue;
   initialZoom = new GString("125");
   defaultFitZoom = 0;
+  initialDisplayMode = new GString("continuous");
+  initialToolbarState = gTrue;
   initialSidebarState = gTrue;
+  initialSelectMode = new GString("linear");
   maxTileWidth = 1500;
   maxTileHeight = 1500;
   tileCacheSize = 10;
@@ -644,6 +761,7 @@
   paperColor = new GString("#ffffff");
   matteColor = new GString("#808080");
   fullScreenMatteColor = new GString("#000000");
+  reverseVideoInvertImages = gFalse;
   launchCommand = NULL;
   movieCommand = NULL;
   defaultPrinter = NULL;
@@ -657,6 +775,7 @@
   tabStateFile = appendToPath(getHomeDir(), ".xpdf.tab-state");
   printCommands = gFalse;
   errQuiet = gFalse;
+  debugLogFile = NULL;
 
   cidToUnicodeCache = new CharCodeToUnicodeCache(cidToUnicodeCacheSize);
   unicodeToUnicodeCache =
@@ -787,6 +906,9 @@
 				     xpdfKeyContextAny, "newWindow"));
   keyBindings->append(new KeyBinding('w', xpdfKeyModCtrl,
 				     xpdfKeyContextAny, "closeTabOrQuit"));
+  keyBindings->append(new KeyBinding('l', xpdfKeyModCtrl,
+				     xpdfKeyContextAny,
+				     "toggleFullScreenMode"));
   keyBindings->append(new KeyBinding('q', xpdfKeyModCtrl,
 				     xpdfKeyContextAny, "quit"));
   keyBindings->append(new KeyBinding(xpdfKeyCodeTab, xpdfKeyModCtrl,
@@ -1022,9 +1144,18 @@
       parseString("initialZoom", &initialZoom, tokens, fileName, line);
     } else if (!cmd->cmp("defaultFitZoom")) {
       parseInteger("defaultFitZoom", &defaultFitZoom, tokens, fileName, line);
+    } else if (!cmd->cmp("initialDisplayMode")) {
+      parseString("initialDisplayMode", &initialDisplayMode,
+		  tokens, fileName, line);
+    } else if (!cmd->cmp("initialToolbarState")) {
+      parseYesNo("initialToolbarState", &initialToolbarState,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("initialSidebarState")) {
       parseYesNo("initialSidebarState", &initialSidebarState,
 		 tokens, fileName, line);
+    } else if (!cmd->cmp("initialSelectMode")) {
+      parseString("initialSelectMode", &initialSelectMode,
+		  tokens, fileName, line);
     } else if (!cmd->cmp("maxTileWidth")) {
       parseInteger("maxTileWidth", &maxTileWidth, tokens, fileName, line);
     } else if (!cmd->cmp("maxTileHeight")) {
@@ -1086,6 +1217,9 @@
     } else if (!cmd->cmp("fullScreenMatteColor")) {
       parseString("fullScreenMatteColor", &fullScreenMatteColor,
 		  tokens, fileName, line);
+    } else if (!cmd->cmp("reverseVideoInvertImages")) {
+      parseYesNo("reverseVideoInvertImages", &reverseVideoInvertImages,
+		 tokens, fileName, line);
     } else if (!cmd->cmp("launchCommand")) {
       parseString("launchCommand", &launchCommand, tokens, fileName, line);
     } else if (!cmd->cmp("movieCommand")) {
@@ -1118,6 +1252,8 @@
       parseYesNo("printCommands", &printCommands, tokens, fileName, line);
     } else if (!cmd->cmp("errQuiet")) {
       parseYesNo("errQuiet", &errQuiet, tokens, fileName, line);
+    } else if (!cmd->cmp("debugLogFile")) {
+      parseString("debugLogFile", &debugLogFile, tokens, fileName, line);
     } else {
       error(errConfig, -1, "Unknown config file command '{0:t}' ({1:t}:{2:d})",
 	    cmd, fileName, line);
@@ -1862,6 +1998,8 @@
   deleteGList(psResidentFontsCC, PSFontParam16);
   delete textEncoding;
   delete initialZoom;
+  delete initialDisplayMode;
+  delete initialSelectMode;
   if (paperColor) {
     delete paperColor;
   }
@@ -1943,6 +2081,7 @@
 	}
       }
     }
+    FreeLibrary(shell32Lib);
   }
   // if something went wrong, or we're on a Terminal Server, try using
   // %SYSTEMROOT%\Fonts
@@ -1958,6 +2097,40 @@
 }
 #endif
 
+#ifdef __APPLE__
+// Apple dfonts and ttc fonts seem to randomly and interchangeably use
+// space and hyphen, and sometimes drop the separator entirely.
+static GBool macFontNameMatches(GString *name1, const char *name2) {
+  const char *p1, *p2;
+  char c1, c2;
+
+  p1 = name1->getCString();
+  p2 = name2;
+  while (*p1 && *p2) {
+    c1 = *p1;
+    c2 = *p2;
+    if (c2 == ' ') {
+      // * space or hyphen matches a space in the pattern
+      // * separators can also be dropped, in which case we move to
+      //   the next char in the pattern
+      if (c1 == ' ' || c1 == '-') {
+	++p1;
+      }
+    } else {
+      if (c1 != c2) {
+	return gFalse;
+      }
+      ++p1;
+    }
+    ++p2;
+  }
+  if (*p1 || *p2) {
+    return gFalse;
+  }
+  return gTrue;
+}
+#endif
+
 void GlobalParams::setupBaseFonts(const char *dir) {
   GString *fontName;
   GString *fileName;
@@ -2036,8 +2209,8 @@
 	    }
 	    if (dfontFontNames) {
 	      for (k = 0; k < dfontFontNames->getLength(); ++k) {
-		if (!((GString *)dfontFontNames->get(k))
-		                     ->cmp(displayFontTab[i].macFontName)) {
+		if (macFontNameMatches((GString *)dfontFontNames->get(k),
+				       displayFontTab[i].macFontName)) {
 		  fontNum = k;
 		  found = gTrue;
 		  break;
@@ -2114,6 +2287,9 @@
     sysFonts->scanWindowsFonts(winFontDir);
   }
 #endif
+#if HAVE_FONTCONFIG
+  sysFonts->scanFontconfigFonts();
+#endif
 }
 
 //------------------------------------------------------------------------
@@ -2653,6 +2829,24 @@
   return z;
 }
 
+GString *GlobalParams::getInitialDisplayMode() {
+  GString *s;
+
+  lockGlobalParams;
+  s = initialDisplayMode->copy();
+  unlockGlobalParams;
+  return s;
+}
+
+GBool GlobalParams::getInitialToolbarState() {
+  GBool state;
+
+  lockGlobalParams;
+  state = initialToolbarState;
+  unlockGlobalParams;
+  return state;
+}
+
 GBool GlobalParams::getInitialSidebarState() {
   GBool state;
 
@@ -2662,6 +2856,15 @@
   return state;
 }
 
+GString *GlobalParams::getInitialSelectMode() {
+  GString *s;
+
+  lockGlobalParams;
+  s = initialSelectMode->copy();
+  unlockGlobalParams;
+  return s;
+}
+
 int GlobalParams::getMaxTileWidth() {
   int w;
 
@@ -2872,6 +3075,15 @@
   return s;
 }
 
+GBool GlobalParams::getReverseVideoInvertImages() {
+  GBool invert;
+
+  lockGlobalParams;
+  invert = reverseVideoInvertImages;
+  unlockGlobalParams;
+  return invert;
+}
+
 GString *GlobalParams::getDefaultPrinter() {
   GString *s;
 
@@ -2998,6 +3210,51 @@
   return errQuiet;
 }
 
+GString *GlobalParams::getDebugLogFile() {
+  return debugLogFile;
+}
+
+void GlobalParams::debugLogPrintf(char *fmt, ...) {
+  GString *path;
+  FILE *f;
+  GBool needClose;
+  time_t t;
+  struct tm tm;
+  va_list args;
+
+  if (!(path = getDebugLogFile())) {
+    return;
+  }
+  needClose = gFalse;
+  if (!path->cmp("-")) {
+    f = stdout;
+  } else if (!path->cmp("+")) {
+    f = stderr;
+  } else {
+    f = fopen(path->getCString(), "a");
+    needClose = gTrue;
+  }
+  if (!f) {
+    return;
+  }
+  t = time(NULL);
+#ifdef _WIN32
+  localtime_s(&tm, &t);
+#else
+  localtime_r(&t, &tm);
+#endif
+  fprintf(f, "[%04d-%02d-%02d %02d:%02d:%02d] ",
+	  tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+	  tm.tm_hour, tm.tm_min, tm.tm_sec);
+  va_start(args, fmt);
+  vfprintf(f, fmt, args);
+  va_end(args);
+  fflush(f);
+  if (needClose) {
+    fclose(f);
+  }
+}
+
 CharCodeToUnicode *GlobalParams::getCIDToUnicode(GString *collection) {
   GString *fileName;
   CharCodeToUnicode *ctu;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/GlobalParams.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -55,7 +55,8 @@
   sysFontPFA,
   sysFontPFB,
   sysFontTTF,
-  sysFontTTC
+  sysFontTTC,
+  sysFontOTF
 };
 
 //------------------------------------------------------------------------
@@ -283,7 +284,10 @@
   GBool getTextKeepTinyChars();
   GString *getInitialZoom();
   int getDefaultFitZoom();
+  GString *getInitialDisplayMode();
+  GBool getInitialToolbarState();
   GBool getInitialSidebarState();
+  GString *getInitialSelectMode();
   int getMaxTileWidth();
   int getMaxTileHeight();
   int getTileCacheSize();
@@ -308,6 +312,7 @@
   GString *getPaperColor();
   GString *getMatteColor();
   GString *getFullScreenMatteColor();
+  GBool getReverseVideoInvertImages();
   GString *getLaunchCommand() { return launchCommand; }
   GString *getMovieCommand() { return movieCommand; }
   GString *getDefaultPrinter();
@@ -322,6 +327,8 @@
   GString *getTabStateFile();
   GBool getPrintCommands();
   GBool getErrQuiet();
+  GString *getDebugLogFile();
+  void debugLogPrintf(char *fmt, ...);
 
   CharCodeToUnicode *getCIDToUnicode(GString *collection);
   CharCodeToUnicode *getUnicodeToUnicode(GString *fontName);
@@ -509,8 +516,13 @@
   GString *initialZoom;		// initial zoom level
   int defaultFitZoom;		// default zoom factor if initialZoom is
 				//   'page' or 'width'.
+  GString *initialDisplayMode;	// initial display mode (single,
+				//   continuous, etc.)
+  GBool initialToolbarState;	// initial toolbar state - open (true)
+				//   or closed (false)
   GBool initialSidebarState;	// initial sidebar state - open (true)
 				//   or closed (false)
+  GString *initialSelectMode;	// initial selection mode (block or linear)
   int maxTileWidth;		// maximum rasterization tile width
   int maxTileHeight;		// maximum rasterization tile height
   int tileCacheSize;		// number of rasterization tiles in cache
@@ -536,6 +548,7 @@
   GString *paperColor;		// paper (page background) color
   GString *matteColor;		// matte (background outside of page) color
   GString *fullScreenMatteColor; // matte color in full-screen mode
+  GBool reverseVideoInvertImages; // invert images in reverse video mode
   GString *launchCommand;	// command executed for 'launch' links
   GString *movieCommand;	// command executed for movie annotations
   GString *defaultPrinter;	// default printer (for interactive printing
@@ -551,6 +564,7 @@
   GString *tabStateFile;	// path for the tab state save file
   GBool printCommands;		// print the drawing commands
   GBool errQuiet;		// suppress error messages?
+  GString *debugLogFile;	// path for debug log file
 
   CharCodeToUnicodeCache *cidToUnicodeCache;
   CharCodeToUnicodeCache *unicodeToUnicodeCache;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -34,9 +34,11 @@
 #include "GList.h"
 #include "SplashBitmap.h"
 #include "PDFDoc.h"
+#include "GfxFont.h"
 #include "TextOutputDev.h"
 #include "SplashOutputDev.h"
 #include "ErrorCodes.h"
+#include "WebFont.h"
 #include "HTMLGen.h"
 
 #ifdef _WIN32
@@ -62,11 +64,14 @@
   {"CondensedBold",           13, gTrue,  gFalse},
   {"CondensedLight",          14, gFalse, gFalse},
   {"SemiBold",                 8, gTrue,  gFalse},
+  {"BoldItalicMT",            12, gTrue,  gTrue},
   {"BoldItalic",              10, gTrue,  gTrue},
   {"Bold_Italic",             11, gTrue,  gTrue},
   {"BoldOblique",             11, gTrue,  gTrue},
   {"Bold_Oblique",            12, gTrue,  gTrue},
+  {"BoldMT",                   6, gTrue,  gFalse},
   {"Bold",                     4, gTrue,  gFalse},
+  {"ItalicMT",                 8, gFalse, gTrue},
   {"Italic",                   6, gFalse, gTrue},
   {"Oblique",                  7, gFalse, gTrue},
   {"Light",                    5, gFalse, gFalse},
@@ -171,9 +176,29 @@
 
 //------------------------------------------------------------------------
 
+class HTMLGenFontDefn {
+public:
 
+  HTMLGenFontDefn(Ref fontIDA, GString *fontFaceA, GString *fontSpecA,
+		  double scaleA)
+    : fontID(fontIDA), fontFace(fontFaceA), fontSpec(fontSpecA)
+    , scale(scaleA), used(gFalse) {}
+  ~HTMLGenFontDefn() { delete fontFace; delete fontSpec; }
+  GBool match(Ref fontIDA)
+    { return fontIDA.num == fontID.num && fontIDA.gen == fontID.gen; }
+
+  Ref fontID;
+  GString *fontFace;		// NULL for substituted fonts
+  GString *fontSpec;
+  double scale;
+  GBool used;			// set when used (per page)
+};
+
 //------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------
+
 HTMLGen::HTMLGen(double backgroundResolutionA) {
   TextOutputControl textOutControl;
   SplashColor paperColor;
@@ -184,6 +209,7 @@
   zoom = 1.0;
   drawInvisibleText = gTrue;
   allTextInvisible = gFalse;
+  extractFontFiles = gFalse;
 
   // set up the TextOutputDev
   textOutControl.mode = textOutReadingOrder;
@@ -196,16 +222,27 @@
   // set up the SplashOutputDev
   paperColor[0] = paperColor[1] = paperColor[2] = 0xff;
   splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
+
+  fontDefns = NULL;
 }
 
 HTMLGen::~HTMLGen() {
   delete textOut;
   delete splashOut;
+  if (fontDefns) {
+    deleteGList(fontDefns, HTMLGenFontDefn);
+  }
 }
 
 void HTMLGen::startDoc(PDFDoc *docA) {
   doc = docA;
   splashOut->startDoc(doc->getXRef());
+
+  if (fontDefns) {
+    deleteGList(fontDefns, HTMLGenFontDefn);
+  }
+  fontDefns = new GList();
+  nextFontFaceIdx = 0;
 }
 
 static inline int pr(int (*writeFunc)(void *stream, const char *data, int size),
@@ -240,7 +277,7 @@
 }
 
 int HTMLGen::convertPage(
-		 int pg, const char *pngURL,
+		 int pg, const char *pngURL, const char *htmlDir,
 		 int (*writeHTML)(void *stream, const char *data, int size),
 		 void *htmlStream,
 		 int (*writePNG)(void *stream, const char *data, int size),
@@ -257,6 +294,7 @@
   TextColumn *col;
   TextParagraph *par;
   TextLine *line;
+  HTMLGenFontDefn *fontDefn;
   GString *s;
   double base;
   int primaryDir, spanDir;
@@ -269,7 +307,7 @@
 		   0, gFalse, gTrue, gFalse);
   bitmap = splashOut->getBitmap();
   if (!(png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
-				       NULL, NULL, NULL)) ||
+				      NULL, NULL, NULL)) ||
       !(pngInfo = png_create_info_struct(png))) {
     return errFileIO;
   }
@@ -314,11 +352,19 @@
   pr(writeHTML, htmlStream, ".txt { white-space:nowrap; }\n");
   fonts = text->getFonts();
   fontScales = (double *)gmallocn(fonts->getLength(), sizeof(double));
+  for (i = 0; i < fontDefns->getLength(); ++i) {
+    fontDefn = (HTMLGenFontDefn *)fontDefns->get(i);
+    fontDefn->used = gFalse;
+  }
   for (i = 0; i < fonts->getLength(); ++i) {
     font = (TextFontInfo *)fonts->get(i);
-    s = getFontDefn(font, &fontScales[i]);
-    pf(writeHTML, htmlStream, "#f{0:d} {{ {1:t} }}\n", i, s);
-    delete s;
+    fontDefn = getFontDefn(font, htmlDir);
+    if (!fontDefn->used && fontDefn->fontFace) {
+      pr(writeHTML, htmlStream, fontDefn->fontFace->getCString());
+    }
+    pf(writeHTML, htmlStream, "#f{0:d} {{ {1:t} }}\n", i, fontDefn->fontSpec);
+    fontScales[i] = fontDefn->scale;
+    fontDefn->used = gTrue;
   }
   pr(writeHTML, htmlStream, "</style>\n");
   pr(writeHTML, htmlStream, "</head>\n");
@@ -592,7 +638,112 @@
   }
 }
 
-GString *HTMLGen::getFontDefn(TextFontInfo *font, double *scale) {
+HTMLGenFontDefn *HTMLGen::getFontDefn(TextFontInfo *font,
+				      const char *htmlDir) {
+  Ref id;
+  HTMLGenFontDefn *fontDefn;
+  int i;
+
+  // check the existing font defns
+  id = font->getFontID();
+  if (id.num >= 0) {
+    for (i = 0; i < fontDefns->getLength(); ++i) {
+      fontDefn = (HTMLGenFontDefn *)fontDefns->get(i);
+      if (fontDefn->match(id)) {
+	return fontDefn;
+      }
+    }
+  }
+
+  // try to extract a font file
+  if (!extractFontFiles ||
+      !(fontDefn = getFontFile(font, htmlDir))) {
+
+    // get a substitute font
+    fontDefn = getSubstituteFont(font);
+  }
+
+  fontDefns->append(fontDefn);
+  return fontDefn;
+}
+
+HTMLGenFontDefn *HTMLGen::getFontFile(TextFontInfo *font,
+				      const char *htmlDir) {
+  Ref id;
+  HTMLGenFontDefn *fontDefn;
+  Object fontObj;
+  GfxFont *gfxFont;
+  WebFont *webFont;
+  GString *fontFile, *fontPath, *fontFace, *fontSpec;
+  const char *family, *weight, *style;
+  double scale;
+
+  id = font->getFontID();
+  if (id.num < 0) {
+    return NULL;
+  }
+
+  doc->getXRef()->fetch(id.num, id.gen, &fontObj);
+  if (!fontObj.isDict()) {
+    fontObj.free();
+    return NULL;
+  }
+
+  gfxFont = GfxFont::makeFont(doc->getXRef(), "F", id, fontObj.getDict());
+  webFont = new WebFont(gfxFont, doc->getXRef());
+  fontDefn = NULL;
+
+  if (webFont->canWriteTTF()) {
+    fontFile = GString::format("{0:d}.ttf", nextFontFaceIdx);
+    fontPath = GString::format("{0:s}/{1:t}", htmlDir, fontFile);
+    if (webFont->writeTTF(fontPath->getCString())) {
+      fontFace = GString::format("@font-face {{ font-family: ff{0:d}; src: url(\"{1:t}\"); }}\n",
+				 nextFontFaceIdx, fontFile);
+      getFontDetails(font, &family, &weight, &style, &scale);
+      fontSpec = GString::format("font-family:ff{0:d},{1:s}; font-weight:{2:s}; font-style:{3:s};",
+				 nextFontFaceIdx, family, weight, style);
+      ++nextFontFaceIdx;
+      fontDefn = new HTMLGenFontDefn(id, fontFace, fontSpec, 1.0);
+    }
+    delete fontPath;
+    delete fontFile;
+
+  } else if (webFont->canWriteOTF()) {
+    fontFile = GString::format("{0:d}.otf", nextFontFaceIdx);
+    fontPath = GString::format("{0:s}/{1:t}", htmlDir, fontFile);
+    if (webFont->writeOTF(fontPath->getCString())) {
+      fontFace = GString::format("@font-face {{ font-family: ff{0:d}; src: url(\"{1:t}\"); }}\n",
+				  nextFontFaceIdx, fontFile);
+      getFontDetails(font, &family, &weight, &style, &scale);
+      fontSpec = GString::format("font-family:ff{0:d},{1:s}; font-weight:{2:s}; font-style:{3:s};",
+				 nextFontFaceIdx, family, weight, style);
+      fontDefn = new HTMLGenFontDefn(id, fontFace, fontSpec, 1.0);
+    }
+    delete fontPath;
+    delete fontFile;
+  }
+
+  delete webFont;
+  delete gfxFont;
+  fontObj.free();
+
+  return fontDefn;
+}
+
+HTMLGenFontDefn *HTMLGen::getSubstituteFont(TextFontInfo *font) {
+  const char *family, *weight, *style;
+  double scale;
+  GString *fontSpec;
+
+  getFontDetails(font, &family, &weight, &style, &scale);
+  fontSpec = GString::format("font-family:{0:s}; font-weight:{1:s}; font-style:{2:s};",
+			     family, weight, style);
+  return new HTMLGenFontDefn(font->getFontID(), NULL, fontSpec, scale);
+}
+
+void HTMLGen::getFontDetails(TextFontInfo *font, const char **family,
+			     const char **weight, const char **style,
+			     double *scale) {
   GString *fontName;
   char *fontName2;
   FontStyleTagInfo *fst;
@@ -666,11 +817,7 @@
     }
   }
 
-  // generate the CSS markup
-  return GString::format("font-family:{0:s}; font-weight:{1:s}; font-style:{2:s};",
-			 fixedWidth ? "monospace"
-			            : serif ? "serif"
-			                    : "sans-serif",
-			 bold ? "bold" : "normal",
-			 italic ? "italic" : "normal");
+  *family = fixedWidth ? "monospace" : serif ? "serif" : "sans-serif";
+  *weight = bold ? "bold" : "normal";
+  *style = italic ? "italic" : "normal";
 }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/HTMLGen.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -20,6 +20,7 @@
 class TextOutputDev;
 class TextFontInfo;
 class SplashOutputDev;
+class HTMLGenFontDefn;
 
 //------------------------------------------------------------------------
 
@@ -46,8 +47,11 @@
   void setAllTextInvisible(GBool allTextInvisibleA)
     { allTextInvisible = allTextInvisibleA; }
 
+  void setExtractFontFiles(GBool extractFontFilesA)
+    { extractFontFiles = extractFontFilesA; }
+
   void startDoc(PDFDoc *docA);
-  int convertPage(int pg, const char *pngURL,
+  int convertPage(int pg, const char *pngURL, const char *htmlDir,
 		  int (*writeHTML)(void *stream, const char *data, int size),
 		  void *htmlStream,
 		  int (*writePNG)(void *stream, const char *data, int size),
@@ -61,20 +65,29 @@
 		   int primaryDir, int spanDir,
 		   double base, GBool dropCapLine, GString *s);
   void appendUTF8(Unicode u, GString *s);
-  GString *getFontDefn(TextFontInfo *font, double *scale);
+  HTMLGenFontDefn *getFontDefn(TextFontInfo *font, const char *htmlDir);
+  HTMLGenFontDefn *getFontFile(TextFontInfo *font, const char *htmlDir);
+  HTMLGenFontDefn *getSubstituteFont(TextFontInfo *font);
+  void getFontDetails(TextFontInfo *font, const char **family,
+		      const char **weight, const char **style,
+		      double *scale);
 
   double backgroundResolution;
   double zoom;
   GBool drawInvisibleText;
   GBool allTextInvisible;
+  GBool extractFontFiles;
 
   PDFDoc *doc;
   TextOutputDev *textOut;
   SplashOutputDev *splashOut;
 
-  GList *fonts;
+  GList *fonts;			// [TextFontInfo]
   double *fontScales;
 
+  GList *fontDefns;		// [HTMLGenFontDefn]
+  int nextFontFaceIdx;
+
   GBool ok;
 };
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -838,6 +838,9 @@
   } else {
     y0 = 0;
   }
+  if (y > INT_MAX - bitmap->h) {
+    return;
+  }
   if (y + bitmap->h > h) {
     y1 = h - y;
   } else {
@@ -1202,10 +1205,13 @@
 }
 
 void JBIG2Stream::reset() {
+  GList *t;
+
+  segments = new GList();
+  globalSegments = new GList();
+
   // read the globals stream
-  globalSegments = new GList();
   if (globalsStream.isStream()) {
-    segments = globalSegments;
     curStr = globalsStream.getStream();
     curStr->reset();
     arithDecoder->setStream(curStr);
@@ -1213,10 +1219,13 @@
     mmrDecoder->setStream(curStr);
     readSegments();
     curStr->close();
+    // swap the newly read segments list into globalSegments
+    t = segments;
+    segments = globalSegments;
+    globalSegments = t;
   }
 
   // read the main stream
-  segments = new GList();
   curStr = str;
   curStr->reset();
   arithDecoder->setStream(curStr);
@@ -1280,7 +1289,8 @@
   return n;
 }
 
-GString *JBIG2Stream::getPSFilter(int psLevel, const char *indent) {
+GString *JBIG2Stream::getPSFilter(int psLevel, const char *indent,
+				  GBool okToReadStream) {
   return NULL;
 }
 
@@ -1506,7 +1516,7 @@
   Guint symHeight, symWidth, totalWidth, x, symID;
   int dh, dw, refAggNum, refDX, refDY, bmSize;
   GBool ex;
-  int run, cnt;
+  int run, prevRun, cnt;
   Guint i, j, k;
 
   symWidths = NULL;
@@ -1853,6 +1863,7 @@
   // exported symbol list
   i = j = 0;
   ex = gFalse;
+  prevRun = 1;
   while (i < numInputSyms + numNewSyms) {
     if (huff) {
       huffDecoder->decodeInt(&run, huffTableA);
@@ -1859,6 +1870,14 @@
     } else {
       arithDecoder->decodeInt(&run, iaexStats);
     }
+    if (run == 0 && prevRun == 0) {
+      // this avoids infinite loops with damaged files (consecutive
+      // zero runs are never useful)
+      error(errSyntaxError, getPos(),
+	    "Invalid exported symbol list in JBIG2 symbol dictionary");
+      delete symbolDict;
+      goto syntaxError;
+    }
     if (i + run > numInputSyms + numNewSyms ||
 	(ex && j + run > numExSyms)) {
       error(errSyntaxError, getPos(),
@@ -1874,6 +1893,7 @@
       i += run;
     }
     ex = !ex;
+    prevRun = run;
   }
   if (j != numExSyms) {
     error(errSyntaxError, getPos(), "Too few symbols in JBIG2 symbol dictionary");
@@ -2143,18 +2163,23 @@
       runLengthTab[i].val = i;
       runLengthTab[i].prefixLen = huffDecoder->readBits(4);
       runLengthTab[i].rangeLen = 0;
+      runLengthTab[i].prefix = 0;
     }
     runLengthTab[32].val = 0x103;
     runLengthTab[32].prefixLen = huffDecoder->readBits(4);
     runLengthTab[32].rangeLen = 2;
+    runLengthTab[32].prefix = 0;
     runLengthTab[33].val = 0x203;
     runLengthTab[33].prefixLen = huffDecoder->readBits(4);
     runLengthTab[33].rangeLen = 3;
+    runLengthTab[33].prefix = 0;
     runLengthTab[34].val = 0x20b;
     runLengthTab[34].prefixLen = huffDecoder->readBits(4);
     runLengthTab[34].rangeLen = 7;
+    runLengthTab[34].prefix = 0;
     runLengthTab[35].prefixLen = 0;
     runLengthTab[35].rangeLen = jbig2HuffmanEOT;
+    runLengthTab[35].prefix = 0;
     huffDecoder->buildTable(runLengthTab, 35);
     symCodeTab = (JBIG2HuffmanTable *)gmallocn(numSyms + 1,
 					       sizeof(JBIG2HuffmanTable));
@@ -2170,6 +2195,12 @@
 	  symCodeTab[i++].prefixLen = 0;
 	}
       } else if (j > 0x100) {
+	if (i == 0) {
+	  error(errSyntaxError, getPos(), "Invalid code in JBIG2 text region");
+	  gfree(syms);
+	  gfree(symCodeTab);
+	  return;
+	}
 	for (j -= 0x100; j && i < numSyms; --j) {
 	  symCodeTab[i].prefixLen = symCodeTab[i-1].prefixLen;
 	  ++i;
@@ -2226,8 +2257,8 @@
 
  codeTableError:
   error(errSyntaxError, getPos(), "Missing code table in JBIG2 text region");
-  gfree(codeTables);
-  delete syms;
+  delete codeTables;
+  gfree(syms);
   return;
 
  eofError:

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JBIG2Stream.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -42,7 +42,8 @@
   virtual int getChar();
   virtual int lookChar();
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -414,18 +414,17 @@
     if (curY >= (img.ySize >> reduction)) {
       return;
     }
-    tileIdx = ((curY - img.yTileOffsetR) / img.yTileSizeR) * img.nXTiles
-              + (curX - img.xTileOffsetR) / img.xTileSizeR;
+    tileIdx = (((curY << reduction) - img.yTileOffset) / img.yTileSize)
+                * img.nXTiles
+              + ((curX << reduction) - img.xTileOffset) / img.xTileSize;
 #if 1 //~ ignore the palette, assume the PDF ColorSpace object is valid
     tileComp = &img.tiles[tileIdx].tileComps[curComp];
 #else
     tileComp = &img.tiles[tileIdx].tileComps[havePalette ? 0 : curComp];
 #endif
-    //~ can curX/curY be less than x/yTileOffsetR?
-    //~ if yes, we need to use tx = max(0, ....)
-    tx = jpxFloorDiv((curX - img.xTileOffsetR) % img.xTileSizeR,
+    tx = jpxFloorDiv(curX - jpxCeilDivPow2(img.tiles[tileIdx].x0, reduction),
 		     tileComp->hSep);
-    ty = jpxFloorDiv((curY - img.yTileOffsetR) % img.yTileSizeR,
+    ty = jpxFloorDiv(curY - jpxCeilDivPow2(img.tiles[tileIdx].y0, reduction),
 		     tileComp->vSep);
     pix = (int)tileComp->data[ty * tileComp->w + tx];
     pixBits = tileComp->prec;
@@ -463,7 +462,8 @@
   } while (readBufLen < 8);
 }
 
-GString *JPXStream::getPSFilter(int psLevel, const char *indent) {
+GString *JPXStream::getPSFilter(int psLevel, const char *indent,
+				GBool okToReadStream) {
   return NULL;
 }
 
@@ -960,10 +960,6 @@
       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)
@@ -1449,8 +1445,7 @@
   ok = gTrue;
   while (1) {
     if (!readTilePart()) {
-      ok = gFalse;
-      break;
+      return jpxDecodeFatalError;
     }
     if (!readMarkerHdr(&segType, &segLen)) {
       error(errSyntaxError, getPos(), "Error in JPX codestream");
@@ -1913,6 +1908,7 @@
     tile->res = 0;
     tile->precinct = 0;
     tile->layer = 0;
+    tile->done = gFalse;
     tile->maxNDecompLevels = 0;
     for (comp = 0; comp < img.nComps; ++comp) {
       tileComp = &tile->tileComps[comp];
@@ -1925,8 +1921,15 @@
       tileComp->y1 = jpxCeilDiv(tile->y1, tileComp->vSep);
       tileComp->cbW = 1 << tileComp->codeBlockW;
       tileComp->cbH = 1 << tileComp->codeBlockH;
-      tileComp->w = jpxCeilDivPow2(tileComp->x1 - tileComp->x0, reduction);
-      tileComp->h = jpxCeilDivPow2(tileComp->y1 - tileComp->y0, reduction);
+      tileComp->w = jpxCeilDivPow2(tileComp->x1, reduction)
+	            - jpxCeilDivPow2(tileComp->x0, reduction);
+      tileComp->h = jpxCeilDivPow2(tileComp->y1, reduction)
+	            - jpxCeilDivPow2(tileComp->y0, reduction);
+      if (tileComp->w == 0 || tileComp->h == 0) {
+	error(errSyntaxError, getPos(),
+	      "Invalid tile size or sample separation in JPX stream");
+	return gFalse;
+      }
       tileComp->data = (int *)gmallocn(tileComp->w * tileComp->h, sizeof(int));
       if (tileComp->x1 - tileComp->x0 > tileComp->y1 - tileComp->y0) {
 	n = tileComp->x1 - tileComp->x0;
@@ -1942,13 +1945,20 @@
 	resLevel->y0 = jpxCeilDivPow2(tileComp->y0, k);
 	resLevel->x1 = jpxCeilDivPow2(tileComp->x1, k);
 	resLevel->y1 = jpxCeilDivPow2(tileComp->y1, k);
+	// the JPEG 2000 spec says that packets for empty res levels
+	// should all be present in the codestream (B.6, B.9, B.10),
+	// but it appears that encoders drop packets if the res level
+	// AND the subbands are all completely empty
+	resLevel->empty = resLevel->x0 == resLevel->x1 ||
+	                  resLevel->y0 == resLevel->y1;
 	if (r == 0) {
 	  resLevel->bx0[0] = resLevel->x0;
 	  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];
+	  resLevel->empty = 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;
@@ -1962,7 +1972,8 @@
 	  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->empty = 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]) &&
@@ -2117,6 +2128,12 @@
 
   tile = &img.tiles[tileIdx];
 
+  // if the tile is finished, just skip this tile part
+  if (tile->done) {
+    bufStr->discardChars(tilePartLen);
+    return gTrue;
+  }
+
   // read all packets from this tile-part
   while (1) {
     if (tilePartToEOC) {
@@ -2373,6 +2390,7 @@
 	  tile->res = 0;
 	  if (++tile->layer == tile->nLayers) {
 	    tile->layer = 0;
+	    tile->done = gTrue;
 	  }
 	}
       }
@@ -2385,6 +2403,7 @@
 	  tile->layer = 0;
 	  if (++tile->res == tile->maxNDecompLevels + 1) {
 	    tile->res = 0;
+	    tile->done = gTrue;
 	  }
 	}
       }
@@ -2398,6 +2417,7 @@
 	  tile->comp = 0;
 	  if (++tile->res == tile->maxNDecompLevels + 1) {
 	    tile->res = 0;
+	    tile->done = gTrue;
 	  }
 	}
       }
@@ -2411,6 +2431,7 @@
 	  tile->res = 0;
 	  if (++tile->comp == img.nComps) {
 	    tile->comp = 0;
+	    tile->done = gTrue;
 	  }
 	}
       }
@@ -2424,6 +2445,7 @@
 	  tile->res = 0;
 	  if (++tile->comp == img.nComps) {
 	    tile->comp = 0;
+	    tile->done = gTrue;
 	  }
 	}
       }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/JPXStream.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -230,10 +230,11 @@
 				//   in any component in this tile
 
   //----- progression order loop counters
-  Guint comp;			//   component
-  Guint res;			//   resolution level
-  Guint precinct;		//   precinct
-  Guint layer;			//   layer
+  Guint comp;			// component
+  Guint res;			// resolution level
+  Guint precinct;		// precinct
+  Guint layer;			// layer
+  GBool done;			// set when this tile is done
 
   //----- tile part info
   Guint nextTilePart;		// next expected tile-part
@@ -253,9 +254,6 @@
         yTileOffset;
   Guint xSizeR, ySizeR;		// size of reference grid >> reduction
   Guint xOffsetR, yOffsetR;	// image offset >> reduction
-  Guint xTileSizeR, yTileSizeR;	// size of tiles >> reduction
-  Guint xTileOffsetR,		// offset of first tile >> reduction
-        yTileOffsetR;
   Guint nComps;			// number of components
 
   //----- computed
@@ -287,7 +285,8 @@
   virtual void close();
   virtual int getChar();
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
   virtual void getImageParams(int *bitsPerComponent,
 			      StreamColorSpaceMode *csMode);

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Lexer.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Lexer.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Lexer.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -112,7 +112,7 @@
 Object *Lexer::getObj(Object *obj) {
   char *p;
   int c, c2;
-  GBool comment, neg, doubleMinus, done;
+  GBool comment, neg, doubleMinus, done, invalid;
   int numParen;
   int xi;
   double xf, scale;
@@ -343,6 +343,7 @@
     p = tokBuf;
     n = 0;
     s = NULL;
+    invalid = gFalse;
     while ((c = lookChar()) != EOF && !specialChars[c]) {
       getChar();
       if (c == '#') {
@@ -370,6 +371,9 @@
 	  goto notEscChar;
 	}
 	getChar();
+	if (c == 0) {
+	  invalid = gTrue;
+	}
       }
      notEscChar:
       // the PDF spec claims that names are limited to 127 chars, but
@@ -385,7 +389,13 @@
 	s->append((char)c);
       }
     }
-    if (n < tokBufSize) {
+    if (invalid) {
+      error(errSyntaxError, getPos(), "Null character in name");
+      obj->initError();
+      if (s) {
+	delete s;
+      }
+    } else if (n < tokBufSize) {
       *p = '\0';
       obj->initName(tokBuf);
     } else {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -39,7 +39,7 @@
 
 PDFCore::PDFCore(SplashColorMode colorMode, int bitmapRowPad,
 		 GBool reverseVideo, SplashColorPtr paperColor) {
-  GString *initialZoom;
+  GString *initialZoom, *initialDisplayMode;
   int z, i;
 
   doc = NULL;
@@ -81,6 +81,19 @@
     state->setZoom(z);
   }
   delete initialZoom;
+  initialDisplayMode = globalParams->getInitialDisplayMode();
+  if (!initialDisplayMode->cmp("single")) {
+    state->setDisplayMode(displaySingle);
+  } else if (!initialDisplayMode->cmp("sideBySideSingle")) {
+    state->setDisplayMode(displaySideBySideSingle);
+  } else if (!initialDisplayMode->cmp("sideBySideContinuous")) {
+    state->setDisplayMode(displaySideBySideContinuous);
+  } else if (!initialDisplayMode->cmp("horizontalContinuous")) {
+    state->setDisplayMode(displayHorizontalContinuous);
+  } else {
+    state->setDisplayMode(displayContinuous);
+  }
+  delete initialDisplayMode;
 
   selectMode = selectModeBlock;
   selectPage = 0;
@@ -615,8 +628,8 @@
   scrollTo(state->getScrollX() + nCols, state->getScrollY());
 }
 
-void PDFCore::scrollUp(int nLines) {
-  scrollTo(state->getScrollX(), state->getScrollY() - nLines);
+void PDFCore::scrollUp(int nLines, GBool snapToPage) {
+  scrollTo(state->getScrollX(), state->getScrollY() - nLines, snapToPage);
 }
 
 void PDFCore::scrollUpPrevPage(int nLines) {
@@ -624,12 +637,12 @@
       state->getScrollY() == 0) {
     gotoPrevPage(1, gFalse, gTrue);
   } else {
-    scrollUp(nLines);
+    scrollUp(nLines, gTrue);
   }
 }
 
-void PDFCore::scrollDown(int nLines) {
-  scrollTo(state->getScrollX(), state->getScrollY() + nLines);
+void PDFCore::scrollDown(int nLines, GBool snapToPage) {
+  scrollTo(state->getScrollX(), state->getScrollY() + nLines, snapToPage);
 }
 
 void PDFCore::scrollDownNextPage(int nLines) {
@@ -643,7 +656,7 @@
       scrollDown(nLines);
     }
   } else {
-    scrollDown(nLines);
+    scrollDown(nLines, gTrue);
   }
 }
 
@@ -655,9 +668,35 @@
   scrollDownNextPage(state->getWinH());
 }
 
-void PDFCore::scrollTo(int x, int y) {
+void PDFCore::scrollTo(int x, int y, GBool snapToPage) {
+  int next, topPage, topPageY, sy, dy;
+
   startUpdate();
   state->setScrollPosition(state->getScrollPage(), x, y);
+
+  if (snapToPage) {
+    if (state->getDisplayMode() == displayContinuous ||
+	state->getDisplayMode() == displaySideBySideContinuous) {
+      next = state->getDisplayMode() == displaySideBySideContinuous ? 2 : 1;
+      topPage = tileMap->getFirstPage();
+      topPageY = tileMap->getPageTopY(topPage);
+      sy = state->getScrollY();
+      dy = sy - topPageY;
+      // note: dy can be negative here if the inter-page gap is at the
+      // top of the window
+      if (-16 < dy && dy < 16) {
+	state->setScrollPosition(state->getScrollPage(), x, topPageY);
+      } else if (topPage + next <= doc->getNumPages()) {
+	topPage += next;
+	topPageY = tileMap->getPageTopY(topPage);
+	dy = sy - topPageY;
+	if (-16 < dy && dy < 0) {
+	  state->setScrollPosition(state->getScrollPage(), x, topPageY);
+	}
+      }
+    }
+  }
+
   finishUpdate(gTrue, gTrue);
 }
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFCore.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -135,13 +135,13 @@
   virtual GBool goBackward();
   virtual void scrollLeft(int nCols = 16);
   virtual void scrollRight(int nCols = 16);
-  virtual void scrollUp(int nLines = 16);
+  virtual void scrollUp(int nLines = 16, GBool snapToPage = gFalse);
   virtual void scrollUpPrevPage(int nLines = 16);
-  virtual void scrollDown(int nLines = 16);
+  virtual void scrollDown(int nLines = 16, GBool snapToPage = gFalse);
   virtual void scrollDownNextPage(int nLines = 16);
   virtual void scrollPageUp();
   virtual void scrollPageDown();
-  virtual void scrollTo(int x, int y);
+  virtual void scrollTo(int x, int y, GBool snapToPage = gFalse);
   virtual void scrollToLeftEdge();
   virtual void scrollToRightEdge();
   virtual void scrollToTopEdge();

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDoc.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDoc.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDoc.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -46,6 +46,15 @@
 #define headerSearchSize 1024	// read this many bytes at beginning of
 				//   file to look for '%PDF'
 
+// Avoid sharing files with child processes on Windows, where sharing
+// can cause problems.
+#ifdef _WIN32
+#  define fopenReadMode "rbN"
+#  define wfopenReadMode L"rbN"
+#else
+#  define fopenReadMode "rb"
+#endif
+
 //------------------------------------------------------------------------
 // PDFDoc
 //------------------------------------------------------------------------
@@ -75,18 +84,18 @@
   // try to open file
   fileName2 = NULL;
 #ifdef VMS
-  if (!(file = fopen(fileName1->getCString(), "rb", "ctx=stm"))) {
+  if (!(file = fopen(fileName1->getCString(), fopenReadMode, "ctx=stm"))) {
     error(errIO, -1, "Couldn't open file '{0:t}'", fileName1);
     errCode = errOpenFile;
     return;
   }
 #else
-  if (!(file = fopen(fileName1->getCString(), "rb"))) {
+  if (!(file = fopen(fileName1->getCString(), fopenReadMode))) {
     fileName2 = fileName->copy();
     fileName2->lowerCase();
-    if (!(file = fopen(fileName2->getCString(), "rb"))) {
+    if (!(file = fopen(fileName2->getCString(), fopenReadMode))) {
       fileName2->upperCase();
-      if (!(file = fopen(fileName2->getCString(), "rb"))) {
+      if (!(file = fopen(fileName2->getCString(), fopenReadMode))) {
 	error(errIO, -1, "Couldn't open file '{0:t}'", fileName);
 	delete fileName2;
 	errCode = errOpenFile;
@@ -127,9 +136,9 @@
   version.dwOSVersionInfoSize = sizeof(version);
   GetVersionEx(&version);
   if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-    file = _wfopen(fileNameU, L"rb");
+    file = _wfopen(fileNameU, wfopenReadMode);
   } else {
-    file = fopen(fileName->getCString(), "rb");
+    file = fopen(fileName->getCString(), fopenReadMode);
   }
   if (!file) {
     error(errIO, -1, "Couldn't open file '{0:t}'", fileName);
@@ -181,18 +190,17 @@
   version.dwOSVersionInfoSize = sizeof(version);
   GetVersionEx(&version);
   if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-    file = _wfopen(fileNameU, L"rb");
+    file = _wfopen(fileNameU, wfopenReadMode);
   } else {
 #endif /* 0 */
-    file = fopen(fileName->getCString(), "rb");
+    file = fopen(fileName->getCString(), fopenReadMode);
 #if 0
   }
 #endif /* 0 */
-
 #elif defined(VMS)
-  file = fopen(fileName->getCString(), "rb", "ctx=stm");
+  file = fopen(fileName->getCString(), fopenReadMode, "ctx=stm");
 #else
-  file = fopen(fileName->getCString(), "rb");
+  file = fopen(fileName->getCString(), fopenReadMode);
 #endif
 
   if (!file) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDocEncoding.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDocEncoding.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PDFDocEncoding.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -6,6 +6,7 @@
 //
 //========================================================================
 
+#include <aconf.h>
 #include "gmempp.h"
 #include "PDFDocEncoding.h"
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PSOutputDev.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PSOutputDev.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/PSOutputDev.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -77,6 +77,7 @@
   "    put",
   "  } for",
   "~123ngs",
+  "/bdef { bind def } bind def",
   "/pdfSetup {",
   "  /pdfDuplex exch def",
   "  /setpagedevice where {",
@@ -393,9 +394,9 @@
   "/f { fCol fill } def",
   "/f* { fCol eofill } def",
   "% clipping operators",
-  "/W { clip newpath } def",
-  "/W* { eoclip newpath } def",
-  "/Ws { strokepath clip newpath } def",
+  "/W { clip newpath } bdef",
+  "/W* { eoclip newpath } bdef",
+  "/Ws { strokepath clip newpath } bdef",
   "% text state operators",
   "/Tc { /pdfCharSpacing exch def } def",
   "/Tf { dup /pdfFontSize exch def",
@@ -985,7 +986,9 @@
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; }
   virtual int lookChar()
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; }
-  virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL; }
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
+    { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -1084,7 +1087,9 @@
     { return (bufIdx >= width && !fillBuf()) ? EOF : buf[bufIdx++]; }
   virtual int lookChar()
     { return (bufIdx >= width && !fillBuf()) ? EOF : buf[bufIdx]; }
-  virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL; }
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
+    { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -1167,7 +1172,9 @@
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; }
   virtual int lookChar()
     { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; }
-  virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL; }
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
+    { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
 
@@ -3841,7 +3848,7 @@
       useLZW = useRLE = gFalse;
       useCompressed = gFalse;
     } else {
-      s = str->getPSFilter(level < psLevel3 ? 2 : 3, "");
+      s = str->getPSFilter(level < psLevel3 ? 2 : 3, "", gTrue);
       if (s) {
 	useLZW = useRLE = gFalse;
 	useCompressed = gTrue;
@@ -4191,7 +4198,13 @@
     }
     sliceX = sliceY = 0;
     sliceW = (int)((box.x2 - box.x1) * hDPI2 / 72.0);
+    if (sliceW == 0) {
+      sliceW = 1;
+    }
     sliceH = (int)((box.y2 - box.y1) * vDPI2 / 72.0);
+    if (sliceH == 0) {
+      sliceH = 1;
+    }
   }
   nStripes = (int)ceil(((double)sliceW * (double)sliceH) /
 		       (double)globalParams->getPSRasterSliceSize());
@@ -5223,6 +5236,7 @@
 
   // set the pattern
   if (paintType == 2) {
+    writePS("fCol\n");
     writePS("currentcolor ");
   }
   writePSFmt("xpdfTile{0:d} setpattern\n", numTilingPatterns);
@@ -6315,7 +6329,7 @@
     useASCII = gFalse;
   } else {
     s = str->getPSFilter(level < psLevel2 ? 1 : level < psLevel3 ? 2 : 3,
-			 "    ");
+			 "    ", !inlineImg);
     if ((colorMap && (colorMap->getColorSpace()->getMode() == csDeviceN ||
 		      level == psLevel2Gray || level == psLevel3Gray)) ||
 	inlineImg || !s) {
@@ -6790,7 +6804,7 @@
       maskUseCompressed = gFalse;
       maskUseASCII = gFalse;
     } else {
-      s = maskStr->getPSFilter(3, "  ");
+      s = maskStr->getPSFilter(3, "  ", !inlineImg);
       if (!s) {
 	if (globalParams->getPSLZW()) {
 	  maskUseLZW = gTrue;
@@ -7018,7 +7032,7 @@
     useCompressed = gFalse;
     useASCII = gFalse;
   } else {
-    s = str->getPSFilter(3, "    ");
+    s = str->getPSFilter(3, "    ", !inlineImg);
     if ((colorMap && level == psLevel3Gray) || inlineImg || !s) {
       if (globalParams->getPSLZW()) {
 	useLZW = gTrue;
@@ -7557,7 +7571,7 @@
       }
       obj1.free();
       sepCSObj.arrayGet(3, &funcObj);
-      if (!(func = Function::parse(&funcObj))) {
+      if (!(func = Function::parse(&funcObj, 1, 4))) {
 	funcObj.free();
 	sepCSObj.free();
 	colorants.free();
@@ -7564,12 +7578,6 @@
 	return NULL;
       }
       funcObj.free();
-      if (func->getInputSize() != 1 || func->getOutputSize() != 4) {
-	delete func;
-	sepCSObj.free();
-	colorants.free();
-	return NULL;
-      }
       sepIn = 1;
       func->transform(&sepIn, cmyk[i]);
       delete func;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -28,6 +28,7 @@
 #include "BuiltinFont.h"
 #include "BuiltinFontTables.h"
 #include "FoFiTrueType.h"
+#include "FoFiType1C.h"
 #include "JPXStream.h"
 #include "SplashBitmap.h"
 #include "SplashGlyphBitmap.h"
@@ -498,6 +499,7 @@
   int cacheAssoc;		// cache associativity (glyphs per set)
   Guchar *cacheData;		// glyph pixmap cache
   T3FontCacheTag *cacheTags;	// cache tags, i.e., char codes
+  GBool inUse;			// set while this T3 font is in active use
 };
 
 T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A,
@@ -539,6 +541,7 @@
   for (i = 0; i < cacheSets * cacheAssoc; ++i) {
     cacheTags[i].mru = (Gushort)(i & (cacheAssoc - 1));
   }
+  inUse = gFalse;
 }
 
 T3FontCache::~T3FontCache() {
@@ -615,8 +618,8 @@
   xref = NULL;
 
   bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
-			    colorMode != splashModeMono1, bitmapTopDown);
-  splash = new Splash(bitmap, vectorAntialias, &screenParams);
+			    colorMode != splashModeMono1, bitmapTopDown, NULL);
+  splash = new Splash(bitmap, vectorAntialias, NULL, &screenParams);
   splash->setMinLineWidth(globalParams->getMinLineWidth());
   splash->setStrokeAdjust(
 		 mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
@@ -761,9 +764,10 @@
       bitmap = NULL;
     }
     bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode,
-			      colorMode != splashModeMono1, bitmapTopDown);
+			      colorMode != splashModeMono1, bitmapTopDown,
+			      NULL);
   }
-  splash = new Splash(bitmap, vectorAntialias, &screenParams);
+  splash = new Splash(bitmap, vectorAntialias, NULL, &screenParams);
   splash->setMinLineWidth(globalParams->getMinLineWidth());
   splash->setEnablePathSimplification(
 		 globalParams->getEnablePathSimplification());
@@ -804,6 +808,7 @@
   splash->setStrokeAdjust(
 	      mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
   splash->clear(paperColor, 0);
+  reverseVideoInvertImages = globalParams->getReverseVideoInvertImages();
   if (startPageCbk) {
     (*startPageCbk)(startPageCbkData);
   }
@@ -1149,6 +1154,7 @@
   SplashFontFile *fontFile;
   int fontNum;
   FoFiTrueType *ff;
+  FoFiType1C *ffT1C;
   Ref embRef;
   Object refObj, strObj;
 #if LOAD_FONTS_FROM_MEM
@@ -1166,9 +1172,9 @@
   double fsx, fsy, w, fontScaleMin, fontScaleAvg, fontScale;
   Gushort ww;
   SplashCoord mat[4];
-  char *name;
+  char *name, *start;
   Unicode uBuf[8];
-  int substIdx, n, code, cmap, cmapPlatform, cmapEncoding, i;
+  int substIdx, n, code, cmap, cmapPlatform, cmapEncoding, length, i;
 
   needFontUpdate = gFalse;
   font = NULL;
@@ -1306,6 +1312,17 @@
       }
       break;
     case fontType1C:
+#if LOAD_FONTS_FROM_MEM
+      if ((ffT1C = FoFiType1C::make(fontBuf->getCString(),
+				    fontBuf->getLength()))) {
+#else
+      if ((ffT1C = FoFiType1C::load(fileName->getCString()))) {
+#endif
+	codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffT1C);
+	delete ffT1C;
+      } else {
+	codeToGID = NULL;
+      }
       if (!(fontFile = fontEngine->loadType1CFont(
 		   id,
 #if LOAD_FONTS_FROM_MEM
@@ -1314,6 +1331,7 @@
 		   fileName->getCString(),
 		   fileName == tmpFileName,
 #endif
+		   codeToGID,
 		   (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
 	error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
 	      gfxFont->getName() ? gfxFont->getName()->getCString()
@@ -1323,6 +1341,21 @@
       }
       break;
     case fontType1COT:
+      codeToGID = NULL;
+#if LOAD_FONTS_FROM_MEM
+      if ((ff = FoFiTrueType::make(fontBuf->getCString(), fontBuf->getLength(),
+				   fontNum, gTrue))) {
+#else
+	if ((ff = FoFiTrueType::load(fileName->getCString(),
+				     fontNum, gTrue))) {
+#endif
+	if (ff->getCFFBlock(&start, &length) &&
+	    (ffT1C = FoFiType1C::make(start, length))) {
+	  codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffT1C);
+	  delete ffT1C;
+	}
+	delete ff;
+      }
       if (!(fontFile = fontEngine->loadOpenTypeT1CFont(
 		   id,
 #if LOAD_FONTS_FROM_MEM
@@ -1331,6 +1364,7 @@
 		   fileName->getCString(),
 		   fileName == tmpFileName,
 #endif
+		   codeToGID,
 		   (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
 	error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
 	      gfxFont->getName() ? gfxFont->getName()->getCString()
@@ -1559,6 +1593,7 @@
       break;
     default:
       // this shouldn't happen
+      delete fontLoc;
       goto err2;
     }
 
@@ -1593,8 +1628,8 @@
 	   (name[0] >= 'a' && name[0] <= 'z') ||
 	   (name[0] >= '0' && name[0] <= '9'))) {
 	w = ((Gfx8BitFont *)gfxFont)->getWidth((Guchar)code);
-	builtinFontSubst[substIdx]->widths->getWidth(name, &ww);
-	if (w > 0.01 && ww > 10) {
+	if (builtinFontSubst[substIdx]->widths->getWidth(name, &ww) &&
+	    w > 0.01 && ww > 10) {
 	  w /= ww * 0.001;
 	  if (w < fontScaleMin) {
 	    fontScaleMin = w;
@@ -1780,7 +1815,10 @@
 
   // check for an excessively large tile size
   tileSize = tileW * tileH;
-  if (tileSize > 1000000 || tileSize < 0) {
+  if (tileXMax - tileXMin + 0.5 > (double)INT_MAX ||
+      tileYMax - tileYMin + 0.5 > (double)INT_MAX ||
+      tileW > INT_MAX / tileH ||
+      tileSize > 1000000) {
     mat1[0] = mat[0];
     mat1[1] = mat[1];
     mat1[2] = mat[2];
@@ -1932,8 +1970,10 @@
   origBitmap = bitmap;
   origSplash = splash;
   bitmap = tileBitmap = new SplashBitmap(tileW, tileH, bitmapRowPad,
-					 colorMode, gTrue, bitmapTopDown);
-  splash = new Splash(bitmap, vectorAntialias, origSplash->getScreen());
+					 colorMode, gTrue, bitmapTopDown,
+					 origBitmap);
+  splash = new Splash(bitmap, vectorAntialias,
+		      origSplash->getImageCache(), origSplash->getScreen());
   for (i = 0; i < splashMaxColorComps; ++i) {
     color[i] = 0;
   }
@@ -2085,7 +2125,7 @@
   bitmapWidth = ixMax - ixMin;
   bitmapHeight = iyMax - iyMin;
   tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1,
-			     srcMode, gTrue, gTrue);
+			     srcMode, gTrue, gTrue, bitmap);
   memset(tBitmap->getAlphaPtr(), 0, (size_t)bitmapWidth * bitmapHeight);
   nComps = splashColorModeNComps[srcMode];
 
@@ -2403,7 +2443,7 @@
   bitmapWidth = ixMax - ixMin;
   bitmapHeight = iyMax - iyMin;
   tBitmap = new SplashBitmap(bitmapWidth, bitmapHeight, 1,
-			     srcMode, gTrue, gTrue);
+			     srcMode, gTrue, gTrue, bitmap);
   memset(tBitmap->getAlphaPtr(), 0, tBitmap->getAlphaRowSize() * bitmapHeight);
   nComps = splashColorModeNComps[srcMode];
 
@@ -2908,13 +2948,26 @@
     if (i >= nT3Fonts) {
 
       // create new entry in the font cache
-      if (nT3Fonts == splashOutT3FontCacheSize) {
-	delete t3FontCache[nT3Fonts - 1];
+      if (nT3Fonts < splashOutT3FontCacheSize) {
+	for (j = nT3Fonts; j > 0; --j) {
+	  t3FontCache[j] = t3FontCache[j - 1];
+	}
+      } else {
+	for (j = nT3Fonts - 1; j >= 0; --j) {
+	  if (!t3FontCache[j]->inUse) {
+	    break;
+	  }
+	}
+	if (j < 0) {
+	  error(errSyntaxError, -1, "Type 3 fonts nested too deeply");
+	  return gTrue;
+	}
+	delete t3FontCache[j];
 	--nT3Fonts;
+	for (; j > 0; --j) {
+	  t3FontCache[j] = t3FontCache[j - 1];
+	}
       }
-      for (j = nT3Fonts; j > 0; --j) {
-	t3FontCache[j] = t3FontCache[j - 1];
-      }
       ++nT3Fonts;
       bbox = gfxFont->getFontBBox();
       if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) {
@@ -2985,6 +3038,8 @@
     }
   }
 
+  t3Font->inUse = gTrue;
+
   // push a new Type 3 glyph record
   t3gs = new T3GlyphStack();
   t3gs->next = t3GlyphStack;
@@ -3021,6 +3076,7 @@
   }
   t3gs = t3GlyphStack;
   t3GlyphStack = t3gs->next;
+  t3gs->cache->inUse = gFalse;
   delete t3gs;
 }
 
@@ -3131,8 +3187,10 @@
   if (colorMode == splashModeMono1) {
     colorMode = splashModeMono1;
     bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
-			      splashModeMono1, gFalse);
-    splash = new Splash(bitmap, gFalse, t3GlyphStack->origSplash->getScreen());
+			      splashModeMono1, gFalse, gTrue, bitmap);
+    splash = new Splash(bitmap, gFalse,
+			t3GlyphStack->origSplash->getImageCache(), 
+			t3GlyphStack->origSplash->getScreen());
     color[0] = 0;
     splash->clear(color);
     color[0] = 0xff;
@@ -3139,8 +3197,9 @@
   } else {
     colorMode = splashModeMono8;
     bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
-			      splashModeMono8, gFalse);
+			      splashModeMono8, gFalse, gTrue, bitmap);
     splash = new Splash(bitmap, vectorAntialias,
+			t3GlyphStack->origSplash->getImageCache(), 
 			t3GlyphStack->origSplash->getScreen());
     color[0] = 0x00;
     splash->clear(color);
@@ -3214,6 +3273,7 @@
   double *ctm;
   SplashCoord mat[6];
   SplashOutImageMaskData imgMaskData;
+  GString *imgTag;
 
   if (state->getFillColorSpace()->isNonMarking()) {
     return;
@@ -3239,8 +3299,11 @@
   imgMaskData.height = height;
   imgMaskData.y = 0;
 
-  splash->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat,
+  imgTag = makeImageTag(ref);
+  splash->fillImageMask(imgTag,
+			&imageMaskSrc, &imgMaskData, width, height, mat,
 			t3GlyphStack != NULL, interpolate);
+
   if (inlineImg) {
     while (imgMaskData.y < height) {
       imgMaskData.imgStr->getLine();
@@ -3248,6 +3311,7 @@
     }
   }
 
+  delete imgTag;
   delete imgMaskData.imgStr;
   str->close();
 }
@@ -3264,6 +3328,7 @@
   SplashBitmap *maskBitmap;
   Splash *maskSplash;
   SplashColor maskColor;
+  GString *imgTag;
 
   ctm = state->getCTM();
   mat[0] = ctm[0];
@@ -3280,8 +3345,8 @@
   imgMaskData.height = height;
   imgMaskData.y = 0;
   maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
-				1, splashModeMono8, gFalse);
-  maskSplash = new Splash(maskBitmap, gTrue);
+				1, splashModeMono8, gFalse, gTrue, bitmap);
+  maskSplash = new Splash(maskBitmap, gTrue, splash->getImageCache());
   maskSplash->setStrokeAdjust(
 		     mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
   maskSplash->setEnablePathSimplification(
@@ -3289,8 +3354,10 @@
   clearMaskRegion(state, maskSplash, 0, 0, 1, 1);
   maskColor[0] = 0xff;
   maskSplash->setFillPattern(new SplashSolidColor(maskColor));
-  maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData,
+  imgTag = makeImageTag(ref);
+  maskSplash->fillImageMask(imgTag, &imageMaskSrc, &imgMaskData,
 			    width, height, mat, gFalse, interpolate);
+  delete imgTag;
   delete imgMaskData.imgStr;
   str->close();
   delete maskSplash;
@@ -3304,6 +3371,7 @@
   SplashColorPtr lookup;
   int *maskColors;
   SplashColorMode colorMode;
+  GBool invert;
   int width, height, y;
 };
 
@@ -3312,7 +3380,7 @@
   SplashOutImageData *imgData = (SplashOutImageData *)data;
   Guchar *p;
   SplashColorPtr q, col;
-  int x;
+  int n, x;
 
   if (imgData->y == imgData->height ||
       !(p = imgData->imgStr->getLine())) {
@@ -3371,6 +3439,13 @@
     }
   }
 
+  if (imgData->invert) {
+    n = imgData->width * splashColorModeNComps[imgData->colorMode];
+    for (x = 0, p = colorLine; x < n; ++x, ++p) {
+      *p ^= 0xff;
+    }
+  }
+
   ++imgData->y;
   return gTrue;
 }
@@ -3381,7 +3456,7 @@
   Guchar *p0, *p, *aq;
   SplashColorPtr q, col;
   Guchar alpha;
-  int nComps, x, i;
+  int nComps, x, n, i;
 
   if (imgData->y == imgData->height ||
       !(p0 = imgData->imgStr->getLine())) {
@@ -3455,6 +3530,13 @@
     *aq++ = alpha;
   }
 
+  if (imgData->invert) {
+    n = imgData->width * splashColorModeNComps[imgData->colorMode];
+    for (x = 0, p = colorLine; x < n; ++x, ++p) {
+      *p ^= 0xff;
+    }
+  }
+
   ++imgData->y;
   return gTrue;
 }
@@ -3470,6 +3552,7 @@
   SplashOutImageData imgData;
   SplashColorMode srcMode;
   SplashImageSource src;
+  GString *imgTag;
   GfxGray gray;
   GfxRGB rgb;
 #if SPLASH_CMYK
@@ -3500,6 +3583,7 @@
   imgData.ri = state->getRenderingIntent();
   imgData.maskColors = maskColors;
   imgData.colorMode = colorMode;
+  imgData.invert = reverseVideo && reverseVideoInvertImages;
   imgData.width = width;
   imgData.height = height;
   imgData.y = 0;
@@ -3559,7 +3643,9 @@
     srcMode = colorMode;
   }
   src = maskColors ? &alphaImageSrc : &imageSrc;
-  splash->drawImage(src, &imgData, srcMode, maskColors ? gTrue : gFalse,
+  imgTag = makeImageTag(ref);
+  splash->drawImage(imgTag,
+		    src, &imgData, srcMode, maskColors ? gTrue : gFalse,
 		    width, height, mat, interpolate);
   if (inlineImg) {
     while (imgData.y < height) {
@@ -3568,6 +3654,7 @@
     }
   }
 
+  delete imgTag;
   gfree(imgData.lookup);
   delete imgData.imgStr;
   str->close();
@@ -3580,6 +3667,7 @@
   SplashBitmap *mask;
   SplashColorPtr lookup;
   SplashColorMode colorMode;
+  GBool invert;
   int width, height, y;
 };
 
@@ -3591,7 +3679,7 @@
   static Guchar bitToByte[2] = {0x00, 0xff};
   Guchar *maskPtr;
   int maskShift;
-  int x;
+  int n, x;
 
   if (imgData->y == imgData->height ||
       !(p = imgData->imgStr->getLine())) {
@@ -3672,6 +3760,13 @@
     }
   }
 
+  if (imgData->invert) {
+    n = imgData->width * splashColorModeNComps[imgData->colorMode];
+    for (x = 0, p = colorLine; x < n; ++x, ++p) {
+      *p ^= 0xff;
+    }
+  }
+
   ++imgData->y;
   return gTrue;
 }
@@ -3692,6 +3787,7 @@
   SplashColorMode srcMode;
   SplashBitmap *maskBitmap;
   Splash *maskSplash;
+  GString *imgTag;
   SplashColor maskColor;
   GfxGray gray;
   GfxRGB rgb;
@@ -3741,8 +3837,9 @@
     imgMaskData.width = maskWidth;
     imgMaskData.height = maskHeight;
     imgMaskData.y = 0;
-    maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, gFalse);
-    maskSplash = new Splash(maskBitmap, gFalse);
+    maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1,
+				  gFalse, gTrue, bitmap);
+    maskSplash = new Splash(maskBitmap, gFalse, splash->getImageCache());
     maskSplash->setStrokeAdjust(
 		       mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
     maskSplash->setEnablePathSimplification(
@@ -3752,7 +3849,7 @@
     maskColor[0] = 0xff;
     maskSplash->setFillPattern(new SplashSolidColor(maskColor));
     // use "glyph mode" here to get the correct scaled size
-    maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData,
+    maskSplash->fillImageMask(NULL, &imageMaskSrc, &imgMaskData,
 			      maskWidth, maskHeight, mat, gTrue, interpolate);
     delete imgMaskData.imgStr;
     maskStr->close();
@@ -3775,6 +3872,7 @@
     imgData.ri = state->getRenderingIntent();
     imgData.mask = maskBitmap;
     imgData.colorMode = colorMode;
+    imgData.invert = reverseVideo && reverseVideoInvertImages;
     imgData.width = width;
     imgData.height = height;
     imgData.y = 0;
@@ -3833,9 +3931,12 @@
     } else {
       srcMode = colorMode;
     }
-    splash->drawImage(&maskedImageSrc, &imgData, srcMode, gTrue,
+    imgTag = makeImageTag(ref);
+    splash->drawImage(imgTag,
+		      &maskedImageSrc, &imgData, srcMode, gTrue,
 		      width, height, mat, interpolate);
 
+    delete imgTag;
     delete maskBitmap;
     gfree(imgData.lookup);
     delete imgData.imgStr;
@@ -3850,6 +3951,7 @@
   GfxRenderingIntent ri;
   Guchar matte[gfxColorMaxComps];
   SplashColorMode colorMode;
+  GBool invert;
   int width, height, y;
 };
 
@@ -3866,7 +3968,7 @@
   GfxCMYK cmyk;
 #endif
   Guchar alpha;
-  int nComps, x;
+  int nComps, n, x;
 
   if (imgData->y == imgData->height ||
       !(p = imgData->imgStr->getLine()) ||
@@ -3938,6 +4040,13 @@
     *aq++ = alpha;
   }
 
+  if (imgData->invert) {
+    n = imgData->width * splashColorModeNComps[imgData->colorMode];
+    for (x = 0, p = colorLine; x < n; ++x, ++p) {
+      *p ^= 0xff;
+    }
+  }
+
   ++imgData->y;
   return gTrue;
 }
@@ -3955,6 +4064,7 @@
   SplashOutImageData imgData;
   SplashOutImageData imgMaskData;
   SplashOutSoftMaskMatteImageData matteImgData;
+  GString *imgTag;
   SplashColorMode srcMode;
   SplashBitmap *maskBitmap;
   Splash *maskSplash;
@@ -4044,11 +4154,14 @@
       n = 1 << 8;
     }
     matteImgData.colorMode = colorMode;
+    matteImgData.invert = reverseVideo && reverseVideoInvertImages;
     matteImgData.width = width;
     matteImgData.height = height;
     matteImgData.y = 0;
-    splash->drawImage(&softMaskMatteImageSrc, &matteImgData,
+    imgTag = makeImageTag(ref);
+    splash->drawImage(imgTag, &softMaskMatteImageSrc, &matteImgData,
 		      srcMode, gTrue, width, height, mat, interpolate);
+    delete imgTag;
     delete matteImgData.maskStr;
     delete matteImgData.imgStr;
     maskStr->close();
@@ -4069,6 +4182,7 @@
     imgMaskData.ri = state->getRenderingIntent();
     imgMaskData.maskColors = NULL;
     imgMaskData.colorMode = splashModeMono8;
+    imgMaskData.invert = gFalse;
     imgMaskData.width = maskWidth;
     imgMaskData.height = maskHeight;
     imgMaskData.y = 0;
@@ -4080,14 +4194,16 @@
       imgMaskData.lookup[i] = colToByte(gray);
     }
     maskBitmap = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
-				  1, splashModeMono8, gFalse);
-    maskSplash = new Splash(maskBitmap, vectorAntialias);
+				  1, splashModeMono8, gFalse, gTrue, bitmap);
+    maskSplash = new Splash(maskBitmap, vectorAntialias,
+			    splash->getImageCache());
     maskSplash->setStrokeAdjust(
 		       mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
     maskSplash->setEnablePathSimplification(
 		       globalParams->getEnablePathSimplification());
     clearMaskRegion(state, maskSplash, 0, 0, 1, 1);
-    maskSplash->drawImage(&imageSrc, &imgMaskData, splashModeMono8, gFalse,
+    maskSplash->drawImage(NULL,
+			  &imageSrc, &imgMaskData, splashModeMono8, gFalse,
 			  maskWidth, maskHeight, mat, interpolate);
     delete imgMaskData.imgStr;
     maskStr->close();
@@ -4105,6 +4221,7 @@
     imgData.ri = state->getRenderingIntent();
     imgData.maskColors = NULL;
     imgData.colorMode = colorMode;
+    imgData.invert = reverseVideo && reverseVideoInvertImages;
     imgData.width = width;
     imgData.height = height;
     imgData.y = 0;
@@ -4156,10 +4273,13 @@
       }
     }
 
-    splash->drawImage(&imageSrc, &imgData, srcMode, gFalse, width, height, mat,
+    imgTag = makeImageTag(ref);
+    splash->drawImage(imgTag,
+		      &imageSrc, &imgData, srcMode, gFalse, width, height, mat,
 		      interpolate);
 
     splash->setSoftMask(NULL);
+    delete imgTag;
     gfree(imgData.lookup);
     delete imgData.imgStr;
 
@@ -4168,6 +4288,13 @@
   }
 }
 
+GString *SplashOutputDev::makeImageTag(Object *ref) {
+  if (!ref || !ref->isRef()) {
+    return NULL;
+  }
+  return GString::format("{0:d}_{1:d}", ref->getRefNum(), ref->getRefGen());
+}
+
 void SplashOutputDev::reduceImageResolution(Stream *str, double *ctm,
 					    int *width, int *height) {
   double sw, sh;
@@ -4174,6 +4301,8 @@
   int reduction;
 
   if (str->getKind() == strJPX &&
+      *width >= 256 &&
+      *height >= 256 &&
       *width * *height > 10000000) {
     sw = (double)*width / (fabs(ctm[0]) + fabs(ctm[1]));
     sh = (double)*height / (fabs(ctm[2]) + fabs(ctm[3]));
@@ -4396,8 +4525,9 @@
 
   // create the temporary bitmap
   bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue,
-			    bitmapTopDown); 
+			    bitmapTopDown, transpGroup->origBitmap); 
   splash = new Splash(bitmap, vectorAntialias,
+		      transpGroup->origSplash->getImageCache(),
 		      transpGroup->origSplash->getScreen());
   splash->setMinLineWidth(globalParams->getMinLineWidth());
   splash->setStrokeAdjust(
@@ -4415,11 +4545,12 @@
   }
   if (!isolated &&
       transpGroup->origBitmap->getAlphaPtr() &&
-      transpGroup->origSplash->getInNonIsolatedGroup()) {
+      transpGroup->origSplash->getInNonIsolatedGroup() &&
+      colorMode != splashModeMono1) {
     // when drawing a non-isolated group into another non-isolated group,
     // compute a backdrop bitmap with corrected alpha values
     backdropBitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue,
-				      bitmapTopDown);
+				      bitmapTopDown, transpGroup->origBitmap);
     transpGroup->origSplash->blitCorrectedAlpha(backdropBitmap,
 						tx, ty, 0, 0, w, h);
     transpGroup->backdropBitmap = backdropBitmap;
@@ -4521,6 +4652,7 @@
     //~ space is given
     if (transpGroupStack->blendingColorSpace) {
       tSplash = new Splash(tBitmap, vectorAntialias,
+			   transpGroupStack->origSplash->getImageCache(),
 			   transpGroupStack->origSplash->getScreen());
       tSplash->setStrokeAdjust(
 		      mapStrokeAdjustMode[globalParams->getStrokeAdjust()]);
@@ -4578,7 +4710,7 @@
   }
 
   softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
-			      1, splashModeMono8, gFalse);
+			      1, splashModeMono8, gFalse, gTrue, bitmap);
   memset(softMask->getDataPtr(), (int)(backdrop2 * 255.0 + 0.5),
 	 softMask->getRowSize() * softMask->getHeight());
   if (tx < softMask->getWidth() && ty < softMask->getHeight()) {
@@ -4660,7 +4792,7 @@
 
   ret = bitmap;
   bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
-			    colorMode != splashModeMono1, bitmapTopDown);
+			    colorMode != splashModeMono1, bitmapTopDown, NULL);
   return ret;
 }
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/SplashOutputDev.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -279,6 +279,7 @@
   static GBool softMaskMatteImageSrc(void *data,
 				     SplashColorPtr colorLine,
 				     Guchar *alphaLine);
+  GString *makeImageTag(Object *ref);
   void reduceImageResolution(Stream *str, double *mat,
 			     int *width, int *height);
   void clearMaskRegion(GfxState *state,
@@ -295,6 +296,7 @@
   GBool allowAntialias;
   GBool vectorAntialias;
   GBool reverseVideo;		// reverse video mode
+  GBool reverseVideoInvertImages;
   SplashColor paperColor;	// paper color
   SplashScreenParams screenParams;
   GBool skipHorizText;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -121,7 +121,8 @@
   return count;
 }
 
-GString *Stream::getPSFilter(int psLevel, const char *indent) {
+GString *Stream::getPSFilter(int psLevel, const char *indent,
+			     GBool okToReadStream) {
   return new GString();
 }
 
@@ -132,15 +133,15 @@
   int i;
 
   str = this;
-  dict->dictLookup("Filter", &obj);
+  dict->dictLookup("Filter", &obj, recursion);
   if (obj.isNull()) {
     obj.free();
-    dict->dictLookup("F", &obj);
+    dict->dictLookup("F", &obj, recursion);
   }
-  dict->dictLookup("DecodeParms", &params);
+  dict->dictLookup("DecodeParms", &params, recursion);
   if (params.isNull()) {
     params.free();
-    dict->dictLookup("DP", &params);
+    dict->dictLookup("DP", &params, recursion);
   }
   if (obj.isName()) {
     str = makeFilter(obj.getName(), str, &params, recursion);
@@ -1096,13 +1097,14 @@
   return buf;
 }
 
-GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent) {
+GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent,
+				     GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 2) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("/ASCIIHexDecode filter\n");
@@ -1181,13 +1183,14 @@
   return b[index];
 }
 
-GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent) {
+GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent,
+				    GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 2) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("/ASCII85Decode filter\n");
@@ -1408,13 +1411,14 @@
   return code;
 }
 
-GString *LZWStream::getPSFilter(int psLevel, const char *indent) {
+GString *LZWStream::getPSFilter(int psLevel, const char *indent,
+				GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 2 || pred) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("<< ");
@@ -1474,13 +1478,14 @@
   return n;
 }
 
-GString *RunLengthStream::getPSFilter(int psLevel, const char *indent) {
+GString *RunLengthStream::getPSFilter(int psLevel, const char *indent,
+				      GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 2) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("/RunLengthDecode filter\n");
@@ -2012,7 +2017,7 @@
 	lookBits(1);
 	eatBits(1);
       }
-      if (encoding >= 0) {
+      if (encoding > 0) {
 	for (i = 0; i < 4; ++i) {
 	  code1 = lookBits(12);
 	  if (code1 != 0x001) {
@@ -2260,7 +2265,8 @@
   return (short)((inputBuf >> (inputBits - n)) & (0xffffffff >> (32 - n)));
 }
 
-GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent) {
+GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent,
+				     GBool okToReadStream) {
   GString *s;
   char s1[50];
 
@@ -2267,7 +2273,7 @@
   if (psLevel < 2) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("<< ");
@@ -2384,6 +2390,11 @@
   jpeg_start_decompress(&decomp);
 }
 
+GBool DCTStream::checkSequentialInterleaved() {
+  //~ this is unimplemented
+  return gTrue;
+}
+
 void DCTStream::close() {
   // we don't call jpeg_finish_decompress() here because it will report
   // an error if the full image wasn't read
@@ -2754,6 +2765,28 @@
   }
 }
 
+GBool DCTStream::checkSequentialInterleaved() {
+  GBool headerOk;
+
+  str->reset();
+
+  progressive = interleaved = gFalse;
+  width = height = 0;
+  numComps = 0;
+  numQuantTables = 0;
+  numDCHuffTables = 0;
+  numACHuffTables = 0;
+  gotJFIFMarker = gFalse;
+  gotAdobeMarker = gFalse;
+  restartInterval = 0;
+
+  headerOk = readHeader(gTrue);
+
+  FilterStream::close();
+
+  return headerOk && !progressive && interleaved;
+}
+
 void DCTStream::close() {
   int i;
 
@@ -3755,7 +3788,7 @@
 
 GBool DCTStream::readHeader(GBool frame) {
   GBool doScan;
-  int n;
+  int n, i;
   int c = 0;
 
   // read headers
@@ -3850,6 +3883,13 @@
     }
   }
 
+  for (i = 0; i < numComps; ++i) {
+    if (compInfo[i].quantTable >= numQuantTables) {
+      error(errSyntaxError, getPos(), "Invalid DCT quant table selector");
+      return gFalse;
+    }
+  }
+
   return gTrue;
 }
 
@@ -3878,8 +3918,14 @@
     compInfo[i].hSample = (c >> 4) & 0x0f;
     compInfo[i].vSample = c & 0x0f;
     compInfo[i].quantTable = str->getChar();
-    if (compInfo[i].hSample < 1 || compInfo[i].hSample > 4 ||
-	compInfo[i].vSample < 1 || compInfo[i].vSample > 4) {
+    // a sampling factor of 3 is allowed by the spec, but requires
+    // messy upsampling, and appears not to be used in practice
+    if (!(compInfo[i].hSample == 1 ||
+	  compInfo[i].hSample == 2 ||
+	  compInfo[i].hSample == 4) ||
+	!(compInfo[i].vSample == 1 ||
+	  compInfo[i].vSample == 2 ||
+	  compInfo[i].vSample == 4)) {
       error(errSyntaxError, getPos(), "Bad DCT sampling factor");
       return gFalse;
     }
@@ -3917,8 +3963,14 @@
     compInfo[i].hSample = (c >> 4) & 0x0f;
     compInfo[i].vSample = c & 0x0f;
     compInfo[i].quantTable = str->getChar();
-    if (compInfo[i].hSample < 1 || compInfo[i].hSample > 4 ||
-	compInfo[i].vSample < 1 || compInfo[i].vSample > 4) {
+    // a sampling factor of 3 is allowed by the spec, but requires
+    // messy upsampling, and appears not to be used in practice
+    if (!(compInfo[i].hSample == 1 ||
+	  compInfo[i].hSample == 2 ||
+	  compInfo[i].hSample == 4) ||
+	!(compInfo[i].vSample == 1 ||
+	  compInfo[i].vSample == 2 ||
+	  compInfo[i].vSample == 4)) {
       error(errSyntaxError, getPos(), "Bad DCT sampling factor");
       return gFalse;
     }
@@ -4182,15 +4234,21 @@
 
 #endif // HAVE_JPEGLIB
 
-GString *DCTStream::getPSFilter(int psLevel, const char *indent) {
+GString *DCTStream::getPSFilter(int psLevel, const char *indent,
+				GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 2) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
+  if (okToReadStream && !checkSequentialInterleaved()) {
+    // PostScript does not allow progressive or interleaved JPEG
+    delete s;
+    return NULL;
+  }
   s->append(indent)->append("<< >> /DCTDecode filter\n");
   return s;
 }
@@ -4982,13 +5040,14 @@
   return n;
 }
 
-GString *FlateStream::getPSFilter(int psLevel, const char *indent) {
+GString *FlateStream::getPSFilter(int psLevel, const char *indent,
+				  GBool okToReadStream) {
   GString *s;
 
   if (psLevel < 3 || pred) {
     return NULL;
   }
-  if (!(s = str->getPSFilter(psLevel, indent))) {
+  if (!(s = str->getPSFilter(psLevel, indent, okToReadStream))) {
     return NULL;
   }
   s->append(indent)->append("<< >> /FlateDecode filter\n");

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/Stream.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -117,7 +117,8 @@
   virtual void setPos(GFileOffset pos, int dir = 0) = 0;
 
   // Get PostScript command for the filter(s).
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
 
   // Does this stream type potentially contain non-printable chars?
   virtual GBool isBinary(GBool last = gTrue) = 0;
@@ -422,7 +423,8 @@
   virtual int getChar()
     { int c = lookChar(); buf = EOF; return c; }
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -446,7 +448,8 @@
   virtual int getChar()
     { int ch = lookChar(); ++index; return ch; }
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -474,7 +477,8 @@
   virtual int lookChar();
   virtual int getRawChar();
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -520,7 +524,8 @@
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -552,7 +557,8 @@
   virtual int getChar();
   virtual int lookChar();
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -650,12 +656,15 @@
   virtual int getChar();
   virtual int lookChar();
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
   Stream *getRawStream() { return str; }
 
 private:
 
+  GBool checkSequentialInterleaved();
+
 #if HAVE_JPEGLIB
 
   int colorXform;		// color transform: -1 = unspecified
@@ -785,7 +794,8 @@
   virtual int lookChar();
   virtual int getRawChar();
   virtual int getBlock(char *blk, int size);
-  virtual GString *getPSFilter(int psLevel, const char *indent);
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream);
   virtual GBool isBinary(GBool last = gTrue);
 
 private:
@@ -840,7 +850,8 @@
   virtual int getChar() { return EOF; }
   virtual int lookChar() { return EOF; }
   virtual int getBlock(char *blk, int size) { return 0; }
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
 };
@@ -859,7 +870,8 @@
   virtual void reset();
   virtual int getChar();
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue);
 
@@ -885,7 +897,8 @@
   virtual void reset();
   virtual int getChar();
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue);
   virtual GBool isEncoder() { return gTrue; }
@@ -912,7 +925,8 @@
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
   virtual GBool isEncoder() { return gTrue; }
@@ -944,7 +958,8 @@
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
   virtual GBool isEncoder() { return gTrue; }
@@ -976,7 +991,8 @@
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
   virtual int lookChar()
     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }
@@ -1012,7 +1028,8 @@
   virtual void reset();
   virtual int getChar();
   virtual int lookChar();
-  virtual GString *getPSFilter(int psLevel, const char *indent)
+  virtual GString *getPSFilter(int psLevel, const char *indent,
+			       GBool okToReadStream)
     { return NULL; }
   virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
   virtual GBool isEncoder() { return gTrue; }

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <math.h>
+#include <limits.h>
 #include <ctype.h>
 #ifdef _WIN32
 #include <fcntl.h> // for O_BINARY
@@ -111,7 +112,7 @@
 
 // In simple layout mode, lines are broken at gaps larger than this
 // value multiplied by font size.
-#define simpleLayoutGapThreshold 0.4
+#define simpleLayoutGapThreshold 0.7
 
 // Table cells (TextColumns) are allowed to overlap by this much
 // in table layout mode (as a fraction of cell width or height).
@@ -407,19 +408,52 @@
 }
 
 //------------------------------------------------------------------------
-// TextGap
+// TextGaps
 //------------------------------------------------------------------------
 
-class TextGap {
+struct TextGap {
+  double x;			// center of gap: x for vertical gaps,
+				//   y for horizontal gaps
+  double w;			// width/height of gap
+};
+
+class TextGaps {
 public:
 
-  TextGap(double aXY, double aW): xy(aXY), w(aW) {}
+  TextGaps();
+  ~TextGaps();
+  void addGap(double x, double w);
+  int getLength() { return length; }
+  double getX(int idx) { return gaps[idx].x; }
+  double getW(int idx) { return gaps[idx].w; }
 
-  double xy;			// center of gap: x for vertical gaps,
-				//   y for horizontal gaps
-  double w;			// width of gap
+private:
+
+  int length;
+  int size;
+  TextGap *gaps;
 };
 
+TextGaps::TextGaps() {
+  length = 0;
+  size = 16;
+  gaps = (TextGap *)gmallocn(size, sizeof(TextGap));
+}
+
+TextGaps::~TextGaps() {
+  gfree(gaps);
+}
+
+void TextGaps::addGap(double x, double w) {
+  if (length == size) {
+    size *= 2;
+    gaps = (TextGap *)greallocn(gaps, size, sizeof(TextGap));
+  }
+  gaps[length].x = x;
+  gaps[length].w = w;
+  ++length;
+}
+
 //------------------------------------------------------------------------
 // TextSuperLine
 //------------------------------------------------------------------------
@@ -508,6 +542,10 @@
   discardInvisibleText = gFalse;
   discardClippedText = gFalse;
   insertBOM = gFalse;
+  marginLeft = 0;
+  marginRight = 0;
+  marginTop = 0;
+  marginBottom = 0;
 }
 
 
@@ -1136,9 +1174,11 @@
       if (name && name[0] == 'm' && name[1] == '\0') {
 	mCode = code;
       }
-      if (letterCode < 0 && name && name[1] == '\0' &&
+      if (letterCode < 0 &&
+	  name &&
 	  ((name[0] >= 'A' && name[0] <= 'Z') ||
-	   (name[0] >= 'a' && name[0] <= 'z'))) {
+	   (name[0] >= 'a' && name[0] <= 'z')) &&
+	  name[1] == '\0') {
 	letterCode = code;
       }
       if (anyCode < 0 && name &&
@@ -1239,9 +1279,12 @@
   // throw away chars that aren't inside the page bounds
   // (and also do a sanity check on the character size)
   state->transform(x, y, &x1, &y1);
-  if (x1 + w1 < 0 || x1 > pageWidth ||
-      y1 + h1 < 0 || y1 > pageHeight ||
-      w1 > pageWidth || h1 > pageHeight) {
+  if (x1 + w1 < control.marginLeft ||
+      x1 > pageWidth - control.marginRight ||
+      y1 + h1 < control.marginTop ||
+      y1 > pageHeight - control.marginBottom ||
+      w1 > pageWidth ||
+      h1 > pageHeight) {
     charPos += nBytes;
     return;
   }
@@ -1876,8 +1919,9 @@
 	  if (fabs(ch2->yMin - ch->yMin) > rawModeLineDelta * ch->fontSize ||
 	      ch2->xMin - ch->xMax < -rawModeCharOverlap * ch->fontSize) {
 	    s->append(eol, eolLen);
-	  } else if (ch2->xMin - ch->xMax >
-		     rawModeWordSpacing * ch->fontSize) {
+	  } else if (ch->spaceAfter ||
+		     ch2->xMin - ch->xMax >
+		       rawModeWordSpacing * ch->fontSize) {
 	    s->append(space, spaceLen);
 	  }
 	  break;
@@ -1885,8 +1929,9 @@
 	  if (fabs(ch->xMax - ch2->xMax) > rawModeLineDelta * ch->fontSize ||
 	      ch2->yMin - ch->yMax < -rawModeCharOverlap * ch->fontSize) {
 	    s->append(eol, eolLen);
-	  } else if (ch2->yMin - ch->yMax >
-		     rawModeWordSpacing * ch->fontSize) {
+	  } else if (ch->spaceAfter ||
+		     ch2->yMin - ch->yMax >
+		       rawModeWordSpacing * ch->fontSize) {
 	    s->append(space, spaceLen);
 	  }
 	  break;
@@ -1894,8 +1939,9 @@
 	  if (fabs(ch->yMax - ch2->yMax) > rawModeLineDelta * ch->fontSize ||
 	      ch->xMin - ch2->xMax  < -rawModeCharOverlap * ch->fontSize) {
 	    s->append(eol, eolLen);
-	  } else if (ch->xMin - ch2->xMax >
-		     rawModeWordSpacing * ch->fontSize) {
+	  } else if (ch->spaceAfter ||
+		     ch->xMin - ch2->xMax >
+		       rawModeWordSpacing * ch->fontSize) {
 	    s->append(space, spaceLen);
 	  }
 	  break;
@@ -1903,8 +1949,9 @@
 	  if (fabs(ch2->xMin - ch->xMin) > rawModeLineDelta * ch->fontSize ||
 	      ch->yMin - ch2->yMax  < -rawModeCharOverlap * ch->fontSize) {
 	    s->append(eol, eolLen);
-	  } else if (ch->yMin - ch2->yMax >
-		     rawModeWordSpacing * ch->fontSize) {
+	  } else if (ch->spaceAfter ||
+		     ch->yMin - ch2->yMax >
+		       rawModeWordSpacing * ch->fontSize) {
 	    s->append(space, spaceLen);
 	  }
 	  break;
@@ -2693,12 +2740,11 @@
 TextBlock *TextPage::split(GList *charsA, int rot) {
   TextBlock *blk;
   GList *chars2, *chars3;
-  GList *horizGaps, *vertGaps;
-  TextGap *gap;
+  TextGaps *horizGaps, *vertGaps;
   TextChar *ch;
   double xMin, yMin, xMax, yMax, avgFontSize;
   double horizGapSize, vertGapSize, minHorizChunkWidth, minVertChunkWidth;
-  double nLines, vertGapThreshold, minChunk;
+  double gap, nLines, vertGapThreshold, minChunk;
   double largeCharSize;
   double x0, x1, y0, y1;
   int nHorizGaps, nVertGaps, nLargeChars;
@@ -2707,8 +2753,8 @@
 
   //----- find all horizontal and vertical gaps
 
-  horizGaps = new GList();
-  vertGaps = new GList();
+  horizGaps = new TextGaps();
+  vertGaps = new TextGaps();
   findGaps(charsA, rot, &xMin, &yMin, &xMax, &yMax, &avgFontSize,
 	   horizGaps, vertGaps);
 
@@ -2716,16 +2762,16 @@
 
   horizGapSize = 0;
   for (i = 0; i < horizGaps->getLength(); ++i) {
-    gap = (TextGap *)horizGaps->get(i);
-    if (gap->w > horizGapSize) {
-      horizGapSize = gap->w;
+    gap = horizGaps->getW(i);
+    if (gap > horizGapSize) {
+      horizGapSize = gap;
     }
   }
   vertGapSize = 0;
   for (i = 0; i < vertGaps->getLength(); ++i) {
-    gap = (TextGap *)vertGaps->get(i);
-    if (gap->w > vertGapSize) {
-      vertGapSize = gap->w;
+    gap = vertGaps->getW(i);
+    if (gap > vertGapSize) {
+      vertGapSize = gap;
     }
   }
 
@@ -2736,14 +2782,14 @@
   if (horizGaps->getLength() > 0) {
     y0 = yMin;
     for (i = 0; i < horizGaps->getLength(); ++i) {
-      gap = (TextGap *)horizGaps->get(i);
-      if (gap->w > horizGapSize - splitGapSlack * avgFontSize) {
+      gap = horizGaps->getW(i);
+      if (gap > horizGapSize - splitGapSlack * avgFontSize) {
 	++nHorizGaps;
-	y1 = gap->xy - 0.5 * gap->w;
+	y1 = horizGaps->getX(i) - 0.5 * gap;
 	if (y1 - y0 < minHorizChunkWidth) {
 	  minHorizChunkWidth = y1 - y0;
 	}
-	y0 = y1 + gap->w;
+	y0 = y1 + gap;
       }
     }
     y1 = yMax;
@@ -2756,14 +2802,14 @@
   if (vertGaps->getLength() > 0) {
     x0 = xMin;
     for (i = 0; i < vertGaps->getLength(); ++i) {
-      gap = (TextGap *)vertGaps->get(i);
-      if (gap->w > vertGapSize - splitGapSlack * avgFontSize) {
+      gap = vertGaps->getW(i);
+      if (gap > vertGapSize - splitGapSlack * avgFontSize) {
 	++nVertGaps;
-	x1 = gap->xy - 0.5 * gap->w;
+	x1 = vertGaps->getX(i) - 0.5 * gap;
 	if (x1 - x0 < minVertChunkWidth) {
 	  minVertChunkWidth = x1 - x0;
 	}
-	x0 = x1 + gap->w;
+	x0 = x1 + gap;
       }
     }
     x1 = xMax;
@@ -2881,9 +2927,8 @@
     printf("vert split xMin=%g yMin=%g xMax=%g yMax=%g small=%d\n",
 	   xMin, pageHeight - yMax, xMax, pageHeight - yMin, smallSplit);
     for (i = 0; i < vertGaps->getLength(); ++i) {
-      gap = (TextGap *)vertGaps->get(i);
-      if (gap->w > vertGapSize - splitGapSlack * avgFontSize) {
-	printf("    x=%g\n", gap->xy);
+      if (vertGaps->getW(i) > vertGapSize - splitGapSlack * avgFontSize) {
+	printf("    x=%g\n", vertGaps->getX(i));
       }
     }
 #endif
@@ -2891,9 +2936,8 @@
     blk->smallSplit = smallSplit;
     x0 = xMin - 1;
     for (i = 0; i < vertGaps->getLength(); ++i) {
-      gap = (TextGap *)vertGaps->get(i);
-      if (gap->w > vertGapSize - splitGapSlack * avgFontSize) {
-	x1 = gap->xy;
+      if (vertGaps->getW(i) > vertGapSize - splitGapSlack * avgFontSize) {
+	x1 = vertGaps->getX(i);
 	chars2 = getChars(charsA, x0, yMin - 1, x1, yMax + 1);
 	blk->addChild(split(chars2, rot));
 	delete chars2;
@@ -2910,9 +2954,8 @@
     printf("horiz split xMin=%g yMin=%g xMax=%g yMax=%g small=%d\n",
 	   xMin, pageHeight - yMax, xMax, pageHeight - yMin, smallSplit);
     for (i = 0; i < horizGaps->getLength(); ++i) {
-      gap = (TextGap *)horizGaps->get(i);
-      if (gap->w > horizGapSize - splitGapSlack * avgFontSize) {
-	printf("    y=%g\n", pageHeight - gap->xy);
+      if (horizGaps->getW(i) > horizGapSize - splitGapSlack * avgFontSize) {
+	printf("    y=%g\n", pageHeight - horizGaps->getX(i));
       }
     }
 #endif
@@ -2920,9 +2963,8 @@
     blk->smallSplit = smallSplit;
     y0 = yMin - 1;
     for (i = 0; i < horizGaps->getLength(); ++i) {
-      gap = (TextGap *)horizGaps->get(i);
-      if (gap->w > horizGapSize - splitGapSlack * avgFontSize) {
-	y1 = gap->xy;
+      if (horizGaps->getW(i) > horizGapSize - splitGapSlack * avgFontSize) {
+	y1 = horizGaps->getX(i);
 	chars2 = getChars(charsA, xMin - 1, y0, xMax + 1, y1);
 	blk->addChild(split(chars2, rot));
 	delete chars2;
@@ -2966,8 +3008,8 @@
     }
   }
 
-  deleteGList(horizGaps, TextGap);
-  deleteGList(vertGaps, TextGap);
+  delete horizGaps;
+  delete vertGaps;
 
   tagBlock(blk);
 
@@ -3001,11 +3043,12 @@
 			double *xMinOut, double *yMinOut,
 			double *xMaxOut, double *yMaxOut,
 			double *avgFontSizeOut,
-			GList *horizGaps, GList *vertGaps) {
+			TextGaps *horizGaps, TextGaps *vertGaps) {
   TextChar *ch;
-  int *horizProfile, *vertProfile;
+  char *horizProfile, *vertProfile;
   double xMin, yMin, xMax, yMax, w;
-  double minFontSize, avgFontSize, splitPrecision, ascentAdjust, descentAdjust;
+  double minFontSize, avgFontSize, splitPrecision, invSplitPrecision;
+  double ascentAdjust, descentAdjust;
   int xMinI, yMinI, xMaxI, yMaxI, xMinI2, yMinI2, xMaxI2, yMaxI2;
   int start, x, y, i;
 
@@ -3037,6 +3080,7 @@
   if (splitPrecision < minSplitPrecision) {
     splitPrecision = minSplitPrecision;
   }
+  invSplitPrecision = 1 / splitPrecision;
   *xMinOut = xMin;
   *yMinOut = yMin;
   *xMaxOut = xMax;
@@ -3045,16 +3089,22 @@
 
   //----- compute the horizontal and vertical profiles
 
+  if (xMin * invSplitPrecision < 0.5 * INT_MIN ||
+      xMax * invSplitPrecision > 0.5 * INT_MAX ||
+      yMin * invSplitPrecision < 0.5 * INT_MIN ||
+      xMax * invSplitPrecision > 0.5 * INT_MAX) {
+    return;
+  }
   // add some slack to the array bounds to avoid floating point
   // precision problems
-  xMinI = (int)floor(xMin / splitPrecision) - 1;
-  yMinI = (int)floor(yMin / splitPrecision) - 1;
-  xMaxI = (int)floor(xMax / splitPrecision) + 1;
-  yMaxI = (int)floor(yMax / splitPrecision) + 1;
-  horizProfile = (int *)gmallocn(yMaxI - yMinI + 1, sizeof(int));
-  vertProfile = (int *)gmallocn(xMaxI - xMinI + 1, sizeof(int));
-  memset(horizProfile, 0, (yMaxI - yMinI + 1) * sizeof(int));
-  memset(vertProfile, 0, (xMaxI - xMinI + 1) * sizeof(int));
+  xMinI = (int)floor(xMin * invSplitPrecision) - 1;
+  yMinI = (int)floor(yMin * invSplitPrecision) - 1;
+  xMaxI = (int)floor(xMax * invSplitPrecision) + 1;
+  yMaxI = (int)floor(yMax * invSplitPrecision) + 1;
+  horizProfile = (char *)gmalloc(yMaxI - yMinI + 1);
+  vertProfile = (char *)gmalloc(xMaxI - xMinI + 1);
+  memset(horizProfile, 0, yMaxI - yMinI + 1);
+  memset(vertProfile, 0, xMaxI - xMinI + 1);
   for (i = 0; i < charsA->getLength(); ++i) {
     ch = (TextChar *)charsA->get(i);
     // yMinI2 and yMaxI2 are adjusted to allow for slightly overlapping lines
@@ -3061,43 +3111,43 @@
     switch (rot) {
     case 0:
     default:
-      xMinI2 = (int)floor(ch->xMin / splitPrecision);
-      xMaxI2 = (int)floor(ch->xMax / splitPrecision);
+      xMinI2 = (int)floor(ch->xMin * invSplitPrecision);
+      xMaxI2 = (int)floor(ch->xMax * invSplitPrecision);
       ascentAdjust = ascentAdjustFactor * (ch->yMax - ch->yMin);
-      yMinI2 = (int)floor((ch->yMin + ascentAdjust) / splitPrecision);
+      yMinI2 = (int)floor((ch->yMin + ascentAdjust) * invSplitPrecision);
       descentAdjust = descentAdjustFactor * (ch->yMax - ch->yMin);
-      yMaxI2 = (int)floor((ch->yMax - descentAdjust) / splitPrecision);
+      yMaxI2 = (int)floor((ch->yMax - descentAdjust) * invSplitPrecision);
       break;
     case 1:
       descentAdjust = descentAdjustFactor * (ch->xMax - ch->xMin);
-      xMinI2 = (int)floor((ch->xMin + descentAdjust) / splitPrecision);
+      xMinI2 = (int)floor((ch->xMin + descentAdjust) * invSplitPrecision);
       ascentAdjust = ascentAdjustFactor * (ch->xMax - ch->xMin);
-      xMaxI2 = (int)floor((ch->xMax - ascentAdjust) / splitPrecision);
-      yMinI2 = (int)floor(ch->yMin / splitPrecision);
-      yMaxI2 = (int)floor(ch->yMax / splitPrecision);
+      xMaxI2 = (int)floor((ch->xMax - ascentAdjust) * invSplitPrecision);
+      yMinI2 = (int)floor(ch->yMin * invSplitPrecision);
+      yMaxI2 = (int)floor(ch->yMax * invSplitPrecision);
       break;
     case 2:
-      xMinI2 = (int)floor(ch->xMin / splitPrecision);
-      xMaxI2 = (int)floor(ch->xMax / splitPrecision);
+      xMinI2 = (int)floor(ch->xMin * invSplitPrecision);
+      xMaxI2 = (int)floor(ch->xMax * invSplitPrecision);
       descentAdjust = descentAdjustFactor * (ch->yMax - ch->yMin);
-      yMinI2 = (int)floor((ch->yMin + descentAdjust) / splitPrecision);
+      yMinI2 = (int)floor((ch->yMin + descentAdjust) * invSplitPrecision);
       ascentAdjust = ascentAdjustFactor * (ch->yMax - ch->yMin);
-      yMaxI2 = (int)floor((ch->yMax - ascentAdjust) / splitPrecision);
+      yMaxI2 = (int)floor((ch->yMax - ascentAdjust) * invSplitPrecision);
       break;
     case 3:
       ascentAdjust = ascentAdjustFactor * (ch->xMax - ch->xMin);
-      xMinI2 = (int)floor((ch->xMin + ascentAdjust) / splitPrecision);
+      xMinI2 = (int)floor((ch->xMin + ascentAdjust) * invSplitPrecision);
       descentAdjust = descentAdjustFactor * (ch->xMax - ch->xMin);
-      xMaxI2 = (int)floor((ch->xMax - descentAdjust) / splitPrecision);
-      yMinI2 = (int)floor(ch->yMin / splitPrecision);
-      yMaxI2 = (int)floor(ch->yMax / splitPrecision);
+      xMaxI2 = (int)floor((ch->xMax - descentAdjust) * invSplitPrecision);
+      yMinI2 = (int)floor(ch->yMin * invSplitPrecision);
+      yMaxI2 = (int)floor(ch->yMax * invSplitPrecision);
       break;
     }
     for (y = yMinI2; y <= yMaxI2; ++y) {
-      ++horizProfile[y - yMinI];
+      horizProfile[y - yMinI] = 1;
     }
     for (x = xMinI2; x <= xMaxI2; ++x) {
-      ++vertProfile[x - xMinI];
+      vertProfile[x - xMinI] = 1;
     }
   }
 
@@ -3112,8 +3162,7 @@
     } else {
       if (horizProfile[y + 1 - yMinI]) {
 	w = (y - start) * splitPrecision;
-	horizGaps->append(new TextGap((start + 1) * splitPrecision + 0.5 * w,
-				      w));
+	horizGaps->addGap((start + 1) * splitPrecision + 0.5 * w, w);
       }
     }
   }
@@ -3129,8 +3178,7 @@
     } else {
       if (vertProfile[x + 1 - xMinI]) {
 	w = (x - start) * splitPrecision;
-	vertGaps->append(new TextGap((start + 1) * splitPrecision + 0.5 * w,
-				     w));
+	vertGaps->addGap((start + 1) * splitPrecision + 0.5 * w, w);
       }
     }
   }
@@ -3818,18 +3866,27 @@
     minGap = 0;
   }
 
-  // if spacing is nearly uniform (minGap is close to maxGap), use the
-  // SpGap/AdjGap values if available, otherwise assume it's a single
-  // word (technically it could be either "ABC" or "A B C", but it's
-  // essentially impossible to tell)
+  // if spacing is nearly uniform (minGap is close to maxGap), there
+  // are three cases:
+  // (1) if the SpGap and AdjGap values are both available and
+  //     sensible, use them
+  // (2) if only the SpGap values are available, meaning that every
+  //     character in the line had a space after it, split after every
+  //     character
+  // (3) otherwise assume it's a single word (technically it could be
+  //     either "ABC" or "A B C", but it's essentially impossible to
+  //     tell)
   if (maxGap - minGap < uniformSpacing * avgFontSize) {
-    if (minAdjGap <= maxAdjGap &&
-	minSpGap <= maxSpGap &&
-	minSpGap - maxAdjGap > 0.01) {
-      return 0.5 * (maxAdjGap + minSpGap);
-    } else {
-      return maxGap + 1;
+    if (minSpGap <= maxSpGap) {
+      if (minAdjGap <= maxAdjGap &&
+	  minSpGap - maxAdjGap > 0.01) {
+	return 0.5 * (maxAdjGap + minSpGap);
+      } else if (minAdjGap > maxAdjGap &&
+		 maxSpGap - minSpGap < uniformSpacing * avgFontSize) {
+	return minSpGap - 1;
+      }
     }
+    return maxGap + 1;
 
   // if there is some variation in spacing, but it's small, assume
   // there are some inter-word spaces
@@ -4033,8 +4090,8 @@
 					   UnicodeMap *uMap) {
   GList *lines;
   TextLine *line0, *line1;
-  double xMin;
-  int px, sp, i, j;
+  double xMin, xMax;
+  int px, px2, sp, i, j;
 
   // build a list of lines and sort by x
   lines = new GList();
@@ -4048,21 +4105,25 @@
   for (i = 0; i < lines->getLength(); ++i) {
     line0 = (TextLine *)lines->get(i);
     computeLinePhysWidth(line0, uMap);
-    line0->px = (int)((line0->xMin - xMin) / (0.5 * line0->fontSize));
+    px = 0;
+    xMax = xMin;
     for (j = 0; j < i; ++j) {
       line1 = (TextLine *)lines->get(j);
       if (line0->xMin > line1->xMax) {
-	sp = (int)((line0->xMin - line1->xMax) /
-		   (0.5 * line0->fontSize) + 0.5);
-	if (sp < 1) {
-	  sp = 1;
+	if (line1->xMax > xMax) {
+	  xMax = line1->xMax;
 	}
-	px = line1->px + line1->pw + sp;
-	if (px > line0->px) {
-	  line0->px = px;
+	px2 = line1->px + line1->pw;
+	if (px2 > px) {
+	  px = px2;
 	}
       }
     }
+    sp = (int)((line0->xMin - xMax) / (0.5 * line0->fontSize) + 0.5);
+    if (sp < 1 && xMax > xMin) {
+      sp = 1;
+    }
+    line0->px = px + sp;
   }
 
   delete lines;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TextOutputDev.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -26,6 +26,7 @@
 
 class TextBlock;
 class TextChar;
+class TextGaps;
 class TextLink;
 class TextPage;
 
@@ -69,6 +70,10 @@
   GBool discardClippedText;	// discard all clipped characters
   GBool insertBOM;		// insert a Unicode BOM at the start of
 				//   the text output
+  double marginLeft,		// characters outside the margins are
+         marginRight,		//   discarded
+         marginTop,
+         marginBottom;
 };
 
 //------------------------------------------------------------------------
@@ -502,7 +507,7 @@
 		double *xMinOut, double *yMinOut,
 		double *xMaxOut, double *yMaxOut,
 		double *avgFontSizeOut,
-		GList *horizGaps, GList *vertGaps);
+		TextGaps *horizGaps, TextGaps *vertGaps);
   void tagBlock(TextBlock *blk);
   void insertLargeChars(GList *largeChars, TextBlock *blk);
   void insertLargeCharsInFirstLeaf(GList *largeChars, TextBlock *blk);

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileCompositor.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileCompositor.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileCompositor.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -67,7 +67,7 @@
     }
     bitmap = new SplashBitmap(state->getWinW(), state->getWinH(),
 			      state->getBitmapRowPad(), state->getColorMode(),
-			      gFalse);
+			      gFalse, gTrue, NULL);
   }
   clearBitmap();
 

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileMap.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileMap.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/TileMap.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -592,6 +592,11 @@
       offsetY = 0;
     }
     *pg = findContinuousPage(yw - offsetY + state->getScrollY());
+    if (*pg < 1 || *pg > state->getDoc()->getNumPages()) {
+      *pg = 0;
+      *xd = *yd = 0;
+      return gFalse;
+    }
     pageW1 = pageW[*pg - 1];
     pageH1 = pageH[*pg - 1];
     if (maxW < state->getWinW()) {
@@ -655,6 +660,11 @@
       offsetY = 0;
     }
     *pg = findSideBySideContinuousPage(yw - offsetY + state->getScrollY());
+    if (*pg < 1 || *pg > state->getDoc()->getNumPages()) {
+      *pg = 0;
+      *xd = *yd = 0;
+      return gFalse;
+    }
     pageW1 = pageW[*pg - 1];
     pageH1 = pageH[*pg - 1];
     if (*pg + 1 <= state->getDoc()->getNumPages()) {
@@ -693,6 +703,11 @@
       offsetX = 0;
     }
     *pg = findHorizContinuousPage(xw - offsetX + state->getScrollX());
+    if (*pg < 1 || *pg > state->getDoc()->getNumPages()) {
+      *pg = 0;
+      *xd = *yd = 0;
+      return gFalse;
+    }
     pageW1 = pageW[*pg - 1];
     pageH1 = pageH[*pg - 1];
     if (maxH < state->getWinH()) {

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/UTF8.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/UTF8.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/UTF8.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -6,6 +6,7 @@
 //
 //========================================================================
 
+#include <aconf.h>
 #include "UTF8.h"
 
 int mapUTF8(Unicode u, char *buf, int bufSize) {

Added: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.cc	                        (rev 0)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,384 @@
+//========================================================================
+//
+// WebFont.cc
+//
+// Copyright 2019 Glyph & Cog, LLC
+//
+//========================================================================
+
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
+#pragma implementation
+#endif
+
+#include "gmem.h"
+#include "gmempp.h"
+#include "GHash.h"
+#include "FoFiTrueType.h"
+#include "FoFiType1C.h"
+#include "CharCodeToUnicode.h"
+#include "WebFont.h"
+
+WebFont::WebFont(GfxFont *gfxFontA, XRef *xref) {
+  GfxFontType type;
+
+  gfxFont = gfxFontA;
+  fontBuf = NULL;
+  ffTrueType = NULL;
+  ffType1C = NULL;
+  isOpenType = gFalse;
+
+  type = gfxFont->getType();
+  if (type == fontTrueType ||
+      type == fontTrueTypeOT ||
+      type == fontCIDType2 ||
+      type == fontCIDType2OT) {
+    if ((fontBuf = gfxFont->readEmbFontFile(xref, &fontLength))) {
+      ffTrueType = FoFiTrueType::make(fontBuf, fontLength, 0);
+    }
+  } else if (type == fontType1C ||
+	     type == fontCIDType0C) {
+    if ((fontBuf = gfxFont->readEmbFontFile(xref, &fontLength))) {
+      ffType1C = FoFiType1C::make(fontBuf, fontLength);
+    }
+  } else if (type == fontType1COT ||
+	     type == fontCIDType0COT) {
+    if ((fontBuf = gfxFont->readEmbFontFile(xref, &fontLength))) {
+      isOpenType = gTrue;
+    }
+  }
+}
+
+WebFont::~WebFont() {
+  delete ffTrueType;
+  delete ffType1C;
+  gfree(fontBuf);
+}
+
+GBool WebFont::canWriteTTF() {
+  return ffTrueType != NULL;
+}
+
+GBool WebFont::canWriteOTF() {
+  return ffType1C || isOpenType;
+}
+
+static void writeToFile(void *stream, const char *data, int len) {
+  fwrite(data, 1, len, (FILE *)stream);
+}
+
+GBool WebFont::writeTTF(const char *fontFilePath) {
+  FILE *out;
+  int *codeToGID;
+  Guchar *cmapTable;
+  GBool freeCodeToGID;
+  int nCodes, cmapTableLength;
+
+  if (!ffTrueType) {
+    return gFalse;
+  }
+  if (gfxFont->isCIDFont()) {
+    codeToGID = ((GfxCIDFont *)gfxFont)->getCIDToGID();
+    nCodes = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
+    if (!codeToGID) {
+      nCodes = ffTrueType->getNumGlyphs();
+    }
+    freeCodeToGID = gFalse;
+  } else {
+    codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffTrueType);
+    nCodes = 256;
+    freeCodeToGID = gTrue;
+  }
+  cmapTable = makeUnicodeCmapTable(codeToGID, nCodes, &cmapTableLength);
+  if (freeCodeToGID) {
+    gfree(codeToGID);
+  }
+  if (!cmapTable) {
+    return gFalse;
+  }
+  if (!(out = fopen(fontFilePath, "wb"))) {
+    gfree(cmapTable);
+    return gFalse;
+  }
+  ffTrueType->writeTTF(writeToFile, out, NULL, NULL,
+		       cmapTable, cmapTableLength);
+  fclose(out);
+  gfree(cmapTable);
+  return gTrue;
+}
+
+GBool WebFont::writeOTF(const char *fontFilePath) {
+  int *codeToGID;
+  Gushort *widths;
+  Guchar *cmapTable;
+  FILE *out;
+  int nCodes, nWidths, cmapTableLength;
+
+  if (ffType1C) {
+    if (gfxFont->getType() == fontType1C) {
+      codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ffType1C);
+      if (!(cmapTable = makeUnicodeCmapTable(codeToGID, 256,
+					     &cmapTableLength))) {
+	gfree(codeToGID);
+	return gFalse;
+      }
+      widths = makeType1CWidths(codeToGID, 256, &nWidths);
+      gfree(codeToGID);
+    } else { // fontCIDType0C
+      codeToGID = ffType1C->getCIDToGIDMap(&nCodes);
+      if (!(cmapTable = makeUnicodeCmapTable(codeToGID, nCodes,
+					     &cmapTableLength))) {
+	gfree(codeToGID);
+	return gFalse;
+      }
+      widths = makeCIDType0CWidths(codeToGID, nCodes, &nWidths);
+      gfree(codeToGID);
+    }
+    if (!(out = fopen(fontFilePath, "wb"))) {
+      gfree(cmapTable);
+      gfree(widths);
+      return gFalse;
+    }
+    ffType1C->convertToOpenType(writeToFile, out,
+				nWidths, widths,
+				cmapTable, cmapTableLength);
+    fclose(out);
+    gfree(cmapTable);
+    gfree(widths);
+
+  } else if (isOpenType) {
+    if (!(out = fopen(fontFilePath, "wb"))) {
+      return gFalse;
+    }
+    if (fwrite(fontBuf, 1, fontLength, out) != (Guint)fontLength) {
+      fclose(out);
+      return gFalse;
+    }
+    fclose(out);
+
+  } else {
+    return gFalse;
+  }
+
+  return gTrue;
+}
+
+Gushort *WebFont::makeType1CWidths(int *codeToGID, int nCodes,
+				   int *nWidths) {
+  Gushort *widths;
+  Gushort width;
+  int widthsLen, gid, i;
+
+  widthsLen = ffType1C->getNumGlyphs();
+  widths = (Gushort *)gmallocn(widthsLen, sizeof(Gushort));
+  for (i = 0; i < widthsLen; ++i) {
+    widths[i] = 0;
+  }
+  for (i = 0; i < nCodes; ++i) {
+    gid = codeToGID[i];
+    if (gid < 0 || gid >= widthsLen) {
+      continue;
+    }
+    width = (Gushort)(((Gfx8BitFont *)gfxFont)->getWidth((Guchar)i)
+		      * 1000 + 0.5);
+    if (width == 0) {
+      continue;
+    }
+    widths[gid] = width;
+  }
+  *nWidths = widthsLen;
+  return widths;
+}
+
+Gushort *WebFont::makeCIDType0CWidths(int *codeToGID, int nCodes,
+				      int *nWidths) {
+  Gushort *widths;
+  Gushort width;
+  int widthsLen, gid, i;
+
+  widthsLen = ffType1C->getNumGlyphs();
+  widths = (Gushort *)gmallocn(widthsLen, sizeof(Gushort));
+  for (i = 0 ; i < widthsLen; ++i) {
+    widths[i] = 0;
+  }
+  for (i = 0; i < nCodes; ++i) {
+    gid = codeToGID[i];
+    if (gid < 0 || gid >= widthsLen) {
+      continue;
+    }
+    width = (Gushort)(((GfxCIDFont *)gfxFont)->getWidth((CID)i)
+		      * 1000 + 0.5);
+    if (width == 0) {
+      continue;
+    }
+    widths[gid] = width;
+  }
+  *nWidths = widthsLen;
+  return widths;
+}
+
+Guchar *WebFont::makeUnicodeCmapTable(int *codeToGID, int nCodes,
+				      int *unicodeCmapLength) {
+  int *unicodeToGID;
+  Guchar *cmapTable;
+  int unicodeToGIDLength, nMappings, len;
+  int nSegs, searchRange, entrySelector, rangeShift;
+  int glyphIdOffset, idRangeOffset;
+  int start, end, c, i;
+
+  if (!(unicodeToGID = makeUnicodeToGID(codeToGID, nCodes,
+					&unicodeToGIDLength))) {
+    return NULL;
+  }
+
+  // count the valid code-to-glyph mappings, and the sequences of
+  // consecutive valid mappings
+  // (note: char code 65535 is used to mark the end of table)
+  nMappings = 0;
+  nSegs = 1; // count the last segment, mapping 65535
+  for (c = 0; c < unicodeToGIDLength && c <= 65534; ++c) {
+    if (unicodeToGID[c]) {
+      ++nMappings;
+      if (c == 0 || !unicodeToGID[c-1]) {
+	++nSegs;
+      }
+    }
+  }
+
+  i = 1;
+  entrySelector = 0;
+  while (2 * i <= nSegs) {
+    i *= 2;
+    ++entrySelector;
+  }
+  searchRange = 1 << (entrySelector + 1);
+  rangeShift = 2 * nSegs - searchRange;
+
+  len = 28 + nSegs * 8 + nMappings * 2;
+  cmapTable = (Guchar *)gmalloc(len);
+
+  // header
+  cmapTable[ 0] = 0x00;	// table version
+  cmapTable[ 1] = 0x00;
+  cmapTable[ 2] = 0x00;	// number of cmaps
+  cmapTable[ 3] = 0x01;
+  cmapTable[ 4] = 0x00;	// platform[0]
+  cmapTable[ 5] = 0x03;
+  cmapTable[ 6] = 0x00;	// encoding[0]
+  cmapTable[ 7] = 0x01;
+  cmapTable[ 8] = 0x00;	// offset[0]
+  cmapTable[ 9] = 0x00;
+  cmapTable[10] = 0x00;
+  cmapTable[11] = 0x0c;
+
+  // table info
+  cmapTable[12] = 0x00;					// cmap format
+  cmapTable[13] = 0x04;
+  cmapTable[14] = (Guchar)((len - 12) >> 8);		// cmap length
+  cmapTable[15] = (Guchar)(len - 12);
+  cmapTable[16] = 0x00;					// cmap version
+  cmapTable[17] = 0x00;
+  cmapTable[18] = (Guchar)(nSegs >> 7);			// segCountX2
+  cmapTable[19] = (Guchar)(nSegs << 1);
+  cmapTable[20] = (Guchar)(searchRange >> 8);		// searchRange
+  cmapTable[21] = (Guchar)searchRange;
+  cmapTable[22] = (Guchar)(entrySelector >> 8);		// entrySelector
+  cmapTable[23] = (Guchar)entrySelector;
+  cmapTable[24] = (Guchar)(rangeShift >> 8);		// rangeShift
+  cmapTable[25] = (Guchar)rangeShift;
+  cmapTable[26 + nSegs*2    ] = 0;			// reservedPad
+  cmapTable[26 + nSegs*2 + 1] = 0;
+
+  i = 0;
+  glyphIdOffset = 28 + nSegs*8;
+  for (c = 0; c < unicodeToGIDLength && c <= 65534; ++c) {
+    if (unicodeToGID[c]) {
+      if (c == 0 || !unicodeToGID[c-1]) {
+	start = c;
+	cmapTable[28 + nSegs*2 + i*2    ] = (Guchar)(start >> 8);
+	cmapTable[28 + nSegs*2 + i*2 + 1] = (Guchar)start;
+	cmapTable[28 + nSegs*4 + i*2    ] = (Guchar)0;	// idDelta
+	cmapTable[28 + nSegs*4 + i*2 + 1] = (Guchar)0;
+	idRangeOffset = glyphIdOffset - (28 + nSegs*6 + i*2);
+	cmapTable[28 + nSegs*6 + i*2    ] = (Guchar)(idRangeOffset >> 8);
+	cmapTable[28 + nSegs*6 + i*2 + 1] = (Guchar)idRangeOffset;
+      }
+      if (c == 65534 || !unicodeToGID[c+1]) {
+	end = c;
+	cmapTable[26 + i*2    ] = (Guchar)(end >> 8);
+	cmapTable[26 + i*2 + 1] = (Guchar)end;
+	++i;
+      }
+      cmapTable[glyphIdOffset++] = (Guchar)(unicodeToGID[c] >> 8);
+      cmapTable[glyphIdOffset++] = (Guchar)unicodeToGID[c];
+    }
+  }
+
+  // last segment maps code 65535 to GID 0
+  cmapTable[26 + i*2    ] = (Guchar)0xff;		// end
+  cmapTable[26 + i*2 + 1] = (Guchar)0xff;
+  cmapTable[28 + nSegs*2 + i*2    ] = (Guchar)0xff;	// start
+  cmapTable[28 + nSegs*2 + i*2 + 1] = (Guchar)0xff;
+  cmapTable[28 + nSegs*4 + i*2    ] = (Guchar)0;	// idDelta
+  cmapTable[28 + nSegs*4 + i*2 + 1] = (Guchar)1;
+  cmapTable[28 + nSegs*6 + i*2    ] = (Guchar)0;	// idRangeOffset
+  cmapTable[28 + nSegs*6 + i*2 + 1] = (Guchar)0;
+
+  gfree(unicodeToGID);
+
+  *unicodeCmapLength = len;
+  return cmapTable;
+}
+
+int *WebFont::makeUnicodeToGID(int *codeToGID, int nCodes,
+			       int *unicodeToGIDLength) {
+  int *unicodeToGID;
+  CharCodeToUnicode *ctu;
+  Unicode u[2];
+  int len, size, newSize, uLen, c, gid;
+
+  if (gfxFont->isCIDFont()) {
+    if (!(ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) {
+      return NULL;
+    }
+  } else {
+    ctu = ((Gfx8BitFont *)gfxFont)->getToUnicode();
+  }
+
+  len = 0;
+  size = 256;
+  unicodeToGID = (int *)gmallocn(size, sizeof(int));
+  memset(unicodeToGID, 0, size * sizeof(int));
+  for (c = 0; c < nCodes; ++c) {
+    gid = codeToGID ? codeToGID[c] : c;
+    if (gid < 0 || gid >= 65536) {
+      continue;
+    }
+    uLen = ctu->mapToUnicode(c, u, 2);
+    if (uLen != 1) {
+      continue;
+    }
+    if (u[0] >= 65536) {    // sanity check
+      continue;
+    }
+    if ((int)u[0] >= size) {
+      newSize = 2 * size;
+      while ((int)u[0] >= newSize) {
+	newSize *= 2;
+      }
+      unicodeToGID = (int *)greallocn(unicodeToGID, newSize, sizeof(int));
+      memset(unicodeToGID + size, 0, (newSize - size) * sizeof(int));
+      size = newSize;
+    }
+    unicodeToGID[u[0]] = gid;
+    if ((int)u[0] >= len) {
+      len = u[0] + 1;
+    }
+  }
+
+  ctu->decRefCnt();
+
+  *unicodeToGIDLength = len;
+  return unicodeToGID;
+}


Property changes on: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.cc
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.h	                        (rev 0)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,69 @@
+//========================================================================
+//
+// WebFont.h
+//
+// Modify/convert embedded PDF fonts to a form usable by web browsers.
+//
+// Copyright 2019 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef WEBFONT_H
+#define WEBFONT_H
+
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
+#pragma interface
+#endif
+
+#include "gtypes.h"
+#include "GfxFont.h"
+
+class FoFiTrueType;
+class FoFiType1C;
+class XRef;
+
+//------------------------------------------------------------------------
+
+class WebFont {
+public:
+
+  WebFont(GfxFont *gfxFontA, XRef *xref);
+
+  ~WebFont();
+
+  // Returns true if the font is, or can be converted to, a TrueType
+  // font.
+  GBool canWriteTTF();
+
+  // Returns true if the font is, or can be converted to, an OpenType
+  // font.
+  GBool canWriteOTF();
+
+  // Write a TrueType (.ttf) file to [fontFilePath].  This can only be
+  // called if canWriteTTF() returns true.  Returns true on success.
+  GBool writeTTF(const char *fontFilePath);
+
+  // Write an OpenType (.otf) file to [fontFilePath].  This can only
+  // be called if canWriteOTF() returns true.  Returns true on
+  // success.
+  GBool writeOTF(const char *fontFilePath);
+
+private:
+
+  Gushort *makeType1CWidths(int *codeToGID, int nCodes, int *nWidths);
+  Gushort *makeCIDType0CWidths(int *codeToGID, int nCodes, int *nWidths);
+  Guchar *makeUnicodeCmapTable(int *codeToGID, int nCodes,
+			       int *unicodeCmapLength);
+  int *makeUnicodeToGID(int *codeToGID, int nCodes, int *unicodeToGIDLength);
+
+  GfxFont *gfxFont;
+  char *fontBuf;
+  int fontLength;
+  FoFiTrueType *ffTrueType;
+  FoFiType1C *ffType1C;
+  GBool isOpenType;
+};
+
+#endif


Property changes on: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/WebFont.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -25,6 +25,7 @@
 #include "GfxFont.h"
 #include "Zoox.h"
 #include "PDF417Barcode.h"
+#include "UTF8.h"
 #include "XFAForm.h"
 
 #ifdef _WIN32
@@ -446,7 +447,7 @@
       fullNameIdx = new GHash();
       xfaForm->scanNode(tmpl, name, fullName, gFalse, NULL,
 			nameCount, nameIdx, fullNameCount, fullNameIdx,
-			catalog);
+			NULL, catalog);
       delete nameCount;
       delete nameIdx;
       delete fullNameCount;
@@ -504,11 +505,6 @@
   gfree(pageOffsetY);
 }
 
-//~ need to handle exclGroup
-//~ - fields in an exclGroup may/must(?) not have names
-//~ - each field has an items element with the the value when that
-//~   field is selected
-
 // Scan <elem>.  Constructs the node's name and full name.  If <elem>
 // is a field, creates an XFAFormField; else scans <elem>'s children.
 void XFAForm::scanNode(ZxElement *elem,
@@ -516,7 +512,7 @@
 		       GBool inPageSet, XFATableInfo *tableInfo,
 		       GHash *nameCount, GHash *nameIdx,
 		       GHash *fullNameCount, GHash *fullNameIdx,
-		       Catalog *catalog) {
+		       GString *exclGroupName, Catalog *catalog) {
   ZxAttr *attr;
   GString *name, *fullName, *namePart, *fullNamePart;
   GHash *childNameCount, *childNameIdx, *childFullNameCount, *childFullNameIdx;
@@ -575,7 +571,8 @@
   }
 
   if (elem->isElement("field")) {
-    scanField(elem, name, fullName, inPageSet, tableInfo, colSpan, catalog);
+    scanField(elem, name, fullName, exclGroupName,
+	      inPageSet, tableInfo, colSpan, catalog);
   } else {
     scanNonField(elem, name, fullName, inPageSet, tableInfo, colSpan,
 		 childNameCount, childNameIdx,
@@ -652,7 +649,7 @@
 }
 
 void XFAForm::scanField(ZxElement *elem, GString *name, GString *fullName,
-			GBool inPageSet,
+			GString *exclGroupName, GBool inPageSet,
 			XFATableInfo *tableInfo, int colSpan,
 			Catalog *catalog) {
   double xSubOffset, ySubOffset, columnWidth, rowHeight;
@@ -679,6 +676,8 @@
   }
 
   fields->append(new XFAFormField(this, elem, name->copy(), fullName->copy(),
+				  exclGroupName ? exclGroupName->copy()
+				                : (GString *)NULL,
 				  curPageNum, curXOffset, curYOffset,
 				  columnWidth, rowHeight));
 
@@ -699,6 +698,7 @@
   ZxNode *child;
   ZxAttr *attr;
   PDFRectangle *box;
+  GString *exclGroupName;
   double xSubOffset, ySubOffset;
   int savedPageNum;
 
@@ -744,7 +744,8 @@
     curXOffset += xSubOffset;
     curYOffset += ySubOffset;
 
-  } else if (elem->isElement("area")) {
+  } else if (elem->isElement("area") ||
+	     elem->isElement("exclGroup")) {
     xSubOffset = XFAFormField::getMeasurement(elem->findAttr("x"), 0);
     ySubOffset = XFAFormField::getMeasurement(elem->findAttr("y"), 0);
     curXOffset += xSubOffset;
@@ -780,11 +781,17 @@
     }
   }
 
+  if (elem->isElement("exclGroup")) {
+    exclGroupName = name;
+  } else {
+    exclGroupName = NULL;
+  }
+
   for (child = elem->getFirstChild(); child; child = child->getNextChild()) {
     if (child->isElement()) {
       scanNode((ZxElement *)child, name, fullName, inPageSet,
 	       newTableInfo, nameCount, nameIdx, fullNameCount, fullNameIdx,
-	       catalog);
+	       exclGroupName, catalog);
     }
   }
 
@@ -871,6 +878,7 @@
 
 XFAFormField::XFAFormField(XFAForm *xfaFormA, ZxElement *xmlA,
 			   GString *nameA, GString *fullNameA,
+			   GString *exclGroupNameA,
 			   int pageNumA, double xOffsetA, double yOffsetA,
 			   double columnWidthA, double rowHeightA) {
   xfaForm = xfaFormA;
@@ -877,6 +885,7 @@
   xml = xmlA;
   name = nameA;
   fullName = fullNameA;
+  exclGroupName = exclGroupNameA;
   pageNum = pageNumA;
   xOffset = xOffsetA;
   yOffset = yOffsetA;
@@ -887,6 +896,9 @@
 XFAFormField::~XFAFormField() {
   delete name;
   delete fullName;
+  if (exclGroupName) {
+    delete exclGroupName;
+  }
 }
 
 int XFAFormField::getPageNum() {
@@ -943,7 +955,9 @@
 	s = getFieldValue("text");
 	break;
       } else if (node->isElement("checkButton")) {
-	s = getFieldValue("integer");
+	if (!(s = getFieldValue("integer"))) {
+	  s = getFieldValue("text");
+	}
 	break;
       } else if (node->isElement("barcode")) {
 	s = getFieldValue("text");
@@ -1921,6 +1935,22 @@
       }
     }
   }
+  if (exclGroupName) {
+    p = exclGroupName->getCString();
+    if (xfaForm->xml->getRoot() && !strncmp(p, "form.",  5)) {
+      if ((datasets =
+	   xfaForm->xml->getRoot()->findFirstChildElement("xfa:datasets")) &&
+	  (data = datasets->findFirstChildElement("xfa:data"))) {
+	elem = findFieldInDatasets(data, p + 5);
+	if (elem &&
+	    elem->getFirstChild() &&
+	    elem->getFirstChild()->isCharData() &&
+	    ((ZxCharData *)elem->getFirstChild())->getData()->getLength() > 0) {
+	  return ((ZxCharData *)elem->getFirstChild())->getData();
+	}
+      }
+    }
+  }
 
   // check the <form> element
   p = fullName->getCString();
@@ -1955,7 +1985,9 @@
 
 ZxElement *XFAFormField::findFieldInDatasets(ZxElement *elem, char *partName) {
   ZxNode *node;
+  ZxElement *result;
   GString *nodeName;
+  char *next;
   int curIdx, idx, n;
 
   curIdx = 0;
@@ -1976,11 +2008,21 @@
 	if (!partName[n]) {
 	  return (ZxElement *)node;
 	} else if (partName[n] == '.') {
-	  return findFieldInDatasets((ZxElement *)node, partName + n + 1);
+	  if ((result = findFieldInDatasets((ZxElement *)node,
+					    partName + n + 1))) {
+	    return result;
+	  }
+	  break;
 	}
       }
     }
   }
+
+  // search for an "ancestor match"
+  if ((next = strchr(partName, '.'))) {
+    return findFieldInDatasets(elem, next + 1);
+  }
+
   return NULL;
 }
 
@@ -2054,14 +2096,26 @@
 			    double x, double y, double w, double h,
 			    GBool whiteBackground,
 			    GfxFontDict *fontDict, GString *appearBuf) {
+  GString *text2;
   GfxFont *font;
   const char *fontTag;
   GString *s;
+  Unicode u;
   double yTop, xx, yy, tw, charWidth, lineHeight;
   double ascent, descent, rectX, rectY, rectW, rectH, blkH;
   int nLines, line, i, j, k, c, rectI;
 
-  //~ deal with Unicode text (is it UTF-8?)
+  // convert UTF-8 to Latin1
+  //~ this currently drops all non-Latin1 characters
+  text2 = new GString();
+  i = 0;
+  while (getUTF8(text, &i, &u)) {
+    if (u <= 0xff) {
+      text2->append((char)u);
+    } else {
+      text2->append('?');
+    }
+  }
 
   // find the font
   if ((font = findFont(fontDict, fontName, bold, italic))) {
@@ -2093,8 +2147,8 @@
     if (vAlign == xfaVAlignBottom || vAlign == xfaVAlignMiddle) {
       nLines = 0;
       i = 0;
-      while (i < text->getLength()) {
-	getNextLine(text, i, font, fontSize, w, &j, &tw, &k);
+      while (i < text2->getLength()) {
+	getNextLine(text2, i, font, fontSize, w, &j, &tw, &k);
 	++nLines;
 	i = k;
       }
@@ -2114,9 +2168,9 @@
     // write a series of lines of text
     line = 0;
     i = 0;
-    while (i < text->getLength()) {
+    while (i < text2->getLength()) {
 
-      getNextLine(text, i, font, fontSize, w, &j, &tw, &k);
+      getNextLine(text2, i, font, fontSize, w, &j, &tw, &k);
       if (tw > rectW) {
 	rectW = tw;
       }
@@ -2140,7 +2194,7 @@
       appearBuf->appendf("1 0 0 1 {0:.4f} {1:.4f} Tm\n", xx, yy);
       appearBuf->append('(');
       for (; i < j; ++i) {
-	c = text->getChar(i) & 0xff;
+	c = text2->getChar(i) & 0xff;
 	if (c == '(' || c == ')' || c == '\\') {
 	  appearBuf->append('\\');
 	  appearBuf->append((char)c);
@@ -2172,13 +2226,13 @@
       xx = x;
       break;
     case xfaHAlignCenter:
-      xx = x + (int)(0.5 * (combCells - text->getLength())) * tw;
+      xx = x + (int)(0.5 * (combCells - text2->getLength())) * tw;
       break;
     case xfaHAlignRight:
-      xx = x + w - text->getLength() * tw;
+      xx = x + w - text2->getLength() * tw;
       break;
     }
-    rectW = text->getLength() * tw;
+    rectW = text2->getLength() * tw;
     switch (vAlign) {
     case xfaVAlignTop:
     default:
@@ -2195,8 +2249,8 @@
     rectH = ascent - descent;
 
     // write the text string
-    for (i = 0; i < text->getLength(); ++i) {
-      c = text->getChar(i) & 0xff;
+    for (i = 0; i < text2->getLength(); ++i) {
+      c = text2->getChar(i) & 0xff;
       if (font && !font->isCIDFont()) {
 	charWidth = fontSize * ((Gfx8BitFont *)font)->getWidth((Guchar)c);
 	appearBuf->appendf("1 0 0 1 {0:.4f} {1:.4f} Tm\n",
@@ -2223,12 +2277,12 @@
     // compute string width
     if (font && !font->isCIDFont()) {
       tw = 0;
-      for (i = 0; i < text->getLength(); ++i) {
-	tw += ((Gfx8BitFont *)font)->getWidth(text->getChar(i));
+      for (i = 0; i < text2->getLength(); ++i) {
+	tw += ((Gfx8BitFont *)font)->getWidth(text2->getChar(i));
       }
     } else {
       // otherwise, make a crude estimate
-      tw = text->getLength() * 0.5;
+      tw = text2->getLength() * 0.5;
     }
     tw *= fontSize;
     rectW = tw;
@@ -2264,8 +2318,8 @@
 
     // write the text string
     appearBuf->append('(');
-    for (i = 0; i < text->getLength(); ++i) {
-      c = text->getChar(i) & 0xff;
+    for (i = 0; i < text2->getLength(); ++i) {
+      c = text2->getChar(i) & 0xff;
       if (c == '(' || c == ')' || c == '\\') {
 	appearBuf->append('\\');
 	appearBuf->append((char)c);
@@ -2304,6 +2358,8 @@
     appearBuf->insert(rectI, s);
     delete s;
   }
+
+  delete text2;
 }
 
 // Searches <fontDict> for a font matching(<fontName>, <bold>,
@@ -2734,7 +2790,7 @@
 	      u <<= 4;
 	      if (c >= '0' && c <= '9') {
 		u += c - '0';
-	      } else if (c >= 'a' && c <= 'F') {
+	      } else if (c >= 'a' && c <= 'f') {
 		u += c - 'a' + 10;
 	      } else if (c >= 'A' && c <= 'F') {
 		u += c - 'A' + 10;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/XFAForm.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -63,11 +63,11 @@
 		GBool inPageSet, XFATableInfo *tableInfo,
 		GHash *nameCount, GHash *nameIdx,
 		GHash *fullNameCount, GHash *fullNameIdx,
-		Catalog *catalog);
+		GString *exclGroupName, Catalog *catalog);
   void scanNames(ZxElement *elem, GHash *nameCount);
   void scanFullNames(ZxElement *elem, GHash *fullNameCount);
   void scanField(ZxElement *elem, GString *name, GString *fullName,
-		 GBool inPageSet,
+		 GString *exclGroupName, GBool inPageSet,
 		 XFATableInfo *tableInfo, int colSpan,
 		 Catalog *catalog);
   void scanNonField(ZxElement *elem, GString *name, GString *fullName,
@@ -102,7 +102,7 @@
 public:
 
   XFAFormField(XFAForm *xfaFormA, ZxElement *xmlA,
-	       GString *nameA, GString *fullNameA,
+	       GString *nameA, GString *fullNameA, GString *exclGroupNameA,
 	       int pageNumA, double xOffsetA, double yOffsetA,
 	       double columnWidthA, double rowHeightA);
 
@@ -166,6 +166,7 @@
   ZxElement *xml;
   GString *name;
   GString *fullName;
+  GString *exclGroupName;
   int pageNum;
   double xOffset, yOffset;
   double columnWidth;		// column width, if this field is in a

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/config.h
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/config.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/config.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -14,14 +14,14 @@
 //------------------------------------------------------------------------
 
 // xpdf version
-#define xpdfVersion          "4.01.01"
-#define xpdfVersionNum       4.01
+#define xpdfVersion          "4.02"
+#define xpdfVersionNum       4.02
 #define xpdfMajorVersion     4
-#define xpdfMinorVersion     1
-#define xpdfUpdateVersion    1
+#define xpdfMinorVersion     2
+#define xpdfUpdateVersion    0
 #define xpdfMajorVersionStr  "4"
-#define xpdfMinorVersionStr  "1"
-#define xpdfUpdateVersionStr "1"
+#define xpdfMinorVersionStr  "2"
+#define xpdfUpdateVersionStr "0"
 
 // supported PDF version
 #define supportedPDFVersionStr "2.0"
@@ -31,7 +31,7 @@
 #define xpdfCopyright "Copyright 1996-2019 Glyph & Cog, LLC"
 
 // Windows resource file stuff
-#define winxpdfVersion "WinXpdf 4.01.01"
+#define winxpdfVersion "WinXpdf 4.02"
 #define xpdfCopyrightAmp "Copyright 1996-2019 Glyph && Cog, LLC"
 
 //------------------------------------------------------------------------

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdffonts.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdffonts.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdffonts.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -159,11 +159,11 @@
 
   // scan the fonts
   if (showFontLoc || showFontLocPS) {
-    printf("name                                 type              emb sub uni prob object ID location\n");
-    printf("------------------------------------ ----------------- --- --- --- ---- --------- --------\n");
+    printf("name                                           type              emb sub uni prob object ID location\n");
+    printf("---------------------------------------------- ----------------- --- --- --- ---- --------- --------\n");
   } else {
-    printf("name                                 type              emb sub uni prob object ID\n");
-    printf("------------------------------------ ----------------- --- --- --- ---- ---------\n");
+    printf("name                                           type              emb sub uni prob object ID\n");
+    printf("---------------------------------------------- ----------------- --- --- --- ---- ---------\n");
   }
   fonts = NULL;
   fontsLen = fontsSize = 0;
@@ -302,7 +302,7 @@
   resDict->lookupNF("ExtGState", &gsDict1);
   if (checkObject(&gsDict1, &gsDict2) && gsDict2.isDict()) {
     for (i = 0; i < gsDict2.dictGetLength(); ++i) {
-      gsDict1.dictGetValNF(i, &gs1);
+      gsDict2.dictGetValNF(i, &gs1);
       if (checkObject(&gs1, &gs2) && gs2.isDict()) {
 	gs2.dictLookupNF("SMask", &smask1);
 	if (checkObject(&smask1, &smask2) && smask2.isDict()) {
@@ -375,7 +375,7 @@
   }
 
   // print the font info
-  printf("%-36s %-17s %-3s %-3s %-3s %-4s",
+  printf("%-46s %-17s %-3s %-3s %-3s %-4s",
 	 name ? name->getCString() : "[none]",
 	 fontTypeNames[font->getType()],
 	 emb ? "yes" : "no",

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -171,6 +171,7 @@
   htmlGen->setZoom(zoom);
   htmlGen->setDrawInvisibleText(!skipInvisible);
   htmlGen->setAllTextInvisible(allInvisible);
+  htmlGen->setExtractFontFiles(gTrue);
   htmlGen->startDoc(doc);
 
   // convert the pages
@@ -191,7 +192,7 @@
       goto err2;
     }
     pngURL = GString::format("page{0:d}.png", pg);
-    err = htmlGen->convertPage(pg, pngURL->getCString(),
+    err = htmlGen->convertPage(pg, pngURL->getCString(), htmlDir,
 			       &writeToFile, htmlFile,
 			       &writeToFile, pngFile);
     delete pngURL;

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftopng.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftopng.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftopng.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -352,6 +352,7 @@
 
 
 
+
 static void finishPNG(png_structp *png, png_infop *pngInfo) {
   if (setjmp(png_jmpbuf(*png))) {
     exit(2);

Modified: branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftotext.cc
===================================================================
--- branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftotext.cc	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/libs/xpdf/xpdf-src/xpdf/pdftotext.cc	2019-11-23 23:34:02 UTC (rev 816)
@@ -50,6 +50,10 @@
 static char textEOL[16] = "";
 static GBool noPageBreaks = gFalse;
 static GBool insertBOM = gFalse;
+static double marginLeft = 0;
+static double marginRight = 0;
+static double marginTop = 0;
+static double marginBottom = 0;
 static char ownerPassword[33] = "\001";
 static char userPassword[33] = "\001";
 static GBool quiet = gFalse;
@@ -88,6 +92,14 @@
    "don't insert page breaks between pages"},
   {"-bom",     argFlag,     &insertBOM,     0,
    "insert a Unicode BOM at the start of the text file"},
+  {"-marginl", argFP,       &marginLeft,    0,
+   "left page margin"},
+  {"-marginr", argFP,       &marginRight,   0,
+   "right page margin"},
+  {"-margint", argFP,       &marginTop,     0,
+   "top page margin"},
+  {"-marginb", argFP,       &marginBottom,  0,
+   "bottom page margin"},
   {"-opw",     argString,   ownerPassword,  sizeof(ownerPassword),
    "owner password (for encrypted files)"},
   {"-upw",     argString,   userPassword,   sizeof(userPassword),
@@ -247,6 +259,10 @@
   textOutControl.clipText = clipText;
   textOutControl.discardDiagonalText = discardDiag;
   textOutControl.insertBOM = insertBOM;
+  textOutControl.marginLeft = marginLeft;
+  textOutControl.marginRight = marginRight;
+  textOutControl.marginTop = marginTop;
+  textOutControl.marginBottom = marginBottom;
   textOut = new TextOutputDev(textFileName->getCString(), &textOutControl,
 			      gFalse);
   if (textOut->isOk()) {

Modified: branches/stable/source/src/texk/kpathsea/ChangeLog
===================================================================
--- branches/stable/source/src/texk/kpathsea/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,75 @@
+2019-11-03  Karl Berry  <karl at tug.org>
+
+	* progname.c: remove nowadays-useless register declarations.
+	Mentioned by Doug McKenna.
+
+2019-10-10  Karl Berry  <karl at tug.org>
+
+	* texmf.cnf (LUAINPUTS.luahblatex{,-dev}): define a la other
+	LUAINPUTS.*. Report from Marcel Fabian Krueger, 10 Oct 2019 23:08:37.
+
+2019-09-04  Akira Kakuto  <kakuto at w32tex.org>
+
+	* hash.c: Typo in a comment.
+
+2019-08-13  Karl Berry  <karl at freefriends.org>
+
+	* cnf.c (do_line): warn about a program name qualifier which is
+	empty or contains one of our usual special characters: .{}$;:
+	since it is probably a misparsing, especially if the = is omitted.
+	Report from Johannes Kunde, 1 Aug 2019 20:57:14.
+	* Makefile.am (TESTS): new tests/cnfprog.test
+	(cnfprog.log): another target for kpsewhich.
+	(EXTRA_DIST): add tests/cnfprog/texmf.cnf.
+	* doc/kpathsea.texi (Config files): mention example of above.
+
+2019-08-09  Karl Berry  <karl at freefriends.org>
+
+	* texmf.cnf (log_openout): new configuration variable, true
+	by default for all but tex and initex, to remove one technical
+	trip incompatibility. Report from David Fuchs.
+
+	* cnf.c,
+	* progname.h,
+	* tex-file.c,
+	* types.h: doc/formatting fixes.
+
+2019-08-06  Karl Berry  <karl at freefriends.org>
+
+	* kpsewhich.c (USAGE, read_command_line): new option --cnf-line.
+	(user_cnf_lines, user_cnf_nlines): new variables to store the args.
+	(init_more): call kpathsea_cnf_line_env_progname on each line.
+
+	* cnf.h (kpathsea_cnf_line_env_progname): declare new fn.
+	* cnf.c (do_line): new argument ENV_PROGNAME,
+	to insert settings in the environment instead of the hash table.
+	(kpathsea_cnf_line_env_progname): entry point to call do_line
+	with env_progname=true.
+	(read_all_cnf): change do_line call to have env_progname=false.
+	Also, don't create cnf_hash here, instead ...
+	(kpathsea_cnf_get): ... here (if needed).
+
+	* tests/cnfline.test: new test for --cnf-line.
+	* tests/cnfline/texmf.cnf: new directory/file for cnfline.test.
+	* Makefile.am (tests),
+	(tests/cnfline.log),
+	(EXTRA_DIST): add new test.
+	* doc/kpathsea.texi (Path sources, Path searching options): doc.
+
+2019-07-26  Karl Berry  <karl at tug.org>
+
+	* texmf.cnf (TEXINPUTS, etc.): include explicit latex,
+	element at end so that files under latex/ are preferred to those
+	under latex-dev/. From Ulrike Fischer.
+
+	* texmf.cnf (TEXINPUTS.latex-dev, *-dev): new -dev format
+	names for LaTeX pre-release testing.
+
+2019-07-24  Akira Kakuto  <kakuto at w32tex.org>
+
+	* texmf.cnf: Define command_line_encoding = utf-8 for
+	Windows only.
+
 2019-07-11  Karl Berry  <karl at tug.org>
 
 	* texmf.cnf (TEXINPUTS.lua{,jit}hb{,la}tex): four new engines,
@@ -1274,7 +1346,7 @@
 
 2012-03-04  Peter Breitenlohner  <peb at mppmu.mpg.de>
 
-	Avoid 'the address of XXX will always evaluate as true' warnings.
+	Avoid 'the address of X will always evaluate as true' warnings.
 	* lib.h (STREQ): Test '(s) != NULL' instead of '(s)'.
 	Gcc >=4.3 produces identical code but -Wall yields no warning.
 

Modified: branches/stable/source/src/texk/kpathsea/Makefile.am
===================================================================
--- branches/stable/source/src/texk/kpathsea/Makefile.am	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/Makefile.am	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
-## $Id: Makefile.am 47973 2018-06-10 06:12:41Z takuji $
+## $Id: Makefile.am 51875 2019-08-13 22:43:09Z karl $
 ## Makefile.am for the TeX Live subdirectory texk/kpathsea/
 ##
-## Copyright 2017 Karl Berry <tex-live at tug.org>
+## Copyright 2017-2019 Karl Berry <tex-live at tug.org>
 ## Copyright 2009-2015 Peter Breitenlohner <tex-live at tug.org>
 ## You may freely use, modify and/or distribute this file.
 
@@ -307,16 +307,20 @@
 AM_TESTS_ENVIRONMENT  = LN_S='$(LN_S)'; export LN_S;
 AM_TESTS_ENVIRONMENT += LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR;
 #
-TESTS  = tests/cnfnewline.test tests/kpseaccess.test
+TESTS  = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test
+TESTS += tests/kpseaccess.test
 TESTS += tests/kpsereadlink.test tests/kpsestat.test tests/kpsewhich.test
 #
-tests/cnfnewline.log tests/kpsewhich.log: kpsewhich$(EXEEXT)
+tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \
+  tests/kpsewhich.log: kpsewhich$(EXEEXT)
 tests/kpseaccess.log: kpseaccess$(EXEEXT)
 tests/kpsereadlink.log: kpsereadlink$(EXEEXT)
 tests/kpsestat.log: kpsestat$(EXEEXT)
 #
 EXTRA_DIST += $(TESTS)
+EXTRA_DIST += tests/cnfline/texmf.cnf
 EXTRA_DIST += tests/cnfnewline/texmf.cnf
+EXTRA_DIST += tests/cnfprog/texmf.cnf
 
 # Rebuild
 rebuild_prereq =

Modified: branches/stable/source/src/texk/kpathsea/Makefile.in
===================================================================
--- branches/stable/source/src/texk/kpathsea/Makefile.in	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/Makefile.in	2019-11-23 23:34:02 UTC (rev 816)
@@ -759,7 +759,8 @@
 SUBDIRS = . doc man $(am__append_6)
 #
 EXTRA_DIST = PROJECTS putenv.c bsnl.awk cnf-to-paths.awk $(TESTS) \
-	tests/cnfnewline/texmf.cnf mktex.cnf
+	tests/cnfline/texmf.cnf tests/cnfnewline/texmf.cnf \
+	tests/cnfprog/texmf.cnf mktex.cnf
 AM_CPPFLAGS = -I$(top_builddir)/.. -I$(top_srcdir)/..
 AM_CFLAGS = $(WARNING_CFLAGS)
 lib_LTLIBRARIES = libkpathsea.la
@@ -866,9 +867,9 @@
 AM_TESTS_ENVIRONMENT = LN_S='$(LN_S)'; export LN_S; \
 	LT_OBJDIR='$(LT_OBJDIR)'; export LT_OBJDIR;
 #
-TESTS = tests/cnfnewline.test tests/kpseaccess.test \
-	tests/kpsereadlink.test tests/kpsestat.test \
-	tests/kpsewhich.test
+TESTS = tests/cnfline.test tests/cnfnewline.test tests/cnfprog.test \
+	tests/kpseaccess.test tests/kpsereadlink.test \
+	tests/kpsestat.test tests/kpsewhich.test
 
 # Rebuild
 rebuild_prereq = 
@@ -2508,7 +2509,7 @@
 	  else :; fi; \
 	done
 
-# $Id: bin_links.am 43248 2017-02-16 21:38:29Z karl $
+# $Id: Makefile.in 51875 2019-08-13 22:43:09Z karl $
 # am/bin_links.am: Makefile fragment for bindir links.
 .PHONY: install-bin-links uninstall-bin-links
 
@@ -2533,7 +2534,8 @@
 
 uninstall-hook: uninstall-bin-links
 #
-tests/cnfnewline.log tests/kpsewhich.log: kpsewhich$(EXEEXT)
+tests/cnfline.log tests/cnfnewline.log tests/cnfprog.log \
+  tests/kpsewhich.log: kpsewhich$(EXEEXT)
 tests/kpseaccess.log: kpseaccess$(EXEEXT)
 tests/kpsereadlink.log: kpsereadlink$(EXEEXT)
 tests/kpsestat.log: kpsestat$(EXEEXT)

Modified: branches/stable/source/src/texk/kpathsea/cnf.c
===================================================================
--- branches/stable/source/src/texk/kpathsea/cnf.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/cnf.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
 /* cnf.c: read config files.
 
    Copyright 1994, 1995, 1996, 1997, 2008, 2009, 2011, 2012, 2016,
-   2017, 2018 Karl Berry.
+   2017, 2018, 2019 Karl Berry.
    Copyright 1997-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -42,17 +42,23 @@
 #define CNF_NAME "texmf.cnf"
 
 

-/* Do a single line in a cnf file: if it's blank or a comment or
+/* Do a single line LINE in a cnf file: if it's blank or a comment or
    erroneous, skip it.  Otherwise, parse
      <variable>[.<program>] [=] <value>
-   Do this even if the <variable> is already set in the environment,
-   since the envvalue might contain a trailing :, in which case we'll be
-   looking for the cnf value.
+   and insert it either into the cnf_hash structure in KPSE (if
+   ENV_PROGNAME is false), or in the environment (if ENV_PROGNAME is true).
    
+   Furthermore, if ENV_PROGNAME is true, and there is no .<program> in
+   LINE, then also insert <variable> "_" `kpse->program_name' with <value>
+   into the environment; see kpathsea_cnf_line_env_progname in cnf.h.
+
+   The name without _<progname> will usually never be looked up, but
+   just in case the program name changes, or whatever.
+   
    We return NULL if ok, an error string otherwise.  */
 
 static string
-do_line (kpathsea kpse, string line)
+do_line (kpathsea kpse, string line, boolean env_progname)
 {
   unsigned len;
   string start;
@@ -97,7 +103,7 @@
   strncpy (var, start, len);
   var[len] = 0;
 
-  /* If the variable is qualified with a program name, find out which. */
+  /* If the variable is qualified with a program name, extract it.  */
   while (*line && ISSPACE (*line))
     line++;
   if (*line == '.') {
@@ -109,12 +115,30 @@
     while (*line && !ISSPACE (*line) && *line != '=')
       line++;
 
-    /* It's annoying to repeat all this, but making a tokenizing
-       subroutine would be just as long and annoying.  */
+    /* The program name is what's in between.  */
     len = line - start;
     prog = (string) xmalloc (len + 1);
     strncpy (prog, start, len);
     prog[len] = 0;
+    /* If the name is empty, or contains one of our usual special
+       characters, it's probably a mistake.  For instance, a cnf line
+         foo .;bar
+       is interpreted as a program name ";bar", because the = between
+       the variable name and value is optional.  We don't try to guess
+       the user's intentions, but just give a warning.  */
+    if (len == 0) {
+      return ("Empty program name qualifier");
+    } else {
+      unsigned i;
+      for (i = 0; i < len; i++) {
+        if (prog[i] == '$' || prog[i] == '{' || prog[i] == '}'
+            || IS_KPSE_SEP (prog[i])) {
+          string msg = xmalloc (50);
+          sprintf (msg, "Unlikely character %c in program name", prog[i]);
+          return msg;
+        }
+      }
+    }
   }
 
   /* Skip whitespace, an optional =, more whitespace.  */
@@ -157,27 +181,59 @@
       }
   }
 
-  /* We want TEXINPUTS.prog to override plain TEXINPUTS.  The simplest
-     way is to put both in the hash table (so we don't have to write
-     hash_delete and hash_replace, and keep track of values' sources),
-     and then look up the .prog version first in `kpse_cnf_get'.  */
-  if (prog) {
-    string lhs = concat3 (var, ".", prog);
-    free (var);
-    free (prog);
-    var = lhs;
+  /* If we're supposed to make the setting in the environment ... */
+  if (env_progname) {
+    string this_prog = prog ? prog : kpse->program_name; /* maybe with .prog */
+    /* last-ditch debug */
+    /* fprintf (stderr, "kpse/cnf.c xputenv(%s,%s)\n", var, value); */
+    xputenv (var, value);
+    /* Use the .prog name on the input line if specified. Otherwise,
+       although kpse->program_name should always be set at this point,
+       check just in case.  */
+    if (this_prog) {
+      string var_prog = concat3 (var, "_", this_prog);
+      /* fprintf (stderr, "kpse/cnf.c xputenv(%s,%s) [implicit]\n",
+               var_prog, value); */
+      xputenv (var_prog, value);
+      free (var_prog); /* xputenv allocates its own */
+    }
+    free (var); /* again, xputenv allocated a copy */
+
+  } else {
+    /* Normal case of not ENV_PROGNAME, insert in cnf_hash, with .prog
+       if specified, which will override non-.prog.  */
+    string lhs = prog ? concat3 (var, ".", prog) : var;
+    /* last-ditch debug */
+    /* fprintf (stderr, "kpse/cnf.c hash_insert(%s,%s)\n", lhs, value); */
+    hash_insert (&(kpse->cnf_hash), lhs, value);
+    if (prog) {  /* the lhs string is new memory if we had .prog */
+      free (var);
+      /* If there was no .prog on the line, the original `var' memory gets
+         inserted into the hash table, so do not free.  */
+    }
   }
-  /* last-ditch debug */
-  /* fprintf (stderr, "kpse/cnf.c hash_insert(%s,%s)\n", var, value); */
-  hash_insert (&(kpse->cnf_hash), var, value);
 
   /* We should check that anything remaining is preceded by a comment
      character, but we don't.  Sorry.  */
   return NULL;
 }
+
 

-/* Read all the configuration files in the path.  */
+/* Just passing along env_progname = true to do_line.  */
 
+void
+kpathsea_cnf_line_env_progname (kpathsea kpse, string line)
+{
+  string msg = do_line (kpse, line, /* env_progname = */ true);
+  if (msg) {
+    WARNING2 ("command line (kpathsea): %s in argument: %s",
+              msg, line);
+  }
+}
+
+

+/* Read all the kpathsea configuration files in the path.  */
+
 static void
 read_all_cnf (kpathsea kpse)
 {
@@ -185,8 +241,6 @@
   string *cnf;
   const_string cnf_path = kpathsea_init_format (kpse, kpse_cnf_format);
 
-  kpse->cnf_hash = hash_create (CNF_HASH_SIZE);
-
   cnf_files = kpathsea_all_path_search (kpse, cnf_path, CNF_NAME);
   if (cnf_files && *cnf_files) {
     for (cnf = cnf_files; *cnf; cnf++) {
@@ -223,7 +277,7 @@
           }
         }
 
-        msg = do_line (kpse, line);
+        msg = do_line (kpse, line, /* env_progname= */ false);
         if (msg) {
           WARNING4 ("%s:%d: (kpathsea) %s on line: %s",
                     *cnf, lineno, msg, line);
@@ -255,15 +309,15 @@
   const_string ret, *ret_list;
 
   /* When we expand the compile-time value for DEFAULT_TEXMFCNF,
-     we end up needing the value for TETEXDIR and other variables,
-     so kpse_var_expand ends up calling us again.  No good.  Except this
-     code is not sufficient, somehow the ls-R path needs to be
-     computed when initializing the cnf path.  Better to ensure that the
-     compile-time path does not contain variable references.  */
+     we end up needing the value for assorted variables,
+     so kpse_var_expand ends up calling us again.  Just return.  */
   if (kpse->doing_cnf_init)
     return NULL;
 
+  /* If no cnf hash yet, initialize.  */
   if (kpse->cnf_hash.size == 0) {
+    kpse->cnf_hash = hash_create (CNF_HASH_SIZE);
+    
     /* Read configuration files and initialize databases.  */
     kpse->doing_cnf_init = true;
     read_all_cnf (kpse);
@@ -300,7 +354,6 @@
 const_string
 kpse_cnf_get (const_string name)
 {
-    return kpathsea_cnf_get(kpse_def, name);
+  return kpathsea_cnf_get(kpse_def, name);
 }
 #endif
-

Modified: branches/stable/source/src/texk/kpathsea/cnf.h
===================================================================
--- branches/stable/source/src/texk/kpathsea/cnf.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/cnf.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 /* cnf.h: runtime config files.
 
-   Copyright 1994, 1995, 2008, 2012 Karl Berry.
+   Copyright 1994, 1995, 2008, 2012, 2019 Karl Berry.
    Copyright 1999, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -27,11 +27,31 @@
 #endif
 
 /* Return the value in the last-read cnf file for VAR, or NULL if none.
-   On the first call, also read all the `texmf.cnf' files in the
-   path for kpse_cnf_format (and initialize the path).  */
+   On the first call, also read all the `texmf.cnf' files in the path
+   for kpse_cnf_format (and initialize the path).  Any error messages are
+   written to stderr.  */
 
-extern KPSEDLL const_string kpathsea_cnf_get (kpathsea kpse, const_string name);
+extern KPSEDLL const_string kpathsea_cnf_get (kpathsea kpse, const_string var);
 
+
+/* Parse L as a texmf.cnf configuration line for the KPSE instance,
+   and insert any <variable> assignment in the environment, both as-is and
+   with the value (if all non-NULL) of <variable> "_" KPSE->program_name. 
+   If <variable>[_<progname>] is already set in the environment, it is
+   overwritten.
+   
+   All of this behavior is because if the user runs tex with
+   --cnf-line=TEXINPUTS=/foo:, it's not unreasonable to expect that
+   cmdline option to override both environment variables TEXINPUTS and
+   TEXINPUTS_tex, and also both configuration values TEXINPUTS and
+   TEXINPUTS.tex -- even though ordinarily <var>.<progname> overrides
+   plain <var>. 
+   
+   Any error message is written to stderr.  */
+
+extern KPSEDLL void kpathsea_cnf_line_env_progname (kpathsea kpse,
+                                                    string l);
+
 #if defined(KPSE_COMPAT_API)
 extern KPSEDLL const_string kpse_cnf_get (const_string var);
 #endif

Modified: branches/stable/source/src/texk/kpathsea/doc/kpathsea.info
===================================================================
--- branches/stable/source/src/texk/kpathsea/doc/kpathsea.info	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/doc/kpathsea.info	2019-11-23 23:34:02 UTC (rev 816)
@@ -37,7 +37,7 @@
 ****************
 
 This manual documents the Kpathsea library for path searching.  It
-corresponds to version 6.3.1, released in March 2019.
+corresponds to version 6.3.2, released in August 2019.
 
 * Menu:
 
@@ -61,8 +61,8 @@
 1 Introduction
 **************
 
-This manual corresponds to version 6.3.1 of the Kpathsea library,
-released in March 2019.
+This manual corresponds to version 6.3.2 of the Kpathsea library,
+released in August 2019.
 
    The library's fundamental purpose is to return a filename from a list
 of directories specified by the user, similar to what shells do when
@@ -467,7 +467,10 @@
 A search path or other configuration value can come from many sources.
 In the order in which Kpathsea looks for them:
 
-  1. A user-set environment variable, e.g., 'TEXINPUTS'.  Environment
+  1. A command-line option such as '--cnf-line', available in
+     'kpsewhich' and most TeX engines.  *Note Path searching options::.
+
+     A user-set environment variable, e.g., 'TEXINPUTS'.  Environment
      variables with an underscore and the program name appended
      override; for example, 'TEXINPUTS_latex' overrides 'TEXINPUTS' if
      the program being run is named 'latex'.
@@ -519,8 +522,8 @@
 
    * Comments start with '%', either at the beginning of a line or
      preceded by whitespace, and continue to the end of the line.  That
-     is, as with most shells, a '%' in the "middle" of a value does not
-     start a comment.  Examples:
+     is, similar to most shells, a '%' in the "middle" of a value does
+     not start a comment.  Examples:
 
           % this is a comment
           var = a%b  % but the value of var will be "a%b".
@@ -540,11 +543,12 @@
    * The VARIABLE name may contain any character other than whitespace,
      '=', or '.', but sticking to 'A-Za-z_' is safest.
 
-   * If '.PROGNAME' is present, the definition only applies if the
-     program that is running is named (i.e., the last component of
-     'argv[0]' is) PROGNAME or 'PROGNAME.{exe,bat,cmd,...}'.  Most
-     notably, this allows different flavors of TeX to have different
-     search paths.
+   * If '.PROGNAME' is present (preceding spaces are ignored), the
+     definition only applies if the program that is running is named
+     (i.e., the last component of 'argv[0]' is) PROGNAME or
+     'PROGNAME.{exe,bat,cmd,...}'.  Most notably, this allows different
+     flavors of TeX to have different search paths.  The PROGNAME value
+     is used literally, without variable or other expansions.
 
    * VALUE may contain any characters except '%' and '@'.  (These
      restrictions are only necessary because of the processing done on
@@ -576,6 +580,16 @@
 information would have to passed back to Kpathsea and parsed there
 anyway, since the 'sh' process couldn't affect its parent's environment.
 
+   The combination of spaces being ignored before the '.' of a program
+name qualifer and the optional '=' for the assignment has an unexpected
+consequence: if the value begins with a literal '.' and the '=' is
+omitted, the intended value is interpreted as a program name.  For
+example, a line 'var .;/some/path' is taken as an empty value for 'var'
+running under the program named ';/some/path'.  To diagnose this,
+Kpathsea warns if the program name contains a path separator or other
+special character.  The simplest way to avoid the problem is to use the
+'='.
+
    The implementation of all this is in 'kpathsea/cnf.c'.
 
 
@@ -1182,6 +1196,27 @@
      case-insensitive, it merely means that Kpathsea does not do any
      casefolding itself.
 
+'--cnf-line=STR'
+     Parse STR as if it were a line in the 'texmf.cnf' configuration
+     file (*note Config files::), overriding settings in the actual
+     configuration files, and also in the environment (*note Path
+     sources::).  This is implemented by making any settings from STR in
+     the environment, overwriting any value already there.  Thus, an
+     extra colon in a '--cnf-line' value will refer to the value from a
+     configuration file, not a user-set environment variable.
+
+     Furthermore, any variable set from STR will also be set with the
+     program name suffix.  For example, 'pdftex
+     --cnf-line=TEXINPUTS=/foo:' will set both 'TEXINPUTS' and
+     'TEXINPUTS_pdftex' in the environment (and the value will be '/foo'
+     followed by the setting from 'texmf.cnf', ignoring any user-set
+     'TEXINPUTS').
+
+     This behavior is desirable because, in practice, many variables in
+     the distributed 'texmf.cnf' are program-specific, and the intuitive
+     behavior is for values set on the command line with '--cnf-line' to
+     override them.
+
 '--dpi=NUM'
      Set the resolution to NUM; this only affects 'gf' and 'pk' lookups.
      '-D' is a synonym, for compatibility with Dvips.  Default is 600.
@@ -1499,8 +1534,8 @@
      Unix-ish system) '.:/home/karl', supposing the latter is the
      current user's home directory.  Note that the ';' in the source
      value, as commonly used in 'texmf.cnf', has changed to a ':', as
-     the normal path separator on the current system.  (On a Windows-ish
-     system, the ';' would remain.)
+     the normal path separator on the current system.  On a Windows-ish
+     system, the ';' would remain.
 
 '--var-value=VARIABLE'
      Outputs the value of VARIABLE (a simple identifier like
@@ -1514,7 +1549,8 @@
      default is not changed) '1'.
 
      Example to contrast with '--var-brace-value': 'FOO='.;~' kpsewhich
-     --var-value=FOO' outputs '.;~', i.e., the same as the input value.
+     --var-value=FOO' outputs '.;~', i.e., the same as the input value,
+     on all systems.
 
 
 File: kpathsea.info,  Node: Standard options,  Prev: Auxiliary tasks,  Up: Invoking kpsewhich
@@ -2988,40 +3024,43 @@
                                                               (line  12)
 * --casefold-search:                     Path searching options.
                                                               (line  19)
+* --cnf-line:                            Path searching options.
+                                                              (line  28)
+* --cnf-line, source for path:           Path sources.        (line   9)
 * --color=tty:                           ls-R.                (line  25)
 * --debug=NUM:                           Auxiliary tasks.     (line   9)
 * --dpi=NUM:                             Path searching options.
-                                                              (line  28)
+                                                              (line  49)
 * --engine=NAME:                         Path searching options.
-                                                              (line  32)
+                                                              (line  53)
 * --expand-braces=STRING:                Auxiliary tasks.     (line  12)
 * --expand-path=STRING:                  Auxiliary tasks.     (line  16)
 * --expand-var=STRING:                   Auxiliary tasks.     (line  34)
 * --format=NAME:                         Path searching options.
-                                                              (line  48)
+                                                              (line  69)
 * --help:                                Standard options.    (line   8)
 * --help-formats:                        Auxiliary tasks.     (line  42)
 * --interactive:                         Path searching options.
-                                                              (line 130)
+                                                              (line 151)
 * --mktex=FILETYPE:                      Path searching options.
-                                                              (line 135)
+                                                              (line 156)
 * --mode=STRING:                         Path searching options.
-                                                              (line 141)
+                                                              (line 162)
 * --must-exist:                          Path searching options.
-                                                              (line 146)
+                                                              (line 167)
 * --no-casefold-search:                  Path searching options.
                                                               (line  19)
 * --no-mktex=FILETYPE:                   Path searching options.
-                                                              (line 135)
+                                                              (line 156)
 * --path=STRING:                         Path searching options.
-                                                              (line 151)
+                                                              (line 172)
 * --progname=NAME:                       Path searching options.
-                                                              (line 159)
+                                                              (line 180)
 * --safe-in-name=NAME:                   Auxiliary tasks.     (line  48)
 * --safe-out-name=NAME:                  Auxiliary tasks.     (line  48)
 * --show-path=NAME:                      Auxiliary tasks.     (line  54)
 * --subdir=STRING:                       Path searching options.
-                                                              (line 164)
+                                                              (line 185)
 * --var-brace-value=VARIABLE:            Auxiliary tasks.     (line  60)
 * --var-value=VARIABLE:                  Auxiliary tasks.     (line  74)
 * --version:                             Standard options.    (line  11)
@@ -3035,7 +3074,7 @@
 * -1 debugging value:                    Debugging.           (line  23)
 * -A option to ls:                       ls-R.                (line  39)
 * -D NUM:                                Path searching options.
-                                                              (line  28)
+                                                              (line  49)
 * -iname, find predicate:                Casefolding examples.
                                                               (line  78)
 * -L option to ls:                       ls-R.                (line  44)
@@ -3228,7 +3267,7 @@
                                                               (line  46)
 * cmr10, as fallback font:               Fallback font.       (line  15)
 * cmr10.vf:                              Searching overview.  (line  31)
-* cnf.c:                                 Config files.        (line  86)
+* cnf.c:                                 Config files.        (line  97)
 * cnf.h:                                 Programming with config files.
                                                               (line  27)
 * comments, in fontmap files:            Fontmap.             (line  27)
@@ -3236,7 +3275,7 @@
 * comments, making:                      Introduction.        (line  29)
 * common features in glyph lookup:       Basic glyph lookup.  (line   6)
 * common problems:                       Common problems.     (line   6)
-* compilation value, source for path:    Path sources.        (line  20)
+* compilation value, source for path:    Path sources.        (line  23)
 * compiler bugs:                         TeX or Metafont failing.
                                                               (line   6)
 * compiler bugs, finding:                TeX or Metafont failing.
@@ -3256,8 +3295,8 @@
                                                               (line  57)
 * config.status:                         Bug checklist.       (line  27)
 * configuration bugs:                    Bug checklist.       (line  27)
-* configuration file, source for path:   Path sources.        (line  17)
-* configuration files as shell scripts.: Config files.        (line  79)
+* configuration file, source for path:   Path sources.        (line  20)
+* configuration files as shell scripts.: Config files.        (line  80)
 * configuration of mktex scripts:        mktex configuration. (line   6)
 * configure options for mktex scripts:   mktex configuration. (line  12)
 * context diff:                          Bug checklist.       (line  52)
@@ -3314,8 +3353,8 @@
 * ENCFONTS:                              Supported file formats.
                                                               (line  61)
 * engine name:                           Path searching options.
-                                                              (line  32)
-* environment variable, source for path: Path sources.        (line   9)
+                                                              (line  53)
+* environment variable, source for path: Path sources.        (line  12)
 * environment variables for TeX:         Supported file formats.
                                                               (line   6)
 * environment variables in paths:        Variable expansion.  (line   6)
@@ -3422,7 +3461,7 @@
                                                               (line  84)
 * input lines, reading:                  Calling sequence.    (line 110)
 * interactive query:                     Path searching options.
-                                                              (line 130)
+                                                              (line 151)
 * interface, not frozen:                 Introduction.        (line  29)
 * introduction:                          Introduction.        (line   6)
 * kdebug::                               Debugging.           (line 105)
@@ -3429,7 +3468,7 @@
 * kdefault.c:                            Default expansion.   (line  48)
 * Knuth, Donald E.:                      History.             (line   6)
 * Knuth, Donald E., archive of programs by: unixtex.ftp.      (line  19)
-* Kpathsea config file, source for path: Path sources.        (line  17)
+* Kpathsea config file, source for path: Path sources.        (line  20)
 * kpathsea.h:                            Programming overview.
                                                               (line  26)
 * kpathsea_cnf_get:                      Programming with config files.
@@ -3645,10 +3684,10 @@
 * reporting bugs:                        Reporting bugs.      (line   6)
 * resident.c:                            Calling sequence.    (line  47)
 * resolution, setting:                   Path searching options.
-                                                              (line  28)
+                                                              (line  49)
 * resolutions, last-resort:              Fallback font.       (line   6)
 * retrieving TeX:                        unixtex.ftp.         (line   6)
-* right-hand side of variable assignments: Config files.      (line  56)
+* right-hand side of variable assignments: Config files.      (line  57)
 * RISINPUTS:                             Supported file formats.
                                                               (line 173)
 * Rokicki, Tom:                          History.             (line  12)
@@ -3672,7 +3711,7 @@
 * setgid scripts:                        Security.            (line  40)
 * SFDFONTS:                              Supported file formats.
                                                               (line 177)
-* shell scripts as configuration files:  Config files.        (line  79)
+* shell scripts as configuration files:  Config files.        (line  80)
 * shell variables:                       Variable expansion.  (line  17)
 * shell_escape, example for code:        Programming with config files.
                                                               (line  10)
@@ -3780,7 +3819,7 @@
 * texmf.cnf missing, warning about:      Config files.        (line  18)
 * texmf.cnf, and variable expansion:     Variable expansion.  (line   6)
 * texmf.cnf, definition for:             Config files.        (line   6)
-* texmf.cnf, source for path:            Path sources.        (line  17)
+* texmf.cnf, source for path:            Path sources.        (line  20)
 * TEXMFCNF:                              Config files.        (line   6)
 * TEXMFCNF <1>:                          Supported file formats.
                                                               (line  49)
@@ -3892,61 +3931,61 @@
 
 Tag Table:
 Node: Top1480
-Node: Introduction2260
-Node: History4330
-Node: unixtex.ftp8926
-Node: Security10351
-Node: TeX directory structure12855
-Node: Path searching16903
-Node: Searching overview17630
-Node: Path sources21449
-Node: Config files22540
-Node: Path expansion26467
-Node: Default expansion27420
-Node: Variable expansion29490
-Node: Tilde expansion30891
-Node: Brace expansion31871
-Node: KPSE_DOT expansion32810
-Node: Subdirectory expansion33323
-Node: Casefolding search35677
-Node: Casefolding rationale36446
-Node: Casefolding examples37785
-Node: Filename database42835
-Node: ls-R43893
-Node: Filename aliases47569
-Node: Database format48747
-Node: Invoking kpsewhich49760
-Node: Path searching options50715
-Node: Specially-recognized files59234
-Node: Auxiliary tasks60589
-Node: Standard options64295
-Node: TeX support64651
-Node: Supported file formats66005
-Node: File lookup73670
-Node: Glyph lookup75419
-Node: Basic glyph lookup76543
-Node: Fontmap77423
-Node: Fallback font79952
-Node: Suppressing warnings80864
-Node: mktex scripts81991
-Node: mktex configuration83206
-Node: mktex script names89009
-Node: mktex script arguments90395
-Node: Programming91274
-Node: Programming overview91847
-Node: Calling sequence94708
-Node: Program-specific files101240
-Node: Programming with config files102263
-Node: Reporting bugs103850
-Node: Bug checklist104528
-Node: Mailing lists108000
-Node: Debugging108675
-Node: Logging113752
-Node: Common problems115619
-Node: Unable to find files116096
-Node: Slow path searching118506
-Node: Unable to generate fonts119881
-Node: TeX or Metafont failing122352
-Node: Index123554
+Node: Introduction2261
+Node: History4332
+Node: unixtex.ftp8928
+Node: Security10353
+Node: TeX directory structure12857
+Node: Path searching16905
+Node: Searching overview17632
+Node: Path sources21451
+Node: Config files22677
+Node: Path expansion27283
+Node: Default expansion28236
+Node: Variable expansion30306
+Node: Tilde expansion31707
+Node: Brace expansion32687
+Node: KPSE_DOT expansion33626
+Node: Subdirectory expansion34139
+Node: Casefolding search36493
+Node: Casefolding rationale37262
+Node: Casefolding examples38601
+Node: Filename database43651
+Node: ls-R44709
+Node: Filename aliases48385
+Node: Database format49563
+Node: Invoking kpsewhich50576
+Node: Path searching options51531
+Node: Specially-recognized files61129
+Node: Auxiliary tasks62484
+Node: Standard options66209
+Node: TeX support66565
+Node: Supported file formats67919
+Node: File lookup75584
+Node: Glyph lookup77333
+Node: Basic glyph lookup78457
+Node: Fontmap79337
+Node: Fallback font81866
+Node: Suppressing warnings82778
+Node: mktex scripts83905
+Node: mktex configuration85120
+Node: mktex script names90923
+Node: mktex script arguments92309
+Node: Programming93188
+Node: Programming overview93761
+Node: Calling sequence96622
+Node: Program-specific files103154
+Node: Programming with config files104177
+Node: Reporting bugs105764
+Node: Bug checklist106442
+Node: Mailing lists109914
+Node: Debugging110589
+Node: Logging115666
+Node: Common problems117533
+Node: Unable to find files118010
+Node: Slow path searching120420
+Node: Unable to generate fonts121795
+Node: TeX or Metafont failing124266
+Node: Index125468
 
 End Tag Table

Modified: branches/stable/source/src/texk/kpathsea/doc/kpathsea.texi
===================================================================
--- branches/stable/source/src/texk/kpathsea/doc/kpathsea.texi	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/doc/kpathsea.texi	2019-11-23 23:34:02 UTC (rev 816)
@@ -2,8 +2,8 @@
 @setfilename kpathsea.info
 @settitle Kpathsea: A library for path searching
 
- at set version 6.3.1
- at set month-year March 2019
+ at set version 6.3.2
+ at set month-year August 2019
 
 @copying
 This file documents the Kpathsea library for path searching.
@@ -570,6 +570,11 @@
 
 @enumerate
 @item
+ at opindex @samp{--cnf-line}, source for path
+A command-line option such as @code{--cnf-line}, available in
+ at file{kpsewhich} and most @TeX{} engines.  @xref{Path searching
+options}. 
+
 @cindex environment variable, source for path
 A user-set environment variable, e.g., @code{TEXINPUTS}.
 Environment variables with an underscore and the program name appended
@@ -642,7 +647,7 @@
 @cindex comments, in @file{texmf.cnf}
 Comments start with @samp{%}, either at the beginning of a line or
 preceded by whitespace, and continue to the end of the line.  That is,
-as with most shells, a @samp{%} in the ``middle'' of a value does not
+similar to most shells, a @samp{%} in the ``middle'' of a value does not
 start a comment.  Examples:
 
 @example
@@ -676,11 +681,13 @@
 The @var{variable} name may contain any character other than whitespace,
 @samp{=}, or @samp{.}, but sticking to @samp{A-Za-z_} is safest.
 
- at item If @samp{. at var{progname}} is present, the definition only
-applies if the program that is running is named (i.e., the last
-component of @code{argv[0]} is) @var{progname} or
- at file{@var{progname}.@{exe,bat,cmd,...@}}.  Most notably, this allows
-different flavors of @TeX{} to have different search paths.
+ at item If @samp{. at var{progname}} is present (preceding spaces are
+ignored), the definition only applies if the program that is running
+is named (i.e., the last component of @code{argv[0]} is)
+ at var{progname} or @file{@var{progname}.@{exe,bat,cmd,...@}}.  Most
+notably, this allows different flavors of @TeX{} to have different
+search paths.  The @var{progname} value is used literally, without
+variable or other expansions.
 
 @item
 @cindex right-hand side of variable assignments
@@ -722,6 +729,16 @@
 to Kpathsea and parsed there anyway, since the @code{sh} process
 couldn't affect its parent's environment.
 
+The combination of spaces being ignored before the @code{.} of a
+program name qualifer and the optional @samp{=} for the assignment has
+an unexpected consequence: if the value begins with a literal @samp{.}
+and the @samp{=} is omitted, the intended value is interpreted as a
+program name.  For example, a line @code{var .;/some/path} is taken as
+an empty value for @code{var} running under the program named
+ at samp{;/some/path}.  To diagnose this, Kpathsea warns if the program
+name contains a path separator or other special character.  The
+simplest way to avoid the problem is to use the @code{=}.
+
 @flindex cnf.c
 The implementation of all this is in @file{kpathsea/cnf.c}.
 
@@ -1473,6 +1490,28 @@
 case-insensitive, it merely means that Kpathsea does not do any
 casefolding itself.
 
+ at item --cnf-line=@var{str}
+ at opindex --cnf-line
+Parse @var{str} as if it were a line in the @file{texmf.cnf}
+configuration file (@pxref{Config files}), overriding settings in the
+actual configuration files, and also in the environment (@pxref{Path
+sources}).  This is implemented by making any settings from @var{str}
+in the environment, overwriting any value already there.  Thus, an
+extra colon in a @samp{--cnf-line} value will refer to the value from
+a configuration file, not a user-set environment variable.
+
+Furthermore, any variable set from @var{str} will also be set with the
+program name suffix.  For example, @code{pdftex
+--cnf-line=TEXINPUTS=/foo:} will set both @code{TEXINPUTS} and
+ at code{TEXINPUTS_pdftex} in the environment (and the value will be
+ at file{/foo} followed by the setting from @file{texmf.cnf}, ignoring
+any user-set @code{TEXINPUTS}).
+
+This behavior is desirable because, in practice, many variables in the
+distributed @file{texmf.cnf} are program-specific, and the intuitive
+behavior is for values set on the command line with @code{--cnf-line}
+to override them.
+
 @item --dpi=@var{num}
 @opindex --dpi=@var{num}
 @opindex -D @var{num}
@@ -1857,8 +1896,8 @@
 a Unix-ish system) @samp{.:/home/karl}, supposing the latter is the
 current user's home directory.  Note that the @samp{;} in the source
 value, as commonly used in @file{texmf.cnf}, has changed to a
- at samp{:}, as the normal path separator on the current system. (On a
-Windows-ish system, the @samp{;} would remain.)
+ at samp{:}, as the normal path separator on the current system.  On a
+Windows-ish system, the @samp{;} would remain.
 
 @item --var-value=@var{variable}
 @opindex --var-value=@var{variable}
@@ -1874,7 +1913,7 @@
 
 Example to contrast with @samp{--var-brace-value}: @samp{FOO='.;~'
 kpsewhich --var-value=FOO} outputs @samp{.;~}, i.e., the same as the
-input value.
+input value, on all systems.
 
 @end table
 

Modified: branches/stable/source/src/texk/kpathsea/hash.c
===================================================================
--- branches/stable/source/src/texk/kpathsea/hash.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/hash.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 /* hash.c: hash table operations.
 
-   Copyright 1994-2000, 2002, 2005, 2008, 2012, 2016, 2017
+   Copyright 1994-2000, 2002, 2005, 2008, 2012, 2016, 2017-2019
    Karl Berry & Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -63,7 +63,7 @@
 hash_table_type
 hash_create (unsigned size)
 {
-  /* The was "static ..." since Oct3, 1997 to work around a gcc
+  /* There was "static ..." since Oct3, 1997 to work around a gcc
      optimizer bug for Alpha. That particular optimization bug
      should be gone by now (Mar4, 2009).
   */

Modified: branches/stable/source/src/texk/kpathsea/kpsewhich.c
===================================================================
--- branches/stable/source/src/texk/kpathsea/kpsewhich.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/kpsewhich.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -19,6 +19,7 @@
 #include <kpathsea/config.h>
 #include <kpathsea/c-ctype.h>
 #include <kpathsea/c-pathch.h>
+#include <kpathsea/cnf.h>
 #include <kpathsea/expand.h>
 #include <kpathsea/getopt.h>
 #include <kpathsea/line.h>
@@ -39,10 +40,14 @@
 string var_to_value = NULL;
 string var_to_brace_value = NULL;
 
+/* Array/count of cnf lines from the command line. (--cnf-line) */
+static string *user_cnf_lines = NULL;
+static unsigned user_cnf_nlines = 0;
+
 /* Base resolution. (-D, -dpi) */
 unsigned dpi = 600;
 
-/* The engine name, for '$engine' construct in texmf.cnf.  (-engine) */
+/* The engine name, for `$engine' construct in texmf.cnf.  (-engine) */
 string engine = NULL;
 
 /* Interactively ask for names to look up?  (-interactive) */
@@ -474,6 +479,7 @@
 \n\
 -all                   output all matches, one per line (no effect with pk/gf).\n\
 [-no]-casefold-search  fall back to case-insensitive search if no exact match.\n\
+-cnf-line=STRING       parse STRING as a configuration file line.\n\
 -debug=NUM             set debugging flags.\n\
 -D, -dpi=NUM           use a base resolution of NUM; default 600.\n\
 -engine=STRING         set engine name to STRING.\n\
@@ -588,6 +594,7 @@
   = { { "D",                    1, 0, 0 },
       { "all",                  0, (int *) &show_all, 1 },
       { "casefold-search",      0, 0, 0 },
+      { "cnf-line",             1, 0, 0 },
       { "debug",                1, 0, 0 },
       { "dpi",                  1, 0, 0 },
       { "engine",               1, 0, 0 },
@@ -637,6 +644,17 @@
          (by default).  */
       xputenv ("texmf_casefold_search", "1");      
 
+    } else if (ARGUMENT_IS ("cnf-line")) {
+      if (user_cnf_lines == NULL) {
+        user_cnf_nlines = 1;
+        user_cnf_lines = xmalloc (sizeof (const_string));
+      } else {
+        user_cnf_nlines++;
+        user_cnf_lines = xrealloc (user_cnf_lines,
+                                   user_cnf_nlines * sizeof (const_string));
+      }
+      user_cnf_lines[user_cnf_nlines-1] = xstrdup (optarg);
+
     } else if (ARGUMENT_IS ("debug")) {
       kpse->debug |= atoi (optarg);
 
@@ -742,6 +760,15 @@
   if (engine)
     kpathsea_xputenv (kpse, "engine", engine);
 
+  /* We want config lines from the command line to override config files.  */
+  if (user_cnf_lines) {
+    unsigned i;
+    for (i = 0; i < user_cnf_nlines; i++) {
+      kpathsea_cnf_line_env_progname (kpse, user_cnf_lines[i]);
+      free (user_cnf_lines[i]);
+    }
+  }
+
   /* Disable all mktex programs unless they were explicitly enabled on our
      command line.  */
 #define DISABLE_MKTEX(fmt) \

Modified: branches/stable/source/src/texk/kpathsea/progname.c
===================================================================
--- branches/stable/source/src/texk/kpathsea/progname.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/progname.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -85,7 +85,7 @@
 static void
 ReadSymLink (char *fn, char *sym)
 {
-  register int n = readlink (fn, sym, BSIZE);
+  int n = readlink (fn, sym, BSIZE);
   if (n < 0) {
     perror (fn);
     exit (1);
@@ -97,10 +97,10 @@
 /* Strip first component from S, and also return it in a static buffer.  */
 
 static char *
-StripFirst (register char *s)
+StripFirst (char *s)
 {
   static char buf[BSIZE];
-  register char *s1;
+  char *s1;
 
   /* Find the end of the first path element */
   for (s1 = s; *s1 && (*s1 != '/' || s1 == s); s1++)
@@ -125,10 +125,10 @@
 /* Strip last component from S, and also return it in a static buffer.  */
 
 static char *
-StripLast (register char *s)
+StripLast (char *s)
 {
   static char buf[BSIZE];
-  register char *s1;
+  char *s1;
 
   for (s1 = s + strlen (s); s1 > s && *s1 != '/'; s1--)
     ;
@@ -142,9 +142,9 @@
 /* Copy first path element from B to A, removing it from B.  */
 
 static void
-CopyFirst (register char *a, char *b)
+CopyFirst (char *a, char *b)
 {
-  register int length = strlen (a);
+  int length = strlen (a);
 
    if (length > 0 && a[length - 1] != '/') {
    a[length] = '/';

Modified: branches/stable/source/src/texk/kpathsea/progname.h
===================================================================
--- branches/stable/source/src/texk/kpathsea/progname.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/progname.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 /* progname.h: Declarations for argv[0] equivalents.
 
-   Copyright 1994, 1996, 2008, 2010-2013 Karl Berry.
+   Copyright 1994, 1996, 2008, 2010-2019 Karl Berry.
    Copyright 1999, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -33,20 +33,20 @@
 extern KPSEDLL string kpathsea_selfdir (kpathsea kpse, const_string argv0);
 #endif
 
-/* Set the first two variables above (if they're not predefined) to a copy
-   of ARGV0 and everything in ARGV0 after the last directory separator,
-   respectively.  Set kpse_program_name to a copy of PROGNAME or the
-   value of kpse_invocation_short_name if PROGNAME is NULL.
-   This function also determines the AUTO* variables. */
+/* Set the two members `invocation_name' and `invocation_short_name'
+   in the KPSE instance to a copy of ARGV0 and everything in ARGV0 after
+   the last directory separator, respectively. Set `program_name' (also in
+   the KPSE instance) to a copy of PROGNAME or the value of
+   kpse_invocation_short_name if PROGNAME is NULL. This function also
+   sets the SELFAUTO* environment variables.  */
 
 extern KPSEDLL void kpathsea_set_program_name (kpathsea kpse,
                             const_string argv0, const_string progname);
 
-/* See also `kpathsea_reset_program_name' which is defined in tex-file.c
-
+/* See also `kpathsea_reset_program_name', which is defined in tex-file.c.
    That function is to be used to set kpse->program_name to a different
    value.  It clears the path searching information, to ensure that
-   the search paths are appropriate to the new name. */
+   the search paths are appropriate to the new name.  */
 
 
 #if defined (KPSE_COMPAT_API)

Added: branches/stable/source/src/texk/kpathsea/tests/cnfline/texmf.cnf
===================================================================
--- branches/stable/source/src/texk/kpathsea/tests/cnfline/texmf.cnf	                        (rev 0)
+++ branches/stable/source/src/texk/kpathsea/tests/cnfline/texmf.cnf	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,5 @@
+# $Id: texmf.cnf 51830 2019-08-06 23:33:17Z karl $
+# Public domain. This tiny texmf.cnf is for kpathsea/tests/cnfline.test. 
+maxpr=100
+maxpr.kpsewhich=200
+othervar=300


Property changes on: branches/stable/source/src/texk/kpathsea/tests/cnfline/texmf.cnf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/stable/source/src/texk/kpathsea/tests/cnfline.test
===================================================================
--- branches/stable/source/src/texk/kpathsea/tests/cnfline.test	                        (rev 0)
+++ branches/stable/source/src/texk/kpathsea/tests/cnfline.test	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,27 @@
+#!/bin/sh -vx
+# $Id: cnfline.test 51830 2019-08-06 23:33:17Z karl $
+# Copyright 2019 Karl Berry <tex-live at tug.org>
+# You may freely use, modify and/or distribute this file.
+
+cnf_dir=$srcdir/tests/cnfline
+
+# Just for fun, let's first try the --cnf-line feature to set TEXMFCNF.
+val=`./kpsewhich "--cnf-line=TEXMFCNF=$cnf_dir" --var-value=othervar`
+test x"$val" = x300 || exit 1
+
+# But for the rest, just use the environment, to keep things simpler.
+TEXMFCNF=$cnf_dir; export TEXMFCNF
+
+# Make sure we get expected values from the test texmf.cnf.
+val=`./kpsewhich --var-value=maxpr`
+test x"$val" = x200 || exit 1
+#
+val=`./kpsewhich --progname=foo --var-value=maxpr`
+test x"$val" = x100 || exit 1
+#
+val=`./kpsewhich --var-value=othervar`
+test x"$val" = x300 || exit 1
+
+# Now override on cmd line -- both texmf.cnf values should get overridden.
+val=`./kpsewhich --cnf-line=maxpr=99 --var-value=maxpr`
+test x"$val" = x99 || exit 1


Property changes on: branches/stable/source/src/texk/kpathsea/tests/cnfline.test
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: branches/stable/source/src/texk/kpathsea/tests/cnfprog/texmf.cnf
===================================================================
--- branches/stable/source/src/texk/kpathsea/tests/cnfprog/texmf.cnf	                        (rev 0)
+++ branches/stable/source/src/texk/kpathsea/tests/cnfprog/texmf.cnf	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,13 @@
+# $Id: texmf.cnf 51875 2019-08-13 22:43:09Z karl $
+# Public domain. This tiny texmf.cnf is for kpathsea/tests/cnfprog.test.
+
+# An empty program name is warned about (as of August 2019).
+justdot. = dval
+
+# Contrary to appearances, this is interpreted as a program name ";val",
+# with no value.  A warning is issued.
+noequals .;qval
+
+# Similarly, the "${var}" is a literal string here, not expanded.
+# Again, a warning is issued.
+braceprog.${var} = bval


Property changes on: branches/stable/source/src/texk/kpathsea/tests/cnfprog/texmf.cnf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/stable/source/src/texk/kpathsea/tests/cnfprog.test
===================================================================
--- branches/stable/source/src/texk/kpathsea/tests/cnfprog.test	                        (rev 0)
+++ branches/stable/source/src/texk/kpathsea/tests/cnfprog.test	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,23 @@
+#!/bin/sh -vx
+# $Id: cnfprog.test 51875 2019-08-13 22:43:09Z karl $
+# Copyright 2019 Karl Berry <tex-live at tug.org>
+# You may freely use, modify and/or distribute this file.
+# Test strange program name qualifiers which should give warnings.
+
+cnf_dir=$srcdir/tests/cnfprog
+
+# But for the rest, just use the environment, to keep things simpler.
+TEXMFCNF=$cnf_dir; export TEXMFCNF
+
+# Make sure we get expected values from the test texmf.cnf.
+errfile=cnfprog.err
+val=`./kpsewhich --var-value=noequals 2>$errfile`
+
+# the vaiable should not have any value.
+test -z "$val" || exit 1
+
+grep 'Empty program name qualifier' $errfile || exit 1
+grep 'Unlikely character ;' $errfile || exit 1
+grep 'Unlikely character \$' $errfile || exit 1
+
+exit 0


Property changes on: branches/stable/source/src/texk/kpathsea/tests/cnfprog.test
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: branches/stable/source/src/texk/kpathsea/tex-file.c
===================================================================
--- branches/stable/source/src/texk/kpathsea/tex-file.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/tex-file.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,7 @@
 /* tex-file.c: high-level file searching by format.
 
    Copyright 1993, 1994, 1995, 1996, 1997, 2007, 2008, 2009, 2010, 2011
-             2012, 2014, 2016, 2017 Karl Berry.
+             2012, 2014, 2016, 2017, 2019 Karl Berry.
    Copyright 1998-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -1429,7 +1429,7 @@
    the paths for kpse_cnf_format and kpse_db_format are not cleared.
 
    This function is defined here, and not in progname.c, because it
-   need format_info, and would cause all of tex-file to be pulled
+   needs format_info, and would cause all of tex-file to be pulled
    in by programs that do not need it. */
 
 void
@@ -1445,14 +1445,14 @@
 
   free (kpse->program_name);
   kpse->program_name = xstrdup (progname);
-  kpathsea_xputenv(kpse, "progname", kpse->program_name);
+  kpathsea_xputenv (kpse, "progname", kpse->program_name);
 
-  /* Clear paths -- do we want the db path to be cleared? */
+  /* Go through all paths ...  */
   for (i = 0; i != kpse_last_format; ++i) {
-    /* Do not erase the cnf of db paths.  This means that the filename
+    /* Do not erase the cnf or db paths.  This means that the filename
        database is not rebuilt, nor are different configuration files
        searched.  The alternative is to tolerate a memory leak of up
-       to 100k if this function is called. */
+       to 100k if this function is called.  */
     if (i == kpse_cnf_format || i == kpse_db_format)
       continue;
     /* Wipe the path (it is tested) and the cnf_path because their
@@ -1461,14 +1461,13 @@
       free (kpse->format_info[i].path);
       kpse->format_info[i].path = NULL;
     }
-    /* We cannot free the cnf_path: it points into the cnf hash, which
-       means all hell will break loose if we did. */
+    /* We cannot free cnf_path: it points into the cnf hash.  */
     if (kpse->format_info[i].cnf_path != NULL) {
       kpse->format_info[i].cnf_path = NULL;
     }
     /* We do not wipe the override_path at this point, though arguably
        we should provide new values.  It is not likely to matter for
-       the programs that call this function. */
+       the programs that call this function.  */
   }
 }
 

Modified: branches/stable/source/src/texk/kpathsea/texmf.cnf
===================================================================
--- branches/stable/source/src/texk/kpathsea/texmf.cnf	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/texmf.cnf	2019-11-23 23:34:02 UTC (rev 816)
@@ -168,98 +168,111 @@
 % formats, past or present.  Not all of them are built these days.
 
 % Plain TeX.  Have the command tex check all directories as a last
-% resort, we may have plain-compatible stuff anywhere.
-TEXINPUTS.tex           = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+% resort, we may have plain-compatible stuff anywhere.  Prefer
+% latex/ to latex-dev/, implying that we have to add a latex, element to
+% every TEXINPUTS tree that recursively searches $TEXMF/tex//, which is
+% all of them except ConTeXt.
+TEXINPUTS.tex           = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 
 % Fontinst needs to read afm files.
 TEXINPUTS.fontinst      = $TEXMFDOTDIR;$TEXMF/{tex,fonts/afm}//
 
 % Other plain-based formats.
-TEXINPUTS.amstex        = $TEXMFDOTDIR;$TEXMF/tex/{amstex,plain,generic,}//
-TEXINPUTS.csplain       = $TEXMFDOTDIR;$TEXMF/tex/{csplain,plain,generic,}//
-TEXINPUTS.eplain        = $TEXMFDOTDIR;$TEXMF/tex/{eplain,plain,generic,}//
-TEXINPUTS.ftex          = $TEXMFDOTDIR;$TEXMF/tex/{formate,plain,generic,}//
-TEXINPUTS.mex           = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,}//
-TEXINPUTS.texinfo       = $TEXMFDOTDIR;$TEXMF/tex/{texinfo,plain,generic,}//
+TEXINPUTS.amstex        = $TEXMFDOTDIR;$TEXMF/tex/{amstex,plain,generic,latex,}//
+TEXINPUTS.csplain       = $TEXMFDOTDIR;$TEXMF/tex/{csplain,plain,generic,latex,}//
+TEXINPUTS.eplain        = $TEXMFDOTDIR;$TEXMF/tex/{eplain,plain,generic,latex,}//
+TEXINPUTS.ftex          = $TEXMFDOTDIR;$TEXMF/tex/{formate,plain,generic,latex,}//
+TEXINPUTS.mex           = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,latex,}//
+TEXINPUTS.texinfo       = $TEXMFDOTDIR;$TEXMF/tex/{texinfo,plain,generic,latex,}//
 
-% LaTeX 2e specific macros are stored in latex/, macros that can only be
+% LaTeX2e specific macros are stored in latex/, macros that can only be
 % used with 2.09 in latex209/.  In addition, we look in the directory
 % latex209, useful for macros that were written for 2.09 and do not
-% mention 2e at all, but can be used with 2e.
+% mention 2e at all, but can be used with 2e.  The latex-dev/ subtree
+% may contain release candidates for testing.
 TEXINPUTS.cslatex       = $TEXMFDOTDIR;$TEXMF/tex/{cslatex,csplain,latex,generic,}//
 TEXINPUTS.latex         = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
+TEXINPUTS.latex-dev     = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,latex,generic,}//
 TEXINPUTS.latex209      = $TEXMFDOTDIR;$TEXMF/tex/{latex209,generic,latex,}//
 TEXINPUTS.olatex        = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
 
 % MLTeX.
 TEXINPUTS.frlatex       = $TEXMFDOTDIR;$TEXMF/tex/{french,latex,generic,}//
-TEXINPUTS.frtex         = $TEXMFDOTDIR;$TEXMF/tex/{french,plain,generic,}//
+TEXINPUTS.frtex         = $TEXMFDOTDIR;$TEXMF/tex/{french,plain,generic,latex,}//
 TEXINPUTS.mllatex       = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
-TEXINPUTS.mltex         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.mltex         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 
 % e-TeX.
 TEXINPUTS.elatex        = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
-TEXINPUTS.etex          = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.etex          = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 
 % pdfTeX.
 TEXINPUTS.pdfcslatex    = $TEXMFDOTDIR;$TEXMF/tex/{cslatex,csplain,latex,generic,}//
-TEXINPUTS.pdfcsplain    = $TEXMFDOTDIR;$TEXMF/tex/{csplain,plain,generic,}//
+TEXINPUTS.pdfcsplain    = $TEXMFDOTDIR;$TEXMF/tex/{csplain,plain,generic,latex,}//
 TEXINPUTS.pdflatex      = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
-TEXINPUTS.pdfmex        = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,}//
-TEXINPUTS.utf8mex       = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,}//
-TEXINPUTS.pdftex        = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
-TEXINPUTS.pdftexinfo    = $TEXMFDOTDIR;$TEXMF/tex/{texinfo,plain,generic,}//
-TEXINPUTS.pdfamstex     = $TEXMFDOTDIR;$TEXMF/tex/{amstex,plain,generic,}//
+TEXINPUTS.pdflatex-dev  = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,latex,generic,}//
+TEXINPUTS.pdfmex        = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,latex,}//
+TEXINPUTS.utf8mex       = $TEXMFDOTDIR;$TEXMF/tex/{mex,plain,generic,latex,}//
+TEXINPUTS.pdftex        = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
+TEXINPUTS.pdftexinfo    = $TEXMFDOTDIR;$TEXMF/tex/{texinfo,plain,generic,latex,}//
+TEXINPUTS.pdfamstex     = $TEXMFDOTDIR;$TEXMF/tex/{amstex,plain,generic,latex,}//
 
 % pdfeTeX.
 TEXINPUTS.pdfelatex     = $TEXMFDOTDIR;$TEXMF/tex/{latex,generic,}//
-TEXINPUTS.pdfetex       = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.pdfetex       = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 
 % LuaTeX.
-TEXINPUTS.luatex        = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,}//
-TEXINPUTS.luajittex     = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,}//
-TEXINPUTS.luahbtex      = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,}//
-TEXINPUTS.luajithbtex   = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,}//
-TEXINPUTS.dviluatex     = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,}//
-TEXINPUTS.lualatex      = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-TEXINPUTS.luajitlatex   = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-TEXINPUTS.luahblatex    = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-TEXINPUTS.luajithblatex = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-TEXINPUTS.dvilualatex   = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.luatex          = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,latex,}//
+TEXINPUTS.luajittex       = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,latex,}//
+TEXINPUTS.luahbtex        = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,latex,}//
+TEXINPUTS.luajithbtex     = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,latex,}//
+TEXINPUTS.dviluatex       = $TEXMFDOTDIR;$TEXMF/tex/{luatex,plain,generic,latex,}//
+TEXINPUTS.lualatex        = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.lualatex-dev    = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,lualatex,latex,luatex,generic,}//
+TEXINPUTS.luajitlatex     = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.luahblatex      = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.luahblatex-dev  = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,lualatex,latex,luatex,generic,}//
+TEXINPUTS.luajithblatex   = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.dvilualatex     = $TEXMFDOTDIR;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+TEXINPUTS.dvilualatex-dev = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,lualatex,latex,luatex,generic,}//
 
 % HarfTeX.
-TEXINPUTS.harftex       = $TEXMFDOTDIR;$TEXMF/tex/{harftex,luatex,plain,generic,}//
+TEXINPUTS.harftex       = $TEXMFDOTDIR;$TEXMF/tex/{harftex,luatex,plain,generic,latex,}//
 TEXINPUTS.harflatex     = $TEXMFDOTDIR;$TEXMF/tex/{harflatex,harftex,lualatex,latex,luatex,generic,}//
+TEXINPUTS.harflatex-dev = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,harflatex,harftex,lualatex,latex,luatex,generic,}//
 
 % XeTeX.
 TEXINPUTS.xelatex       = $TEXMFDOTDIR;$TEXMF/tex/{xelatex,latex,xetex,generic,}//
-TEXINPUTS.xeplain       = $TEXMFDOTDIR;$TEXMF/tex/{xeplain,eplain,plain,xetex,generic,}//
-TEXINPUTS.xetex         = $TEXMFDOTDIR;$TEXMF/tex/{xetex,plain,generic,}//
+TEXINPUTS.xelatex-dev   = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,xelatex,latex,xetex,generic,}//
+TEXINPUTS.xeplain       = $TEXMFDOTDIR;$TEXMF/tex/{xeplain,eplain,plain,xetex,generic,latex,}//
+TEXINPUTS.xetex         = $TEXMFDOTDIR;$TEXMF/tex/{xetex,plain,generic,latex,}//
 
 % Omega / Aleph.
-TEXINPUTS.aleph         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.aleph         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 TEXINPUTS.elambda       = $TEXMFDOTDIR;$TEXMF/tex/{lambda,latex,generic,}//
-TEXINPUTS.eomega        = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.eomega        = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 TEXINPUTS.lambda        = $TEXMFDOTDIR;$TEXMF/tex/{lambda,latex,generic,}//
 TEXINPUTS.lamed         = $TEXMFDOTDIR;$TEXMF/tex/{lambda,latex,generic,}//
-TEXINPUTS.omega         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,}//
+TEXINPUTS.omega         = $TEXMFDOTDIR;$TEXMF/tex/{plain,generic,latex,}//
 
 % p(La)TeX.
-TEXINPUTS.ptex          = $TEXMFDOTDIR;$TEXMF/tex/{ptex,plain,generic,}//
+TEXINPUTS.ptex          = $TEXMFDOTDIR;$TEXMF/tex/{ptex,plain,generic,latex,}//
 TEXINPUTS.platex        = $TEXMFDOTDIR;$TEXMF/tex/{platex,latex,generic,}//
+TEXINPUTS.platex-dev    = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,platex,latex,generic,}//
 
-% epTeX, and for pmpost.
-TEXINPUTS.eptex         = $TEXMFDOTDIR;$TEXMF/tex/{ptex,plain,generic,}//
+% epTeX, and use that engine for pmpost.
+TEXINPUTS.eptex         = $TEXMFDOTDIR;$TEXMF/tex/{ptex,plain,generic,latex,}//
 TEX.pmpost = eptex
 
 % p(La)TeX-ng
-TEXINPUTS.ptex-ng   = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,}//
+TEXINPUTS.ptex-ng   = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,latex,}//
 TEXINPUTS.platex-ng = $TEXMFDOTDIR;$TEXMF/tex/{uplatex,platex,latex,generic,}//
 
 % (e)up(La)TeX, and for upmpost
-TEXINPUTS.uplatex = $TEXMFDOTDIR;$TEXMF/tex/{uplatex,platex,latex,generic,}//
-TEXINPUTS.uptex   = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,}//
-TEXINPUTS.euptex  = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,}//
+TEXINPUTS.uplatex     = $TEXMFDOTDIR;$TEXMF/tex/{uplatex,platex,latex,generic,}//
+TEXINPUTS.uplatex-dev = $TEXMFDOTDIR;$TEXMF/tex/{latex-dev,uplatex,platex,latex,generic,}//
+TEXINPUTS.uptex   = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,latex,}//
+TEXINPUTS.euptex  = $TEXMFDOTDIR;$TEXMF/tex/{uptex,ptex,plain,generic,latex,}//
 TEX.upmpost = euptex
 
 % pBibTeX bibliographies and style files.
@@ -274,8 +287,8 @@
 TEXINPUTS.context       = $TEXMFDOTDIR;$TEXMF/tex/{context,plain,generic,}//
 
 % jadetex.
-TEXINPUTS.jadetex       = $TEXMFDOTDIR;$TEXMF/tex/{jadetex,latex,generic,}//
-TEXINPUTS.pdfjadetex    = $TEXMFDOTDIR;$TEXMF/tex/{jadetex,latex,generic,}//
+TEXINPUTS.jadetex       = $TEXMFDOTDIR;$TEXMF/tex/{jadetex,latex,generic,latex,}//
+TEXINPUTS.pdfjadetex    = $TEXMFDOTDIR;$TEXMF/tex/{jadetex,latex,generic,latex,}//
 
 % XMLTeX.
 TEXINPUTS.xmltex        = $TEXMFDOTDIR;$TEXMF/tex/{xmltex,latex,generic,}//
@@ -282,13 +295,13 @@
 TEXINPUTS.pdfxmltex     = $TEXMFDOTDIR;$TEXMF/tex/{xmltex,latex,generic,}//
 
 % Miscellany, no longer built.
-TEXINPUTS.lamstex       = $TEXMFDOTDIR;$TEXMF/tex/{lamstex,plain,generic,}//
-TEXINPUTS.lollipop      = $TEXMFDOTDIR;$TEXMF/tex/{lollipop,plain,generic,}//
+TEXINPUTS.lamstex       = $TEXMFDOTDIR;$TEXMF/tex/{lamstex,plain,generic,latex,}//
+TEXINPUTS.lollipop      = $TEXMFDOTDIR;$TEXMF/tex/{lollipop,plain,generic,latex,}//
 TEXINPUTS.frpdflatex    = $TEXMFDOTDIR;$TEXMF/tex/{french,latex,generic,}//
-TEXINPUTS.frpdftex      = $TEXMFDOTDIR;$TEXMF/tex/{french,plain,generic,}//
+TEXINPUTS.frpdftex      = $TEXMFDOTDIR;$TEXMF/tex/{french,plain,generic,latex,}//
 
 % Earlier entries override later ones, so put this generic one last.
-TEXINPUTS               = $TEXMFDOTDIR;$TEXMF/tex/{$progname,generic,}//
+TEXINPUTS               = $TEXMFDOTDIR;$TEXMF/tex/{$progname,generic,latex,}//
 
 % ttf2tfm.
 TTF2TFMINPUTS =                 $TEXMFDOTDIR;$TEXMF/ttf2pk//
@@ -478,14 +491,24 @@
 % But we can't simply use $TEXINPUTS, since then if TEXINPUTS is set in
 % the environment with a colon, say, TEXINPUTS=/some/dir:, the intended
 % default expansion of TEXINPUTS will not happen and .lua files under
-% the /tex/ will not be found.
+% the /tex/ tree will not be found.
 % 
 % So, duplicate the TEXINPUTS.*lualatex values as LUAINPUTS.*lualatex.
 % The default LUAINPUTS suffices for luatex and dviluatex.
 %
-LUAINPUTS.lualatex = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-LUAINPUTS.dvilualatex = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
-LUAINPUTS = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{luatex,plain,generic,}//
+LUAINPUTS.lualatex        = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+LUAINPUTS.lualatex-dev    = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{latex-dev,lualatex,latex,luatex,generic,}//
+%
+LUAINPUTS.luahblatex      = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{luahblatex,luahbtex,lualatex,latex,luatex,generic,}//
+LUAINPUTS.luahblatex-dev  = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{latex-dev,luahblatex,luahbtex,lualatex,latex,luatex,generic,}//
+%
+LUAINPUTS.dvilualatex     = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}//
+LUAINPUTS.dvilualatex-dev = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{latex-dev,lualatex,latex,luatex,generic,}//
+%
+LUAINPUTS.harflatex     = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{harflatex,harftex,lualatex,latex,luatex,generic,}//
+LUAINPUTS.harflatex-dev = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{latex-dev,harflatex,harftex,lualatex,latex,luatex,generic,}//
+%
+LUAINPUTS = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{luatex,plain,generic,latex,}//
 
 % Lua needs to look for binary lua libraries distributed with packages.
 CLUAINPUTS = $TEXMFDOTDIR;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//
@@ -673,6 +696,12 @@
 parse_first_line.tex = f
 parse_first_line.initex = f
 
+% Normally we mention files created by \openout in the log file,
+% but again, trip-compatibility forbids this for (ini)tex.
+log_openout = t
+log_openout.tex = f
+log_openout.initex = f
+
 % Control file:line:error style messages.
 file_line_error_style = f
 
@@ -845,3 +874,23 @@
 % Guess input encoding (SJIS vs. Unicode, etc.) in pTeX and friends?
 % Default is 1, to guess. Used on Windows only.
 guess_input_kanji_encoding = 1
+
+% command_line_encoding
+%
+% This variable is used on Windows only, and affects 4 TeX engines:
+% uptex, euptex, pdftex, xetex, and 2 drivers: dvips, [x]dvipdfmx.
+% Several applications also are affected by the variable:
+% dvi2tty.exe, disdvi.exe, dvibook.exe, dviconcat.exe, dviselect.exe,
+% dvitodvi.exe, and dvidvi.exe.
+% Only values utf8 or utf-8 are meaningful. Other values are simply
+% ignored. If file names in sources and DVI or XDV files are ASCII
+% only, the value of command_line_encoding is irrelevant.
+% If command_line_encoding = utf8 or command_line_encoding = utf-8,
+% file names in sources and DVI or XDV files are assumed to be UTF-8.
+% Default is utf-8, from 2019-07-24, to assume UTF-8 file names.
+% In order to switch off the function, define an environment variable:
+% set command_line_encoding=none
+% or write a line:
+% command_line_encoding = none
+% in a texmf.cnf prefered, for example $TEXMFLOCAL/web2c/texmf.cnf.
+command_line_encoding = utf-8

Modified: branches/stable/source/src/texk/kpathsea/types.h
===================================================================
--- branches/stable/source/src/texk/kpathsea/types.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/kpathsea/types.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 /* types.h: general types for kpathsea.
 
-   Copyright 1993, 1995, 1996, 2005, 2008-2014, 2016 Karl Berry.
+   Copyright 1993, 1995, 1996, 2005, 2008-2014, 2016, 2019 Karl Berry.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -21,7 +21,10 @@
 /* Our string, boolean, etc.  */
 #include <kpathsea/simpletypes.h>
 
-/* Required until all programs use the new API, if ever.  */
+/* Required forever for any normal build, since we will never want to
+   remove the original interface.  But to check that a program
+   only uses the new-style declarations, that is, is thread-safe,
+   could be useful to undefine.  */
 #define KPSE_COMPAT_API 1
 
 #include <stdio.h> /* for FILE* */

Modified: branches/stable/source/src/texk/tests/TeXLive/TLConfig.pm
===================================================================
--- branches/stable/source/src/texk/tests/TeXLive/TLConfig.pm	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/tests/TeXLive/TLConfig.pm	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,11 +1,11 @@
 # TeXLive::TLConfig.pm - module exporting configuration values
-# Copyright 2007-2018 Norbert Preining
+# Copyright 2007-2019 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
 package TeXLive::TLConfig;
 
-my $svnrev = '$Revision: 50190 $';
+my $svnrev = '$Revision: 52745 $';
 my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown";
 sub module_revision { return $_modulerevision; }
 
@@ -113,10 +113,10 @@
 our @AcceptedFallbackDownloaders = qw/curl wget/;
 our %FallbackDownloaderProgram = ( 'wget' => 'wget', 'curl' => 'curl');
 our %FallbackDownloaderArgs = (
-  'curl' => ['--user-agent', 'texlive/curl', '--retry', '10', 
+  'curl' => ['--user-agent', 'texlive/curl', '--retry', '4', '--retry-delay', '5',
              '--fail', '--location',
              '--connect-timeout', "$NetworkTimeout", '--silent', '--output'],
-  'wget' => ['--user-agent=texlive/wget', '--tries=10',
+  'wget' => ['--user-agent=texlive/wget', '--tries=4',
              "--timeout=$NetworkTimeout", '-q', '-O'],
 );
 # the way we package things on the web
@@ -232,7 +232,7 @@
 our $WindowsMainMenuName = "TeX Live $ReleaseYear";
 
 # Comma-separated list of engines which do not exist on all platforms.
-our $PartialEngineSupport = "luajittex,mfluajit";
+our $PartialEngineSupport = "luahbtex,luajittex,mfluajit";
 
 # Flags for error handling across the scripts and modules
 # all fine

Modified: branches/stable/source/src/texk/tests/TeXLive/TLUtils.pm
===================================================================
--- branches/stable/source/src/texk/tests/TeXLive/TLUtils.pm	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/tests/TeXLive/TLUtils.pm	2019-11-23 23:34:02 UTC (rev 816)
@@ -5,7 +5,7 @@
 
 package TeXLive::TLUtils;
 
-my $svnrev = '$Revision: 50493 $';
+my $svnrev = '$Revision: 52815 $';
 my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown";
 sub module_revision { return $_modulerevision; }
 
@@ -38,7 +38,7 @@
   TeXLive::TLUtils::wsystem($msg, at args);
   TeXLive::TLUtils::xsystem(@args);
   TeXLive::TLUtils::run_cmd($cmd);
-  TeXLive::TLUtils::system_pipe($prog, $infile, $outfile, $removeIn, @extraargs);
+  TeXLive::TLUtils::system_pipe($prog, $infile, $outfile, $removeIn, @args);
 
 =head2 File utilities
 
@@ -79,6 +79,19 @@
   TeXLive::TLUtils::w32_remove_from_path($bindir, $multiuser);
   TeXLive::TLUtils::setup_persistent_downloads();
 
+=head2 Logging and debugging
+
+  TeXLive::TLUtils::info($str1, ...);    # output unless -q
+  TeXLive::TLUtils::debug($str1, ...);   # output if -v
+  TeXLive::TLUtils::ddebug($str1, ...);  # output if -vv
+  TeXLive::TLUtils::dddebug($str1, ...); # output if -vvv
+  TeXLive::TLUtils::log($str1, ...);     # only to log file
+  TeXLive::TLUtils::tlwarn($str1, ...);  # warn on stderr and log
+  TeXLive::TLUtils::tldie($str1, ...);   # tlwarn and die
+  TeXLive::TLUtils::debug_hash($label, HASH);   # warn stringified HASH
+  TeXLive::TLUtils::backtrace();                # return call stack as string
+  TeXLive::TLUtils::process_logging_options($texdir); # handle -q -v* -logfile
+
 =head2 Miscellaneous
 
   TeXLive::TLUtils::sort_uniq(@list);
@@ -114,7 +127,7 @@
 # avoid -warnings.
 our $PERL_SINGLE_QUOTE; # we steal code from Text::ParseWords
 use vars qw(
-  $::LOGFILENAME @::LOGLINES 
+  $::LOGFILE $::LOGFILENAME @::LOGLINES 
     @::debug_hook @::ddebug_hook @::dddebug_hook @::info_hook 
     @::install_packages_hook @::warn_hook
   $TeXLive::TLDownload::net_lib_avail
@@ -1088,18 +1101,25 @@
 
 =item C<copy("-f", $file, $destfile)>
 
+=item C<copy("-L", $file, $destfile)>
+
 Copy file C<$file> to directory C<$target_dir>, or to the C<$destfile>
-in the second case.  No external programs are involved.  Since we need
-C<sysopen()>, the Perl module C<Fcntl.pm> is required.  The time stamps
-are preserved and symlinks are created on Unix systems.  On Windows,
-C<(-l $file)> will never return 'C<true>' and so symlinks will be
-(uselessly) copied as regular files.
+if the first argument is C<"-f">. No external programs are involved.
+Since we need C<sysopen()>, the Perl module C<Fcntl.pm> is required. The
+time stamps are preserved and symlinks are created on Unix systems. On
+Windows, C<(-l $file)> will never return 'C<true>' and so symlinks will
+be (uselessly) copied as regular files.
 
+If the argument is C<"-L"> and C<$file> is a symlink, the link is
+dereferenced before the copying is done. (If both C<"-f"> and C<"-L">
+are desired, they must be given in that order, although the current code
+has no need to do this.)
+
 C<copy> invokes C<mkdirhier> if target directories do not exist.  Files
 have mode C<0777> if they are executable and C<0666> otherwise, with
 the set bits in I<umask> cleared in each case.
 
-C<$file> can begin with a file:/ prefix.
+C<$file> can begin with a C<file:/> prefix.
 
 If C<$file> is not readable, we return without copying anything.  (This
 can happen when the database and files are not in perfect sync.)  On the
@@ -1109,14 +1129,24 @@
 =cut
 
 sub copy {
+  #too verbose ddebug("TLUtils::copy(", join (",", @_), "\n");
   my $infile = shift;
   my $filemode = 0;
+  my $dereference = 0;
   if ($infile eq "-f") { # second argument is a file
     $filemode = 1;
     $infile = shift;
   }
+  if ($infile eq "-L") {
+    $dereference = 1;
+    $infile = shift;
+  }
   my $destdir=shift;
 
+  # while we're trying to figure out the versioned containers.
+  #debug("copy($infile, $destdir, filemode=$filemode)\n");
+  #debug("copy: backtrace:\n", backtrace(), "copy: end backtrace\n");
+
   my $outfile;
   my @stat;
   my $mode;
@@ -1141,9 +1171,25 @@
     die "mkdirhier($destdir) failed: $err\n" if ! $ret;
   }
 
-  if (-l "$infile") {
-    symlink (readlink $infile, "$destdir/$filename")
-    || die "symlink(readlink $infile, $destdir/$filename) failed: $!";
+  # if we should dereference, change $infile to refer to the link target.
+  if (-l $infile && $dereference) {
+    my $linktarget = readlink($infile);
+    # The symlink target should always be relative, and we need to
+    # prepend the directory containing the link in that case.
+    # (Although it should never happen, if the symlink target happens
+    # to already be absolute, do not prepend.)
+    if ($linktarget !~ m,^/,) {
+      $infile = Cwd::abs_path(dirname($infile)) . "/$linktarget";
+    }
+    ddebug("TLUtils::copy: dereferencing symlink $infile -> $linktarget");
+  }
+
+  if (-l $infile) {
+    my $linktarget = readlink($infile);
+    my $dest = "$destdir/$filename";
+    ddebug("TLUtils::copy: doing symlink($linktarget,$dest)"
+          . " [from readlink($infile)]\n");
+    symlink($linktarget, $dest) || die "symlink($linktarget,$dest) failed: $!";
   } else {
     if (! open (IN, $infile)) {
       warn "open($infile) failed, not copying: $!";
@@ -2101,14 +2147,21 @@
 
 =pod
 
-=item C<check_file($what, $checksum, $checksize>
+=item C<check_file_and_remove($what, $checksum, $checksize>
 
-Remove C<$what> if either the given C<$checksum> or C<$checksize> does
-not agree. If a check argument is not given, that check is not performed.
+Remove the file C<$what> if either the given C<$checksum> or
+C<$checksize> for C<$what> does not agree with our recomputation using
+C<TLCrypto::tlchecksum> and C<stat>, respectively. If a check argument
+is not given, that check is not performed. If the checksums agree, the
+size is not checked. The return status is random.
 
+This unusual behavior (removing the given file) is because this is used
+for newly-downloaded files; see the calls in the C<unpack> routine
+(which is the only caller).
+
 =cut
 
-sub check_file {
+sub check_file_and_remove {
   my ($xzfile, $checksum, $checksize) = @_;
   debug("check_file $xzfile, $checksum, $checksize\n");
   if (!$checksum && !$checksize) {
@@ -2116,12 +2169,23 @@
            "available for $xzfile, cannot check integrity"); 
     return;
   }
+  
+  # The idea is that if one of the tests fail, we want to save a copy of
+  # the input file for debugging. But we can't just omit removing the
+  # file, since the caller depends on the removal. So we copy it to a
+  # new temporary directory, which we want to persist, so can't use tl_tmpdir.
+  my $check_file_tmpdir = undef;
+
   # only run checksum tests if we can actually compute the checksum
   if ($checksum && ($checksum ne "-1") && $::checksum_method) {
     my $tlchecksum = TeXLive::TLCrypto::tlchecksum($xzfile);
     if ($tlchecksum ne $checksum) {
-      tlwarn("TLUtils::check_file: removing $xzfile, checksums differ:\n");
-      tlwarn("TLUtils::check_file:   TL=$tlchecksum, arg=$checksum\n");
+      tlwarn("TLUtils::check_file: checksums differ for $xzfile:\n");
+      tlwarn("TLUtils::check_file:   tlchecksum=$tlchecksum, arg=$checksum\n");
+      (undef,$check_file_tmpdir) = File::Temp::tempdir("tlcheckfileXXXXXXXX");
+      tlwarn("TLUtils::check_file:   removing $xzfile, "
+             . "but saving copy in $check_file_tmpdir\n");
+      copy($xzfile, $check_file_tmpdir);
       unlink($xzfile);
       return;
     } else {
@@ -2134,7 +2198,14 @@
     my $filesize = (stat $xzfile)[7];
     if ($filesize != $checksize) {
       tlwarn("TLUtils::check_file: removing $xzfile, sizes differ:\n");
-      tlwarn("TLUtils::check_file:   TL=$filesize, arg=$checksize\n");
+      tlwarn("TLUtils::check_file:   tlfilesize=$filesize, arg=$checksize\n");
+      if (!defined($check_file_tmpdir)) {
+        # the tmpdir should always be undefined, since we shouldn't get
+        # here if the checksums failed, but test anyway.
+        $check_file_tmpdir = File::Temp::tempdir("tlcheckfileXXXXXXXX");
+        tlwarn("TLUtils::check_file:  saving copy in $check_file_tmpdir\n");
+        copy($xzfile, $check_file_tmpdir);
+      }
       unlink($xzfile);
       return;
     }
@@ -2149,10 +2220,11 @@
 
 If necessary, downloads C$what>, and then unpacks it into C<$targetdir>.
 C<@opts> is assigned to a hash and can contain the following 
-options: C<tmpdir> (use this directory for downloaded files), 
+keys: C<tmpdir> (use this directory for downloaded files), 
 C<checksum> (check downloaded file against this checksum), 
 C<size> (check downloaded file against this size),
 C<remove> (remove temporary files after operation).
+
 Returns a pair of values: in case of error return 0 and an additional
 explanation, in case of success return 1 and the name of the package.
 
@@ -2202,26 +2274,26 @@
     # we are installing from the NET
     # check for the presence of $what in $tempdir
     if (-r $containerfile) {
-      check_file($containerfile, $checksum, $size);
+      check_file_and_remove($containerfile, $checksum, $size);
     }
     # if the file is now not present, we can use it
     if (! -r $containerfile) {
       # try download the file and put it into temp
       if (!download_file($what, $containerfile)) {
-        return(0, "downloading did not succeed");
+        return(0, "downloading did not succeed (download_file failed)");
       }
       # remove false downloads
-      check_file($containerfile, $checksum, $size);
+      check_file_and_remove($containerfile, $checksum, $size);
       if ( ! -r $containerfile ) {
-        return(0, "downloading did not succeed");
+        return(0, "downloading did not succeed (check_file_and_remove failed)");
       }
     }
   } else {
     # we are installing from local compressed files
-    # copy it to temp
-    TeXLive::TLUtils::copy($what, $tempdir);
+    # copy it to temp with dereferencing of link target
+    TeXLive::TLUtils::copy("-L", $what, $tempdir);
 
-    check_file($containerfile, $checksum, $size);
+    check_file_and_remove($containerfile, $checksum, $size);
     if (! -r $containerfile) {
       return (0, "consistency checks failed");
     }
@@ -2451,7 +2523,7 @@
     $::progs{'compressor'} = $ENV{'TEXLIVE_COMPRESSOR'};
   }
 
-  if ($::opt_verbosity >= 1) {
+  if ($::opt_verbosity >= 2) {
     require Data::Dumper;
     use vars qw($Data::Dumper::Indent $Data::Dumper::Sortkeys
                 $Data::Dumper::Purity); # -w pain
@@ -2532,16 +2604,16 @@
   debug("(unix) trying to set up $p, default $def, arg $arg\n");
   if (-r $def) {
     if (-x $def) {
-      ddebug("default $def has executable permissions\n");
+      ddebug(" Default $def has executable permissions\n");
       # we have to check for actual "executability" since a "noexec"
       # mount option may interfere, which is not taken into account by -x.
       my $ret = system("'$def' $arg >/dev/null 2>&1" ); # we are on Unix
       if ($ret == 0) {
         $::progs{$p} = $def;
-        debug("Using shipped $def for $p (tested).\n");
+        debug(" Using shipped $def for $p (tested).\n");
         return(1);
       } else {
-        ddebug("Shipped $def has -x but cannot be executed, "
+        ddebug(" Shipped $def has -x but cannot be executed, "
                . "trying tmp copy.\n");
       }
     }
@@ -2562,7 +2634,7 @@
     if (! -x $tmpprog) {
       # hmm, something is going really bad, not even the copy is
       # executable. Fall back to normal path element
-      ddebug("Copied $p $tmpprog does not have -x bit, strange!\n");
+      ddebug(" Copied $p $tmpprog does not have -x bit, strange!\n");
       return(0);
     } else {
       # check again for executability
@@ -2569,12 +2641,12 @@
       my $ret = system("$tmpprog $arg > /dev/null 2>&1");
       if ($ret == 0) {
         # ok, the copy works
-        debug("Using copied $tmpprog for $p (tested).\n");
+        debug(" Using copied $tmpprog for $p (tested).\n");
         $::progs{$p} = $tmpprog;
         return(1);
       } else {
         # even the copied prog is not executable, strange
-        ddebug("Copied $p $tmpprog has x bit but not executable?!\n");
+        ddebug(" Copied $p $tmpprog has x bit but not executable?!\n");
         return(0);
       }
     }
@@ -3210,124 +3282,21 @@
   return %ret;
 }
 
-
 =back
 
-=head2 Miscellaneous
+=head2 Logging
 
-Ideas from Fabrice Popineau's C<FileUtils.pm>.
+Logging and debugging messages.
 
-=over 4
+=item C<logit($out,$level, at rest)>
 
-=item C<sort_uniq(@list)>
+Internal routine to write message to both C<$out> (references to
+filehandle) and C<$::LOGFILE>, at level C<$level>, of concatenated items
+in C<@rest>. If the log file is not initialized yet, the message is
+saved to be logged later (unless the log file never comes into existence).
 
-The C<sort_uniq> function sorts the given array and throws away multiple
-occurrences of elements. It returns a sorted and unified array.
-
 =cut
 
-sub sort_uniq {
-  my (@l) = @_;
-  my ($e, $f, @r);
-  $f = "";
-  @l = sort(@l);
-  foreach $e (@l) {
-    if ($e ne $f) {
-      $f = $e;
-      push @r, $e;
-    }
-  }
-  return @r;
-}
-
-
-=item C<push_uniq(\@list, @new_items)>
-
-The C<push_uniq> function pushes the last argument @ITEMS to the $LIST
-referenced by the first argument, if they are not already in the list.
-
-=cut
-
-sub push_uniq {
-  my ($l, @new_items) = @_;
-  for my $e (@new_items) {
-    if (! &member($e, @$l)) {
-      push (@$l, $e);
-    }
-  }
-}
-
-=item C<member($item, @list)>
-
-The C<member> function returns true if the first argument 
-is also inclued in the list of the remaining arguments.
-
-=cut
-
-sub member {
-  my $what = shift;
-  return scalar grep($_ eq $what, @_);
-}
-
-
-=item C<merge_into(\%to, \%from)>
-
-Merges the keys of %from into %to.
-
-=cut
-
-sub merge_into {
-  my ($to, $from) = @_;
-  foreach my $k (keys %$from) {
-    if (defined($to->{$k})) {
-      push @{$to->{$k}}, @{$from->{$k}};
-    } else {
-      $to->{$k} = [ @{$from->{$k}} ];
-    }
-  }
-}
-
-
-=item C<texdir_check($texdir)>
-
-Test whether installation with TEXDIR set to $texdir would succeed due to
-writing permissions.
-
-Writable or not, we will not allow installation to the root
-directory (Unix) or the root of a drive (Windows).
-
-=cut
-
-sub texdir_check {
-  my $texdir = shift;
-  return 0 unless defined $texdir;
-  # convert to absolute, for safer parsing.
-  # The return value may still contain symlinks,
-  # but no unnecessary terminating '/'.
-  $texdir = tl_abs_path($texdir);
-  return 0 unless defined $texdir;
-  # also reject the root of a drive,
-  # assuming that only the canonical form of the root ends with /
-  return 0 if $texdir =~ m!/$!;
-  # win32: for now, reject the root of a samba share
-  return 0 if win32() && $texdir =~ m!^//[^/]+/[^/]+$!;
-  my $texdirparent;
-  my $texdirpparent;
-
-  return dir_writable($texdir) if (-d $texdir);
-  ($texdirparent = $texdir) =~ s!/[^/]*$!!;
-  #print STDERR "Checking $texdirparent".'[/]'."\n";
-  return  dir_creatable($texdirparent) if -d dir_slash($texdirparent);
-  # try another level up the tree
-  ($texdirpparent = $texdirparent) =~ s!/[^/]*$!!;
-  #print STDERR "Checking $texdirpparent".'[/]'."\n";
-  return dir_creatable($texdirpparent) if -d dir_slash($texdirpparent);
-  return 0;
-}
-
-

-# no newlines or spaces are added, multiple args are just concatenated.
-#
 sub logit {
   my ($out, $level, @rest) = @_;
   _logit($out, $level, @rest) unless $::opt_quiet;
@@ -3353,7 +3322,6 @@
   }
 }
 
-
 =item C<info ($str1, $str2, ...)>
 
 Write a normal informational message, the concatenation of the argument
@@ -3377,7 +3345,6 @@
   }
 }
 
-
 =item C<debug ($str1, $str2, ...)>
 
 Write a debugging message, the concatenation of the argument strings.
@@ -3399,7 +3366,6 @@
   }
 }
 
-
 =item C<ddebug ($str1, $str2, ...)>
 
 Write a deep debugging message, the concatenation of the argument
@@ -3495,7 +3461,7 @@
   }
 }
 
-=item C<debug_hash ($label, hash))>
+=item C<debug_hash ($label, HASH)>
 
 Write LABEL followed by HASH elements, all on one line, to stderr.
 If HASH is a reference, it is followed.
@@ -3520,7 +3486,26 @@
   warn "$str\n";
 }
 
-

+=item C<backtrace()>
+
+Return call(er) stack, as a string.
+
+=cut
+
+sub backtrace {
+  my $ret = "";
+
+  my ($line, $subr);
+  my $stackframe = 1;  # skip ourselves
+  while ((undef,$filename,$line,$subr) = caller ($stackframe)) {
+    # the undef is for the package, which is already included in $subr.
+    $ret .= " -> ${filename}:${line}: ${subr}\n";
+    $stackframe++;
+  }
+
+  return $ret;
+}
+
 =item C<process_logging_options ($texdir)>
 
 This function handles the common logging options for TeX Live scripts.
@@ -3593,6 +3578,118 @@
   }
 }
 
+=back
+
+=head2 Miscellaneous
+
+Some ideas from Fabrice Popineau's C<FileUtils.pm>.
+
+=over 4
+
+=item C<sort_uniq(@list)>
+
+The C<sort_uniq> function sorts the given array and throws away multiple
+occurrences of elements. It returns a sorted and unified array.
+
+=cut
+
+sub sort_uniq {
+  my (@l) = @_;
+  my ($e, $f, @r);
+  $f = "";
+  @l = sort(@l);
+  foreach $e (@l) {
+    if ($e ne $f) {
+      $f = $e;
+      push @r, $e;
+    }
+  }
+  return @r;
+}
+
+
+=item C<push_uniq(\@list, @new_items)>
+
+The C<push_uniq> function pushes the last argument @ITEMS to the $LIST
+referenced by the first argument, if they are not already in the list.
+
+=cut
+
+sub push_uniq {
+  my ($l, @new_items) = @_;
+  for my $e (@new_items) {
+    if (! &member($e, @$l)) {
+      push (@$l, $e);
+    }
+  }
+}
+
+=item C<member($item, @list)>
+
+The C<member> function returns true if the first argument 
+is also inclued in the list of the remaining arguments.
+
+=cut
+
+sub member {
+  my $what = shift;
+  return scalar grep($_ eq $what, @_);
+}
+
+=item C<merge_into(\%to, \%from)>
+
+Merges the keys of %from into %to.
+
+=cut
+
+sub merge_into {
+  my ($to, $from) = @_;
+  foreach my $k (keys %$from) {
+    if (defined($to->{$k})) {
+      push @{$to->{$k}}, @{$from->{$k}};
+    } else {
+      $to->{$k} = [ @{$from->{$k}} ];
+    }
+  }
+}
+
+=item C<texdir_check($texdir)>
+
+Test whether installation with TEXDIR set to $texdir would succeed due to
+writing permissions.
+
+Writable or not, we will not allow installation to the root
+directory (Unix) or the root of a drive (Windows).
+
+=cut
+
+sub texdir_check {
+  my $texdir = shift;
+  return 0 unless defined $texdir;
+  # convert to absolute, for safer parsing.
+  # The return value may still contain symlinks,
+  # but no unnecessary terminating '/'.
+  $texdir = tl_abs_path($texdir);
+  return 0 unless defined $texdir;
+  # also reject the root of a drive,
+  # assuming that only the canonical form of the root ends with /
+  return 0 if $texdir =~ m!/$!;
+  # win32: for now, reject the root of a samba share
+  return 0 if win32() && $texdir =~ m!^//[^/]+/[^/]+$!;
+  my $texdirparent;
+  my $texdirpparent;
+
+  return dir_writable($texdir) if (-d $texdir);
+  ($texdirparent = $texdir) =~ s!/[^/]*$!!;
+  #print STDERR "Checking $texdirparent".'[/]'."\n";
+  return  dir_creatable($texdirparent) if -d dir_slash($texdirparent);
+  # try another level up the tree
+  ($texdirpparent = $texdirparent) =~ s!/[^/]*$!!;
+  #print STDERR "Checking $texdirpparent".'[/]'."\n";
+  return dir_creatable($texdirpparent) if -d dir_slash($texdirpparent);
+  return 0;
+}
+
 =pod
 
 This function takes a single argument I<path> and returns it with
@@ -4165,6 +4262,7 @@
   return(@pieces);
 }
 
+

 =item C<mktexupd ()>
 
 Append entries to C<ls-R> files.  Usage example:
@@ -4262,7 +4360,7 @@
   return $hash;
 }
 
-
+

 =item C<check_sys_user_mode($user,$sys,$tmfc, $tmfsc, $tmfv, $tmfsv)>
 
 =cut
@@ -4314,6 +4412,7 @@
   return ($texmfconfig, $texmfvar);
 }
 
+

 =item C<prepend_own_path()>
 
 Prepend the location of the TeX Live binaries to the PATH environment
@@ -4335,7 +4434,7 @@
   }
 }
 
-
+

 =item C<repository_to_array($r)>
 
 Return hash of tags to urls for space-separated list of repositories
@@ -4376,6 +4475,7 @@
   return %r;
 }
 
+

 =item C<encode_json($ref)>
 
 Returns the JSON representation of the object C<$ref> is pointing at.

Modified: branches/stable/source/src/texk/web2c/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,7 +1,38 @@
+2019-09-23  Karl Berry  <karl at freefriends.org>
+
+	* patgen.ch (trie_size),
+	(triec_size): reduce again, back to the original values,
+	10,000,000 and 5,000,000. A sad story.
+	Report from Mojca, 23 Sep 2019 21:21:42.
+
+2019-08-09  Karl Berry  <karl at freefriends.org>
+
+	* tex.ch (53.1374): only log \openout files if the log_openout
+	config value is true. Report from David Fuchs.
+	* cpascal.h (texmfyes): #define texmf_yesno, for web visibility.
+	* triptest.test: no need to remove \openout lines since they are
+	no longer written.
+	* triptrap/trip.diffs: update.
+
+2019-08-06  Karl Berry  <karl at freefriends.org>
+
+	* texmfmp-help.h (ALEPHHELP, EPTEXHELP, ETEXHELP, EUPTEXHELP,
+	MFHELP, PDFTEXHELP, PTEXHELP, TEXHELP, UPTEXHELP, XETEXHELP):
+	add -cnf-line. (I.e., everything but the lua-based engines,
+	as they do not share the common source.)
+
+2019-08-04  Karl Berry  <karl at freefriends.org>
+
+	* doc/web2c.texi (Shell escapes): default value no longer as stated.
+
+2019-07-19  Karl Berry  <karl at tug.org>
+
+	* patgen.ch: mention adding swap/zram to deal with larger tries.
+
 2019-07-10  Karl Berry  <karl at freefriends.org>
 
 	* patgen.ch (trie_size),
-	(trie_size): reduce again to 76,000,000 and 38,000,000,
+	(triec_size): reduce again to 76,000,000 and 38,000,000,
 	per Johannes Hielscher, 10 Jul 2019 00:00:03.
 
 2019-06-26  Karl Berry  <karl at freefriends.org>

Modified: branches/stable/source/src/texk/web2c/Makefile.in
===================================================================
--- branches/stable/source/src/texk/web2c/Makefile.in	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/Makefile.in	2019-11-23 23:34:02 UTC (rev 816)
@@ -3081,12 +3081,13 @@
 	$(pdftex_tests) tests/wprob.tex pdftexdir/tests/pdfimage.tex \
 	tests/1-4.jpg tests/B.pdf tests/basic.tex \
 	tests/lily-ledger-broken.png tests/expanded.tex \
-	$(ttf2afm_tests) pdftexdir/tests/postV3.afm \
-	pdftexdir/tests/postV3.ttf pdftexdir/tests/postV7.afm \
-	pdftexdir/tests/postV7.ttf $(pdftosrc_tests) \
-	pdftexdir/tests/test-13.pdf pdftexdir/tests/test-13.xref \
-	pdftexdir/tests/test-15.pdf pdftexdir/tests/test-15.xref \
-	$(libluasocket_sources) luatexdir/luasocket/src/ftp_lua.c \
+	tests/expanded.txt tests/cnfline.tex $(ttf2afm_tests) \
+	pdftexdir/tests/postV3.afm pdftexdir/tests/postV3.ttf \
+	pdftexdir/tests/postV7.afm pdftexdir/tests/postV7.ttf \
+	$(pdftosrc_tests) pdftexdir/tests/test-13.pdf \
+	pdftexdir/tests/test-13.xref pdftexdir/tests/test-15.pdf \
+	pdftexdir/tests/test-15.xref $(libluasocket_sources) \
+	luatexdir/luasocket/src/ftp_lua.c \
 	luatexdir/luasocket/src/headers_lua.c \
 	luatexdir/luasocket/src/http_lua.c \
 	luatexdir/luasocket/src/ltn12_lua.c \
@@ -3335,8 +3336,9 @@
 	synctexdir/synctex-e-rec.ch0 synctexdir/synctex-p-mem.ch0 \
 	synctexdir/synctex-p-mem.ch1 synctexdir/synctex-p-rec.ch0 \
 	synctexdir/synctex-p-rec.ch1 synctexdir/synctex-ep-mem.ch0 \
-	synctexdir/synctex-ep-mem.ch1 synctexdir/synctex-pdf-rec.ch2 \
-	synctexdir/synctex-xe-rec.ch3 $(synctex_tests) libmd5/md5.test
+	synctexdir/synctex-ep-mem.ch1 synctexdir/synctex-ep-rec.ch0 \
+	synctexdir/synctex-pdf-rec.ch2 synctexdir/synctex-xe-rec.ch3 \
+	$(synctex_tests) libmd5/md5.test
 DISTCLEANFILES = CXXLD.sh tangle.c tangle.h tangle.p tangle-web2c \
 	tangleboot.c tangleboot.h tangleboot.p tangleboot-web2c \
 	ctangle.c cweb.c common-ctangle ctangleboot.c cwebboot.c \
@@ -3397,10 +3399,10 @@
 	pdfprimitive-euptex.* $(nodist_pdftex_SOURCES) pdftex.ch \
 	pdftex-web2c pdftex.p pdftex.pool pdftex-tangle pwprob.log \
 	pwprob.tex pdfimage.fmt pdfimage.log pdfimage.pdf expanded.log \
-	postV3.afm postV7.afm test-13.pdf test-13.xref test-15.pdf \
-	test-15.xref $(nodist_libluatex_sources) luaimage.* \
-	luajitimage.* $(nodist_xetex_SOURCES) xetex.web xetex.ch \
-	xetex-web2c xetex.p xetex.pool xetex-tangle bug73.fmt \
+	cnfline.log postV3.afm postV7.afm test-13.pdf test-13.xref \
+	test-15.pdf test-15.xref $(nodist_libluatex_sources) \
+	luaimage.* luajitimage.* $(nodist_xetex_SOURCES) xetex.web \
+	xetex.ch xetex-web2c xetex.p xetex.pool xetex-tangle bug73.fmt \
 	bug73.log bug73.out bug73.tex filedump.log filedump.out \
 	filedump.tex $(omegaware_programs:=.c) \
 	$(omegaware_programs:=.h) $(omegaware_programs:=.p) \
@@ -4062,7 +4064,8 @@
 # pdfTeX tests
 #
 pdftex_tests = pdftexdir/wprob.test pdftexdir/pdftex.test \
-  pdftexdir/pdfimage.test pdftexdir/expanded.test
+  pdftexdir/pdfimage.test pdftexdir/expanded.test \
+  pdftexdir/tests/cnfline.test
 
 ttf2afm_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/pdftexdir
 ttf2afm_SOURCES = pdftexdir/ttf2afm.c
@@ -5004,6 +5007,7 @@
 @EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-p-rec.ch0 \
 @EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-rec.ch0 \
 @EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-rec.ch1 \
+ at EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-ep-rec.ch0 \
 @EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-e-rec.ch0 \
 @EPTEX_SYNCTEX_TRUE@	synctexdir/synctex-p-rec.ch1
 
@@ -5016,6 +5020,7 @@
 @EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-p-rec.ch0 \
 @EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-rec.ch0 \
 @EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-rec.ch1 \
+ at EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-ep-rec.ch0 \
 @EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-e-rec.ch0 \
 @EUPTEX_SYNCTEX_TRUE@	synctexdir/synctex-p-rec.ch1
 
@@ -19642,7 +19647,8 @@
 	weave $(srcdir)/pdftexdir/pdftex.web
 
 pdftexdir/wprob.log pdftexdir/pdftex.log \
-  pdftexdir/pdfimage.log pdftexdir/expanded.log: pdftex$(EXEEXT)
+  pdftexdir/pdfimage.log pdftexdir/expanded.log \
+  pdftexdir/cnfline.log: pdftex$(EXEEXT)
 pdftexdir/ttf2afm.log: ttf2afm$(EXEEXT)
 
 $(pdftosrc_OBJECTS): $(ZLIB_DEPEND) $(LIBPNG_DEPEND) $(XPDF_DEPEND)
@@ -19880,7 +19886,7 @@
 synctexdir/synctex.log: synctex$(EXEEXT)
 libmd5/md5.log: md5main$(EXEEXT)
 
-# $Id: Makefile.in 51577 2019-07-08 06:07:11Z lscarso $
+# $Id: Makefile.in 52388 2019-10-15 12:54:51Z hironobu $
 # am/bin_links.am: Makefile fragment for bindir links.
 .PHONY: install-bin-links uninstall-bin-links
 

Modified: branches/stable/source/src/texk/web2c/NEWS
===================================================================
--- branches/stable/source/src/texk/web2c/NEWS	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/NEWS	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,5 +1,9 @@
 This file records noteworthy changes.  (Public domain.)
 
+

+* New cross-engine option -cnf-line=STR.
+
+2019 (for TeX Live 2019,  7 April 2019)
 BibTeX: subsidiary .aux files are looked for in the directory of the
 main .aux file, if not found as-is (to work better with -output-directory).
 
@@ -8,7 +12,6 @@
 more language support, and more.
 
 

-2019 (for TeX Live 2019,  7 April 2019)
 2018 (for TeX Live 2018, 14 April 2018)
 * Directories in the -output-directory do not mask files by the same name.
 

@@ -16,8 +19,6 @@
 2016 (for TeX Live 2016, 21 May 2016)
 2015 (for TeX Live 2015, 21 May 2015)
 2014 (for TeX Live 2014, 24 May 2014)
-* Ditto.
-
 2013 (for TeX Live 2013, 30 May 2013)
 * Doc changes and bug fixes.
 

Modified: branches/stable/source/src/texk/web2c/cpascal.h
===================================================================
--- branches/stable/source/src/texk/web2c/cpascal.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/cpascal.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -285,6 +285,7 @@
 #define kpsesrccompile	kpse_src_compile
 #define recorderchangefilename	recorder_change_filename
 #define recorderenabled	recorder_enabled
+#define texmfyesno      texmf_yesno
 
 /* We need a new type for the argument parsing, too.  */
 typedef struct option getoptstruct;

Modified: branches/stable/source/src/texk/web2c/doc/web2c.info
===================================================================
--- branches/stable/source/src/texk/web2c/doc/web2c.info	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/doc/web2c.info	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,4 +1,4 @@
-This is web2c.info, produced by makeinfo version 6.5 from web2c.texi.
+This is web2c.info, produced by makeinfo version 6.6 from web2c.texi.
 
 This file documents the installation and use of the programs in Web2c,
 an implementation of Donald Knuth's TeX system.
@@ -58,7 +58,7 @@
 
 This document describes how to install and use the programs in the Web2c
 implementation of the TeX system, especially for Unix systems.  It
-corresponds to Web2c version 2019, released in February 2019.
+corresponds to Web2c version 2019, released in August 2019.
 
 * Menu:
 
@@ -82,7 +82,7 @@
 1 Introduction
 **************
 
-This manual corresponds to version 2019 of Web2c, released in February
+This manual corresponds to version 2019 of Web2c, released in August
 2019.
 
    "Web2c" is the name of a TeX implementation, originally for Unix, but
@@ -1485,9 +1485,10 @@
 
    The 'shell_escape_commands' value is a comma-separated list of words.
 Whitespace is significant, and typically should not be present.  The
-default definition looks like this, but with more commands included:
+default definition in 'texmf.cnf' looks like this, but with more
+commands included:
 
-     shell_escape_commands = bibtex,dvips,epstopdf,...,tex
+     shell_escape_commands = bibtex,kpsewhich,repstopdf,...
 
    pdfTeX and luaTeX support reading (via '\input' and '\openin') and
 writing (via '\openout') from pipes if the first character is '|'.  The
@@ -3571,14 +3572,14 @@
 * \fontdimen:                            tftopl invocation.   (line  99)
 * \immediate\write18:                    Shell escapes.       (line   6)
 * \input filenames:                      \input filenames.    (line   6)
-* \input, and pipes:                     Shell escapes.       (line  63)
+* \input, and pipes:                     Shell escapes.       (line  64)
 * \mag:                                  dvicopy invocation.  (line  20)
 * \mag <1>:                              dvitype invocation.  (line  28)
-* \openin, and pipes:                    Shell escapes.       (line  63)
+* \openin, and pipes:                    Shell escapes.       (line  64)
 * \openout and security:                 tex invocation.      (line  48)
-* \openout, and pipes:                   Shell escapes.       (line  63)
+* \openout, and pipes:                   Shell escapes.       (line  64)
 * \output routine, and \write:           Shell escapes.       (line  28)
-* \pdfshellescape:                       Shell escapes.       (line  63)
+* \pdfshellescape:                       Shell escapes.       (line  64)
 * \string:                               \input filenames.    (line  59)
 * \tracingcharsubdef and MLTeX:          \tracingcharsubdef.  (line   6)
 * \tracinglostchars and MLTeX:           \tracingcharsubdef.  (line  11)
@@ -4088,7 +4089,7 @@
 * pfaedit:                               Font utilities available elsewhere.
                                                               (line  30)
 * PiCTeX, increasing memory for:         Runtime options.     (line  20)
-* pipes, reading and writing:            Shell escapes.       (line  63)
+* pipes, reading and writing:            Shell escapes.       (line  64)
 * pixel height:                          pktype invocation.   (line  62)
 * pixel width:                           pktype invocation.   (line  62)
 * PK bitmaps from PostScript:            Font utilities available elsewhere.
@@ -4341,7 +4342,7 @@
 * vptovf:                                vptovf invocation.   (line   6)
 * weave:                                 weave invocation.    (line   6)
 * WEB:                                   WEB.                 (line   6)
-* web environments, and security:        Shell escapes.       (line  70)
+* web environments, and security:        Shell escapes.       (line  71)
 * WEB pool files, displaying:            pooltype invocation. (line   6)
 * WEB programs, compiling:               tangle invocation.   (line   6)
 * WEB programs, typesetting:             weave invocation.    (line   6)
@@ -4390,74 +4391,74 @@
 
 Tag Table:
 Node: Top2754
-Node: Introduction3752
-Node: Installation6913
-Node: configure options9015
-Node: Compile-time options11037
-Node: Additional targets12139
-Node: Triptrap13416
-Node: Runtime options14943
-Node: Commonalities16701
-Node: Option conventions17302
-Node: Common options18525
-Node: Path searching22905
-Node: Output file location23877
-Node: Three programs25202
-Node: Initial and virgin25956
-Node: Memory dumps26885
-Node: Creating memory dumps27341
-Node: Determining the memory dump to use28552
-Node: Hardware and memory dumps30133
-Node: Editor invocation32583
-Node: \input filenames33450
-Node: TeX36443
-Node: tex invocation37594
-Node: Initial TeX44497
-Node: Formats45861
-Node: Languages and hyphenation48787
-Node: MLTeX49217
-Node: \charsubdef50705
-Node: \tracingcharsubdef53028
-Node: TCX files53603
-Node: patgen invocation59043
-Node: Shell escapes59749
-Node: IPC and TeX63313
-Node: TeX extensions63883
-Node: Metafont65014
-Node: mf invocation66302
-Node: Initial Metafont70139
-Node: Modes71769
-Node: Online Metafont graphics74019
-Node: gftodvi invocation77444
-Node: mft invocation80264
-Node: MetaPost84262
-Node: mpost invocation85024
-Node: Initial MetaPost90200
-Node: dvitomp invocation91122
-Node: BibTeX91787
-Node: bibtex invocation92148
-Node: Basic BibTeX style files94622
-Node: WEB95952
-Node: tangle invocation97161
-Node: weave invocation99284
-Node: pooltype invocation100691
-Node: DVI utilities101821
-Node: dvicopy invocation102753
-Node: dvitype invocation104036
-Node: dvitype output example106365
-Node: Font utilities109416
-Node: Font file formats110596
-Node: gftopk invocation113865
-Node: pktogf invocation115056
-Node: pktype invocation116222
-Node: gftype invocation119045
-Node: tftopl invocation123548
-Node: pltotf invocation128141
-Node: vftovp invocation129192
-Node: vptovf invocation131427
-Node: Font utilities available elsewhere132454
-Node: Legalisms134834
-Node: References136988
-Node: Index141555
+Node: Introduction3750
+Node: Installation6909
+Node: configure options9011
+Node: Compile-time options11033
+Node: Additional targets12135
+Node: Triptrap13412
+Node: Runtime options14939
+Node: Commonalities16697
+Node: Option conventions17298
+Node: Common options18521
+Node: Path searching22901
+Node: Output file location23873
+Node: Three programs25198
+Node: Initial and virgin25952
+Node: Memory dumps26881
+Node: Creating memory dumps27337
+Node: Determining the memory dump to use28548
+Node: Hardware and memory dumps30129
+Node: Editor invocation32579
+Node: \input filenames33446
+Node: TeX36439
+Node: tex invocation37590
+Node: Initial TeX44493
+Node: Formats45857
+Node: Languages and hyphenation48783
+Node: MLTeX49213
+Node: \charsubdef50701
+Node: \tracingcharsubdef53024
+Node: TCX files53599
+Node: patgen invocation59039
+Node: Shell escapes59745
+Node: IPC and TeX63325
+Node: TeX extensions63895
+Node: Metafont65026
+Node: mf invocation66314
+Node: Initial Metafont70151
+Node: Modes71781
+Node: Online Metafont graphics74031
+Node: gftodvi invocation77456
+Node: mft invocation80276
+Node: MetaPost84274
+Node: mpost invocation85036
+Node: Initial MetaPost90212
+Node: dvitomp invocation91134
+Node: BibTeX91799
+Node: bibtex invocation92160
+Node: Basic BibTeX style files94634
+Node: WEB95964
+Node: tangle invocation97173
+Node: weave invocation99296
+Node: pooltype invocation100703
+Node: DVI utilities101833
+Node: dvicopy invocation102765
+Node: dvitype invocation104048
+Node: dvitype output example106377
+Node: Font utilities109428
+Node: Font file formats110608
+Node: gftopk invocation113877
+Node: pktogf invocation115068
+Node: pktype invocation116234
+Node: gftype invocation119057
+Node: tftopl invocation123560
+Node: pltotf invocation128153
+Node: vftovp invocation129204
+Node: vptovf invocation131439
+Node: Font utilities available elsewhere132466
+Node: Legalisms134846
+Node: References137000
+Node: Index141567
 
 End Tag Table

Modified: branches/stable/source/src/texk/web2c/doc/web2c.texi
===================================================================
--- branches/stable/source/src/texk/web2c/doc/web2c.texi	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/doc/web2c.texi	2019-11-23 23:34:02 UTC (rev 816)
@@ -12,7 +12,7 @@
 @end tex
 
 @set version 2019
- at set month-year February 2019
+ at set month-year August 2019
 
 @c Define new indices for commands in auxiliary files, filenames, and options.
 @defcodeindex cm
@@ -1667,11 +1667,11 @@
 
 The @code{shell_escape_commands} value is a comma-separated list of
 words.  Whitespace is significant, and typically should not be
-present.  The default definition looks like this, but with more
-commands included:
+present.  The default definition in @file{texmf.cnf} looks like this,
+but with more commands included:
 
 @example
-shell_escape_commands = bibtex,dvips,epstopdf,...,tex
+shell_escape_commands = bibtex,kpsewhich,repstopdf,...
 @end example
 
 @cindex pipes, reading and writing

Modified: branches/stable/source/src/texk/web2c/lib/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/lib/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/lib/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,35 @@
+2019-08-10  Andreas Scherer  <https://ascherer.github.io>
+
+	* lib.h: add missing prototypes from 'openclose.c' and 'texmfmp.c'.
+
+2019-08-09  Karl Berry  <karl at freefriends.org>
+
+	* texmfmp.c (texmf_yesno): no longer static, since we call it
+	from tex.ch.
+
+	* texmfmp.c: doc fixes; most "fixme"s were nothing that we ever
+	need to fix at this late date.
+
+2019-08-08  Akira Kakuto  <kakuto at w32tex.org>
+
+	* texmfmp.c: This file is not used in lua[jit]tex.
+
+2019-08-07  Akira Kakuto  <kakuto at w32tex.org>
+
+	* texmfmp.c: Improve support of non-ascii path names in
+	synctex. Support -cnf-line=command_line_encoding=value.
+	These changes are for Windows only.
+
+2019-08-06  Karl Berry  <karl at freefriends.org>
+
+	* texmfmp.c (long_options): new option --cnf-line.
+	(user_cnf_lines, user_cnf_nlines): new globals.
+	(maininit): call kpathsea_cnf_line_env_progname
+	on each specified --cnf-line.
+	(parse_options): recognize it and save each arg.
+	Following suggestion from Pavel Sanda on ntg-pdftex,
+	15 Jun 2019 19:02:11.
+
 2019-07-01  Hironobu Yamashita  <h.y.acetaminophen at gmail.com>
 
 	* texmfmp.c (getcreationdate): Fix a wrong conditional (XeTeX only).

Modified: branches/stable/source/src/texk/web2c/lib/lib.h
===================================================================
--- branches/stable/source/src/texk/web2c/lib/lib.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/lib/lib.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -37,6 +37,7 @@
 /* openclose.c */
 extern boolean open_input (FILE **, int, const_string fopen_mode);
 extern boolean open_output (FILE **, const_string fopen_mode);
+extern boolean open_input_with_dirname (FILE **, int, const char *);
 extern void close_file (FILE *);
 extern void recorder_change_filename (string);
 extern void recorder_record_input (const_string);
@@ -53,6 +54,9 @@
 /* Set an array size from texmf.cnf.  */
 extern void setupboundvariable (integer *, const_string, integer);
 
+/* texmfmp.c */
+extern boolean texmf_yesno(const_string);
+
 /* version.c */
 extern const char *versionstring;
 

Modified: branches/stable/source/src/texk/web2c/lib/texmfmp.c
===================================================================
--- branches/stable/source/src/texk/web2c/lib/texmfmp.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/lib/texmfmp.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -5,7 +5,7 @@
    
    This file is public domain.  */
 
-/* This file is included from, e.g., texextra,c after
+/* This file is included from, e.g., texextra.c after
       #define EXTERN
       #include <texd.h>
    to instantiate data from texd.h here.  The ?d.h file is what
@@ -14,6 +14,7 @@
 
 #include <kpathsea/config.h>
 #include <kpathsea/c-ctype.h>
+#include <kpathsea/cnf.h>
 #include <kpathsea/line.h>
 #include <kpathsea/readable.h>
 #include <kpathsea/variable.h>
@@ -130,9 +131,18 @@
    --output-directory option is given.
    Borrowed from LuaTeX.
 */
+#if defined(_WIN32)
+#if defined(pdfTeX) || defined(upTeX) || defined(eupTeX) || defined(XeTeX)
+#define W32USYNCTEX 1
+#endif
+#endif
+
 char *generic_synctex_get_current_name (void)
 {
   char *pwdbuf, *ret;
+#if defined(W32USYNCTEX)
+  wchar_t *wpwd;
+#endif /* W32USYNCTEX */
   if (!fullnameoffile) {
     ret = xstrdup("");
     return ret;
@@ -141,6 +151,14 @@
      return xstrdup(fullnameoffile);
   }
   pwdbuf = xgetcwd();
+#if defined(W32USYNCTEX)
+  if (file_system_codepage != 0 && file_system_codepage != win32_codepage) {
+     wpwd = get_wstring_from_mbstring(win32_codepage, pwdbuf, wpwd=NULL);
+     free (pwdbuf);
+     pwdbuf = get_mbstring_from_wstring(file_system_codepage, wpwd, pwdbuf=NULL);
+     free (wpwd);
+  }
+#endif /* W32USYNCTEX */
   ret = concat3(pwdbuf, DIR_SEP_STRING, fullnameoffile);
   free(pwdbuf) ;
   return ret;
@@ -663,6 +681,10 @@
 /* If the user overrides argv[0] with -progname.  */
 static const_string user_progname;
 
+/* Array and count of values given with --config-line.  */
+static string *user_cnf_lines = NULL;
+static unsigned user_cnf_nlines = 0;
+
 /* The C version of the jobname, if given. */
 static const_string c_job_name;
 
@@ -687,8 +709,10 @@
 /* Try to figure out if we have been given a filename. */
 static string get_input_file_name (void);
 
-/* Get a true/false value for a variable from texmf.cnf and the environment. */
-static boolean
+/* Get a true/false value for a variable from texmf.cnf and the
+   environment.  Not static because we call it from tex.ch.  */
+
+boolean
 texmf_yesno(const_string var)
 {
   string value = kpse_var_value (var);
@@ -705,8 +729,10 @@
 normalize_quotes (const_string name, const_string mesg);
 #endif /* WIN32 */
 
-/* The entry point: set up for reading the command line, which will
-   happen in `topenin', then call the main body.  */
+/* maininit, called from main() - this is most of the main routine,
+   including our C-level option handling and concomitant kpse setup.
+   The original TeX/MF code for handling first lines is still live, and
+   we set up for that in `topenin' (which is called from the .web).  */
 
 void
 maininit (int ac, string *av)
@@ -745,6 +771,30 @@
   kpse_set_program_name (argv[0], NULL);
 #endif
 #if (IS_upTeX || defined(XeTeX) || defined(pdfTeX)) && defined(WIN32)
+/* 
+   -cnf-line=command_line_encoding=value cannot give effect because
+   command_line_encoding is read here before parsing the command
+   line. So we add the following.
+*/
+  { /* support old compilers which are incompatible with C99 */
+    int n;
+    for (n = 1; n < ac; n++) {
+      if (!strncasecmp (av[n], "-cnf-line=command_line_encoding=", 32)) {
+        putenv (av[n] + 10);
+        break;
+      }
+      if (!strncasecmp (av[n], "--cnf-line=command_line_encoding=", 33)) {
+        putenv (av[n] + 11);
+        break;
+      }
+      if (n < ac - 1 && (!strncasecmp (av[n], "-cnf-line", 9) ||
+          !strncasecmp (av[n], "--cnf-line", 10)) &&
+          !strncasecmp (av[n+1], "command_line_encoding=", 22)) {
+        putenv (av[n+1]);
+        break;
+      }
+    }
+  }
   enc = kpse_var_value("command_line_encoding");
   get_command_line_args_utf8(enc, &argc, &argv);
 #endif
@@ -796,23 +846,30 @@
 
 #if defined(MF)
 #if defined(MFLua)
-  /* If the program name is "mflua-nowin", then reset the name as "mflua". */
+  /* Reset mf*-nowin program names.  */
   if (strncasecmp (kpse_invocation_name, "mflua-nowin", 11) == 0)
     kpse_reset_program_name ("mflua");
 #elif defined(MFLuaJIT)
-  /* If the program name is "mfluajit-nowin", then reset the name as "mfluajit". */
   if (strncasecmp (kpse_invocation_name, "mfluajit-nowin", 14) == 0)
     kpse_reset_program_name ("mfluajit");
 #else
-  /* If the program name is "mf-nowin", then reset the name as "mf". */
   if (strncasecmp (kpse_invocation_name, "mf-nowin", 8) == 0)
     kpse_reset_program_name ("mf");
 #endif
 #endif
 
-  /* FIXME: gather engine names in a single spot. */
+  /* Make the given engine name available in the variable `engine'.  */
   xputenv ("engine", TEXMFENGINENAME);
   
+  if (user_cnf_lines) {
+    unsigned i;
+    for (i = 0; i < user_cnf_nlines; i++) {
+      /* debug printf ("ucnf%d: %s\n", i, user_cnf_lines[i]); */
+      kpathsea_cnf_line_env_progname (kpse_def, user_cnf_lines[i]);
+      free (user_cnf_lines[i]);
+    }
+  }
+
   /* Were we given a simple filename? */
   main_input_file = get_input_file_name ();
 
@@ -879,7 +936,6 @@
   }
   /* Check whether there still is no translate_filename known.  If so,
      use the default_translate_filename. */
-  /* FIXME: deprecated. */
   if (!translate_filename) {
     translate_filename = default_translate_filename;
   }
@@ -995,9 +1051,10 @@
 #endif /* TeX */
 }
 
-/* The entry point: set up for reading the command line, which will
-   happen in `topenin', then call the main body.  */
-
+/* main: Set up for reading the command line, which will happen in
+   `maininit' and `topenin', then call the main body, plus
+   special Windows/Kanji initializations.  */
+ 
 int
 #if defined(DLLPROC)
 DLLPROC (int ac, string *av)
@@ -1432,8 +1489,6 @@
    tex.pool.  If no suffix in FNAME, use .tcx (don't bother trying to
    support extension-less names for these files).  */
 
-/* FIXME: A new format ought to be introduced for these files. */
-
 void
 readtcxfile (void)
 {
@@ -1633,9 +1688,10 @@
 static struct option long_options[]
   = { { DUMP_OPTION,                 1, 0, 0 },
 #ifdef TeX
-      /* FIXME: Obsolete -- for backward compatibility only. */
+      /* Obsolete -- for backward compatibility only. */
       { "efmt",                      1, 0, 0 },
 #endif
+      { "cnf-line",                  1, 0, 0 },
       { "help",                      0, 0, 0 },
       { "ini",                       0, &iniversion, 1 },
       { "interaction",               1, 0, 0 },
@@ -1642,8 +1698,8 @@
       { "halt-on-error",             0, &haltonerrorp, 1 },
       { "kpathsea-debug",            1, 0, 0 },
       { "progname",                  1, 0, 0 },
+      { "recorder",                  0, &recorder_enabled, 1 },
       { "version",                   0, 0, 0 },
-      { "recorder",                  0, &recorder_enabled, 1 },
 #ifdef TeX
 #ifdef IPC
       { "ipc",                       0, &ipcon, 1 },
@@ -1721,7 +1777,6 @@
       break;
 
     if (g == '?') { /* Unknown option.  */
-      /* FIXME: usage (argv[0]); replaced by continue. */
       continue;
     }
 
@@ -1740,6 +1795,17 @@
     } else if (ARGUMENT_IS ("progname")) {
       user_progname = optarg;
 
+    } else if (ARGUMENT_IS ("cnf-line")) {
+      if (user_cnf_lines == NULL) {
+        user_cnf_nlines = 1;
+        user_cnf_lines = xmalloc (sizeof (const_string));
+      } else {
+        user_cnf_nlines++;
+        user_cnf_lines = xrealloc (user_cnf_lines,
+                                   user_cnf_nlines * sizeof (const_string));
+      }
+      user_cnf_lines[user_cnf_nlines-1] = xstrdup (optarg);
+
     } else if (ARGUMENT_IS ("jobname")) {
 #ifdef XeTeX
       c_job_name = optarg;
@@ -1752,7 +1818,7 @@
       dumpoption = true;
 
 #ifdef TeX
-    /* FIXME: Obsolete -- for backward compatibility only. */
+    /* For backward compatibility only. */
     } else if (ARGUMENT_IS ("efmt")) {
       dump_name = optarg;
       dumpoption = true;
@@ -2008,7 +2074,6 @@
           s = *parse+16;
         }
         /* Just set the name, no sanity checks here. */
-        /* FIXME: remove trailing spaces. */
         if (s && *s) {
           translate_filename = xstrdup(s);
         }
@@ -2772,7 +2837,7 @@
 #endif
 }
 

-/* FIXME -- some (most?) of this can/should be moved to the Pascal/WEB side. */
+/* Some (most?) of this could be moved to the WEB side, but oh well.  */
 #if defined(TeX) || defined(MF)
 #if !defined(pdfTeX)
 static void

Modified: branches/stable/source/src/texk/web2c/man/Makefile.in
===================================================================
--- branches/stable/source/src/texk/web2c/man/Makefile.in	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/man/Makefile.in	2019-11-23 23:34:02 UTC (rev 816)
@@ -101,7 +101,10 @@
 @PTEX_TRUE at am__append_12 = ptex:eptex ptex:euptex ptex:uptex \
 @PTEX_TRUE@	ppltotf:uppltotf ptftopl:uptftopl
 @LUATEX_TRUE at am__append_13 = luatex.man
- at LUATEX_TRUE@am__append_14 = luatex:texlua luatex:texluac
+ at LUATEX_TRUE@am__append_14 = luatex:texlua luatex:texluac \
+ at LUATEX_TRUE@  luatex:luahbtex luatex:luajittex \
+ at LUATEX_TRUE@  luatex:dviluatex
+
 @XETEX_TRUE at am__append_15 = xetex.man
 @OTANGLE_TRUE at am__append_16 = $(otangle_man_sources)
 @OTANGLE_TRUE at am__append_17 = dvicopy:odvicopy dvitype:odvitype tangle:otangle
@@ -455,7 +458,10 @@
 man1_links = cweb:ctangle cweb:cweave ctwill:ctwill-refsort \
 	ctwill:ctwill-twinx $(am__append_3) $(am__append_5) \
 	$(am__append_6) $(am__append_10) $(am__append_12) \
-	$(am__append_14) $(am__append_17) $(am__append_19)
+	$(am__append_14) $(am__append_17) $(am__append_19) \
+	latex-dev:pdflatex-dev latex-dev:xelatex-dev \
+	latex-dev:lualatex-dev latex-dev:dvilualatex-dev \
+	latex-dev:platex-dev latex-dev:uplatex-dev
 web_man_sources = bibtex.man dvicopy.man dvitomp.man dvitype.man gftodvi.man \
 	gftopk.man gftype.man mft.man patgen.man pktogf.man pktype.man \
 	pltotf.man pooltype.man tftopl.man vftovp.man vptovf.man weave.man
@@ -465,6 +471,7 @@
 misc_man_sources = \
 	amstex.man \
 	latex.man \
+	latex-dev.man \
 	pdfetex.man
 
 SUFFIXES = .1 .man .ps .dvi

Modified: branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/pdftexdir/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,10 @@
+2019-08-06  Karl Berry  <karl at freefriends.org>
+
+	* tests/cnfline.test,
+	* tests/cnfline.tex: new files.
+	* am/pdftex.am (pdftex_tests): add pdftexdir/tests/cnfline.test.
+	(cnfline.log): depend on pdftex$(EXEEXT).
+
 2019-05-08  Akira Kakuto  <kakuto at w32tex.org>
 
 	* writeimg.c: Use a new function find_input_file() to find

Modified: branches/stable/source/src/texk/web2c/pdftexdir/am/pdftex.am
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/am/pdftex.am	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/pdftexdir/am/pdftex.am	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 ## texk/web2c/pdftexdir/am/pdftex.am: Makefile fragment for pdfTeX.
 ##
-## Copyright 2016-2018 Karl Berry <tex-live at tug.org>
+## Copyright 2016-2019 Karl Berry <tex-live at tug.org>
 ## Copyright 2009-2015 Peter Breitenlohner <tex-live at tug.org>
 ## You may freely use, modify and/or distribute this file.
 
@@ -95,10 +95,12 @@
 # pdfTeX tests
 #
 pdftex_tests = pdftexdir/wprob.test pdftexdir/pdftex.test \
-  pdftexdir/pdfimage.test pdftexdir/expanded.test
+  pdftexdir/pdfimage.test pdftexdir/expanded.test \
+  pdftexdir/tests/cnfline.test
 
 pdftexdir/wprob.log pdftexdir/pdftex.log \
-  pdftexdir/pdfimage.log pdftexdir/expanded.log: pdftex$(EXEEXT)
+  pdftexdir/pdfimage.log pdftexdir/expanded.log \
+  pdftexdir/cnfline.log: pdftex$(EXEEXT)
 
 EXTRA_DIST += $(pdftex_tests)
 
@@ -116,5 +118,9 @@
 DISTCLEANFILES += pdfimage.fmt pdfimage.log pdfimage.pdf
 
 ## expanded.test
-EXTRA_DIST += tests/expanded.tex
+EXTRA_DIST += tests/expanded.tex tests/expanded.txt
 DISTCLEANFILES += expanded.log
+
+## cnfline.test
+EXTRA_DIST += tests/cnfline.tex
+DISTCLEANFILES += cnfline.log

Added: branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.test
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.test	                        (rev 0)
+++ branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.test	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,23 @@
+#! /bin/sh -vx
+# $Id: cnfline.test 51834 2019-08-07 03:54:14Z kakuto $
+# Public domain. Originally written by Karl Berry
+# Basic check that --cnf-line does something.
+
+LC_ALL=C; export LC_ALL;  LANGUAGE=C; export LANGUAGE
+
+TEXMFCNF=$srcdir/../kpathsea; export TEXMFCNF
+TEXINPUTS=$srcdir/pdftexdir/tests; export TEXINPUTS
+
+./pdftex -ini --interaction=batchmode \
+  --cnf-line=max_print_line=500 cnfline.tex || exit $?
+
+if grep 'those hyphens are' cnfline.log >/dev/null; then
+  : # ok, all ended up on one line
+else
+  echo "log message got broken despite max_print_line" >&2
+  cat cnfline.log >&2
+  exit 1
+fi
+
+exit 0
+


Property changes on: branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.test
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.tex
===================================================================
--- branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.tex	                        (rev 0)
+++ branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.tex	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,13 @@
+% $Id: cnfline.tex 51830 2019-08-06 23:33:17Z karl $
+% Public domain. Test file for --cnf-line.
+% Originally written 2019 by Karl Berry.
+
+\catcode`\{=1 \catcode`\}=2 % can run under -ini
+
+\write-1{the idea is to write a message longer than the default
+         max-print-line (those hyphens are really underscores).} 
+\end
+
+% with the default max_print_line, we get:
+%   the idea is to write a message longer than the default max-print-line (those hy
+%   phens are really underscores).


Property changes on: branches/stable/source/src/texk/web2c/pdftexdir/tests/cnfline.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: branches/stable/source/src/texk/web2c/synctexdir/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/synctexdir/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/synctexdir/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,14 @@
+2019-10-10  Hironori Kitagawa  <h_kitagawa2001 at yahoo.co.jp>
+
+	* synctex-p-rec.ch0, synctex-ep-rec.ch0: Fix \meaning\synctex
+	for pTeX and upTeX.
+	* am/synctex.am: Adjusted.
+
+2019-08-07  Akira Kakuto  <kakuto at w32tex.org>
+
+	* synctex.c: Improve support of non-ascii path names
+	(Windows only).
+
 2018-10-25  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	* synctex.c: Cleanup for non-ascii file names (w32 only).

Modified: branches/stable/source/src/texk/web2c/synctexdir/am/synctex.am
===================================================================
--- branches/stable/source/src/texk/web2c/synctexdir/am/synctex.am	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/synctexdir/am/synctex.am	2019-11-23 23:34:02 UTC (rev 816)
@@ -231,6 +231,7 @@
 	synctexdir/synctex-p-rec.ch0 \
 	synctexdir/synctex-rec.ch0 \
 	synctexdir/synctex-rec.ch1 \
+	synctexdir/synctex-ep-rec.ch0 \
 	synctexdir/synctex-e-rec.ch0 \
 	synctexdir/synctex-p-rec.ch1
 
@@ -246,7 +247,8 @@
 
 EXTRA_DIST += \
 	synctexdir/synctex-ep-mem.ch0 \
-	synctexdir/synctex-ep-mem.ch1
+	synctexdir/synctex-ep-mem.ch1 \
+	synctexdir/synctex-ep-rec.ch0
 
 ## SyncTeX infrastructure: e-upTeX
 
@@ -266,6 +268,7 @@
 	synctexdir/synctex-p-rec.ch0 \
 	synctexdir/synctex-rec.ch0 \
 	synctexdir/synctex-rec.ch1 \
+	synctexdir/synctex-ep-rec.ch0 \
 	synctexdir/synctex-e-rec.ch0 \
 	synctexdir/synctex-p-rec.ch1
 

Added: branches/stable/source/src/texk/web2c/synctexdir/synctex-ep-rec.ch0
===================================================================
--- branches/stable/source/src/texk/web2c/synctexdir/synctex-ep-rec.ch0	                        (rev 0)
+++ branches/stable/source/src/texk/web2c/synctexdir/synctex-ep-rec.ch0	2019-11-23 23:34:02 UTC (rev 816)
@@ -0,0 +1,13 @@
+ at x srcdir/etex.ch l.536
+@/@<synctex case for |print_param|@>@/
+othercases print("[unknown integer parameter!]")
+ at y
+othercases print("[unknown integer parameter!]")
+ at z
+
+ at x
+@ @<synctex case for |print_param|@>=
+synctex_code:    print_esc("synctex");
+
+ at y
+ at z


Property changes on: branches/stable/source/src/texk/web2c/synctexdir/synctex-ep-rec.ch0
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: branches/stable/source/src/texk/web2c/synctexdir/synctex-p-rec.ch0
===================================================================
--- branches/stable/source/src/texk/web2c/synctexdir/synctex-p-rec.ch0	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/synctexdir/synctex-p-rec.ch0	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,5 +1,31 @@
+ at x srcdir/etex.ch l.536
+othercases print("[unknown integer parameter!]")
+ at y
+@/@<synctex case for |print_param|@>@/
+othercases print("[unknown integer parameter!]")
+ at z
+
 @x tex.web l.12533
 left_edge:=cur_h; cur_v:=cur_v-height(this_box);
 @y
 save_loc:=dvi_offset+dvi_ptr; left_edge:=cur_h; cur_v:=cur_v-height(this_box);
 @z
+
+ at x synctex-mem.ch0 l.236
+It is initialized by the {\sl Sync\TeX} controller to the command-line option if given.
+The controller may filter some reserved bits.
+
+@ @<Put each...@>=
+primitive("synctex",assign_int,int_base+synctex_code);@/
+@!@:synctex_}{\.{\\synctex} primitive@>
+ at y
+It is initialized by the {\sl Sync\TeX} controller to the command-line option if given.
+The controller may filter some reserved bits.
+
+@ @<Put each...@>=
+primitive("synctex",assign_int,int_base+synctex_code);@/
+@!@:synctex_}{\.{\\synctex} primitive@>
+
+@ @<synctex case for |print_param|@>=
+synctex_code:    print_esc("synctex");
+ at z

Modified: branches/stable/source/src/texk/web2c/synctexdir/synctex.c
===================================================================
--- branches/stable/source/src/texk/web2c/synctexdir/synctex.c	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/synctexdir/synctex.c	2019-11-23 23:34:02 UTC (rev 816)
@@ -293,7 +293,7 @@
 #   endif
 
 #if defined(_WIN32)
-#if defined(pdfTeX) || defined(upTeX) || defined(eupTeX) || defined(XeTeX)
+#if defined(pdfTeX) || defined(upTeX) || defined(eupTeX) || defined(XeTeX) || defined(LuaTeX) || defined(LuajitTeX)
 #define W32UPTEXSYNCTEX 1
 #include <wchar.h>
 static char *chgto_oem(char *src);
@@ -591,7 +591,8 @@
 }
 
 #undef fopen
-#define fopen fsyscp_fopen
+extern FILE *f_fsyscp_fopen(const char *filename, const char *mode);
+#define fopen f_fsyscp_fopen
 #define gzopen fsyscp_gzopen
 #define rename fsyscp_rename
 #define remove fsyscp_remove

Modified: branches/stable/source/src/texk/web2c/tex.ch
===================================================================
--- branches/stable/source/src/texk/web2c/tex.ch	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/tex.ch	2019-11-23 23:34:02 UTC (rev 816)
@@ -4391,7 +4391,7 @@
         prompt_file_name("output file name",".tex");
       write_open[j]:=true;
       {If on first line of input, log file is not ready yet, so don't log.}
-      if log_opened then begin
+      if log_opened and texmf_yesno('log_openout') then begin
         old_setting:=selector;
         if (tracing_online<=0) then
           selector:=log_only  {Show what we're doing in the log file.}

Modified: branches/stable/source/src/texk/web2c/texmfmp-help.h
===================================================================
--- branches/stable/source/src/texk/web2c/texmfmp-help.h	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/texmfmp-help.h	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,6 +1,6 @@
 /* The help messages for TeX & MF family of programs.
 
-Copyright 1995, 1996, 2008-2016 Karl Berry.
+Copyright 1995, 1996, 2008-2019 Karl Berry.
 Copyright 2001-05 Olaf Weber.
 
 This program is free software; you can redistribute it and/or modify
@@ -40,6 +40,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-etex                   enable e-TeX extensions",
     "[-no]-file-line-error   disable/enable file:line:error style messages",
     "-fmt=FMTNAME            use FMTNAME instead of program name or a %& line",
@@ -95,6 +96,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-etex                   enable e-TeX extensions",
     "-fmt=NAME               use NAME instead of program name or %&format.",
 #if defined(WIN32)
@@ -159,6 +161,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-enc                    enable encTeX extensions such as \\mubyte",
     "-etex                   enable e-TeX extensions",
     "[-no]-file-line-error   disable/enable file:line:error style messages",
@@ -222,6 +225,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-etex                   enable e-TeX extensions",
     "-fmt=NAME               use NAME instead of program name or %&format.",
 #if defined(WIN32)
@@ -289,6 +293,7 @@
     "  If no arguments or options are specified, prompt for input.",
     "",
     "-base=BASENAME          use BASENAME instead of program name or a %& line",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "[-no]-file-line-error   disable/enable file:line:error style messages",
     "-halt-on-error          stop processing at the first error",
     "-ini                    be inimf, for dumping bases; this is implicitly",
@@ -421,6 +426,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-draftmode              switch on draft mode (generates no output PDF)",
     "-enc                    enable encTeX extensions such as \\mubyte",
     "-etex                   enable e-TeX extensions",
@@ -489,6 +495,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-fmt=NAME               use NAME instead of program name or %&format.",
 #if defined(WIN32)
     "[-no]-guess-input-enc   disable/enable to guess input file encoding",
@@ -552,6 +559,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-enc                    enable encTeX extensions such as \\mubyte",
     "[-no]-file-line-error   disable/enable file:line:error style messages",
     "-fmt=FMTNAME            use FMTNAME instead of program name or a %& line",
@@ -614,6 +622,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-fmt=NAME               use NAME instead of program name or %&format.",
 #if defined(WIN32)
     "[-no]-guess-input-enc   disable/enable to guess input file encoding",
@@ -677,6 +686,7 @@
     "",
     "  If no arguments or options are specified, prompt for input.",
     "",
+    "-cnf-line=STRING        parse STRING as a configuration file line",
     "-etex                   enable e-TeX extensions",
     "[-no]-file-line-error   disable/enable file:line:error style messages",
     "-fmt=FMTNAME            use FMTNAME instead of program name or a %& line",

Modified: branches/stable/source/src/texk/web2c/web2c/ChangeLog
===================================================================
--- branches/stable/source/src/texk/web2c/web2c/ChangeLog	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/web2c/ChangeLog	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,3 +1,7 @@
+2019-08-09  Karl Berry  <karl at freefriends.org>
+
+	* web2c.defines (texmfyes): new function.
+
 2018-11-11  Andreas Scherer  <https://ascherer.github.io>
 
 	* fixwrites.c (main): check return value from fgets.

Modified: branches/stable/source/src/texk/web2c/web2c/texmf.defines
===================================================================
--- branches/stable/source/src/texk/web2c/web2c/texmf.defines	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/texk/web2c/web2c/texmf.defines	2019-11-23 23:34:02 UTC (rev 816)
@@ -33,6 +33,7 @@
 @define function roundfraction ();
 @define function roundunscaled ();
 @define function runsystem ();
+ at define function texmfyesno ();
 @define function wopenin ();
 @define function wopenout ();
 

Modified: branches/stable/source/src/utils/README
===================================================================
--- branches/stable/source/src/utils/README	2019-07-11 15:55:39 UTC (rev 815)
+++ branches/stable/source/src/utils/README	2019-11-23 23:34:02 UTC (rev 816)
@@ -1,15 +1,15 @@
-$Id: README 50715 2019-04-02 22:05:50Z karl $
+$Id: README 52856 2019-11-19 00:04:10Z karl $
 Public domain.  Originally written 2005 by Karl Berry.
 
 Extra utilities we (optionally) compile for TeX Live.
 See comments in ../texk/README.
 
-asymptote 2.49 - checked 3apr19
+asymptote 2.61 - checked 19nov19
   update to TL from CTAN, to include prebuilt doc.
   see http://tug.org/texlive/build.html#asymptote
   and tlpkg/bin/tl-update-asy
 
-autosp 2019-01-08 - checked 10Jan19
+autosp 2019-08-26 - checked 29aug19
   http://ctan.org/pkg/autosp
 
 devnag - from devanagari package installed in texmf-dist.



More information about the pdftex-commits mailing list